diff --git a/static/webui/index.html b/static/webui/index.html index 09aa22d5..d3e0eab5 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -108,6 +108,13 @@ +
+
Bulk Actions
+
+ + +
+
diff --git a/static/webui/script.js b/static/webui/script.js index 67aba6d6..948be4e5 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -190,6 +190,7 @@ function updateInventory() { document.getElementById("warframe-list").innerHTML = ""; data.Suits.forEach(item => { const tr = document.createElement("tr"); + tr.setAttribute("data-item-type", item.ItemType); { const td = document.createElement("td"); td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType; @@ -267,6 +268,7 @@ function updateInventory() { ["LongGuns", "Pistols", "Melee"].forEach(category => { data[category].forEach(item => { const tr = document.createElement("tr"); + tr.setAttribute("data-item-type", item.ItemType); { const td = document.createElement("td"); td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType; @@ -572,6 +574,43 @@ $("#weapon-to-acquire").on("input", () => { $("#weapon-to-acquire").removeClass("is-invalid"); }); +function dispatchAddItemsRequestsBatch(requests) { + revalidateAuthz(() => { + const req = $.post({ + url: "/custom/addItems?" + window.authz, + contentType: "application/json", + data: JSON.stringify(requests) + }); + req.done(() => { + updateInventory(); + }); + }); +} + +function addMissingWarframes() { + const requests = []; + document.querySelectorAll("#datalist-warframes option").forEach(elm => { + if (!document.querySelector("#warframe-list [data-item-type='" + elm.getAttribute("data-key") + "']")) { + requests.push({ type: "Powersuit", internalName: elm.getAttribute("data-key") }); + } + }); + if (requests.length != 0 && window.confirm("Are you sure you want to add " + requests.length + " items to your account?")) { + dispatchAddItemsRequestsBatch(requests); + } +} + +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") }); + } + }); + if (requests.length != 0 && window.confirm("Are you sure you want to add " + requests.length + " items to your account?")) { + dispatchAddItemsRequestsBatch(requests); + } +} + function addGearExp(category, oid, xp) { const data = {}; data[category] = [