Skip to content

Commit

Permalink
Menu exact-match order fix
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed May 15, 2024
1 parent 8e3f0c0 commit 11fe033
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions Protest/Front/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,10 @@ const MENU = {
}
}

let count = 0;
if (keywords.length > 0) { //inventory
let count = 0;
exactMatchDevices = [];

for (const file in LOADER.devices.data) {
const match = keywords.every(
keyword=> Object.values(LOADER.devices.data[file]).some(
Expand Down Expand Up @@ -661,8 +663,9 @@ const MENU = {
}

if (exactMatch) {
MENU.list.unshift(item);
menulist.prepend(item);
//MENU.list.unshift(item);
//menulist.prepend(item);
exactMatchDevices.push(item);
}
else {
MENU.list.push(item);
Expand All @@ -672,6 +675,9 @@ const MENU = {
if (++count > 32) break;
}

count = 0;
exactMatchUsers = [];

for (const file in LOADER.users.data) {
const match = keywords.every(
keyword=> Object.values(LOADER.users.data[file]).some(
Expand Down Expand Up @@ -724,8 +730,9 @@ const MENU = {
}

if (exactMatch) {
MENU.list.unshift(item);
menulist.prepend(item);
//MENU.list.unshift(item);
//menulist.prepend(item);
exactMatchUsers.push(item);
}
else {
MENU.list.push(item);
Expand All @@ -735,6 +742,16 @@ const MENU = {
if (++count > 32) break;
}

for (let i=exactMatchUsers.length-1; i >= 0; i--) {
MENU.list.unshift(exactMatchUsers[i]);
menulist.prepend(exactMatchUsers[i]);
}

for (let i=exactMatchDevices.length-1; i >= 0; i--) {
MENU.list.unshift(exactMatchDevices[i]);
menulist.prepend(exactMatchDevices[i]);
}

if (MENU.list.length > 0) {
MENU.index = 0;
MENU.list[0].style.backgroundColor = "var(--clr-transparent)";
Expand Down

0 comments on commit 11fe033

Please sign in to comment.