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;">
|
<form class="mt-2" onsubmit="doChangeSupportedSyndicate(); return false;">
|
||||||
<label class="form-label" for="changeSyndicate" data-loc="cheats_changeSupportedSyndicate"></label>
|
<label class="form-label" for="changeSyndicate" data-loc="cheats_changeSupportedSyndicate"></label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select class="form-control" id="changeSyndicate">
|
<input class="form-control" id="changeSyndicate" list="datalist-Syndicates" />
|
||||||
<option value="" data-loc="cheats_none"></option>
|
|
||||||
</select>
|
|
||||||
<button class="btn btn-primary" type="submit" data-loc="cheats_changeButton"></button>
|
<button class="btn btn-primary" type="submit" data-loc="cheats_changeButton"></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -593,6 +591,7 @@
|
|||||||
<datalist id="datalist-Sentinels"></datalist>
|
<datalist id="datalist-Sentinels"></datalist>
|
||||||
<datalist id="datalist-ModularParts"></datalist>
|
<datalist id="datalist-ModularParts"></datalist>
|
||||||
<datalist id="datalist-MechSuits"></datalist>
|
<datalist id="datalist-MechSuits"></datalist>
|
||||||
|
<datalist id="datalist-Syndicates"></datalist>
|
||||||
<datalist id="datalist-miscitems"></datalist>
|
<datalist id="datalist-miscitems"></datalist>
|
||||||
<datalist id="datalist-mods">
|
<datalist id="datalist-mods">
|
||||||
<option data-key="/Lotus/Upgrades/Mods/Fusers/LegendaryModFuser" value="Legendary Core"></option>
|
<option data-key="/Lotus/Upgrades/Mods/Fusers/LegendaryModFuser" value="Legendary Core"></option>
|
||||||
|
@ -129,7 +129,11 @@ function setActiveLanguage(lang) {
|
|||||||
|
|
||||||
window.dictPromise = new Promise(resolve => {
|
window.dictPromise = new Promise(resolve => {
|
||||||
const webui_lang = ["en", "ru", "fr"].indexOf(lang) == -1 ? "en" : lang;
|
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.src = "/translations/" + webui_lang + ".js";
|
||||||
script.onload = function () {
|
script.onload = function () {
|
||||||
updateLocElements();
|
updateLocElements();
|
||||||
@ -157,6 +161,15 @@ function fetchItemList() {
|
|||||||
req.done(async data => {
|
req.done(async data => {
|
||||||
await dictPromise;
|
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;
|
window.archonCrystalUpgrades = data.archonCrystalUpgrades;
|
||||||
|
|
||||||
const itemMap = {
|
const itemMap = {
|
||||||
@ -198,15 +211,6 @@ function fetchItemList() {
|
|||||||
});
|
});
|
||||||
} else if (type == "uniqueLevelCaps") {
|
} else if (type == "uniqueLevelCaps") {
|
||||||
uniqueLevelCaps = items;
|
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 {
|
} else {
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
if ("badReason" in item) {
|
if ("badReason" in item) {
|
||||||
@ -216,6 +220,9 @@ function fetchItemList() {
|
|||||||
item.name += " " + loc("code_badItem");
|
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") {
|
if (item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/" && item.badReason != "notraw") {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.setAttribute("data-key", item.uniqueName);
|
option.setAttribute("data-key", item.uniqueName);
|
||||||
@ -564,8 +571,10 @@ function updateInventory() {
|
|||||||
single.loadRoute("/webui/inventory");
|
single.loadRoute("/webui/inventory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
document.getElementById("changeSyndicate").value =
|
||||||
document.getElementById("changeSyndicate").value = data.SupportedSyndicate ?? "";
|
[...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() {
|
function doChangeSupportedSyndicate() {
|
||||||
const uniqueName = document.getElementById("changeSyndicate").value;
|
const uniqueName = getKey(document.getElementById("changeSyndicate"));
|
||||||
|
|
||||||
revalidateAuthz(() => {
|
revalidateAuthz(() => {
|
||||||
$.get("/api/setSupportedSyndicate.php?" + window.authz + "&syndicate=" + uniqueName).done(function () {
|
$.get("/api/setSupportedSyndicate.php?" + window.authz + "&syndicate=" + uniqueName).done(function () {
|
||||||
updateInventory();
|
updateInventory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user