chore(webui): give feedback via toasts instead of alerts (#1269)

Reviewed-on: OpenWF/SpaceNinjaServer#1269
This commit is contained in:
Sainan 2025-03-22 01:10:41 -07:00
parent 5038095c13
commit aa95074ee0
7 changed files with 29 additions and 5 deletions

View File

@ -593,6 +593,7 @@
<button class="btn btn-primary mt-3" onclick="doImport();" data-loc="import_submit"></button>
</div>
</div>
<div class="toast-container position-fixed bottom-0 end-0 p-3"></div>
</div>
<datalist id="datalist-Suits"></datalist>
<datalist id="datalist-SpaceSuits"></datalist>

View File

@ -707,7 +707,7 @@ function maxRankAllEquipment(categories) {
return sendBatchGearExp(batchData);
}
alert(loc("code_noEquipmentToRankUp"));
toast(loc("code_noEquipmentToRankUp"));
});
});
}
@ -740,6 +740,7 @@ function sendBatchGearExp(data) {
contentType: "application/json",
data: JSON.stringify(data)
}).done(() => {
toast(loc("code_succRankUp"));
updateInventory();
});
});
@ -822,7 +823,7 @@ function doAcquireMiscItems() {
}
])
}).done(function () {
alert(loc("code_succAdded"));
toast(loc("code_succAdded"));
});
});
}
@ -1019,9 +1020,9 @@ function doUnlockAllFocusSchools() {
await unlockFocusSchool(upgradeType);
}
if (Object.keys(missingFocusUpgrades).length == 0) {
alert(loc("code_focusAllUnlocked"));
toast(loc("code_focusAllUnlocked"));
} else {
alert(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
}
});
});
@ -1155,7 +1156,7 @@ function doImport() {
inventory: JSON.parse($("#import-inventory").val())
})
}).then(function () {
alert(loc("code_succImport"));
toast(loc("code_succImport"));
updateInventory();
});
});
@ -1192,3 +1193,20 @@ function doQuestUpdate(operation) {
updateInventory();
});
}
function toast(text) {
const toast = document.createElement("div");
toast.className = "toast align-items-center text-bg-primary border-0";
const div = document.createElement("div");
div.className = "d-flex";
const body = document.createElement("div");
body.className = "toast-body";
body.textContent = text;
div.appendChild(body);
const button = document.createElement("button");
button.className = "btn-close btn-close-white me-2 m-auto";
button.setAttribute("data-bs-dismiss", "toast");
div.appendChild(button);
toast.appendChild(div);
new bootstrap.Toast(document.querySelector(".toast-container").appendChild(toast)).show();
}

View File

@ -26,6 +26,7 @@ dict = {
code_renamePrompt: `Neuen benutzerdefinierten Namen eingeben:`,
code_remove: `Entfernen`,
code_addItemsConfirm: `Bist du sicher, dass du |COUNT| Gegenstände zu deinem Account hinzufügen möchtest?`,
code_succRankUp: `[UNTRANSLATED] Successfully ranked up.`,
code_noEquipmentToRankUp: `Keine Ausstattung zum Rangaufstieg verfügbar.`,
code_succAdded: `Erfolgreich hinzugefügt.`,
code_buffsNumber: `Anzahl der Buffs`,

View File

@ -25,6 +25,7 @@ dict = {
code_renamePrompt: `Enter new custom name:`,
code_remove: `Remove`,
code_addItemsConfirm: `Are you sure you want to add |COUNT| items to your account?`,
code_succRankUp: `Successfully ranked up.`,
code_noEquipmentToRankUp: `No equipment to rank up.`,
code_succAdded: `Successfully added.`,
code_buffsNumber: `Number of buffs`,

View File

@ -26,6 +26,7 @@ dict = {
code_renamePrompt: `Nouveau nom :`,
code_remove: `Retirer`,
code_addItemsConfirm: `Ajouter |COUNT| items à l'inventaire ?`,
code_succRankUp: `[UNTRANSLATED] Successfully ranked up.`,
code_noEquipmentToRankUp: `No equipment to rank up.`,
code_succAdded: `Ajouté.`,
code_buffsNumber: `Nombre de buffs`,

View File

@ -26,6 +26,7 @@ dict = {
code_renamePrompt: `Введите новое имя:`,
code_remove: `Удалить`,
code_addItemsConfirm: `Вы уверены, что хотите добавить |COUNT| предметов на ваш аккаунт?`,
code_succRankUp: `[UNTRANSLATED] Successfully ranked up.`,
code_noEquipmentToRankUp: `Нет снаряжения для повышения ранга.`,
code_succAdded: `Успешно добавлено.`,
code_buffsNumber: `Количество усилений`,

View File

@ -26,6 +26,7 @@ dict = {
code_renamePrompt: `输入新的自定义名称:`,
code_remove: `移除`,
code_addItemsConfirm: `确定要向账户添加 |COUNT| 件物品吗?`,
code_succRankUp: `[UNTRANSLATED] Successfully ranked up.`,
code_noEquipmentToRankUp: `没有可升级的装备。`,
code_succAdded: `已成功添加。`,
code_buffsNumber: `增益数量`,