create new html views

This commit is contained in:
2025-11-11 20:55:18 +07:00
parent a9da83e6ab
commit 697c5bc428
9 changed files with 195 additions and 162 deletions

35
views/script.html Normal file
View File

@@ -0,0 +1,35 @@
{{ block "script" .}}
<script>
function updateActiveNav() {
const url = window.location.pathname;
document.querySelectorAll('.nav-link').forEach((link) => {
link.classList.remove('active');
if (link.getAttribute('hx-get') === url) {
link.classList.add('active');
}
});
}
document.addEventListener('DOMContentLoaded', (event) => {
updateActiveNav();
document.body.addEventListener('htmx:pushedIntoHistory', function (evt) {
updateActiveNav();
});
document.body.addEventListener('htmx:historyRestore', function () {
updateActiveNav();
});
document.body.addEventListener('htmx:beforeRequest', function (evt) {
const elt = evt.target;
if (
elt.classList &&
elt.classList.contains('nav-link') &&
elt.classList.contains('active')
) {
evt.preventDefault();
evt.stopPropagation();
}
});
});
</script>
{{ end }}