blob: 0735ae9d465efcaaa482ca45a58942e8d6d2ca33 (
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
42
43
44
45
46
47
48
49
50
|
<!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 when done installing */
if (reg.installing) {
reg.installing.addEventListener ('statechange', function (e) {
if (e.target.state !== 'installing') {
console.log ('reloading');
window.location.reload ();
return false;
}
return true;
});
}
}).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>
|