From 9ff0d7f3243eecaff0b354b392fa1e3ef4784098 Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 9 Feb 2024 19:00:31 -0500 Subject: static/js/forms: Use var on loops Avoid minification breaking scripts on browsers that have shadowing issues --- assets/js/index.js | 8 ++++---- static/js/forms.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/assets/js/index.js b/assets/js/index.js index 9374f5d..42d87f3 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -700,7 +700,7 @@ const select = Array.prototype.slice.call(document.querySelectorAll("form select")); const textarea = Array.prototype.slice.call(document.querySelectorAll("form textarea")); const states = input.concat(select).concat(textarea); - for(let i1 = 0; i1 < states.length; i1++){ + for(var i1 = 0; i1 < states.length; i1++){ if (localStorage[states[i1].id]) { if (states[i1].type === "radio" || states[i1].type === "checkbox") { if (localStorage[states[i1].id] === "on") states[i1].checked = true; @@ -710,9 +710,9 @@ states[i1].addEventListener("change", function(event) { localStorage[event.target.id] = event.target.value; const group = document.querySelectorAll(`input[name='${event.target.name}']`); - for(let i1 = 0; i1 < group.length; i1++){ - if ((group[i1].type === "radio" || group[i1].type === "checkbox") && !group[i1].checked) { - localStorage[group[i1].id] = "off"; + for(var j = 0; j < group.length; j++){ + if ((group[j].type === "radio" || group[j].type === "checkbox") && !group[j].checked) { + localStorage[group[j].id] = "off"; } } self.dispatchEvent(new Event("storage")); diff --git a/static/js/forms.ts b/static/js/forms.ts index 3b1aedc..c9fc963 100644 --- a/static/js/forms.ts +++ b/static/js/forms.ts @@ -16,7 +16,7 @@ const states = input.concat(select).concat(textarea); - for (let i = 0; i < states.length; i++) { + for (var i = 0; i < states.length; i++) { if (localStorage[states[i].id]) { if (states[i].type === "radio" || states[i].type === "checkbox") { @@ -38,9 +38,9 @@ const group = document.querySelectorAll(`input[name='${event.target.name}']`); - for (let i = 0; i < group.length; i++) { - if ((group[i].type === "radio" || group[i].type === "checkbox") && !group[i].checked) { - localStorage[group[i].id] = "off"; + for (var j = 0; j < group.length; j++) { + if ((group[j].type === "radio" || group[j].type === "checkbox") && !group[j].checked) { + localStorage[group[j].id] = "off"; } } self.dispatchEvent(new Event("storage")); -- cgit v1.2.3