blog-browse #40

Merged
PlexSheep merged 17 commits from blog-browse into devel 2023-10-08 14:46:09 +02:00
1 changed files with 25 additions and 4 deletions
Showing only changes of commit 260005dcf0 - Show all commits

View File

@ -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();
};
});