diff --git a/static/.DS_Store b/static/.DS_Store index 653ee23..1f78bef 100644 Binary files a/static/.DS_Store and b/static/.DS_Store differ diff --git a/static/img/Vierkant logo.png b/static/img/Vierkant logo.png new file mode 100644 index 0000000..c6e5bd2 Binary files /dev/null and b/static/img/Vierkant logo.png differ diff --git a/static/img/icons-192.png b/static/img/icons-192.png new file mode 100644 index 0000000..314ec5d Binary files /dev/null and b/static/img/icons-192.png differ diff --git a/static/img/icons-512.png b/static/img/icons-512.png new file mode 100644 index 0000000..b1e732f Binary files /dev/null and b/static/img/icons-512.png differ diff --git a/static/js/sw.js b/static/js/sw.js new file mode 100644 index 0000000..ea706b5 --- /dev/null +++ b/static/js/sw.js @@ -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; + } + ); + }) + ); +}); \ No newline at end of file diff --git a/static/manifest.json b/static/manifest.json new file mode 100644 index 0000000..e141db0 --- /dev/null +++ b/static/manifest.json @@ -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" +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index b97b2e7..3f583c6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,8 +16,10 @@ Spoor APP - + + + @@ -209,6 +211,21 @@

Example requests:

+ + + diff --git a/templates/ovfiets.html b/templates/ovfiets.html index 64443c2..3f815e2 100644 --- a/templates/ovfiets.html +++ b/templates/ovfiets.html @@ -15,6 +15,9 @@ Spoor APP + + + @@ -136,6 +139,21 @@
Openingstijden
+ + + + @@ -189,6 +192,21 @@

OV-fiets

+ + + + + +