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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

chrore(webui): don't add duplicates to datalists (#1510)

Browsers will show all options, even if this makes no sense, causing some confusion for users. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1510 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

1 个文件 +7 -7
Modified static/webui/script.js +7 -7
@@ -265,6 +265,7 @@ function fetchItemList() {
265 265 } else if (type == "uniqueLevelCaps") {
266 266 uniqueLevelCaps = items;
267 267 } else {
268 const nameSet = new Set();
268 269 items.forEach(item => {
269 270 if (item.name.includes("<ARCHWING> ")) {
270 271 item.name = item.name.replace("<ARCHWING> ", "");
@@ -311,20 +312,19 @@ function fetchItemList() {
311 312 document
312 313 .getElementById("datalist-" + type + "-" + item.partType.slice(5))
313 314 .appendChild(option);
315 }
316 } else if (item.badReason != "notraw") {
317 if (nameSet.has(item.name)) {
318 //console.log(`Not adding ${item.uniqueName} to datalist for ${type} due to duplicate display name: ${item.name}`);
314 319 } else {
315 console.log(item.partType);
320 nameSet.add(item.name);
321
316 322 const option = document.createElement("option");
317 323 option.setAttribute("data-key", item.uniqueName);
318 324 option.value = item.name;
319 325 document.getElementById("datalist-" + type).appendChild(option);
320 326 }
321 327 }
322 if (item.badReason != "notraw") {
323 const option = document.createElement("option");
324 option.setAttribute("data-key", item.uniqueName);
325 option.value = item.name;
326 document.getElementById("datalist-" + type).appendChild(option);
327 }
328 328 itemMap[item.uniqueName] = { ...item, type };
329 329 });
330 330 }