forked from OpenWF/SpaceNinjaServer
fix(webui): remove unnecessary elements when changing language (#1095)
Fixes #1094 Reviewed-on: OpenWF/SpaceNinjaServer#1095 Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
This commit is contained in:
parent
77aa1caa8f
commit
519cb26044
@ -555,9 +555,7 @@
|
||||
<form class="mt-2" onsubmit="doChangeSupportedSyndicate(); return false;">
|
||||
<label class="form-label" for="changeSyndicate" data-loc="cheats_changeSupportedSyndicate"></label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="changeSyndicate">
|
||||
<option value="" data-loc="cheats_none"></option>
|
||||
</select>
|
||||
<input class="form-control" id="changeSyndicate" list="datalist-Syndicates" />
|
||||
<button class="btn btn-primary" type="submit" data-loc="cheats_changeButton"></button>
|
||||
</div>
|
||||
</form>
|
||||
@ -593,6 +591,7 @@
|
||||
<datalist id="datalist-Sentinels"></datalist>
|
||||
<datalist id="datalist-ModularParts"></datalist>
|
||||
<datalist id="datalist-MechSuits"></datalist>
|
||||
<datalist id="datalist-Syndicates"></datalist>
|
||||
<datalist id="datalist-miscitems"></datalist>
|
||||
<datalist id="datalist-mods">
|
||||
<option data-key="/Lotus/Upgrades/Mods/Fusers/LegendaryModFuser" value="Legendary Core"></option>
|
||||
|
@ -129,7 +129,11 @@ function setActiveLanguage(lang) {
|
||||
|
||||
window.dictPromise = new Promise(resolve => {
|
||||
const webui_lang = ["en", "ru", "fr"].indexOf(lang) == -1 ? "en" : lang;
|
||||
const script = document.createElement("script");
|
||||
let script = document.getElementById("translations");
|
||||
if (script) document.documentElement.removeChild(script);
|
||||
|
||||
script = document.createElement("script");
|
||||
script.id = "translations";
|
||||
script.src = "/translations/" + webui_lang + ".js";
|
||||
script.onload = function () {
|
||||
updateLocElements();
|
||||
@ -157,6 +161,15 @@ function fetchItemList() {
|
||||
req.done(async data => {
|
||||
await dictPromise;
|
||||
|
||||
document.querySelectorAll('[id^="datalist-"]').forEach(datalist => {
|
||||
datalist.innerHTML = "";
|
||||
});
|
||||
|
||||
const syndicateNone = document.createElement("option");
|
||||
syndicateNone.setAttribute("data-key", "");
|
||||
syndicateNone.value = loc("cheats_none");
|
||||
document.getElementById("datalist-Syndicates").appendChild(syndicateNone);
|
||||
|
||||
window.archonCrystalUpgrades = data.archonCrystalUpgrades;
|
||||
|
||||
const itemMap = {
|
||||
@ -198,15 +211,6 @@ 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.innerHTML = item.name;
|
||||
document.getElementById("changeSyndicate").appendChild(option);
|
||||
itemMap[item.uniqueName] = { ...item, type };
|
||||
});
|
||||
} else {
|
||||
items.forEach(item => {
|
||||
if ("badReason" in item) {
|
||||
@ -216,6 +220,9 @@ function fetchItemList() {
|
||||
item.name += " " + loc("code_badItem");
|
||||
}
|
||||
}
|
||||
if (type == "Syndicates" && item.uniqueName.startsWith("RadioLegion")) {
|
||||
item.name += " (" + item.uniqueName + ")";
|
||||
}
|
||||
if (item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/" && item.badReason != "notraw") {
|
||||
const option = document.createElement("option");
|
||||
option.setAttribute("data-key", item.uniqueName);
|
||||
@ -564,8 +571,10 @@ function updateInventory() {
|
||||
single.loadRoute("/webui/inventory");
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("changeSyndicate").value = data.SupportedSyndicate ?? "";
|
||||
document.getElementById("changeSyndicate").value =
|
||||
[...document.querySelectorAll("#datalist-Syndicates option")].find(
|
||||
option => option.getAttribute("data-key") === (data.SupportedSyndicate ?? "")
|
||||
)?.value ?? loc("cheats_none");
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -1138,7 +1147,8 @@ function doImport() {
|
||||
}
|
||||
|
||||
function doChangeSupportedSyndicate() {
|
||||
const uniqueName = document.getElementById("changeSyndicate").value;
|
||||
const uniqueName = getKey(document.getElementById("changeSyndicate"));
|
||||
|
||||
revalidateAuthz(() => {
|
||||
$.get("/api/setSupportedSyndicate.php?" + window.authz + "&syndicate=" + uniqueName).done(function () {
|
||||
updateInventory();
|
||||
|
Loading…
x
Reference in New Issue
Block a user