36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
{{ block "script" .}}
|
|
<script>
|
|
function clickBackButton() {
|
|
console.log('Back button clicked', window.history.state);
|
|
if (window.history.state && window.history.state["htmx"]) {
|
|
window.history.back();
|
|
} else {
|
|
window.location.href = '/';
|
|
}
|
|
}
|
|
function setScatteredWordsVisibility() {
|
|
const scatteredWords = document.getElementById('scatteredWords');
|
|
if (!scatteredWords) return;
|
|
const url = window.location.pathname;
|
|
console.log('Current URL:', url);
|
|
if (url === '/' || url === '') {
|
|
scatteredWords.classList.add('md:block');
|
|
} else {
|
|
console.log('Hiding scattered words');
|
|
scatteredWords.classList.remove('md:block');
|
|
}
|
|
}
|
|
document.addEventListener('DOMContentLoaded', (event) => {
|
|
setScatteredWordsVisibility();
|
|
document.body.addEventListener('htmx:pushedIntoHistory', function (evt) {
|
|
setScatteredWordsVisibility();
|
|
});
|
|
|
|
document.body.addEventListener('htmx:historyRestore', function (e) {
|
|
console.log('Restoring history state', e.detail);
|
|
setScatteredWordsVisibility();
|
|
});
|
|
});
|
|
</script>
|
|
{{ end }}
|