@@ -7,7 +7,7 @@ title: $:/NoteSelf/templates/online.html
7
7
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Force IE standards mode for Intranet and HTA - should be the first meta -->
8
8
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
9
9
10
- <link rel="manifest" href="manifest.json" / >
10
+ <link rel="manifest" href="manifest.json" >
11
11
12
12
<meta name="application-name" content="NoteSelf" />
13
13
<meta name="generator" content="NoteSelf" />
@@ -51,5 +51,29 @@ title: $:/NoteSelf/templates/online.html
51
51
<div id="bootKernel" style="display:none;">
52
52
{{ $:/boot/boot.js ||$:/core/templates/javascript-tiddler}}
53
53
</div>
54
+ <script>
55
+ (function(){
56
+ var shouldRegister = window.location.protocol === 'https:' || window.location.hostname === 'localhost';
57
+ if ('serviceWorker' in navigator && shouldRegister) {
58
+ navigator.serviceWorker.register('sw.js').then(function(registration) {
59
+ // only show message on worker installed event
60
+ registration.onupdatefound = function() {
61
+ var worker = registration.installing;
62
+ if (!worker) return;
63
+
64
+ worker.onstatechange = function() {
65
+ if (worker.state === "installed") {
66
+ console.log('<i class="fa fa-download"></i> Caching completed. This app works offline!');
67
+ console.log($tw);
68
+ }
69
+ };
70
+ };
71
+ }).catch(function(err) {
72
+ Raven.captureException(err);
73
+ console.log('sw failure', err);
74
+ });
75
+ }
76
+ })();
77
+ </script>
54
78
</body>
55
79
</html>
0 commit comments