Remove non-TLS support
This commit is contained in:
1 parent
84c07a912b
commit
b59ef914da
9 files changed
+88
-171
No files matched your search
+10
-27
@@ -1,7 +1,7 @@
|
||||
// Page startup.
|
||||
//
|
||||
// Pages arrive whole -- composed by the service worker, or by boot.html on the
|
||||
// visit before there is one -- so there is nothing here that builds a page.
|
||||
// Pages arrive whole -- the service worker composes every one of them -- so
|
||||
// there is nothing here that builds a page.
|
||||
// What is left is the three things a composed document cannot do for itself:
|
||||
// put a swapped-in page where it belongs before it is painted, land the
|
||||
// reference picker where the reader asked to go, and tell the chrome when a
|
||||
@@ -94,11 +94,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
// A worker-composed page is an ordinary document and the browser scrolls to
|
||||
// the anchor itself. One composed by boot.html is not: it replaced a
|
||||
// document the browser had already finished with, so the fragment identifier
|
||||
// has been spent. Repeating it costs nothing in the first case and is what
|
||||
// makes a link to GEN#v1_1 land on the verse in the second.
|
||||
// The browser scrolls to the anchor itself on a document it navigated to,
|
||||
// so this is for the one it does not: a reload that landed on boot.html and
|
||||
// was reloaded again into the real page. Costs nothing when the browser has
|
||||
// already been there.
|
||||
function scrollToHash() {
|
||||
var el = hashTarget();
|
||||
if (el) jumpTo(el);
|
||||
@@ -166,25 +165,12 @@
|
||||
//
|
||||
// Toggling the class rather than the style because Bootstrap declares
|
||||
// .d-none !important, which an inline display would lose to.
|
||||
//
|
||||
// Only the digest line is missing on a page boot.html composed -- there was
|
||||
// no worker to name a version -- so the element itself is always here.
|
||||
function showVersion() {
|
||||
var el = document.getElementById('app-version');
|
||||
if (!el) return;
|
||||
el.classList.toggle('d-none', !document.querySelector('#content .index'));
|
||||
}
|
||||
|
||||
// api/bookmark has no origin server -- it is answered by the worker -- so
|
||||
// there is nothing to ask until the worker is controlling this page.
|
||||
// controller, not ready: ready can resolve a tick before clients.claim()
|
||||
// takes effect, and a request sent in that gap reaches the network and 404s.
|
||||
function whenControlled(fn) {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
if (navigator.serviceWorker.controller) return fn();
|
||||
navigator.serviceWorker.addEventListener('controllerchange', fn, { once: true });
|
||||
}
|
||||
|
||||
// Deferred scripts run before DOMContentLoaded fires, so this always lands,
|
||||
// and it lands after htmx has processed the shell.
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
@@ -192,15 +178,12 @@
|
||||
showVersion();
|
||||
|
||||
// Registered from the page it is going to serve, not from a page of its
|
||||
// own: there is nothing to wait for and nothing to reload. This load is
|
||||
// already the real app -- the worker installs alongside it, and takes over
|
||||
// composing, the bookmark and the offline download from the next
|
||||
// navigation on.
|
||||
// own: this load is already the real app, composed by the worker that is
|
||||
// controlling it. What this catches is the copy on disk having changed
|
||||
// since -- the browser refetches sw.js, sees different bytes, and installs
|
||||
// the new one alongside, which takes over from the next navigation on.
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('sw.js').catch(function () {});
|
||||
}
|
||||
whenControlled(function () {
|
||||
document.body.dispatchEvent(new CustomEvent('worker-ready'));
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in new issue
Block a user