svg.escobar.life

Unnamed repository; edit this file 'description' to name the repository.

commit 9123c068f2d3ebbea7c8b2c534cc85877a9b7981
parent 73a70906721b9132716ccff7e3c10db86a36cc1c
Author: Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
Date:   Sun,  1 Sep 2019 12:46:00 -0300

Refactored manifest.json

Diffstat:
Mbuild/template.html | 10+++++++++-
Mindex.html | 10+++++++++-
Mmanifest.json | 5++---
Aservice-worker.js | 19+++++++++++++++++++
4 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/build/template.html b/build/template.html
@@ -14,12 +14,20 @@
         <link rel="shortcut icon" href="assets/icons/favicon.ico">
         <meta name="msapplication-TileColor" content="#9f00a7">
         <meta name="msapplication-config" content="assets/icons/browserconfig.xml">
-        <meta name="theme-color" content="#ffffff">
 
         <script src="script.min.js"></script>
 	</head>
 
 	<body>
 		<script>Elm.Main.init()</script>
+        <script>
+            const load = () => navigator.serviceWorker
+                .register('/RawSvg/service-worker.js')
+                .then(console.log)
+                .catch(console.error);
+
+            if ('serviceWorker' in navigator)
+                window.addEventListener('load', load);
+        </script>
 	</body>
 </html> 
\ No newline at end of file
diff --git a/index.html b/index.html
@@ -14,12 +14,20 @@
         <link rel="shortcut icon" href="assets/icons/favicon.ico">
         <meta name="msapplication-TileColor" content="#9f00a7">
         <meta name="msapplication-config" content="assets/icons/browserconfig.xml">
-        <meta name="theme-color" content="#ffffff">
 
         <script src="script.min.js"></script>
 	</head>
 
 	<body>
 		<script>Elm.Main.init()</script>
+        <script>
+            const load = () => navigator.serviceWorker
+                .register('/RawSvg/service-worker.js')
+                .then(console.log)
+                .catch(console.error);
+
+            if ('serviceWorker' in navigator)
+                window.addEventListener('load', load);
+        </script>
 	</body>
 </html> 
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
@@ -1,6 +1,7 @@
 {
   "name": "RawSvg",
   "short_name": "RawSvg",
+  "display": "standalone",
   "icons": [
     {
       "src": "assets/icons/android-chrome-192x192.png",
@@ -13,9 +14,7 @@
       "type": "image/png"
     }
   ],
-  "start_url": "/index.html",
+  "start_url": "index.html",
   "background_color": "#2D2B55",
-  "display": "standalone",
-  "scope": "/",
   "theme_color": "#B362FF"
 } 
\ No newline at end of file
diff --git a/service-worker.js b/service-worker.js
@@ -0,0 +1,18 @@
+self.addEventListener('install', installHandler);
+self.addEventListener('fetch', fetchHandler);
+
+function installHandler(e) {
+    e.waitUntil(
+        caches.open('progessive-elm')
+            .then((cache) => cache.addAll(['/', '/index.html']))
+            .catch(console.error)
+    );
+}
+
+function fetchHandler(e) {
+    e.respondWith(
+        caches.match(event.request)
+            .then((response) => response || fetch(e.request))
+            .catch(console.error)
+    );
+}+
\ No newline at end of file