返回提交历史
Modified
static/webui/index.html
+6
-0
Modified
static/webui/script.js
+44
-0
XFEstudio/XFESpaceNinjaServer
feat(webui): add "add missing mods" (#804)
Co-authored-by: Chinosu <46995931+Chinosu@users.noreply.github.com>
fc8537ba
代码差异
2 个文件
+50
-0
@@ -199,6 +199,12 @@
199
199
</table>
200
200
</div>
201
201
</div>
202
<div class="card mb-3">
203
<h5 class="card-header">Bulk Actions</h5>
204
<div class="card-body">
205
<button class="btn btn-primary" onclick="doAddAllMods();">Add Missing Mods</button>
206
</div>
207
</div>
202
208
</div>
203
209
</div>
204
210
</div>
@@ -1077,6 +1077,50 @@ function doHelminthUnlockAll() {
1077
1077
});
1078
1078
}
1079
1079
1080
function doAddAllMods() {
1081
let modsAll = new Set();
1082
for (const child of document.getElementById("datalist-mods").children) {
1083
modsAll.add(child.getAttribute("data-key"));
1084
}
1085
1086
revalidateAuthz(() => {
1087
const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1");
1088
req.done(data => {
1089
for (const modOwned of data.RawUpgrades) {
1090
if (modOwned.ItemCount ?? 1 > 0) {
1091
modsAll.delete(modOwned.ItemType);
1092
}
1093
}
1094
1095
modsAll = Array.from(modsAll);
1096
if (
1097
modsAll.length != 0 &&
1098
window.confirm("Are you sure you want to add " + modsAll.length + " mods to your account?")
1099
) {
1100
// Batch to avoid PayloadTooLargeError
1101
const batches = [];
1102
for (let i = 0; i < modsAll.length; i += 1000) {
1103
batches.push(modsAll.slice(i, i + 1000));
1104
}
1105
batches.forEach(batch => {
1106
$.post({
1107
url: "/api/missionInventoryUpdate.php?" + window.authz,
1108
contentType: "text/plain",
1109
data: JSON.stringify({
1110
RawUpgrades: batch.map(mod => ({
1111
ItemType: mod,
1112
ItemCount: 21 // To fully upgrade certain arcanes
1113
}))
1114
})
1115
}).done(function () {
1116
updateInventory();
1117
});
1118
});
1119
}
1120
});
1121
});
1122
}
1123
1080
1124
// Powersuit Route
1081
1125
1082
1126
single.getRoute("#powersuit-route").on("beforeload", function () {