From 8c6300d4e2bfc8a9874e299588a2be82db900a06 Mon Sep 17 00:00:00 2001 From: Chinosu <46995931+Chinosu@users.noreply.github.com> Date: Sat, 18 Jan 2025 19:08:42 +1100 Subject: [PATCH 1/7] Add all missing mods --- static/webui/index.html | 3 ++- static/webui/script.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/static/webui/index.html b/static/webui/index.html index 5d037980..3d690e16 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -320,7 +320,8 @@
Account

- +

+
diff --git a/static/webui/script.js b/static/webui/script.js index 68dd9db1..f9e6e851 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1077,6 +1077,38 @@ function doHelminthUnlockAll() { }); } +function doAddAllMods() { + const mods = []; + for (const child of document.getElementById("datalist-mods").children) { + mods.push(child.getAttribute("data-key")); + } + + // Batch to avoid PayloadTooLargeError + const batchSize = 500; + const batches = []; + for (let i = 0; i < mods.length; i += batchSize) { + batches.push(mods.slice(i, i + batchSize)); + } + + batches.forEach(batch => { + revalidateAuthz(() => { + $.post({ + url: "/api/missionInventoryUpdate.php?" + window.authz, + contentType: "text/plain", + data: JSON.stringify({ + RawUpgrades: batch.map(mod => ({ + ItemType: mod, + ItemCount: 21 // Needed to fully upgrade certain arcanes + })) + }) + }).done(function () { + document.getElementById("mod-to-acquire").value = ""; + updateInventory(); + }); + }); + }); +} + // Powersuit Route single.getRoute("#powersuit-route").on("beforeload", function () { -- 2.47.2 From c2f4176a7470171982a1534540523da0e1e33991 Mon Sep 17 00:00:00 2001 From: Chinosu <46995931+Chinosu@users.noreply.github.com> Date: Sat, 18 Jan 2025 20:05:06 +1100 Subject: [PATCH 2/7] Only add missing mods --- static/webui/index.html | 2 +- static/webui/script.js | 51 +++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/static/webui/index.html b/static/webui/index.html index 3d690e16..47c24097 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -321,7 +321,7 @@

- +
diff --git a/static/webui/script.js b/static/webui/script.js index f9e6e851..2e45ff4d 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1078,32 +1078,39 @@ function doHelminthUnlockAll() { } function doAddAllMods() { - const mods = []; + let modsAll = new Set(); for (const child of document.getElementById("datalist-mods").children) { - mods.push(child.getAttribute("data-key")); + modsAll.add(child.getAttribute("data-key")); } - // Batch to avoid PayloadTooLargeError - const batchSize = 500; - const batches = []; - for (let i = 0; i < mods.length; i += batchSize) { - batches.push(mods.slice(i, i + batchSize)); - } + const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1"); + req.done(data => { + for (const modOwned of data.RawUpgrades) { + if (modOwned.ItemCount ?? 1 > 0) { + modsAll.delete(modOwned.ItemType); + } + } - batches.forEach(batch => { - revalidateAuthz(() => { - $.post({ - url: "/api/missionInventoryUpdate.php?" + window.authz, - contentType: "text/plain", - data: JSON.stringify({ - RawUpgrades: batch.map(mod => ({ - ItemType: mod, - ItemCount: 21 // Needed to fully upgrade certain arcanes - })) - }) - }).done(function () { - document.getElementById("mod-to-acquire").value = ""; - updateInventory(); + modsAll = Array.from(modsAll); + const batches = []; + for (let i = 0; i < modsAll.length; i += 1000) { + batches.push(modsAll.slice(i, i + 1000)); + } + batches.forEach(batch => { + revalidateAuthz(() => { + $.post({ + url: "/api/missionInventoryUpdate.php?" + window.authz, + contentType: "text/plain", + data: JSON.stringify({ + RawUpgrades: batch.map(mod => ({ + ItemType: mod, + ItemCount: 21 // To fully upgrade certain arcanes + })) + }) + }).done(function () { + document.getElementById("mod-to-acquire").value = ""; + updateInventory(); + }); }); }); }); -- 2.47.2 From 0889c70acc1424b30efd971f0716a83bd18d4fa6 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 10:54:47 +0100 Subject: [PATCH 3/7] Maintain comment --- static/webui/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/webui/script.js b/static/webui/script.js index 2e45ff4d..36b610a2 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1092,6 +1092,7 @@ function doAddAllMods() { } modsAll = Array.from(modsAll); + // Batch to avoid PayloadTooLargeError const batches = []; for (let i = 0; i < modsAll.length; i += 1000) { batches.push(modsAll.slice(i, i + 1000)); -- 2.47.2 From 8702b95a81951af83a48457038ab2c7ce0c61b79 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 10:57:14 +0100 Subject: [PATCH 4/7] Revalidate authz before requesting inventory --- static/webui/script.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 36b610a2..f4bcf1f3 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1083,22 +1083,22 @@ function doAddAllMods() { modsAll.add(child.getAttribute("data-key")); } - const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1"); - req.done(data => { - for (const modOwned of data.RawUpgrades) { - if (modOwned.ItemCount ?? 1 > 0) { - modsAll.delete(modOwned.ItemType); + revalidateAuthz(() => { + const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1"); + req.done(data => { + for (const modOwned of data.RawUpgrades) { + if (modOwned.ItemCount ?? 1 > 0) { + modsAll.delete(modOwned.ItemType); + } } - } - modsAll = Array.from(modsAll); - // Batch to avoid PayloadTooLargeError - const batches = []; - for (let i = 0; i < modsAll.length; i += 1000) { - batches.push(modsAll.slice(i, i + 1000)); - } - batches.forEach(batch => { - revalidateAuthz(() => { + modsAll = Array.from(modsAll); + // Batch to avoid PayloadTooLargeError + const batches = []; + for (let i = 0; i < modsAll.length; i += 1000) { + batches.push(modsAll.slice(i, i + 1000)); + } + batches.forEach(batch => { $.post({ url: "/api/missionInventoryUpdate.php?" + window.authz, contentType: "text/plain", -- 2.47.2 From 664e3cc9caa0ff3046d25030cc1f081603278ee1 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 10:58:34 +0100 Subject: [PATCH 5/7] Not needed --- static/webui/script.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/webui/script.js b/static/webui/script.js index f4bcf1f3..a2a1be52 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1109,7 +1109,6 @@ function doAddAllMods() { })) }) }).done(function () { - document.getElementById("mod-to-acquire").value = ""; updateInventory(); }); }); -- 2.47.2 From c312814001930ffe898defd711991982c075e024 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 11:00:32 +0100 Subject: [PATCH 6/7] Require confirmation --- static/webui/script.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index a2a1be52..0c023d44 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1093,25 +1093,30 @@ function doAddAllMods() { } modsAll = Array.from(modsAll); - // Batch to avoid PayloadTooLargeError - const batches = []; - for (let i = 0; i < modsAll.length; i += 1000) { - batches.push(modsAll.slice(i, i + 1000)); - } - batches.forEach(batch => { - $.post({ - url: "/api/missionInventoryUpdate.php?" + window.authz, - contentType: "text/plain", - data: JSON.stringify({ - RawUpgrades: batch.map(mod => ({ - ItemType: mod, - ItemCount: 21 // To fully upgrade certain arcanes - })) - }) - }).done(function () { - updateInventory(); + if ( + modsAll.length != 0 && + window.confirm("Are you sure you want to add " + modsAll.length + " mods to your account?") + ) { + // Batch to avoid PayloadTooLargeError + const batches = []; + for (let i = 0; i < modsAll.length; i += 1000) { + batches.push(modsAll.slice(i, i + 1000)); + } + batches.forEach(batch => { + $.post({ + url: "/api/missionInventoryUpdate.php?" + window.authz, + contentType: "text/plain", + data: JSON.stringify({ + RawUpgrades: batch.map(mod => ({ + ItemType: mod, + ItemCount: 21 // To fully upgrade certain arcanes + })) + }) + }).done(function () { + updateInventory(); + }); }); - }); + } }); }); } -- 2.47.2 From 26d8d7696db43635753353d04cd1177224314634 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 11:02:40 +0100 Subject: [PATCH 7/7] Move add missing mods button to mods tab --- static/webui/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/webui/index.html b/static/webui/index.html index 47c24097..eb455a18 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -199,6 +199,12 @@ +
+
Bulk Actions
+
+ +
+
@@ -320,8 +326,7 @@
Account

-

- +
-- 2.47.2