summaryrefslogtreecommitdiff
path: root/swayback/templates/sw.html
blob: 2abfac260ef5f6706cf2d968bdd8a51e1f89b6ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>Just a second…</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<style>
		.hidden {
			display: none;
		}
		</style>
    </head>
    <body>
	<div class="hidden" id="unsupported">
		<p>Service workers are not supported by your browser.</p>
	</div>
	<div id="waiting">
		<p>Just a second…</p>
	</div>
	<script>
	if ('serviceWorker' in navigator) {
		/* service workers must be hosted in the same origin (i.e. subdomain) */
		navigator.serviceWorker.register('/static/sw.js', {scope: '/'})
		.then(function(reg) {
			/* load actual content using the service worker */
			window.location.reload ();
		}).catch(function(error) {
			console.log ('sw error', error);
			document.getElementById ('unsupported').classList.remove ('hidden');
			document.getElementById ('waiting').classList.add ('hidden');
		});
	} else {
		console.log ('not supported');
		document.getElementById ('unsupported').classList.remove ('hidden');
		document.getElementById ('waiting').classList.add ('hidden');
	}
	</script>
    </body>
</html>