61 lines
2.3 KiB
HTML
61 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||
<title>World English Bible Updated</title>
|
||
<link rel="stylesheet" href="bootstrap.min.css">
|
||
<meta name="theme-color" content="#1a202c">
|
||
</head>
|
||
<body class="bg-body-tertiary">
|
||
<!-- Pages are fragments now: the shell is assembled by the service worker, so
|
||
a first visit has nothing to render until the worker is installed and
|
||
controlling. This page installs it and reloads into the real app. -->
|
||
<main class="boot container py-5 text-center">
|
||
<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>
|
||
<noscript><p class="alert alert-warning">This app assembles its pages in the browser and needs JavaScript.</p></noscript>
|
||
</main>
|
||
<script>
|
||
(function () {
|
||
var status = document.getElementById('boot-status');
|
||
function fail(text) { status.textContent = text; }
|
||
|
||
if (!('serviceWorker' in navigator)) {
|
||
fail('This browser has no service worker support, which this app needs.');
|
||
return;
|
||
}
|
||
|
||
// Guards against a reload loop if the worker activates but never claims:
|
||
// better to sit on this page with a message than to spin.
|
||
var tries = 0;
|
||
try { tries = parseInt(sessionStorage.getItem('boot:tries') || '0', 10); }
|
||
catch (e) { tries = 0; }
|
||
if (tries >= 2) {
|
||
fail('The offline copy could not start. Try clearing this site’s data.');
|
||
return;
|
||
}
|
||
try { sessionStorage.setItem('boot:tries', String(tries + 1)); } catch (e) {}
|
||
|
||
function go() {
|
||
try { sessionStorage.removeItem('boot:tries'); } catch (e) {}
|
||
location.reload();
|
||
}
|
||
|
||
navigator.serviceWorker.register('sw.js').then(function () {
|
||
// controller is what actually matters: ready can resolve a tick before
|
||
// clients.claim() takes effect, and reloading then lands here again.
|
||
if (navigator.serviceWorker.controller) return go();
|
||
navigator.serviceWorker.addEventListener('controllerchange', go);
|
||
setTimeout(function () {
|
||
if (navigator.serviceWorker.controller) go();
|
||
else fail('The offline copy is taking longer than expected. Reload to retry.');
|
||
}, 10000);
|
||
}, function (err) {
|
||
fail('Could not install the offline copy: ' + err.message);
|
||
});
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|