From fe9f19af1c9b46b48f92027c5049ac8d00c16652 Mon Sep 17 00:00:00 2001 From: ny <64143453+nyaoouo@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:32:07 +0800 Subject: [PATCH] add remove button and clear input after add booster --- static/webui/script.js | 29 +++++++++++++++++++++-------- static/webui/translations/de.js | 1 + static/webui/translations/en.js | 1 + static/webui/translations/es.js | 1 + static/webui/translations/fr.js | 1 + static/webui/translations/ru.js | 1 + static/webui/translations/zh.js | 1 + 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 62abca5c..9024c02e 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1033,6 +1033,17 @@ function updateInventory() { const input = document.createElement("input"); const a = document.createElement("a"); + const removeButton = document.createElement("a"); + removeButton.title = loc("code_remove"); + removeButton.innerHTML = ``; + removeButton.href = "#"; + removeButton.onclick = function (event) { + event.preventDefault(); + setBooster(ItemType, 0); + }; + removeButton.classList.add("me-2"); + td.appendChild(removeButton); + a.href = "#"; a.onclick = event => { event.preventDefault(); @@ -1053,7 +1064,7 @@ function updateInventory() { td.appendChild(a); const submit = () => { - if (doChangeBoosterExpiry(ItemType, input.value)) { + if (doChangeBoosterExpiry(ItemType, input)) { inlineForm.style.display = "none"; input.value = ""; a.style.display = "inline"; @@ -2099,7 +2110,7 @@ function handleModularSelection(category) { }); } -function setBooster(ItemType, ExpiryDate) { +function setBooster(ItemType, ExpiryDate, callback) { revalidateAuthz(() => { $.post({ url: "/custom/setBooster?" + window.authz, @@ -2112,6 +2123,7 @@ function setBooster(ItemType, ExpiryDate) { ]) }).done(function () { updateInventory(); + if (callback) callback(); }); }); } @@ -2123,17 +2135,18 @@ function doAcquireBoosters() { return; } const ExpiryDate = Date.now() / 1000 + 3 * 24 * 60 * 60; // default 3 days - setBooster(uniqueName, ExpiryDate); + setBooster(uniqueName, ExpiryDate, () => { + $("#acquire-type-Boosters").val(""); + updateInventory(); + }); } function doChangeBoosterExpiry(ItemType, ExpiryDateInput) { - console.log("Changing booster expiry for", ItemType, "to", ExpiryDateInput); + console.log("Changing booster expiry for", ItemType, "to", ExpiryDateInput.value); // cast local datetime string to unix timestamp - const ExpiryDate = new Date(ExpiryDateInput).getTime() / 1000; + const ExpiryDate = new Date(ExpiryDateInput.value).getTime() / 1000; if (isNaN(ExpiryDate)) { - $("#expiry-date-" + ItemType) - .addClass("is-invalid") - .focus(); + ExpiryDateInput.addClass("is-invalid").focus(); return false; } setBooster(ItemType, ExpiryDate); diff --git a/static/webui/translations/de.js b/static/webui/translations/de.js index 4e1b8a2d..9fb692df 100644 --- a/static/webui/translations/de.js +++ b/static/webui/translations/de.js @@ -37,6 +37,7 @@ dict = { code_rankUp: `Rang erhöhen`, code_rankDown: `Rang verringern`, code_count: `Anzahl`, + code_changeExpiry: `[UNTRANSLATED] Change Expiry Time`, code_focusAllUnlocked: `Alle Fokus-Schulen sind bereits freigeschaltet.`, code_focusUnlocked: `|COUNT| neue Fokus-Schulen freigeschaltet! Ein Inventar-Update wird benötigt, damit die Änderungen im Spiel sichtbar werden. Die Sternenkarte zu besuchen, sollte der einfachste Weg sein, dies auszulösen.`, code_addModsConfirm: `Bist du sicher, dass du |COUNT| Mods zu deinem Account hinzufügen möchtest?`, diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index 79cec6e7..3372d574 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -36,6 +36,7 @@ dict = { code_rankUp: `Rank up`, code_rankDown: `Rank down`, code_count: `Count`, + code_changeExpiry: `Change Expiry Time`, code_focusAllUnlocked: `All focus schools are already unlocked.`, code_focusUnlocked: `Unlocked |COUNT| new focus schools! An inventory update will be needed for the changes to be reflected in-game. Visiting the navigation should be the easiest way to trigger that.`, code_addModsConfirm: `Are you sure you want to add |COUNT| mods to your account?`, diff --git a/static/webui/translations/es.js b/static/webui/translations/es.js index 72d8453b..c1c7d549 100644 --- a/static/webui/translations/es.js +++ b/static/webui/translations/es.js @@ -37,6 +37,7 @@ dict = { code_rankUp: `Subir de rango`, code_rankDown: `Bajar de rango`, code_count: `Cantidad`, + code_changeExpiry: `[UNTRANSLATED] Change Expiry Time`, code_focusAllUnlocked: `Todas las escuelas de enfoque ya están desbloqueadas.`, code_focusUnlocked: `¡Desbloqueadas |COUNT| nuevas escuelas de enfoque! Se necesita una actualización del inventario para reflejar los cambios en el juego. Visitar la navegación debería ser la forma más sencilla de activarlo.`, code_addModsConfirm: `¿Estás seguro de que deseas agregar |COUNT| modificadores a tu cuenta?`, diff --git a/static/webui/translations/fr.js b/static/webui/translations/fr.js index bc079ef0..31bee75e 100644 --- a/static/webui/translations/fr.js +++ b/static/webui/translations/fr.js @@ -37,6 +37,7 @@ dict = { code_rankUp: `Monter de rang`, code_rankDown: `Baisser de rang`, code_count: `Quantité`, + code_changeExpiry: `[UNTRANSLATED] Change Expiry Time`, code_focusAllUnlocked: `Les écoles de Focus sont déjà déverrouillées.`, code_focusUnlocked: `|COUNT| écoles de Focus déverrouillées ! Synchronisation de l'inventaire nécessaire.`, code_addModsConfirm: `Ajouter |COUNT| mods à l'inventaire ?`, diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js index c99ca154..181f6fac 100644 --- a/static/webui/translations/ru.js +++ b/static/webui/translations/ru.js @@ -37,6 +37,7 @@ dict = { code_rankUp: `Повысить Ранг`, code_rankDown: `Понизить Ранг`, code_count: `Количество`, + code_changeExpiry: `[UNTRANSLATED] Change Expiry Time`, code_focusAllUnlocked: `Все школы фокуса уже разблокированы.`, code_focusUnlocked: `Разблокировано |COUNT| новых школ фокуса! Для отображения изменений в игре потребуется обновление инвентаря. Посещение навигации — самый простой способ этого добиться.`, code_addModsConfirm: `Вы уверены, что хотите добавить |COUNT| модов на ваш аккаунт?`, diff --git a/static/webui/translations/zh.js b/static/webui/translations/zh.js index d6eb68b3..24561018 100644 --- a/static/webui/translations/zh.js +++ b/static/webui/translations/zh.js @@ -37,6 +37,7 @@ dict = { code_rankUp: `[UNTRANSLATED] Rank up`, code_rankDown: `[UNTRANSLATED] Rank down`, code_count: `数量`, + code_changeExpiry: `更改逾期时间`, code_focusAllUnlocked: `所有专精学派均已解锁。`, code_focusUnlocked: `已解锁 |COUNT| 个新专精学派!需要游戏内仓库更新才能生效,您可以通过访问星图来触发仓库更新。`, code_addModsConfirm: `确定要向账户添加 |COUNT| 张MOD吗?`,