This commit is contained in:
mark committed 2026-09-09 10:41:29 -04:00
1 parent b59ef914da
commit 4e3cd36b7c
1 file changed
+9 -5
+9 -5
View File
@@ -32,7 +32,11 @@
<main class="boot container py-5 text-center"> <main class="boot container py-5 text-center">
<div class="spinner-border text-secondary mb-3" role="status" aria-hidden="true"></div> <div class="spinner-border text-secondary mb-3" role="status" aria-hidden="true"></div>
<p id="boot-status" class="text-body-secondary">Preparing the offline copy…</p> <!-- Empty until there is something to say. This page is on screen for a
moment on a first visit and then never again, and a line naming what it
is doing is a line nobody needs to read: the spinner already says wait.
It is here, and empty, because it is where fail() writes. -->
<p id="boot-status" class="text-body-secondary"></p>
<noscript><p class="alert alert-warning d-inline-block">This app builds its <noscript><p class="alert alert-warning d-inline-block">This app builds its
pages on the device and needs JavaScript.</p></noscript> pages on the device and needs JavaScript.</p></noscript>
</main> </main>
@@ -59,7 +63,7 @@
} }
function start() { function start() {
if (tries >= 2) return fail('The offline copy could not start.'); if (tries >= 2) return fail('Setup could not finish.');
try { sessionStorage.setItem('boot:tries', String(tries + 1)); } catch (err) {} try { sessionStorage.setItem('boot:tries', String(tries + 1)); } catch (err) {}
navigator.serviceWorker.register('sw.js').then(function (registration) { navigator.serviceWorker.register('sw.js').then(function (registration) {
@@ -67,12 +71,12 @@
// controlled yet. Otherwise wait for the one installing to get there. // controlled yet. Otherwise wait for the one installing to get there.
if (registration.active) return go(); if (registration.active) return go();
var worker = registration.installing || registration.waiting; var worker = registration.installing || registration.waiting;
if (!worker) return fail('The offline copy did not install.'); if (!worker) return fail('Setup did not start.');
worker.addEventListener('statechange', function (event) { worker.addEventListener('statechange', function (event) {
if (event.target.state === 'activated') go(); if (event.target.state === 'activated') go();
}); });
}, function (err) { }, function (err) {
fail('Could not install the offline copy: ' + err.message); fail('Setup failed: ' + err.message);
}); });
} }
@@ -86,7 +90,7 @@
} }
if ('serviceWorker' in navigator) start(); if ('serviceWorker' in navigator) start();
else fail('This browser has no service worker support.'); else fail('Setup needs service workers, which this browser does not have.');
})(); })();
</script> </script>
</body> </body>