jamestthompson3
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
25 additions and
0 deletions
-
public/js/manifest.json
-
public/js/register-sw.js
-
public/js/sw.js
-
views/index.php
|
|
@ -2,6 +2,9 @@ |
|
|
|
"name": "Quill", |
|
|
|
"short_name": "Quill", |
|
|
|
"description": "Quill is a simple app for posting to your website", |
|
|
|
"background_color": "#428bca", |
|
|
|
"display": "standalone", |
|
|
|
"start_url": "/dashboard", |
|
|
|
"icons": [ |
|
|
|
{ |
|
|
|
"src": "/images/quill-icon-57.png", |
|
|
|
|
|
@ -0,0 +1,7 @@ |
|
|
|
(function registerSW() { |
|
|
|
if ("serviceWorker" in navigator) { |
|
|
|
navigator.serviceWorker.register("/js/sw.js").catch((e) => { |
|
|
|
console.log("Registration fail: ", e); |
|
|
|
}); |
|
|
|
} |
|
|
|
})(); |
|
|
@ -0,0 +1,14 @@ |
|
|
|
// NOTE: This currently doesn't cache anything
|
|
|
|
// We are just installing it so that chrome users can be
|
|
|
|
// prompted to install Quill via add to homescreen
|
|
|
|
self.addEventListener("install", installWorker); |
|
|
|
|
|
|
|
async function installWorker() { |
|
|
|
await self.skipWaiting(); |
|
|
|
} |
|
|
|
|
|
|
|
self.addEventListener("activate", activateServiceWorker); |
|
|
|
|
|
|
|
async function activateServiceWorker(event) { |
|
|
|
event.waitUntil(clients.claim()); // make the current sw the active sw in all pages
|
|
|
|
} |
|
|
@ -32,4 +32,5 @@ |
|
|
|
<a href="" class="u-url"></a> |
|
|
|
</div> |
|
|
|
|
|
|
|
<script src="/js/register-sw.js"></script> |
|
|
|
</div> |