move selected to the bottom in search result

This commit is contained in:
Woody 2024-11-16 19:53:10 +01:00
parent 8c5e0cd4e9
commit 6fe2024542
No known key found for this signature in database

View File

@ -2847,11 +2847,16 @@ function search(field, listId = null) {
// filter list items but leave (Default & Solid) always visible
const listItems = gId(listId).querySelectorAll('.lstI');
listItems.forEach((listItem, i) => {
if (listId!=='pcont' && i===0) return;
const listItemName = listItem.querySelector('.lstIname').innerText.toUpperCase();
const searchIndex = listItemName.indexOf(field.value.toUpperCase());
listItem.style.display = (searchIndex < 0) && !listItem.classList.contains("selected") ? 'none' : '';
if (searchIndex < 0) {
listItem.dataset.searchIndex = Number.MAX_SAFE_INTEGER;
} else {
listItem.dataset.searchIndex = searchIndex;
}
if ((listId !== 'pcont' && i === 0) || listItem.classList.contains("selected")) return;
listItem.style.display = (searchIndex < 0) ? 'none' : '';
});
// sort list items by search index and name