From daf492bf2fd07329e6823682a250aaf3743b4854 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 30 Jun 2025 22:13:01 +0200 Subject: [PATCH] simplify/improve the element query --- static/webui/script.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 6083fdcd..cf83042e 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1984,16 +1984,14 @@ single.getRoute("/webui/cheats").on("beforeload", function () { $(".config-admin-show").removeClass("d-none"); Object.entries(json).forEach(entry => { const [key, value] = entry; - var x = document.getElementById(`${key}`); - if (x != null) { - if (x.type == "checkbox") { - x.checked = value; - } else if (x.classList.contains("tags-input")) { - x.value = value.join(", "); - x.oninput(); - } else { - x.value = value ?? x.getAttribute("data-default"); - } + var elm = document.getElementById(key); + if (elm.type == "checkbox") { + elm.checked = value; + } else if (elm.classList.contains("tags-input")) { + elm.value = value.join(", "); + elm.oninput(); + } else { + elm.value = value ?? elm.getAttribute("data-default"); } }); })