From c211817f78bc990e33a941f827fb6ba6025cd51e Mon Sep 17 00:00:00 2001 From: ostertun Date: Mon, 5 Oct 2020 23:52:09 +0200 Subject: [PATCH 1/4] Added no-db warning --- client/scripts/custom.js.php | 10 +++++----- client/scripts/database.js | 4 ++++ client/scripts/regatten.js.php | 14 ++++++++++++++ server/page/menus.php | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/client/scripts/custom.js.php b/client/scripts/custom.js.php index 308f4a4..ae95a2e 100644 --- a/client/scripts/custom.js.php +++ b/client/scripts/custom.js.php @@ -27,6 +27,11 @@ $(window).on('load',function(){ hideLoader(); }) +//Generating Cookies +function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + n * 365 * 24 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"} +function readCookie(e) {for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {for (var r = n[o];" " == r.charAt(0);) r = r.substring(1, r.length);if (0 == r.indexOf(t)) return r.substring(t.length, r.length)}return null} +function eraseCookie(e) {createCookie(e, "", -1)} + $(document).ready(function(){ 'use strict' @@ -187,11 +192,6 @@ $(document).ready(function(){ return false; }); - //Generating Cookies - function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + n * 365 * 24 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"} - function readCookie(e) {for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {for (var r = n[o];" " == r.charAt(0);) r = r.substring(1, r.length);if (0 == r.indexOf(t)) return r.substring(t.length, r.length)}return null} - function eraseCookie(e) {createCookie(e, "", -1)} - //Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance. function allowTransitions(){$('body').find('#transitions-remove').remove();} function removeTransitions(){$('body').append(''); setTimeout(function(){allowTransitions();},10);} diff --git a/client/scripts/database.js b/client/scripts/database.js index 37186f6..40345cc 100644 --- a/client/scripts/database.js +++ b/client/scripts/database.js @@ -933,6 +933,8 @@ function initDatabase() { request.onerror = function (event) { log("Cannot open DB: " + event.target); + if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded(); + runPageScript(); }; request.onsuccess = function (event) { @@ -1048,6 +1050,8 @@ function initDatabase() { osUpdateTimes.put({ table: 'last_sync', time: 0 }); } } else { + if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded(); + runPageScript(); } } diff --git a/client/scripts/regatten.js.php b/client/scripts/regatten.js.php index c53b6f7..42de4de 100644 --- a/client/scripts/regatten.js.php +++ b/client/scripts/regatten.js.php @@ -470,6 +470,20 @@ var onServiceWorkerLoaded = function() { } var onDatabaseLoaded = function() { + if (!canUseLocalDB) { + function NoDbWarningOk() { + createCookie('regatten_nodb_banner', true, 1); + $('#menu-nodb-warning').hideMenu(); + } + function showNoDbWarning() { + if (!readCookie('regatten_nodb_banner')) { + $('#menu-nodb-warning').showMenu(); + } + } + $('#menu-nodb-warning-okay').click(NoDbWarningOk); + showNoDbWarning(); + } + onServiceWorkerLoaded(); initPushSettings(); diff --git a/server/page/menus.php b/server/page/menus.php index 7ef3608..0e0fff3 100644 --- a/server/page/menus.php +++ b/server/page/menus.php @@ -291,6 +291,21 @@ + +