Pure CSS sorting by name

This commit is contained in:
SillyLossy
2023-04-09 01:10:30 +03:00
parent fe90d1afea
commit d59e1880f0
3 changed files with 12 additions and 1 deletions

View File

@ -58,7 +58,7 @@
<div id="leftNavDrawerIcon" class="drawer-icon icon-sliders closedIcon" title="AI Response Configuration"></div> <div id="leftNavDrawerIcon" class="drawer-icon icon-sliders closedIcon" title="AI Response Configuration"></div>
</div> </div>
<div id="left-nav-panel" class="drawer-content fillLeft closedDrawer widthFreeExpand"> <div id="left-nav-panel" class="drawer-content fillLeft closedDrawer widthFreeExpand">
<div class="right_menu_button" id="lm_button_panel_pin_div" title="Locked = Character Management panel will stay open"> <div class="right_menu_button" id="lm_button_panel_pin_div" title="Locked = AI Configuration panel will stay open">
<input type="checkbox" id="lm_button_panel_pin"> <input type="checkbox" id="lm_button_panel_pin">
<label for="lm_button_panel_pin"> <label for="lm_button_panel_pin">
<img class="unchecked svg_icon" alt="" src="img/lock-open-solid.svg" /> <img class="unchecked svg_icon" alt="" src="img/lock-open-solid.svg" />

View File

@ -604,6 +604,7 @@ function printCharacters() {
); );
//console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')'); //console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')');
}); });
sortCharactersList('name', 'asc');
printGroups(); printGroups();
} }
@ -3052,6 +3053,14 @@ 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]) });
}
}
window["TavernAI"].getContext = function () { window["TavernAI"].getContext = function () {
return { return {
chat: chat, chat: chat,

View File

@ -717,6 +717,8 @@ input[type="file"] {
padding: 15px 0; padding: 15px 0;
overflow-y: auto; overflow-y: auto;
flex-grow: 1; flex-grow: 1;
display: flex;
flex-direction: column;
} }
#rm_ch_create_block { #rm_ch_create_block {