-
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
Showing
10 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var CACHE_NAME = 'spoor-app-cache-v1'; | ||
var urlsToCache = [ | ||
'/', | ||
'/../static/css/materialize.css', | ||
'/../static/css/style.css', | ||
'/../static/js/jquery-2.1.1.min.js', | ||
'/../static/js/materialize.js', | ||
'/../static/js/custom.js', | ||
'/../static/js/dichtbij.js', | ||
'/../static/img/achtergrond.jpg' | ||
]; | ||
|
||
self.addEventListener('install', function(event) { | ||
// Perform install steps | ||
event.waitUntil( | ||
caches.open(CACHE_NAME) | ||
.then(function(cache) { | ||
console.log('Opened cache'); | ||
return cache.addAll(urlsToCache); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('fetch', function(event) { | ||
event.respondWith( | ||
caches.match(event.request) | ||
.then(function(response) { | ||
// Cache hit - return response | ||
if (response) { | ||
return response; | ||
} | ||
|
||
// IMPORTANT: Clone the request. A request is a stream and | ||
// can only be consumed once. Since we are consuming this | ||
// once by cache and once by the browser for fetch, we need | ||
// to clone the response. | ||
var fetchRequest = event.request.clone(); | ||
|
||
return fetch(fetchRequest).then( | ||
function(response) { | ||
// Check if we received a valid response | ||
if(!response || response.status !== 200 || response.type !== 'basic') { | ||
return response; | ||
} | ||
|
||
// IMPORTANT: Clone the response. A response is a stream | ||
// and because we want the browser to consume the response | ||
// as well as the cache consuming the response, we need | ||
// to clone it so we have two streams. | ||
var responseToCache = response.clone(); | ||
|
||
caches.open(CACHE_NAME) | ||
.then(function(cache) { | ||
cache.put(event.request, responseToCache); | ||
}); | ||
|
||
return response; | ||
} | ||
); | ||
}) | ||
); | ||
}); |
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 @@ | ||
{ | ||
"short_name": "Spoor", | ||
"name": "Spoor.app", | ||
"icons": [ | ||
{ | ||
"src": "/../static/img/icons-192.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "/../static/img/icons-512.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": "/", | ||
"background_color": "#ffffff", | ||
"display": "standalone", | ||
"theme_color": "#009688" | ||
} |
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
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