76 lines
2.7 KiB
HTML
76 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>World English Bible Updated</title>
|
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="css/app.css">
|
|
<meta name="theme-color" content="#1a202c">
|
|
<link rel="icon" href="icons/favicon.ico" sizes="16x16 32x32 48x48">
|
|
<link rel="icon" href="icons/favicon.svg" type="image/svg+xml">
|
|
</head>
|
|
<body class="bg-body-tertiary">
|
|
|
|
<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"></p>
|
|
<noscript><p class="alert alert-warning d-inline-block">This app builds its
|
|
pages on the device and needs JavaScript.</p></noscript>
|
|
</main>
|
|
|
|
<script>
|
|
(function () {
|
|
'use strict';
|
|
|
|
function status(text) {
|
|
document.getElementById('boot-status').textContent = text;
|
|
}
|
|
|
|
// The reload lands on this page again if the worker somehow activates
|
|
// without taking over the navigation. Two attempts is enough to cover a
|
|
// browser that needed one, and stops a device that never will from
|
|
// reloading forever.
|
|
var tries = 0;
|
|
try { tries = parseInt(sessionStorage.getItem('boot:tries') || '0', 10); }
|
|
catch (err) { tries = 0; }
|
|
|
|
function go() {
|
|
try { sessionStorage.removeItem('boot:tries'); } catch (err) {}
|
|
location.reload();
|
|
}
|
|
|
|
function start() {
|
|
if (tries >= 2) return fail('Setup could not finish.');
|
|
try { sessionStorage.setItem('boot:tries', String(tries + 1)); } catch (err) {}
|
|
|
|
navigator.serviceWorker.register('sw.js').then(function (registration) {
|
|
// Active already: this load raced the install and is simply not
|
|
// controlled yet. Otherwise wait for the one installing to get there.
|
|
if (registration.active) return go();
|
|
var worker = registration.installing || registration.waiting;
|
|
if (!worker) return fail('Setup did not start.');
|
|
worker.addEventListener('statechange', function (event) {
|
|
if (event.target.state === 'activated') go();
|
|
});
|
|
}, function (err) {
|
|
fail('Setup failed: ' + err.message);
|
|
});
|
|
}
|
|
|
|
// The end of the road. Every page in this app is put together by the
|
|
// worker, so a device that cannot install one has nothing to read here --
|
|
// and a spinner that turns forever says less than the reason does.
|
|
function fail(why) {
|
|
var spinner = document.querySelector('.boot .spinner-border');
|
|
if (spinner) spinner.remove();
|
|
status(why);
|
|
}
|
|
|
|
if ('serviceWorker' in navigator) start();
|
|
else fail('Setup needs service workers, which this browser does not have.');
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|