summaryrefslogtreecommitdiffstats
path: root/dist
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-06-08 22:43:11 +0200
committersijanec <sijanecantonluka@gmail.com>2020-06-08 22:43:11 +0200
commit571c27a64e8452a58a05d85bf40e1d7885d2dd1b (patch)
tree7a67d2f3f7f50e9ec6f7e4dc25508711bf08abc8 /dist
parentfixed grades for edge-case and removed performance optimizations (diff)
downloadbeziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar.gz
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar.bz2
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar.lz
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar.xz
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.tar.zst
beziapp-571c27a64e8452a58a05d85bf40e1d7885d2dd1b.zip
Diffstat (limited to 'dist')
-rw-r--r--dist/cache_name.txt5
-rwxr-xr-xdist/js/app.js119
-rw-r--r--dist/js/setup-storage.js2
-rwxr-xr-xdist/pages/about.html265
-rwxr-xr-xdist/sw.js253
5 files changed, 358 insertions, 286 deletions
diff --git a/dist/cache_name.txt b/dist/cache_name.txt
new file mode 100644
index 0000000..30e3bd1
--- /dev/null
+++ b/dist/cache_name.txt
@@ -0,0 +1,5 @@
+
+
+
+
+///site-static-1.0.14.3-beta-134d890|||
diff --git a/dist/js/app.js b/dist/js/app.js
index f5c2f1b..87de1fc 100755
--- a/dist/js/app.js
+++ b/dist/js/app.js
@@ -2,22 +2,22 @@
-const app_version = "1.0.14.2-beta";
-const previous_commit = "c28c1c56dd807f620e916f9711d4c969817c6dd0";
-
+const app_version = "1.0.14.3-beta";
+const previous_commit = "134d89078f864250abf340713edc1d23d90ede24";
+const BEZIAPP_UPDATE_INTERVAL = 300; // update vsakih 300 sekund
if ("serviceWorker" in navigator) {
- navigator.serviceWorker.register("/sw.js")
- .then(() => { })
- .catch((err) => console.log("Service worker registration failed", err));
+ navigator.serviceWorker.register("/sw.js")
+ .then(() => { })
+ .catch((err) => console.log("Service worker registration failed", err));
}
// Listen to messages from service workers.
if (navigator.serviceWorker) {
- navigator.serviceWorker.addEventListener('message', (event) => {
- if (event.data.msg === "install") {
- window.location.replace("/index.html");
- }
- });
+ navigator.serviceWorker.addEventListener('message', (event) => {
+ if (event.data.msg === "install") {
+ window.location.replace("/index.html");
+ }
+ });
}
/**
@@ -27,12 +27,12 @@ if (navigator.serviceWorker) {
* @param {string} devmsg Developer-friendly message
*/
async function UIAlert(usermsg, devmsg) {
- if (true) { // če bo kakšen dev switch?
- M.toast( { html: usermsg } );
- console.log(`[BežiApp UIAlert] ${usermsg} ${devmsg}`);
- } else {
- M.toast( { html: `${usermsg} ${devmsg}` } );
- }
+ if (true) { // če bo kakšen dev switch?
+ M.toast({ html: usermsg });
+ console.log(`[BežiApp UIAlert] ${usermsg} ${devmsg}`);
+ } else {
+ M.toast({ html: `${usermsg} ${devmsg}` });
+ }
}
/**
@@ -40,44 +40,69 @@ async function UIAlert(usermsg, devmsg) {
* @param {Object} err GSEC error object
*/
function gsecErrorHandlerUI(err) {
- console.log(`gsecErrorHanderUI: handling ${err}`);
- if(err == GSEC_ERR_NET || err == GSEC_ERR_NET_POSTBACK_GET ||
- err == GSEC_ERR_NET_POSTBACK_POST) {
+ console.log(`gsecErrorHanderUI: handling ${err}`);
+ if (err == GSEC_ERR_NET || err == GSEC_ERR_NET_POSTBACK_GET ||
+ err == GSEC_ERR_NET_POSTBACK_POST) {
- UIAlert( D("gsecErrNet") );
- } else if(err == GSEC_ERR_LOGIN) {
- UIAlert( D("gsecErrLogin") );
- localforage.setItem("logged_in", false).then( () => {
- window.location.replace("/index.html");
- });
- } else {
- UIAlert( D("gsecErrOther") );
- }
+ UIAlert(D("gsecErrNet"));
+ } else if (err == GSEC_ERR_LOGIN) {
+ UIAlert(D("gsecErrLogin"));
+ localforage.setItem("logged_in", false).then(() => {
+ window.location.replace("/index.html");
+ });
+ } else {
+ UIAlert(D("gsecErrOther"));
+ }
}
+var update_app_function = async function () {
+ $.get("/cache_name.txt", (data, status) => {
+ var cache_name = data.split("///")[1].split("|||")[0];
+ var data_to_send = {
+ action: "checkversion",
+ valid_cache_name: cache_name
+ }
+ navigator.serviceWorker.controller.postMessage(JSON.stringify(data_to_send));
+ });
+}
var error_report_function = async function (msg, url, lineNo, columnNo, error) {
- localforage.getItem("errorReporting").then(async function(value) {
- let selectedE = value;
- if(value == null || value.length < 1) {
- selectedE = "on";
- }
- if(selectedE == "on") {
- var data = {};
- data.error = {"msg": msg, "url": url, "line": lineNo, "column": columnNo, "obj": error};
- data.client = {"ua": navigator.userAgent, "app_version": app_version, "previous_commit": previous_commit, "username": null};
+ // catching everything here so no looping error shit. that's the last thing we want
+ try {
+ localforage.getItem("errorReporting").then(async function (value) {
+ let selectedE = value;
+ if (value == null || value.length < 1) {
+ selectedE = "on";
+ }
+ if (selectedE == "on") {
+ var data = {};
+ data.error = { "msg": msg, "url": url, "line": lineNo, "column": columnNo, "obj": error };
+ data.client = { "ua": navigator.userAgent, "app_version": app_version, "previous_commit": previous_commit, "username": null };
- // Load required data
- data.client.username = await localforage.getItem("username");
+ // Load required data
+ data.client.username = await localforage.getItem("username");
- data.type = "error";
- $.post("https://beziapp-report.gimb.tk/", data);
- } else {
- console.log("error not reported as reporting is disabled!");
- }
- }).catch(() => {});
- return false;
+ data.type = "error";
+ $.post("https://beziapp-report.gimb.tk/", data);
+ } else {
+ console.log("error not reported as reporting is disabled!");
+ }
+ }).catch(() => { });
+ return false;
+ } catch (e) {
+ console.log("error_erport_function: !!! ERROR! (caught) - probably some network error.");
+ }
}
window.onerror = error_report_function;
window.onunhandledrejection = error_report_function;
+
+
+document.addEventListener("DOMContentLoaded", () => {
+ localforage.getItem("lastUpdate").then((data) => {
+ if(Math.floor(Date.now() / 1000) > data + BEZIAPP_UPDATE_INTERVAL) {
+ // trigger an update
+ update_app_function();
+ }
+ });
+})
diff --git a/dist/js/setup-storage.js b/dist/js/setup-storage.js
index b394f1e..be05650 100644
--- a/dist/js/setup-storage.js
+++ b/dist/js/setup-storage.js
@@ -1,2 +1,2 @@
-async function setupStorage(force=false){let logged_in;promises_check_if_already_installed=[localforage.getItem("logged_in").then(function(val){console.log("[setupStorage] logged in status: "+val);logged_in=val;})];await Promise.all(promises_check_if_already_installed);let promises_update=[localforage.setItem("profile",{}),localforage.setItem("timetable",[]),localforage.setItem("teachers",[]),localforage.setItem("gradings",[]),localforage.setItem("grades",[]),localforage.setItem("absences",{}),localforage.setItem("messages",[[],[],[]]),localforage.setItem("directory",{}),localforage.setItem("meals",{}),localforage.setItem("chosenLang","en"),localforage.setItem("theme","light"),localforage.setItem("errorReporting","on"),localforage.setItem("triggerWarningAccepted",false)];if(logged_in&&force==false){await Promise.all(promises_update);console.log("[setupStorage] user logged in: only updated");}else{let promises_first_install=[localforage.setItem("logged_in",false),localforage.setItem("username",""),localforage.setItem("password",""),localforage.setItem("chosenLang","en"),localforage.setItem("theme","light"),localforage.setItem("triggerWarningAccepted",false)];await localforage.clear();await Promise.all(promises_first_install);console.log("[setupStorage] user not logged in: set up whole database");}} \ No newline at end of file
+async function setupStorage(force=false){let logged_in;promises_check_if_already_installed=[localforage.getItem("logged_in").then(function(val){console.log("[setupStorage] logged in status: "+val);logged_in=val;})];await Promise.all(promises_check_if_already_installed);let promises_update=[localforage.setItem("profile",{}),localforage.setItem("timetable",[]),localforage.setItem("teachers",[]),localforage.setItem("gradings",[]),localforage.setItem("grades",[]),localforage.setItem("absences",{}),localforage.setItem("messages",[[],[],[]]),localforage.setItem("directory",{}),localforage.setItem("meals",{}),localforage.setItem("chosenLang","en"),localforage.setItem("theme","light"),localforage.setItem("errorReporting","on"),localforage.setItem("lastUpdate",0),localforage.setItem("triggerWarningAccepted",false)];if(logged_in&&force==false){await Promise.all(promises_update);console.log("[setupStorage] user logged in: only updated");}else{let promises_first_install=[localforage.setItem("logged_in",false),localforage.setItem("username",""),localforage.setItem("password",""),];await localforage.clear();await Promise.all(promises_first_install);await Promise.all(promises_update);console.log("[setupStorage] user not logged in: set up whole database");}} \ No newline at end of file
diff --git a/dist/pages/about.html b/dist/pages/about.html
index 834a0a6..179db07 100755
--- a/dist/pages/about.html
+++ b/dist/pages/about.html
@@ -2,51 +2,52 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <meta name="google" content="notranslate">
- <title>About &laquo; BežiApp</title>
-
- <!-- Materialize -->
- <link type="text/css" href="/css/materialize.min.css" rel="stylesheet">
- <link href="/css/materialicons.css" rel="stylesheet">
- <link href="/css/fontawesome.min.css" rel="stylesheet">
- <script type="text/javascript" src="/js/lib/materialize.min.js"></script>
-
- <script src="/js/lib/jquery.min.js"></script>
- <script type="text/javascript" src="/js/lib/localforage.min.js"></script>
-
- <link type="text/css" href="/css/styles.css" rel="stylesheet">
- <script type="text/javascript" src="/js/about.js"></script>
-
- <link rel="manifest" href="/manifest.json">
- <script src="/js/app.js"></script>
- <script src="/js/lib/themes.js"></script>
- <script src="/js/lang/bundle.js"></script>
- <link rel="shortcut icon" type="image/png" href="/favicon.png" />
-
- <!-- iOS support -->
- <link rel="apple-touch-icon" href="/img/icons/icon_96.png">
- <link rel="apple-touch-icon" href="/img/icons/icon_512.png">
- <meta name="apple-mobile-web-app-status-bar" content="#004d32">
-</head>
-
-<body>
- <nav class="z-depth-0" id="navigation-main">
- <div class="nav-wrapper container">
- <b class="app-header-bold">Beži</b><span class="app-header-span">App</span> &raquo; <x-su>about</x-su>
- <span class="right white-text">
- <i class="material-icons sidenav-trigger" data-target="side-menu">menu</i>
- </span>
- </div>
- <div id="loading-bar" class="progress hidden">
- <div class="indeterminate"></div>
- </div>
- </nav>
+ <!DOCTYPE html>
+ <html>
+
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <meta name="google" content="notranslate">
+ <title>About &laquo; BežiApp</title>
+
+ <!-- Materialize -->
+ <link type="text/css" href="/css/materialize.min.css" rel="stylesheet">
+ <link href="/css/materialicons.css" rel="stylesheet">
+ <link href="/css/fontawesome.min.css" rel="stylesheet">
+ <script type="text/javascript" src="/js/lib/materialize.min.js"></script>
+
+ <script src="/js/lib/jquery.min.js"></script>
+ <script type="text/javascript" src="/js/lib/localforage.min.js"></script>
+
+ <link type="text/css" href="/css/styles.css" rel="stylesheet">
+ <script type="text/javascript" src="/js/about.js"></script>
+
+ <link rel="manifest" href="/manifest.json">
+ <script src="/js/app.js"></script>
+ <script src="/js/lib/themes.js"></script>
+ <script src="/js/lang/bundle.js"></script>
+ <link rel="shortcut icon" type="image/png" href="/favicon.png" />
+
+ <!-- iOS support -->
+ <link rel="apple-touch-icon" href="/img/icons/icon_96.png">
+ <link rel="apple-touch-icon" href="/img/icons/icon_512.png">
+ <meta name="apple-mobile-web-app-status-bar" content="#004d32">
+ </head>
+
+ <body>
+ <nav class="z-depth-0" id="navigation-main">
+ <div class="nav-wrapper container">
+ <b class="app-header-bold">Beži</b><span class="app-header-span">App</span> &raquo; <x-su>about</x-su>
+ <span class="right white-text">
+ <i class="material-icons sidenav-trigger" data-target="side-menu">menu</i>
+ </span>
+ </div>
+ <div id="loading-bar" class="progress hidden">
+ <div class="indeterminate"></div>
+ </div>
+ </nav>
<ul id="side-menu" class="sidenav side-menu">
<li><a class="subheader"><h4 class="sidenav-beziapp-subheader"><b>Beži</b>App</h4></a></li>
@@ -66,87 +67,105 @@
<li><a href="/pages/settings.html" class="waves-effect"><i class="material-icons">settings</i><x-su>settings</x-su></a></li>
</ul>
- <div class="container">
- <div class="row">
- <div class="col s12">
- <h3>
- <b class="title-secondary">Beži</b><span class="title-primary">App</span>
- </h3>
- <!-- One day in the future we may have sw cache version covered by this as well -->
- <h5 class="subheader"><x-su>version</x-su> 1.0.14.2-beta</h5>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <ul class="collection with-header">
- <li class="collection-header">
- <h5><x-su>authors</x-su></h5>
- </li>
- <li class="valign-wrapper collection-item avatar">
- <img src="/img/avatars/rstular.png" class="circle">
- <span class="title about-text">Rok Štular</span>
-
- <div class="secondary-content about-button-box">
- <a href="messaging.html#Rok Štular" class="btn-floating btn-medium waves-effect waves-light button-theme-gimb" type="button">
- <i class="material-icons">message</i>
- </a>
- <a target="_blank" href="https://instagram.com/rstular/"
- class="btn-floating btn-medium waves-effect waves-light button-theme-gimb">
- <i class="fab fa-instagram"></i>
- </a>
- </div>
-
- </li>
-
- <li class="valign-wrapper collection-item avatar">
- <img src="/img/avatars/asijanec.png" class="circle">
- <span class="title about-text">Anton Luka Šijanec</span>
-
- <div class="secondary-content about-button-box">
- <a href="messaging.html#Anton Luka Šijanec" class="btn-floating btn-medium waves-effect waves-light button-theme-gimb" type="button">
- <i class="material-icons">message</i>
- </a>
- <a target="_blank" href="https://instagram.com/rstular/"
- class="btn-floating btn-medium waves-effect waves-light button-theme-gimb">
- <i class="fab fa-instagram"></i>
- </a>
- </div>
- </li>
- </ul>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <ul class="collection with-header">
- <li class="collection-header">
- <h5><x-su>translatorsForThisLanguage</x-su> - <x-su>miscTranslationLanguage</x-su></h5>
- </li>
- <li class="collection-item">
- <span class="title about-text"><x-su>miscTranslationAuthors</x-su></span>
- </li>
- </ul>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <div class="collection">
- <a href="/pages/changelog.html" class="collection-item"><x-su>whatIsNew</x-su></a>
- <a href="/pages/tos.html" class="collection-item"><x-su>theToS</x-su></a>
- <a href="/pages/privacypolicy.html" class="collection-item"><x-su>thePrivacyPolicy</x-su></a>
- <a href="https://instagram.com/beziapp/" target="_blank" class="collection-item">
- <x-su>reportABug</x-su> / <x-su>sendASuggestion</x-su> (<x-su>instagram</x-su>: @beziapp)
- </a>
- </div>
- </div>
- </div>
+ <div class="container">
+ <div class="row">
+ <div class="col s12">
+ <h3>
+ <b class="title-secondary">Beži</b><span class="title-primary">App</span>
+ </h3>
+ <!-- One day in the future we may have sw cache version covered by this as well -->
+ # I agree, will make a script
+ <h5 class="subheader">
+ <x-su>version</x-su>
+ 1.0.14.3-beta
+ </h5>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <ul class="collection with-header">
+ <li class="collection-header">
+ <h5>
+ <x-su>authors</x-su>
+ </h5>
+ </li>
+ <li class="valign-wrapper collection-item avatar">
+ <img src="/img/avatars/rstular.png" class="circle">
+ <span class="title about-text">Rok Štular</span>
+
+ <div class="secondary-content about-button-box">
+ <a href="messaging.html#Rok Štular"
+ class="btn-floating btn-medium waves-effect waves-light button-theme-gimb" type="button">
+ <i class="material-icons">message</i>
+ </a>
+ <a target="_blank" href="https://instagram.com/rstular/"
+ class="btn-floating btn-medium waves-effect waves-light button-theme-gimb">
+ <i class="fab fa-instagram"></i>
+ </a>
+ </div>
+
+ </li>
+
+ <li class="valign-wrapper collection-item avatar">
+ <img src="/img/avatars/asijanec.png" class="circle">
+ <span class="title about-text">Anton Luka Šijanec</span>
+
+ <div class="secondary-content about-button-box">
+ <a href="messaging.html#Anton Luka Šijanec"
+ class="btn-floating btn-medium waves-effect waves-light button-theme-gimb" type="button">
+ <i class="material-icons">message</i>
+ </a>
+ <a target="_blank" href="https://instagram.com/rstular/"
+ class="btn-floating btn-medium waves-effect waves-light button-theme-gimb">
+ <i class="fab fa-instagram"></i>
+ </a>
+ </div>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <ul class="collection with-header">
+ <li class="collection-header">
+ <h5>
+ <x-su>translatorsForThisLanguage</x-su> - <x-su>miscTranslationLanguage</x-su>
+ </h5>
+ </li>
+ <li class="collection-item">
+ <span class="title about-text">
+ <x-su>miscTranslationAuthors</x-su>
+ </span>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="collection">
+ <a href="/pages/changelog.html" class="collection-item">
+ <x-su>whatIsNew</x-su>
+ </a>
+ <a href="/pages/tos.html" class="collection-item">
+ <x-su>theToS</x-su>
+ </a>
+ <a href="/pages/privacypolicy.html" class="collection-item">
+ <x-su>thePrivacyPolicy</x-su>
+ </a>
+ <a href="https://instagram.com/beziapp/" target="_blank" class="collection-item">
+ <x-su>reportABug</x-su> / <x-su>sendASuggestion</x-su> (<x-su>instagram</x-su>: @beziapp)
+ </a>
+ </div>
+ </div>
+ </div>
<div class="row">
<p>
<small>
- ^HEAD c28c1c56dd807f620e916f9711d4c969817c6dd0
- </small>
+ ^HEAD 134d89078f864250abf340713edc1d23d90ede24
+ </small>
</p>
</div>
- </div>
-</body>
+ </div>
+ </body>
-</html>
+ </html
diff --git a/dist/sw.js b/dist/sw.js
index 36962ce..17e06d6 100755
--- a/dist/sw.js
+++ b/dist/sw.js
@@ -3,85 +3,85 @@
// Change version to cause cache refresh
-const static_cache_name = "site-static-1.0.14.2-beta-c28c1c5";
-// commit before the latest is c28c1c56dd807f620e916f9711d4c969817c6dd0
+const static_cache_name = "site-static-1.0.14.3-beta-134d890";
+// commit before the latest is 134d89078f864250abf340713edc1d23d90ede24
// Got them with find . -not -path '*/\.*' | sed "s/.*/\"&\",/" | grep -v sw.js
// sw.js NE SME BITI CACHAN, ker vsebuje verzijo!
const assets = [
- "/css/materialize.min.css",
- "/css/fontawesome.min.css",
- "/css/materialicons.css",
- "/css/styles.css",
- "/css/fullcalendar/custom.css",
- "/css/fullcalendar/daygrid/main.min.css",
- "/css/fullcalendar/core/main.min.css",
- "/css/fullcalendar/timegrid/main.min.css",
-
- "/fonts/fa-solid-900.eot",
- "/fonts/fa-solid-900.woff2",
- "/fonts/fa-brands-400.woff2",
- "/fonts/fa-regular-400.eot",
- "/fonts/fa-regular-400.woff2",
- "/fonts/fa-brands-400.eot",
- "/fonts/materialicons.woff2",
-
- "/img/avatars/asijanec.png",
- "/img/avatars/rstular.png",
- "/img/icons/icon_384.png",
- "/img/icons/icon_192.png",
- "/img/icons/icon_72.png",
- "/img/icons/icon_144.png",
- "/img/icons/icon_512.png",
- "/img/icons/icon_96.png",
- "/img/icons/icon_48.png",
-
- "/js/timetable.js",
- "/js/gradings.js",
- "/js/messaging.js",
- "/js/privacypolicy.js",
- "/js/teachers.js",
- "/js/tos.js",
- "/js/login.js",
- "/js/app.js",
- "/js/meals.js",
- "/js/settings.js",
+ "/css/materialize.min.css",
+ "/css/fontawesome.min.css",
+ "/css/materialicons.css",
+ "/css/styles.css",
+ "/css/fullcalendar/custom.css",
+ "/css/fullcalendar/daygrid/main.min.css",
+ "/css/fullcalendar/core/main.min.css",
+ "/css/fullcalendar/timegrid/main.min.css",
+
+ "/fonts/fa-solid-900.eot",
+ "/fonts/fa-solid-900.woff2",
+ "/fonts/fa-brands-400.woff2",
+ "/fonts/fa-regular-400.eot",
+ "/fonts/fa-regular-400.woff2",
+ "/fonts/fa-brands-400.eot",
+ "/fonts/materialicons.woff2",
+
+ "/img/avatars/asijanec.png",
+ "/img/avatars/rstular.png",
+ "/img/icons/icon_384.png",
+ "/img/icons/icon_192.png",
+ "/img/icons/icon_72.png",
+ "/img/icons/icon_144.png",
+ "/img/icons/icon_512.png",
+ "/img/icons/icon_96.png",
+ "/img/icons/icon_48.png",
+
+ "/js/timetable.js",
+ "/js/gradings.js",
+ "/js/messaging.js",
+ "/js/privacypolicy.js",
+ "/js/teachers.js",
+ "/js/tos.js",
+ "/js/login.js",
+ "/js/app.js",
+ "/js/meals.js",
+ "/js/settings.js",
"/js/lang/bundle.js",
"/js/setup-storage.js",
- "/js/lib/materialize.min.js",
- "/js/lib/jquery.min.js",
- "/js/lib/localforage.min.js",
- "/js/lib/xss.js",
- "/js/lib/mergedeep.js",
-
- "/js/lib/fullcalendar/daygrid/main.min.js",
- "/js/lib/fullcalendar/core/main.min.js",
- "/js/lib/fullcalendar/timegrid/main.min.js",
- "/js/grades.js",
- "/js/about.js",
- "/js/logout.js",
- "/js/initialize.js",
- "/js/absences.js",
- "/js/changelog.js",
-
- "/pages/timetable.html",
- "/pages/teachers.html",
- "/pages/absences.html",
- "/pages/about.html",
- "/pages/changelog.html",
- "/pages/messaging.html",
- "/pages/gradings.html",
- "/pages/grades.html",
- "/pages/privacypolicy.html",
- "/pages/tos.html",
- "/pages/meals.html",
- "/pages/settings.html",
-
- "/manifest.json",
- "/index.html",
- "/login.html",
- "/logout.html",
+ "/js/lib/materialize.min.js",
+ "/js/lib/jquery.min.js",
+ "/js/lib/localforage.min.js",
+ "/js/lib/xss.js",
+ "/js/lib/mergedeep.js",
+
+ "/js/lib/fullcalendar/daygrid/main.min.js",
+ "/js/lib/fullcalendar/core/main.min.js",
+ "/js/lib/fullcalendar/timegrid/main.min.js",
+ "/js/grades.js",
+ "/js/about.js",
+ "/js/logout.js",
+ "/js/initialize.js",
+ "/js/absences.js",
+ "/js/changelog.js",
+
+ "/pages/timetable.html",
+ "/pages/teachers.html",
+ "/pages/absences.html",
+ "/pages/about.html",
+ "/pages/changelog.html",
+ "/pages/messaging.html",
+ "/pages/gradings.html",
+ "/pages/grades.html",
+ "/pages/privacypolicy.html",
+ "/pages/tos.html",
+ "/pages/meals.html",
+ "/pages/settings.html",
+
+ "/manifest.json",
+ "/index.html",
+ "/login.html",
+ "/logout.html",
"/favicon.png",
"/pages/jitsi.html",
"/js/jitsi.js",
@@ -96,58 +96,81 @@ const assets = [
importScripts("/js/lib/localforage.min.js");
importScripts("/js/setup-storage.js");
self.addEventListener("install", (evt) => {
- // Add localforage.clear() if storage purge is required
- evt.waitUntil(
- // localforage.clear()
- setupStorage()
- );
-
- evt.waitUntil(
- caches.open(static_cache_name).then((cache) => {
- cache.addAll(assets);
- })
- );
+ // Add localforage.clear() if storage purge is required
+ evt.waitUntil(
+ // localforage.clear()
+ setupStorage()
+ );
+
+ evt.waitUntil(
+ caches.open(static_cache_name).then((cache) => {
+ cache.addAll(assets);
+ })
+ );
});
// Delete old caches
self.addEventListener("activate", evt => {
- evt.waitUntil(
- caches.keys().then((keys) => {
- return Promise.all(keys
- .filter(key => key !== static_cache_name)
- .map(key => caches.delete(key))
- );
- })
- );
+ evt.waitUntil(
+ caches.keys().then((keys) => {
+ return Promise.all(keys
+ .filter(key => key !== static_cache_name)
+ .map(key => caches.delete(key))
+ );
+ })
+ );
});
self.addEventListener("message", event => {
- if (event.data) {
- let data = JSON.parse(event.data); // parse the message back to JSON
- if (data.action == "addtocache") { // check the action
- event.waitUntil(
- caches.open(static_cache_name).then(function (cache) {
- try {
- return cache.add([data.url]);
- }
- catch (error) {
- console.error("[sw.js] error: " + error);
- }
- })
- );
- } else if (data.action == "deletecaches") {
- caches.keys().then(function (names) {
- for (let name of names)
- console.log("[sw.js] deleting cache named " + name);
- caches.delete(name);
- });
- }
- }
+ if (event.data) {
+ let data = JSON.parse(event.data); // parse the message back to JSON
+ if (data.action == "addtocache") { // check the action
+ event.waitUntil(
+ caches.open(static_cache_name).then(function (cache) {
+ try {
+ return cache.add([data.url]);
+ }
+ catch (error) {
+ console.error("[sw.js] error: " + error);
+ }
+ })
+ );
+ } else if (data.action == "deletecaches") {
+ caches.keys().then(function (names) {
+ for (let name of names) {
+ console.log("[sw.js] deleting cache named " + name);
+ caches.delete(name);
+ }
+ });
+ } else if (data.action.startsWith("checkversion")) {
+ try {
+ var names = await caches.keys();
+ console.log("[sw.js] checkversion: ***** checkversion v0 for BežiApp ***** hello, world!");
+ if(!(data.valid_cache_name == undefined || data.valid_cache_name == null || data.valid_cache_name == "")) {
+ var valid_cache_name = data.valid_cache_name;
+ console.log("[sw.js] checkversion: requested version (cachename) " + valid_cache_name);
+ } else {
+ var valid_cache_name = static_cache_name;
+ console.log("[sw.js] checkversion: no version to keep specified, using current "+valid_cache_name+", but that makes no sense to me.");
+ }
+ console.log("[sw.js] checkversion: deleting caches that don't match that cache name ...");
+ for (let name of names) {
+ if(valid_cache_name != name) {
+ caches.delete(name);
+ console.log("[sw.js] checkversion: done requesting delete of cache " + name);
+ }
+ }
+ console.log("[sw.js] checkversion: done, exiting!");
+ } catch (e) {
+ console.log("[sw.js] checkversion: !!! ERRORS! (caught)");
+ }
+ }
+ }
});
self.addEventListener("fetch", (evt) => {
- evt.respondWith(caches.match(evt.request).then((cache_res) => {
- return cache_res || fetch(evt.request);
- }))
+ evt.respondWith(caches.match(evt.request).then((cache_res) => {
+ return cache_res || fetch(evt.request);
+ }))
});