Customizable sorting order for characters list

This commit is contained in:
SillyLossy
2023-04-10 17:48:17 +03:00
parent d1fb575243
commit defa7f357e
5 changed files with 79 additions and 15 deletions

View File

@ -42,6 +42,7 @@ import {
collapseNewlines,
loadPowerUserSettings,
playMessageSound,
sortCharactersList,
power_user,
} from "./scripts/power-user.js";
@ -609,7 +610,7 @@ function printCharacters() {
//console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')');
});
printGroups();
sortCharactersList('name', 'asc');
sortCharactersList();
}
async function getCharacters() {
@ -3066,14 +3067,6 @@ function setGenerationProgress(progress) {
}
}
function sortCharactersList(field, order) {
let orderedList = characters.slice().sort((a, b) => order == 'asc' ? a[field].localeCompare(b[field]) : b[field].localeCompare(a[field]));
for (let i = 0; i < characters.length; i++) {
$(`.character_select[chid="${i}"]`).css({ 'order': orderedList.indexOf(characters[i]) });
}
}
function isHordeGenerationNotAllowed() {
if (main_api == "kobold" && horde_settings.use_horde && preset_settings == "gui") {
callPopup('GUI Settings preset is not supported for Horde. Please select another preset.', 'text');