diff --git a/skolehjem/public/js/serviceWorkerCachedWebpags.js b/skolehjem/public/js/serviceWorkerCachedWebpags.js
deleted file mode 100644
index 11e18af..0000000
--- a/skolehjem/public/js/serviceWorkerCachedWebpags.js
+++ /dev/null
@@ -1,81 +0,0 @@
-const staticCacheName = 'site-static-v2';
-const dynamicCacheName = 'site-dynamic-v1';
-const assets = [
- '/',
- '/css/app.css',
- '/css/normalize.css',
- '/css/webapp.css',
- '/css/webappdark.css',
- '/home',
- '/events'
-];
-
-// install event
-self.addEventListener('install', evt => {
- //console.log('service worker installed');
- evt.waitUntil(
- caches.open(staticCacheName).then((cache) => {
- console.log('caching shell assets');
- return cache.addAll(assets);
- })
- );
-});
-
-// activate event
-self.addEventListener('activate', evt => {
- //console.log('service worker activated');
- evt.waitUntil(
- caches.keys().then(keys => {
- //console.log(keys);
- return Promise.all(keys
- .filter(key => key !== staticCacheName && key !== dynamicCacheName)
- .map(key => caches.delete(key))
- );
- })
- );
-});
-
-// fetch event
-self.addEventListener('fetch', evt => {
- //console.log('fetch event', evt);
- evt.respondWith(
- caches.match(evt.request).then(cacheRes => {
- return cacheRes || fetch(evt.request).then(fetchRes => {
- return caches.open(dynamicCacheName).then(cache => {
- cache.put(evt.request.url, fetchRes.clone()).then(r => {
- return fetchRes;
- });
-
- })
- });
- })
- );
-});
-
-
-//Push notification, this is more of a demo you can test in the dev tool
-self.addEventListener('push', evt => {
- const title = "Test Notification";
- const body = "Det her et en demo på hvordan en notification kan se ud! ";
- const icon = "/icons/browserFavIcon.svg"
- const tag = "simple-push-example-tag";
- evt.waitUntil(
- self.registration.showNotification(title, {
- body : body,
- icon : icon,
- tag : tag
- })
- );
-});
-
-
-
-function displayNotification(){
- if(Notification.permission === 'granted'){
- navigator.serviceWorker.getRegistration()
- .then(function (reg){
- reg.showNotification('Helloe ')
- })
- }
-}
-
diff --git a/skolehjem/public/offline.html b/skolehjem/public/offline.html
new file mode 100644
index 0000000..58f5bba
--- /dev/null
+++ b/skolehjem/public/offline.html
@@ -0,0 +1,27 @@
+
+
+
+ @yield("title")
+
+
+
+
+
+
+
+
+
+ ERROR: NO NETWORK
+ Du har ikke cachet denne side
+
+
+
+
+
+
diff --git a/skolehjem/public/serviceWorkerCachedWebpags.js b/skolehjem/public/serviceWorkerCachedWebpags.js
new file mode 100644
index 0000000..4c241a6
--- /dev/null
+++ b/skolehjem/public/serviceWorkerCachedWebpags.js
@@ -0,0 +1,142 @@
+const staticCacheName = 'site-static-v2';
+const dynamicCacheName = 'site-dynamic-v1';
+const assets = [
+ '/offline.html',
+ '/css/app.css',
+ '/css/normalize.css',
+ '/css/webapp.css',
+ '/css/webappdark.css',
+ '/images/icons/Vagttelefon-normal.svg',
+ '/images/icons/Vagttelefon-hvid.svg',
+ '/images/icons/about.svg',
+ '/images/icons/Aktiviteter.svg',
+ '/images/icons/Home.svg',
+ '/images/icons/Kontoret.svg',
+ '/images/icons/location.svg',
+ '/images/icons/Menuplan.svg',
+ '/images/icons/news.svg',
+ '/images/icons/phone.svg',
+ '/images/icons/questionmark.svg',
+ '/images/icons/settings-hvid.svg',
+ '/images/icons/user.svg',
+ '/images/icons/user-hvid.svg',
+ '/images/icons/Vejledninger.svg',
+ '/images/icons/watermelon.svg',
+ '/images/logos/Logo-hvid.svg',
+ '/images/logos/Logo-normal.svg',
+ '/images/icons/Logout.svg'
+
+];
+
+// install event
+self.addEventListener('install', evt => {
+ //console.log('service worker installed');
+ evt.waitUntil(
+ caches.open(staticCacheName).then((cache) => {
+ //console.log('caching shell assets');
+ return cache.addAll(assets);
+ }).catch((r) => {
+ console.log("I dont workkkkk");
+ })
+ );
+});
+
+// activate event
+self.addEventListener('activate', evt => {
+ //console.log('service worker activated');
+ evt.waitUntil(
+ caches.keys().then(keys => {
+ //console.log(keys);
+ return Promise.all(keys
+ .filter(key => key !== staticCacheName && key !== dynamicCacheName)
+ .map(key => caches.delete(key))
+ );
+ })
+ );
+});
+
+// fetch event
+/*
+self.addEventListener('fetch', evt => {
+ console.log('fetch event');
+ evt.respondWith(
+ caches.match(evt.request).then(async function (cacheRes) {
+ return cacheRes || fetch(evt.request).then(fetchRes => {
+ return caches.open(dynamicCacheName).then(cache => {
+ cache.put(evt.request.url, fetchRes.clone()).then(r => {
+ return fetchRes;
+ });
+ }).catch((r) => {
+ console.log("I dont work");
+ });
+ });
+ })
+ );
+});*/
+
+self.addEventListener('fetch', evt => {
+ console.log('fetch event', evt);
+ evt.respondWith(
+ caches.match(evt.request).then(cacheRes => {
+ return cacheRes || fetch(evt.request).then(fetchRes => {
+ return caches.open(dynamicCacheName).then(cache => {
+ cache.put(evt.request.url, fetchRes.clone());
+ return fetchRes;
+ })
+ });
+ }).catch(function () {
+ return caches.match('/offline.html');
+ })
+ );
+});
+
+/*
+self.addEventListener('fetch', evt => {
+ console.log("ARGHHHH");
+
+ if(navigator.onLine) {
+ evt.respondWith(async function() {
+ return fetch(evt.request).then((fetchRes) => {
+ caches.open(dynamicCacheName).then(cache => {
+ cache.put(evt.request.url, fetchRes.clone());
+ })
+ })
+ });
+ } else {
+ console.log('fetch event');
+ evt.respondWith(async function () {
+ let cachedResponse = await caches.match(evt.request);
+
+ if(cachedResponse) return cachedResponse;
+ else return caches.match("/offline.html");
+ });
+ }
+});*/
+
+
+/*
+self.addEventListener('push', evt => {
+ const title = "Test Notification";
+ const body = "Det her et en demo på hvordan en notification kan se ud! ";
+ const icon = "/icons/browserFavIcon.svg"
+ const tag = "simple-push-example-tag";
+ evt.waitUntil(
+ self.registration.showNotification(title, {
+ body : body,
+ icon : icon,
+ tag : tag
+ })
+ );
+});
+
+
+
+function displayNotification(){
+ if(Notification.permission === 'granted'){
+ navigator.serviceWorker.getRegistration()
+ .then(function (reg){
+ reg.showNotification('Helloe ')
+ })
+ }
+}
+*/
diff --git a/skolehjem/public/js/serviceWorkerRegistration.js b/skolehjem/public/serviceWorkerRegistration.js
similarity index 92%
rename from skolehjem/public/js/serviceWorkerRegistration.js
rename to skolehjem/public/serviceWorkerRegistration.js
index 23f5498..b9c8b65 100644
--- a/skolehjem/public/js/serviceWorkerRegistration.js
+++ b/skolehjem/public/serviceWorkerRegistration.js
@@ -7,7 +7,7 @@ Make sure that we support service worker :)
if('serviceWorker' in navigator){
window.addEventListener('load', () => {
navigator.serviceWorker
- .register('/js/serviceWorkerCachedWebpags.js')
+ .register('/serviceWorkerCachedWebpags.js')
.then(reg => console.log("Service Worker has been: registered"))
.catch(err => console.log(`Service Worker error: ${err}`))
})
diff --git a/skolehjem/resources/views/app/layout/base.blade.php b/skolehjem/resources/views/app/layout/base.blade.php
index 1fcd7f5..b15da0c 100644
--- a/skolehjem/resources/views/app/layout/base.blade.php
+++ b/skolehjem/resources/views/app/layout/base.blade.php
@@ -14,7 +14,7 @@
-
+
@@ -121,7 +121,7 @@
@yield("content")
-
+
@if(request()->cookie("mode") == "dark")
+
@yield("scripts")