reset button empties
This commit is contained in:
parent
21f3b19111
commit
260005dcf0
|
@ -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();
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue