From ad02878561178429e4b8fcbd4594d9ce78f4c407 Mon Sep 17 00:00:00 2001 From: rstular Date: Wed, 29 Jan 2020 17:54:19 +0100 Subject: Spacing, bug fixes, version bump, deployment test --- js/app.js | 11 +++++++++-- js/login.js | 2 +- pages/about.html | 4 ++-- pages/absences.html | 2 +- pages/grades.html | 1 + pages/teachers.html | 1 + sw.js | 27 +++++++++++++++++---------- 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/js/app.js b/js/app.js index d79fb88..97e671f 100644 --- a/js/app.js +++ b/js/app.js @@ -1,5 +1,12 @@ if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/sw.js") - .then(() => {}) + .then(() => { }) .catch((err) => console.log("Service worker registration failed", err)); -} \ No newline at end of file +} + +// Listen to messages from service workers. +navigator.serviceWorker.addEventListener('message', (event) => { + if (event.data.msg === "install") { + window.location.replace("/index.html"); + } +}); \ No newline at end of file diff --git a/js/login.js b/js/login.js index ff8d4ed..a7ab25c 100644 --- a/js/login.js +++ b/js/login.js @@ -47,7 +47,7 @@ function login() { localforage.setItem("password", password) ]; Promise.all(promises_to_run).then(function () { - window.location.replace("/pages/teachers.html"); + window.location.replace("/pages/timetable.html"); }); } diff --git a/pages/about.html b/pages/about.html index 1db7e07..28626be 100644 --- a/pages/about.html +++ b/pages/about.html @@ -71,7 +71,7 @@

BežiApp

-
Version 1.0.1b
+
Version 1.0.2-beta
@@ -103,7 +103,7 @@
diff --git a/pages/absences.html b/pages/absences.html index d7dbdbf..78bfd79 100644 --- a/pages/absences.html +++ b/pages/absences.html @@ -68,7 +68,7 @@ - +
diff --git a/pages/grades.html b/pages/grades.html index 2d6c761..95acd22 100644 --- a/pages/grades.html +++ b/pages/grades.html @@ -88,6 +88,7 @@
  • +
      diff --git a/pages/teachers.html b/pages/teachers.html index 53eea2a..7e869ca 100644 --- a/pages/teachers.html +++ b/pages/teachers.html @@ -84,6 +84,7 @@
    • +
      diff --git a/sw.js b/sw.js index f733ff6..3e38576 100644 --- a/sw.js +++ b/sw.js @@ -1,5 +1,5 @@ // Change version to cause cache refresh -const static_cache_name = "site-static-v1.0.1"; +const static_cache_name = "site-static-v1.0.2"; // Got them with du -a and minor cleaning up const assets = [ "/img/avatars/asijanec.png", @@ -72,22 +72,29 @@ const assets = [ "/", "/index.html", "/login.html", - "/logout.js" + "/logout.html" ]; importScripts("/js/lib/localforage.min.js"); self.addEventListener("install", (evt) => { // Add localforage.clear() if storage purge is required - evt.waitUntil( - localforage.clear() - ); - - evt.waitUntil( + evt.waitUntil(async function () { + localforage.clear(); caches.open(static_cache_name).then((cache) => { cache.addAll(assets); - }) - ); + }); + + if (!evt.clientId) return; + const client = await clients.get(event.clientId); + + if (!client) return; + + client.postMessage({ + msg: "install" + }); + + }); }); // Delete old caches @@ -106,4 +113,4 @@ self.addEventListener("fetch", (evt) => { evt.respondWith(caches.match(evt.request).then((cache_res) => { return cache_res || fetch(evt.request); })) -}); \ No newline at end of file +}); -- cgit v1.2.3