From 5f22473be3faa9cd2a50444f8bea4af46725c030 Mon Sep 17 00:00:00 2001 From: sijanec Date: Mon, 8 Jun 2020 23:13:49 +0200 Subject: added some protection, proby can merge now --- assets/js/app.js.bvr | 34 +++++++++++++++++++--------------- dist/cache_name.txt | 2 +- dist/js/app.js | 36 ++++++++++++++++++++---------------- dist/pages/about.html | 2 +- dist/sw.js | 4 ++-- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/assets/js/app.js.bvr b/assets/js/app.js.bvr index 5b74aba..0bc7bcb 100644 --- a/assets/js/app.js.bvr +++ b/assets/js/app.js.bvr @@ -54,18 +54,22 @@ function gsecErrorHandlerUI(err) { } 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 - } - try { - navigator.serviceWorker.controller.postMessage(JSON.stringify(data_to_send)); - } catch (e) { - console.log("update requested but sw is not available in app.js"); - } - }); + try { + $.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 + } + try { + navigator.serviceWorker.controller.postMessage(JSON.stringify(data_to_send)); + } catch (e) { + console.log("update requested but sw is not available in app.js"); + } + }); + } catch (e) { + console.log("update requested but failed because of network error probably in update_app_function in app.js"); + } } var error_report_function = async function (msg, url, lineNo, columnNo, error) { @@ -101,12 +105,12 @@ window.onunhandledrejection = error_report_function; document.addEventListener("DOMContentLoaded", () => { - var update_interval = setInterval( () => { // ok, it's value is never read, so what?! + var update_interval = setInterval(() => { // ok, it's value is never read, so what?! localforage.getItem("lastUpdate").then((data) => { - if(Math.floor(Date.now() / 1000) > data + BEZIAPP_UPDATE_INTERVAL) { + if (Math.floor(Date.now() / 1000) > data + BEZIAPP_UPDATE_INTERVAL) { // trigger an update update_app_function(); } }); - }, 1000*BEZIAPP_UPDATE_INTERVAL); + }, 1000 * BEZIAPP_UPDATE_INTERVAL); }); \ No newline at end of file diff --git a/dist/cache_name.txt b/dist/cache_name.txt index 6f7f338..ae024b0 100644 --- a/dist/cache_name.txt +++ b/dist/cache_name.txt @@ -2,4 +2,4 @@ -///site-static-1.0.14.3-beta-f1e3fea||| +///site-static-1.0.14.3-beta-0d4d639||| diff --git a/dist/js/app.js b/dist/js/app.js index 8825438..e0d40ad 100755 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -3,7 +3,7 @@ const app_version = "1.0.14.3-beta"; -const previous_commit = "f1e3feaf44adb79aec054fce431b0a235a929466"; +const previous_commit = "0d4d63927cb2b608c65641859bfe43ba6b17b204"; const BEZIAPP_UPDATE_INTERVAL = 300; // update vsakih 300 sekund if ("serviceWorker" in navigator) { @@ -57,18 +57,22 @@ function gsecErrorHandlerUI(err) { } 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 - } - try { - navigator.serviceWorker.controller.postMessage(JSON.stringify(data_to_send)); - } catch (e) { - console.log("update requested but sw is not available in app.js"); - } - }); + try { + $.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 + } + try { + navigator.serviceWorker.controller.postMessage(JSON.stringify(data_to_send)); + } catch (e) { + console.log("update requested but sw is not available in app.js"); + } + }); + } catch (e) { + console.log("update requested but failed because of network error probably in update_app_function in app.js"); + } } var error_report_function = async function (msg, url, lineNo, columnNo, error) { @@ -104,12 +108,12 @@ window.onunhandledrejection = error_report_function; document.addEventListener("DOMContentLoaded", () => { - var update_interval = setInterval( () => { // ok, it's value is never read, so what?! + var update_interval = setInterval(() => { // ok, it's value is never read, so what?! localforage.getItem("lastUpdate").then((data) => { - if(Math.floor(Date.now() / 1000) > data + BEZIAPP_UPDATE_INTERVAL) { + if (Math.floor(Date.now() / 1000) > data + BEZIAPP_UPDATE_INTERVAL) { // trigger an update update_app_function(); } }); - }, 1000*BEZIAPP_UPDATE_INTERVAL); + }, 1000 * BEZIAPP_UPDATE_INTERVAL); }) diff --git a/dist/pages/about.html b/dist/pages/about.html index f4efcf4..bea99c7 100755 --- a/dist/pages/about.html +++ b/dist/pages/about.html @@ -161,7 +161,7 @@

- ^HEAD f1e3feaf44adb79aec054fce431b0a235a929466 + ^HEAD 0d4d63927cb2b608c65641859bfe43ba6b17b204

diff --git a/dist/sw.js b/dist/sw.js index f8aaaf5..5578deb 100755 --- a/dist/sw.js +++ b/dist/sw.js @@ -3,8 +3,8 @@ // Change version to cause cache refresh -const static_cache_name = "site-static-1.0.14.3-beta-f1e3fea"; -// commit before the latest is f1e3feaf44adb79aec054fce431b0a235a929466 +const static_cache_name = "site-static-1.0.14.3-beta-0d4d639"; +// commit before the latest is 0d4d63927cb2b608c65641859bfe43ba6b17b204 // Got them with find . -not -path '*/\.*' | sed "s/.*/\"&\",/" | grep -v sw.js // sw.js NE SME BITI CACHAN, ker vsebuje verzijo! -- cgit v1.2.3