From 8378797c36f5c6c1f736ed9b285858550924e428 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Thu, 10 Apr 2025 01:08:45 +0200 Subject: [PATCH] chore(webui): use select for "supported syndicate" --- static/webui/index.html | 3 +-- static/webui/script.js | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/static/webui/index.html b/static/webui/index.html index 6468d53a..86416283 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -645,7 +645,7 @@
- +
@@ -672,7 +672,6 @@ - diff --git a/static/webui/script.js b/static/webui/script.js index d55219a0..64c20cd9 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -178,9 +178,9 @@ function fetchItemList() { }); const syndicateNone = document.createElement("option"); - syndicateNone.setAttribute("data-key", ""); - syndicateNone.value = loc("cheats_none"); - document.getElementById("datalist-Syndicates").appendChild(syndicateNone); + syndicateNone.textContent = loc("cheats_none"); + document.getElementById("changeSyndicate").innerHTML = ""; + document.getElementById("changeSyndicate").appendChild(syndicateNone); window.archonCrystalUpgrades = data.archonCrystalUpgrades; @@ -264,6 +264,16 @@ function fetchItemList() { }); } else if (type == "uniqueLevelCaps") { uniqueLevelCaps = items; + } else if (type == "Syndicates") { + items.forEach(item => { + if (item.uniqueName.startsWith("RadioLegion")) { + item.name += " (" + item.uniqueName + ")"; + } + const option = document.createElement("option"); + option.value = item.uniqueName; + option.textContent = item.name; + document.getElementById("changeSyndicate").appendChild(option); + }); } else { const nameSet = new Set(); items.forEach(item => { @@ -277,9 +287,6 @@ function fetchItemList() { item.name += " " + loc("code_badItem"); } } - if (type == "Syndicates" && item.uniqueName.startsWith("RadioLegion")) { - item.name += " (" + item.uniqueName + ")"; - } if (type == "ModularParts") { const supportedModularParts = [ "LWPT_HB_DECK", @@ -823,10 +830,7 @@ function updateInventory() { single.loadRoute("/webui/inventory"); } } - document.getElementById("changeSyndicate").value = - [...document.querySelectorAll("#datalist-Syndicates option")].find( - option => option.getAttribute("data-key") === (data.SupportedSyndicate ?? "") - )?.value ?? loc("cheats_none"); + document.getElementById("changeSyndicate").value = data.SupportedSyndicate ?? ""; }); }); } @@ -1506,7 +1510,7 @@ function doImport() { } function doChangeSupportedSyndicate() { - const uniqueName = getKey(document.getElementById("changeSyndicate")); + const uniqueName = document.getElementById("changeSyndicate").value; revalidateAuthz(() => { $.get("/api/setSupportedSyndicate.php?" + window.authz + "&syndicate=" + uniqueName).done(function () {