diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 9a37fa14..bf531737 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -17,23 +17,30 @@ interface ListedItem { fusionLimit?: number; } -const getItemListsController: RequestHandler = (req, res) => { +const getItemListsController: RequestHandler = (req, response) => { const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en"); - const weapons = []; - const miscitems = []; + const res: Record = {}; + res.LongGuns = []; + res.Pistols = []; + res.Melee = []; + res.miscitems = []; for (const [uniqueName, item] of Object.entries(ExportWeapons)) { - if (item.productCategory !== "OperatorAmps") { - if (item.totalDamage !== 0) { - weapons.push({ + if (item.totalDamage !== 0) { + if ( + item.productCategory == "LongGuns" || + item.productCategory == "Pistols" || + item.productCategory == "Melee" + ) { + res[item.productCategory].push({ uniqueName, name: getString(item.name, lang) }); - } else if (!item.excludeFromCodex) { - miscitems.push({ - uniqueName: "MiscItems:" + uniqueName, - name: getString(item.name, lang) - }); } + } else if (!item.excludeFromCodex) { + res.miscitems.push({ + uniqueName: "MiscItems:" + uniqueName, + name: getString(item.name, lang) + }); } } for (const [uniqueName, item] of Object.entries(ExportResources)) { @@ -48,13 +55,13 @@ const getItemListsController: RequestHandler = (req, res) => { name = name.split("|FISH_SIZE|").join(getString("/Lotus/Language/Fish/FishSizeSmallAbbrev", lang)); } } - miscitems.push({ + res.miscitems.push({ uniqueName: item.productCategory + ":" + uniqueName, name: name }); } for (const [uniqueName, item] of Object.entries(ExportGear)) { - miscitems.push({ + res.miscitems.push({ uniqueName: "Consumables:" + uniqueName, name: getString(item.name, lang) }); @@ -64,7 +71,7 @@ const getItemListsController: RequestHandler = (req, res) => { if (!item.hidden) { const resultName = getItemName(item.resultType); if (resultName) { - miscitems.push({ + res.miscitems.push({ uniqueName: "Recipes:" + uniqueName, name: recipeNameTemplate.replace("|ITEM|", getString(resultName, lang)) }); @@ -72,10 +79,10 @@ const getItemListsController: RequestHandler = (req, res) => { } } - const mods: ListedItem[] = []; + res.mods = []; const badItems: Record = {}; for (const [uniqueName, upgrade] of Object.entries(ExportUpgrades)) { - mods.push({ + res.mods.push({ uniqueName, name: getString(upgrade.name, lang), fusionLimit: upgrade.fusionLimit @@ -85,7 +92,7 @@ const getItemListsController: RequestHandler = (req, res) => { } } for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) { - mods.push({ + res.mods.push({ uniqueName, name: getString(arcane.name, lang) }); @@ -94,7 +101,7 @@ const getItemListsController: RequestHandler = (req, res) => { } } - res.json({ + response.json({ warframes: Object.entries(ExportWarframes) .filter(([_uniqueName, warframe]) => warframe.productCategory == "Suits") .map(([uniqueName, warframe]) => { @@ -104,11 +111,9 @@ const getItemListsController: RequestHandler = (req, res) => { exalted: warframe.exalted }; }), - weapons, - miscitems, - mods, badItems, - archonCrystalUpgrades + archonCrystalUpgrades, + ...res }); }; diff --git a/static/webui/index.html b/static/webui/index.html index eb455a18..d11946a4 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -96,7 +96,7 @@
-
+
Warframes
@@ -110,15 +110,45 @@
-
-
Weapons
+
+
Primary Weapons
- - + + - + +
+
+
+
+
+
+
+
+
Secondary Weapons
+
+
+ + +
+ + +
+
+
+
+
+
+
Melee Weapons
+
+
+ + +
+ +
@@ -355,7 +385,9 @@
- + + + diff --git a/static/webui/script.js b/static/webui/script.js index 6801c77d..53d39b46 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -265,8 +265,8 @@ function updateInventory() { } document.getElementById("warframe-list").appendChild(tr); }); - document.getElementById("weapon-list").innerHTML = ""; ["LongGuns", "Pistols", "Melee"].forEach(category => { + document.getElementById(category + "-list").innerHTML = ""; data[category].forEach(item => { const tr = document.createElement("tr"); tr.setAttribute("data-item-type", item.ItemType); @@ -319,7 +319,7 @@ function updateInventory() { } tr.appendChild(td); } - document.getElementById("weapon-list").appendChild(tr); + document.getElementById(category + "-list").appendChild(tr); }); }); @@ -548,14 +548,16 @@ function doAcquireWarframe() { }); } -$("#warframe-to-acquire").on("input", () => { - $("#warframe-to-acquire").removeClass("is-invalid"); +$("input[list]").on("input", function () { + $(this).removeClass("is-invalid"); }); -function doAcquireWeapon() { - const uniqueName = getKey(document.getElementById("weapon-to-acquire")); +function doAcquireWeapon(category) { + const uniqueName = getKey(document.getElementById("acquire-type-" + category)); if (!uniqueName) { - $("#weapon-to-acquire").addClass("is-invalid").focus(); + $("#acquire-type-" + category) + .addClass("is-invalid") + .focus(); return; } revalidateAuthz(() => { @@ -570,16 +572,12 @@ function doAcquireWeapon() { ]) }); req.done(() => { - document.getElementById("weapon-to-acquire").value = ""; + document.getElementById("acquire-type-" + category).value = ""; updateInventory(); }); }); } -$("#weapon-to-acquire").on("input", () => { - $("#weapon-to-acquire").removeClass("is-invalid"); -}); - function dispatchAddItemsRequestsBatch(requests) { revalidateAuthz(() => { const req = $.post({ @@ -650,11 +648,13 @@ function maxRankAllWarframes() { function addMissingWeapons() { const requests = []; - document.querySelectorAll("#datalist-weapons option").forEach(elm => { - if (!document.querySelector("#weapon-list [data-item-type='" + elm.getAttribute("data-key") + "']")) { - requests.push({ type: "Weapon", internalName: elm.getAttribute("data-key") }); - } - }); + document + .querySelectorAll("#datalist-LongGuns option, #datalist-Pistols option, #datalist-Melee option") + .forEach(elm => { + if (!document.querySelector("#weapon-list [data-item-type='" + elm.getAttribute("data-key") + "']")) { + requests.push({ type: "Weapon", internalName: elm.getAttribute("data-key") }); + } + }); if ( requests.length != 0 && window.confirm("Are you sure you want to add " + requests.length + " items to your account?") @@ -809,10 +809,6 @@ function doAcquireMiscItems() { }); } -$("#miscitem-type").on("input", () => { - $("#miscitem-type").removeClass("is-invalid"); -}); - function doAcquireRiven() { let fingerprint; try { @@ -925,10 +921,6 @@ function doAcquireMod() { }); } -$("#mod-to-acquire").on("input", () => { - $("#mod-to-acquire").removeClass("is-invalid"); -}); - const uiConfigs = [...$("#server-settings input[id]")].map(x => x.id); function doChangeSettings() { @@ -1155,10 +1147,6 @@ function doPushArchonCrystalUpgrade() { }); } -$("[list='datalist-archonCrystalUpgrades']").on("input", () => { - $("[list='datalist-archonCrystalUpgrades']").removeClass("is-invalid"); -}); - function doPopArchonCrystalUpgrade(type) { revalidateAuthz(() => { $.get(