feat: closes #11 and fixed database cons remaining open
This commit is contained in:
@@ -1,3 +1,47 @@
|
||||
function tabs() {
|
||||
for (const elm of document.querySelectorAll(".tabs")) {
|
||||
let count = 0;
|
||||
let selected = 0;
|
||||
for (const child of elm.children) {
|
||||
if (child.tagName == "BUTTON") {
|
||||
count++;
|
||||
if (child.classList.contains("selected")) {
|
||||
selected++;
|
||||
}
|
||||
if (!child.getAttribute("data-armed")) {
|
||||
child.addEventListener("click", () => {
|
||||
if (!child.classList.contains("selected")) {
|
||||
for (const elm of child.parentElement.children) {
|
||||
elm.classList.remove("selected");
|
||||
}
|
||||
child.classList.add("selected");
|
||||
document.querySelector(`.tabs .content[data-tab="${
|
||||
child.getAttribute("data-tab")
|
||||
}"]`)?.classList.add("selected");
|
||||
}
|
||||
});
|
||||
child.setAttribute("data-armed", "true")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selected > 1 || selected == 0) {
|
||||
for (const child of elm.children) {
|
||||
child.classList.remove("selected");
|
||||
}
|
||||
for (const child of elm.children) {
|
||||
if (child.tagName == "BUTTON") {
|
||||
child.classList.add("selected");
|
||||
document.querySelector(`.tabs .content[data-tab="${
|
||||
child.getAttribute("data-tab")
|
||||
}"]`)?.classList.add("selected");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
function load() {
|
||||
for (const elm of document.querySelectorAll("form > button")) {
|
||||
elm.addEventListener('click', (e) => {
|
||||
@@ -35,6 +79,7 @@ function load() {
|
||||
}
|
||||
});
|
||||
}
|
||||
tabs();
|
||||
}
|
||||
window.onload = load;
|
||||
htmx.on('htmx:afterSwap', load);
|
||||
|
||||
Reference in New Issue
Block a user