From beb02bffb01033a001eb55fe9ef801af4e458316 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Mar 2025 03:37:06 -0700 Subject: [PATCH] chore(webui): say "successfully removed" when using a negative quantity (#1271) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1271 --- static/webui/script.js | 31 +++++++++++++++++++------------ static/webui/translations/en.js | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 12894c2b..d786b2b4 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -812,20 +812,27 @@ function doAcquireMiscItems() { $("#miscitem-type").addClass("is-invalid").focus(); return; } - revalidateAuthz(() => { - $.post({ - url: "/custom/addItems?" + window.authz, - contentType: "application/json", - data: JSON.stringify([ - { - ItemType: uniqueName, - ItemCount: parseInt($("#miscitem-count").val()) + const count = parseInt($("#miscitem-count").val()); + if (count != 0) { + revalidateAuthz(() => { + $.post({ + url: "/custom/addItems?" + window.authz, + contentType: "application/json", + data: JSON.stringify([ + { + ItemType: uniqueName, + ItemCount: count + } + ]) + }).done(function () { + if (count > 0) { + toast(loc("code_succAdded")); + } else { + toast(loc("code_succRemoved")); } - ]) - }).done(function () { - toast(loc("code_succAdded")); + }); }); - }); + } } function doAcquireRiven() { diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index 4b10f0cf..ee197c9e 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -28,6 +28,7 @@ dict = { code_succRankUp: `Successfully ranked up.`, code_noEquipmentToRankUp: `No equipment to rank up.`, code_succAdded: `Successfully added.`, + code_succRemoved: `Successfully removed.`, code_buffsNumber: `Number of buffs`, code_cursesNumber: `Number of curses`, code_rerollsNumber: `Number of rerolls`,