svg.escobar.life

A simple SVG markup editor for the web

Commit
9123c068f2d3ebbea7c8b2c534cc85877a9b7981
Parent
73a70906721b9132716ccff7e3c10db86a36cc1c
Author
Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
Date

Refactored manifest.json

Diffstat

4 files changed, 39 insertions, 5 deletions

Status File Name N° Changes Insertions Deletions
Modified build/template.html 10 9 1
Modified index.html 10 9 1
Modified manifest.json 5 2 3
Added service-worker.js 19 19 0
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