forked from publiclab/community-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc71c05
commit 5ddba29
Showing
7 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "Community Toolbox", | ||
"short_name": "Community Toolbox", | ||
"start_url": "/index.html", | ||
"scope": ".", | ||
"display": "standalone", | ||
"background_color": "#fff", | ||
"theme_color": "#3F51B5", | ||
"description": "A platform for community growth.", | ||
"dir": "ltr", | ||
"lang": "en-US", | ||
"orientation": "portrait-primary", | ||
"icons": [ | ||
{ | ||
"src": "./images/icons/icon-144.png", | ||
"type": "image/png", | ||
"sizes": "144x144" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Community Toolbox</title> | ||
</head> | ||
<body> | ||
<h1 style="text-align: center;">Sorry, You're offline!!!</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var deferredPrompt; | ||
|
||
if('serviceWorker' in navigator) { | ||
navigator.serviceWorker | ||
.register('../../sw.js') | ||
.then(() => { | ||
console.log("Service Worker registered!"); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var STATIC_CACHE = "static-v1"; | ||
var DYNAMIC_CACHE = "dynamic-v1"; | ||
|
||
self.addEventListener('install', (e) => { | ||
console.log("[Service Worker] installing..."); | ||
}); | ||
|
||
self.addEventListener('activate', (e) => { | ||
console.log("[Service Worker] activating...",e); | ||
e.waitUntil( | ||
caches.keys() | ||
.then((keyList) => { | ||
return Promise.all(keyList.map((key) => { | ||
if(key !== STATIC_CACHE && key !== DYNAMIC_CACHE) { | ||
return caches.delete(key); | ||
} | ||
})) | ||
}) | ||
); | ||
|
||
return self.clients.claim(); | ||
}); | ||
|
||
|
||
self.addEventListener('fetch', function (e) { | ||
let urlReq = e.request; | ||
|
||
e.respondWith( | ||
fetch(urlReq) | ||
.then((res) => { | ||
var resClone = res.clone(); | ||
return caches.open(DYNAMIC_CACHE) | ||
.then((cache) => { | ||
cache.delete(urlReq.url) | ||
.then((bool) => { | ||
cache.add(urlReq.url, resClone); | ||
}) | ||
|
||
return res; | ||
}) | ||
}) | ||
.catch((err) => { | ||
return caches.match(urlReq.url) | ||
.then((data) => { | ||
if(data!=undefined) { | ||
return data; | ||
} | ||
}) | ||
}) | ||
); | ||
}); |