返回提交历史
Modified
static/webui/index.html
+2
-1
Modified
static/webui/script.js
+28
-25
XFEstudio/SpaceNinjaServer
feat(webui): count input for raw add items (#3750)
Closes #2786 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3750 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
c6eab71f
代码差异
2 个文件
+30
-26
@@ -123,7 +123,8 @@
123
123
<form class="card-body" onsubmit="addItemByItemType();return false;">
124
124
<p data-loc="inventory_addItemByItemType_warning"></p>
125
125
<div class="input-group">
126
<input class="form-control" id="typeName-type" />
126
<input class="form-control" id="typeName-count" type="number" value="1" />
127
<input class="form-control w-50" id="typeName-type" />
127
128
<button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
128
129
</div>
129
130
</form>
@@ -3718,32 +3718,35 @@ function removeCountItems(uniqueName, count) {
3718
3718
3719
3719
function addItemByItemType() {
3720
3720
const ItemType = document.getElementById("typeName-type").value;
3721
// Must start with "/Lotus/", contain only letters A–Z, digits 0–9, no "//", and not end with "/"
3722
if (!ItemType || !/^\/Lotus\/(?:[A-Za-z0-9]+(?:\/[A-Za-z0-9]+)*)$/.test(ItemType)) {
3723
$("#typeName-type").addClass("is-invalid").focus();
3724
return;
3725
}
3726
revalidateAuthz().then(() => {
3727
$.post({
3728
url: "/custom/addItems?" + window.authz,
3729
contentType: "application/json",
3730
data: JSON.stringify([
3731
{
3732
ItemType,
3733
ItemCount: 1
3734
}
3735
])
3736
})
3737
.done(function (_, __, jqXHR) {
3738
if (jqXHR.status === 200) {
3739
toast(loc("code_succAdded"));
3740
updateInventory();
3741
}
3721
const ItemCount = parseInt($(`#typeName-count`).val());
3722
if (ItemCount != 0 && !Number.isNaN(ItemCount)) {
3723
revalidateAuthz().then(() => {
3724
$.post({
3725
url: "/custom/addItems?" + window.authz,
3726
contentType: "application/json",
3727
data: JSON.stringify([
3728
{
3729
ItemType,
3730
ItemCount
3731
}
3732
])
3742
3733
})
3743
.fail(function () {
3744
$("#typeName-type").addClass("is-invalid").focus();
3745
});
3746
});
3734
.done(function (didAnything) {
3735
if (didAnything) {
3736
if (ItemCount > 0) {
3737
toast(loc("code_succAdded"));
3738
} else {
3739
toast(loc("code_succRemoved"));
3740
}
3741
} else {
3742
toast(loc("code_nothingToDo"));
3743
}
3744
})
3745
.fail(r => {
3746
toast(r.responseText);
3747
});
3748
});
3749
}
3747
3750
}
3748
3751
3749
3752
function doAcquireRiven() {