Restore last active group

This commit is contained in:
SillyLossy
2023-03-28 22:58:36 +03:00
parent 9d512e09bc
commit 6ab38964dc
2 changed files with 325 additions and 310 deletions

View File

@@ -170,9 +170,14 @@ async function RA_autoloadchat() {
if (document.getElementById('CharID0') !== null) { if (document.getElementById('CharID0') !== null) {
//console.log('char list loaded! clicking activeChar'); //console.log('char list loaded! clicking activeChar');
var CharToAutoLoad = document.getElementById('CharID' + LoadLocal('ActiveChar')); var CharToAutoLoad = document.getElementById('CharID' + LoadLocal('ActiveChar'));
let autoLoadGroup = document.querySelector(`.group_select[grid="${LoadLocal('ActiveGroup')}"]`);
if (CharToAutoLoad != null) { if (CharToAutoLoad != null) {
CharToAutoLoad.click(); CharToAutoLoad.click();
} else { }
else if (autoLoadGroup != null) {
autoLoadGroup.click();
}
else {
console.log(CharToAutoLoad + ' ActiveChar local var - not found: ' + LoadLocal('ActiveChar')); console.log(CharToAutoLoad + ' ActiveChar local var - not found: ' + LoadLocal('ActiveChar'));
} }
RestoreNavTab(); RestoreNavTab();
@@ -334,8 +339,17 @@ $("document").ready(function () {
SaveLocal('SelectedNavTab', 'rm_button_characters'); SaveLocal('SelectedNavTab', 'rm_button_characters');
characters.sort(Intl.Collator().compare); // we sort the list characters.sort(Intl.Collator().compare); // we sort the list
}); });
// when a char is selected from the list, save them as the auto-load character for next page load // when a char is selected from the list, save them as the auto-load character for next page load
$(document).on("click", ".character_select", function () { SaveLocal('ActiveChar', $(this).attr('chid')); }); $(document).on("click", ".character_select", function () {
SaveLocal('ActiveChar', $(this).attr('chid'));
SaveLocal('ActiveGroup', null);
});
$(document).on("click", ".group_select", function () {
SaveLocal('ActiveChar', null);
SaveLocal('ActiveGroup', $(this).data('id'));
});
//this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height) //this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
$('#send_textarea').on('input', function () { $('#send_textarea').on('input', function () {

View File

@@ -180,6 +180,7 @@ function printGroups() {
for (let group of groups) { for (let group of groups) {
const template = $("#group_list_template .group_select").clone(); const template = $("#group_list_template .group_select").clone();
template.data("id", group.id); template.data("id", group.id);
template.attr("grid", group.id);
template.find(".ch_name").text(group.name); template.find(".ch_name").text(group.name);
$("#rm_print_characters_block").prepend(template); $("#rm_print_characters_block").prepend(template);
updateGroupAvatar(group); updateGroupAvatar(group);