diff --git a/gawa/static/custom.js b/gawa/static/custom.js index de88054..3117a52 100644 --- a/gawa/static/custom.js +++ b/gawa/static/custom.js @@ -3,14 +3,14 @@ const setTheme = (theme) => { document.documentElement.setAttribute("data-bs-theme", theme); if (theme === "dark") { - var to_invert = document.querySelectorAll('.darkmode-invert'); - to_invert.forEach(element => { + var to_invert = document.querySelectorAll(".darkmode-invert"); + to_invert.forEach((element) => { element.style.filter = "invert(100%)"; }); } if (theme === "light") { - var to_invert = document.querySelectorAll('.darkmode-invert'); - to_invert.forEach(element => { + var to_invert = document.querySelectorAll(".darkmode-invert"); + to_invert.forEach((element) => { element.style.filter = "invert(0%)"; }); } @@ -37,3 +37,24 @@ document.getElementById("toggleThemeButton").onclick = function () { function get_current_lang() { return location.pathname.split("/")[1]; } + +// reset some forms to empty instead of the defaults in value attrs +document.querySelectorAll(".reset-empty-button").forEach((element) => { + element.onclick = function () { + var items = element.form.querySelectorAll("input, select, .tagify"); + items.forEach((element) => { + if (element.type === "reset") { + } else { + if (element instanceof HTMLInputElement) { + element.setAttribute("value", element.getAttribute("defaultValue")); + } else if (element instanceof HTMLSelectElement) { + element.options + .item(element.selectedIndex) + .removeAttribute("selected"); + element.options.item(0).setAttribute("selected", ""); + } + } + }); + element.form.reset(); + }; +});