feat(webui): add "add missing mods" #804

Merged
Sainan merged 7 commits from addmods into main 2025-01-18 16:57:39 -08:00
2 changed files with 34 additions and 1 deletions
Showing only changes of commit 8c6300d4e2 - Show all commits

View File

@ -320,7 +320,8 @@
<h5 class="card-header">Account</h5>
<div class="card-body">
<p><button class="btn btn-primary" onclick="doUnlockAllFocusSchools();">Unlock All Focus Schools</button></p>
<button class="btn btn-primary" onclick="doHelminthUnlockAll();">Fully Level Up Helminth</button>
<p><button class="btn btn-primary" onclick="doHelminthUnlockAll();">Fully Level Up Helminth</button></p>
<button class="btn btn-primary" onclick="doAddAllMods();">Add All Mods</button>
</div>
</div>
</div>

View File

@ -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 () {