diff --git a/assets/js/app.js b/assets/js/app.js deleted file mode 100644 index a6a70ec..0000000 --- a/assets/js/app.js +++ /dev/null @@ -1,46 +0,0 @@ -(function () { - 'use strict'; - - document.body.addEventListener('htmx:afterSwap', function (event) { - var target = event.detail.target; - if (!target) return; - if (target.id === 'reference-verse') return scrollToHash(); - if (target.id === 'content') return land(); - }); - - document.body.addEventListener('htmx:historyRestore', function () { - land(); - }); - - function hashTarget() { - if (!location.hash) return null; - return document.getElementById(decodeURIComponent(location.hash.slice(1))); - } - - function jumpTo(el) { - el.scrollIntoView({ block: 'start', behavior: 'instant' }); - } - - function jumpToTop() { - window.scrollTo({ top: 0, behavior: 'instant' }); - } - - function scrollToHash() { - var el = hashTarget(); - if (el) jumpTo(el); - } - - function land() { - var el = hashTarget(); - if (el) jumpTo(el); - else jumpToTop(); - } - - document.addEventListener('DOMContentLoaded', function () { - scrollToHash(); - - if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('sw.js').catch(function () {}); - } - }); -})(); diff --git a/assets/sw.js b/assets/sw.js index ad0e13a..87a3c28 100644 --- a/assets/sw.js +++ b/assets/sw.js @@ -23,7 +23,6 @@ const PRECACHE = [ './manifest.webmanifest', './css/app.css', './css/bootstrap.min.css', - './js/app.js', './js/htmx.min.js', './js/bootstrap.bundle.min.js' ].concat(TEMPLATE_URLS); @@ -265,7 +264,7 @@ router.get('/api/reference', async (call) => { headers: { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store', - 'HX-Reswap': 'innerHTML settle:0', + 'HX-Reswap': 'innerHTML settle:0 show:#' + target + ':top', 'HX-Replace-Url': page.pathname + page.search + '#' + target } }); diff --git a/assets/templates/base.njk b/assets/templates/base.njk index 5a83a49..02bf99e 100644 --- a/assets/templates/base.njk +++ b/assets/templates/base.njk @@ -10,7 +10,6 @@ content='{"historyCacheSize":0,"refreshOnHistoryMiss":false}'> -