From 11fe03346084411fba6f2569788d56a5ea79e33c Mon Sep 17 00:00:00 2001 From: venizelou andreas Date: Wed, 15 May 2024 23:08:19 +0300 Subject: [PATCH] Menu exact-match order fix --- Protest/Front/ui.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Protest/Front/ui.js b/Protest/Front/ui.js index 53861794..27849432 100644 --- a/Protest/Front/ui.js +++ b/Protest/Front/ui.js @@ -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( @@ -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); @@ -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( @@ -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); @@ -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)";