XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix(webui): recreate missing datalist-QuestKeys entries after refreshing inventory (#2452)

Closes #2448 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2452 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

ba70ba88
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +18 -4
Modified static/webui/script.js +18 -4
@@ -273,6 +273,8 @@ function fetchItemList() {
273 273 window.itemListPromise = new Promise(resolve => {
274 274 const req = $.get("/custom/getItemLists?lang=" + window.lang);
275 275 req.done(async data => {
276 window.allQuestKeys = data.QuestKeys;
277
276 278 await dictPromise;
277 279
278 280 document.querySelectorAll('[id^="datalist-"]').forEach(datalist => {
@@ -879,6 +881,14 @@ function updateInventory() {
879 881
880 882 // Populate quests route
881 883 document.getElementById("QuestKeys-list").innerHTML = "";
884 window.allQuestKeys.forEach(questKey => {
885 if (!data.QuestKeys.some(x => x.ItemType == questKey.uniqueName)) {
886 const datalist = document.getElementById("datalist-QuestKeys");
887 if (!datalist.querySelector(`option[data-key="${questKey.uniqueName}"]`)) {
888 readdQuestKey(itemMap, questKey.uniqueName);
889 }
890 }
891 });
882 892 data.QuestKeys.forEach(item => {
883 893 const tr = document.createElement("tr");
884 894 tr.setAttribute("data-item-type", item.ItemType);
@@ -972,10 +982,7 @@ function updateInventory() {
972 982 a.href = "#";
973 983 a.onclick = function (event) {
974 984 event.preventDefault();
975 const option = document.createElement("option");
976 option.setAttribute("data-key", item.ItemType);
977 option.value = itemMap[item.ItemType]?.name ?? item.ItemType;
978 document.getElementById("datalist-QuestKeys").appendChild(option);
985 readdQuestKey(itemMap, item.ItemType);
979 986 doQuestUpdate("deleteKey", item.ItemType);
980 987 };
981 988 a.title = loc("code_remove");
@@ -2270,6 +2277,13 @@ function doAddCurrency(currency) {
2270 2277 });
2271 2278 }
2272 2279
2280 function readdQuestKey(itemMap, itemType) {
2281 const option = document.createElement("option");
2282 option.setAttribute("data-key", itemType);
2283 option.value = itemMap[itemType]?.name ?? itemType;
2284 document.getElementById("datalist-QuestKeys").appendChild(option);
2285 }
2286
2273 2287 function doQuestUpdate(operation, itemType) {
2274 2288 revalidateAuthz().then(() => {
2275 2289 $.post({