diff options
Diffstat (limited to 'static/js/forms.ts')
-rw-r--r-- | static/js/forms.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/static/js/forms.ts b/static/js/forms.ts index 4784b20..263fda1 100644 --- a/static/js/forms.ts +++ b/static/js/forms.ts @@ -8,6 +8,9 @@ return console.warn("WARNING: Cannot persist form state due to cookie restrictions"); } + const storage = document.createEvent("Event"); + storage.initEvent("storage", true, true); + ["pageshow", "URLChangedCustomEvent", "DOMContentLoaded"].forEach(function (event) { self.addEventListener(event, function (event) { const input = Array.prototype.slice.call(document.querySelectorAll("form input")); @@ -27,7 +30,7 @@ } else state.value = localStorage[state.id]; } - if (sync) self.dispatchEvent(new Event("storage")); + if (sync) self.dispatchEvent(storage); state.addEventListener("change", function (event) { @@ -40,7 +43,7 @@ localStorage[event.target.id] = event.target.value; - const group = document.querySelectorAll(`input[name='${event.target.name}']`); + const group = document.querySelectorAll("input[name='".concat(event.target.name, "']")); for (var j = 0; j < group.length; j++) { const member = group[j]; @@ -115,13 +118,13 @@ function persistence() { if (document.styleSheets.length > 0) { - self.dispatchEvent(new Event("storage")); + self.dispatchEvent(storage); clearInterval(early); } } self.addEventListener("DOMContentLoaded", function () { - self.dispatchEvent(new Event("storage")); + self.dispatchEvent(storage); clearInterval(early); }); })(); |