Compare commits
45 Commits
hide_prelo
...
ios_proble
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d38de287dd | ||
|
|
da2beac8d3 | ||
|
|
92a11bcfa5 | ||
|
|
fa4770e12a | ||
|
|
a6f2568753 | ||
|
|
6d0fdea0e8 | ||
|
|
1252c02d7c | ||
|
|
f617fa7923 | ||
|
|
c66dc96598 | ||
|
|
f5d059202e | ||
|
|
5962e1cc90 | ||
|
|
9f3019b4c5 | ||
|
|
326ba4a6bd | ||
|
|
4228ec739d | ||
|
|
a38c48dab4 | ||
|
|
da48e79a36 | ||
|
|
de5abcdfaf | ||
|
|
6b1e35cc14 | ||
|
|
89e24f69b7 | ||
|
|
554b810e85 | ||
|
|
fbd1eaaae8 | ||
|
|
ce42f87227 | ||
|
|
e66f95ff50 | ||
|
|
fcd791ed65 | ||
|
|
439679bbbe | ||
|
|
9a8d6892f2 | ||
|
|
3b71f3d707 | ||
|
|
94c6a42106 | ||
|
|
0c9eb9c013 | ||
|
|
2034e8b659 | ||
|
|
e57bf4a426 | ||
|
|
3c8289d11c | ||
|
|
63de725ebd | ||
|
|
69efb93646 | ||
|
|
6f302d6527 | ||
|
|
bfc2f84f0f | ||
|
|
0660b2b6b3 | ||
|
|
3ee722f6c2 | ||
|
|
0ce58aeacc | ||
|
|
28ba380cca | ||
|
|
357449c1c6 | ||
|
|
e84eaa2562 | ||
|
|
de70522850 | ||
|
|
775a7bd27a | ||
|
|
4106a177f8 |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -20,11 +20,11 @@ var getJSON = function(url, callback) {
|
||||
callback(xhr.status, xhr.response);
|
||||
};
|
||||
xhr.ontimeout = function () {
|
||||
log("getJSON: timeout");
|
||||
log("[db] getJSON: timeout");
|
||||
callback(0, null);
|
||||
}
|
||||
xhr.onerror = function () {
|
||||
log("getJSON: error");
|
||||
log("[db] getJSON: error");
|
||||
callback(0, null);
|
||||
}
|
||||
if (USER_ID != null) {
|
||||
@@ -76,7 +76,7 @@ function dbGetData(table, id = null) {
|
||||
if (code == 200) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
log("Something went wrong (HTTP " + code + ")");
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
fail(strings.error_network, 5000);
|
||||
resolve([]);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ function dbGetData(table, id = null) {
|
||||
if (code == 200) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
log("Something went wrong (HTTP " + code + ")");
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
fail(strings.error_network, 5000);
|
||||
resolve(null);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ function dbGetDataIndex(table, indexName, value) {
|
||||
if (code == 200) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
log("Something went wrong (HTTP " + code + ")");
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
fail(strings.error_network, 5000);
|
||||
resolve([]);
|
||||
}
|
||||
@@ -445,6 +445,7 @@ async function updateSyncStatus() {
|
||||
}
|
||||
|
||||
async function runPageScript() {
|
||||
log('[db] running page script...')
|
||||
if (canUseLocalDB) {
|
||||
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
||||
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
||||
@@ -473,8 +474,10 @@ async function runPageScript() {
|
||||
}
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
log('[db] loading site script');
|
||||
siteScript();
|
||||
} else {
|
||||
log('[db] no site script');
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
@@ -494,7 +497,7 @@ function sync() {
|
||||
|
||||
syncInProgress = 11;
|
||||
var syncOkay = true;
|
||||
log("Sync Start");
|
||||
log("[db] Sync Start");
|
||||
$('#i-sync').addClass('fa-spin');
|
||||
|
||||
var interval = window.setInterval(function () {
|
||||
@@ -504,7 +507,7 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'last_sync', time: now });
|
||||
}
|
||||
log("Sync Stop");
|
||||
log("[db] Sync Stop");
|
||||
setTimeout(function(){
|
||||
$('#i-sync').removeClass('fa-spin');
|
||||
}, 500);
|
||||
@@ -513,6 +516,7 @@ function sync() {
|
||||
onAfterSync();
|
||||
}
|
||||
removeSyncInfoToPreloader();
|
||||
showLoader();
|
||||
runPageScript();
|
||||
resolve();
|
||||
}
|
||||
@@ -540,14 +544,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
|
||||
syncInProgress --;
|
||||
log('clubs synced, remaining:', syncInProgress);
|
||||
log('[db] clubs synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("clubs: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] clubs: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('clubs failed, remaining:', syncInProgress);
|
||||
log('[db] clubs failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -573,14 +577,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
|
||||
syncInProgress --;
|
||||
log('boats synced, remaining:', syncInProgress);
|
||||
log('[db] boats synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("boats: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] boats: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('boats failed, remaining:', syncInProgress);
|
||||
log('[db] boats failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -606,14 +610,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
|
||||
syncInProgress --;
|
||||
log('sailors synced, remaining:', syncInProgress);
|
||||
log('[db] sailors synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("sailors: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] sailors: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('sailors failed, remaining:', syncInProgress);
|
||||
log('[db] sailors failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -655,14 +659,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
||||
syncInProgress --;
|
||||
log('regattas synced, remaining:', syncInProgress);
|
||||
log('[db] regattas synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("regattas: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] regattas: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('regattas failed, remaining:', syncInProgress);
|
||||
log('[db] regattas failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -688,14 +692,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'results', time: serverTimes['results'] });
|
||||
syncInProgress --;
|
||||
log('results synced, remaining:', syncInProgress);
|
||||
log('[db] results synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("results: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] results: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('results failed, remaining:', syncInProgress);
|
||||
log('[db] results failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -721,14 +725,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] });
|
||||
syncInProgress --;
|
||||
log('plannings synced, remaining:', syncInProgress);
|
||||
log('[db] plannings synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("plannings: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] plannings: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('plannings failed, remaining:', syncInProgress);
|
||||
log('[db] plannings failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -755,14 +759,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
|
||||
syncInProgress --;
|
||||
log('trim_boats synced, remaining:', syncInProgress);
|
||||
log('[db] trim_boats synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("trim_boats: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] trim_boats: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('trim_boats failed, remaining:', syncInProgress);
|
||||
log('[db] trim_boats failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -788,14 +792,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
|
||||
syncInProgress --;
|
||||
log('trim_users synced, remaining:', syncInProgress);
|
||||
log('[db] trim_users synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("trim_users: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] trim_users: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('trim_users failed, remaining:', syncInProgress);
|
||||
log('[db] trim_users failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -821,14 +825,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
|
||||
syncInProgress --;
|
||||
log('trim_trims synced, remaining:', syncInProgress);
|
||||
log('[db] trim_trims synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("trim_trims: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] trim_trims: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('trim_trims failed, remaining:', syncInProgress);
|
||||
log('[db] trim_trims failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -858,14 +862,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'news', time: serverTimes['news'] });
|
||||
syncInProgress --;
|
||||
log('news synced, remaining:', syncInProgress);
|
||||
log('[db] news synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("news: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] news: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('news failed, remaining:', syncInProgress);
|
||||
log('[db] news failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -891,14 +895,14 @@ function sync() {
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'users', time: serverTimes['users'] });
|
||||
syncInProgress --;
|
||||
log('users synced, remaining:', syncInProgress);
|
||||
log('[db] users synced, remaining:', syncInProgress);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
log("users: Something went wrong (HTTP " + code + ")");
|
||||
log("[db] users: Something went wrong (HTTP " + code + ")");
|
||||
syncOkay = false;
|
||||
syncInProgress --;
|
||||
log('users failed, remaining:', syncInProgress);
|
||||
log('[db] users failed, remaining:', syncInProgress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -906,7 +910,12 @@ function sync() {
|
||||
}
|
||||
|
||||
} else {
|
||||
log("Something went wrong (HTTP " + code + ")");
|
||||
if (code == 401) {
|
||||
log("[db] Auth invalid. Logout initiated");
|
||||
logoutClearStorage();
|
||||
} else {
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
}
|
||||
syncOkay = false;
|
||||
syncInProgress = 0;
|
||||
}
|
||||
@@ -928,17 +937,18 @@ function checkSync() {
|
||||
}
|
||||
|
||||
function initDatabase() {
|
||||
log('[db] Initializing DB...');
|
||||
if (window.indexedDB) {
|
||||
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
|
||||
request.onerror = function (event) {
|
||||
log("Cannot open DB: " + event.target);
|
||||
log("[db] Cannot open DB: " + event.target);
|
||||
|
||||
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||
|
||||
runPageScript();
|
||||
};
|
||||
request.onsuccess = function (event) {
|
||||
log("Database loaded");
|
||||
log("[db] Database loaded");
|
||||
db = event.target.result;
|
||||
|
||||
db.onversionchange = function (event) {
|
||||
@@ -951,7 +961,7 @@ function initDatabase() {
|
||||
}
|
||||
|
||||
db.onerror = function (event) {
|
||||
log("DB Error: " + event.target);
|
||||
log("[db] DB Error: " + event.target);
|
||||
};
|
||||
|
||||
canUseLocalDB = true;
|
||||
@@ -960,11 +970,12 @@ function initDatabase() {
|
||||
|
||||
db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) {
|
||||
var lastSync = event.target.result.time;
|
||||
if (lastSync > 0) {
|
||||
if (lastSync > 1) {
|
||||
runPageScript();
|
||||
} else {
|
||||
addSyncInfoToPreloader();
|
||||
if (lastSync < 1) addSyncInfoToPreloader();
|
||||
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
||||
loaderCount --;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -982,10 +993,10 @@ function initDatabase() {
|
||||
var oldVersion = event.oldVersion;
|
||||
var newVersion = event.newVersion;
|
||||
|
||||
log("Datenbank Version Upgrade von " + oldVersion + " auf " + newVersion);
|
||||
log("[db] DB Version Upgrade from " + oldVersion + " to " + newVersion);
|
||||
|
||||
if ((oldVersion < 1) && (newVersion >= 1)) {
|
||||
log('to version 1');
|
||||
log('[db] to version 1');
|
||||
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
|
||||
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
|
||||
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
|
||||
@@ -1014,7 +1025,7 @@ function initDatabase() {
|
||||
}
|
||||
|
||||
if ((oldVersion < 2) && (newVersion >= 2)) {
|
||||
log('to version 2');
|
||||
log('[db] to version 2');
|
||||
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
|
||||
osUsers.createIndex('username', 'username', { unique: true });
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
@@ -1022,32 +1033,35 @@ function initDatabase() {
|
||||
}
|
||||
|
||||
if ((oldVersion < 3) && (newVersion >= 3)) {
|
||||
log('to version 3');
|
||||
log('[db] to version 3');
|
||||
var osYears = db.createObjectStore('years', { keyPath: 'year' });
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
||||
}
|
||||
|
||||
if ((oldVersion < 4) && (newVersion >= 4)) {
|
||||
log('to version 4');
|
||||
log('[db] to version 4');
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
||||
}
|
||||
|
||||
if ((oldVersion < 5) && (newVersion >= 5)) {
|
||||
log('to version 5');
|
||||
log('[db] to version 5');
|
||||
var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
|
||||
}
|
||||
|
||||
if ((oldVersion < 6) && (newVersion >= 6)) {
|
||||
log('to version 6');
|
||||
log('[db] to version 6');
|
||||
var osNews = db.createObjectStore('news', { keyPath: 'id' });
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.add({ table: 'news', time: 0 });
|
||||
}
|
||||
|
||||
// Force resync after db update
|
||||
if (oldVersion >= 1) {
|
||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 1 });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||
@@ -1060,7 +1074,7 @@ function resetDb() {
|
||||
if (canUseLocalDB) {
|
||||
showLoader();
|
||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
||||
osUpdateTimes.put({ table: 'last_sync', time: 1 });
|
||||
osUpdateTimes.put({ table: 'clubs', time: 0 });
|
||||
osUpdateTimes.put({ table: 'boats', time: 0 });
|
||||
osUpdateTimes.put({ table: 'sailors', time: 0 });
|
||||
@@ -1072,7 +1086,7 @@ function resetDb() {
|
||||
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
||||
osUpdateTimes.put({ table: 'news', time: 0 });
|
||||
osUpdateTimes.put({ table: 'users', time: 0 });
|
||||
log('DB update times reset');
|
||||
log('[db] DB update times reset');
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,16 @@ function parseDate(string) {
|
||||
return date;
|
||||
}
|
||||
|
||||
function parseDbTimestamp(string) {
|
||||
var year = string.substr(0, 4);
|
||||
var month = string.substr(5, 2);
|
||||
var day = string.substr(8, 2);
|
||||
var hour = string.substr(11, 2);
|
||||
var minute = string.substr(14, 2);
|
||||
var second = string.substr(17, 2);
|
||||
return new Date(year, month - 1, day, hour, minute, second);
|
||||
}
|
||||
|
||||
function getToday() {
|
||||
var date = new Date();
|
||||
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||
|
||||
@@ -20,8 +20,6 @@ $(document).ready(function(){
|
||||
'use strict'
|
||||
|
||||
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop
|
||||
var pwaCookie = true; // if set to false, the PWA prompt will appear even if the user selects "maybe later"
|
||||
var pwaNoCache = false; // always keep the cache clear to serve the freshest possible content
|
||||
|
||||
|
||||
$('[data-pwa-version]').data('pwa-version', pwaVersion);
|
||||
@@ -35,7 +33,7 @@ $(document).ready(function(){
|
||||
//Enabling dismiss button
|
||||
setTimeout(function(){
|
||||
$('.pwa-dismiss').on('click',function(){
|
||||
log('User Closed Add to Home / PWA Prompt')
|
||||
log('[pwa] User Closed Add to Home / PWA Prompt')
|
||||
createCookie('Sticky_pwa_rejected_install', true, 1);
|
||||
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active');
|
||||
});
|
||||
@@ -52,10 +50,10 @@ $(document).ready(function(){
|
||||
|
||||
//Firing PWA prompts for specific versions and when not on home screen.
|
||||
if (isMobile.Android()) {
|
||||
log('Android Detected');
|
||||
log('[pwa] Android Detected');
|
||||
function showInstallPromotion(){
|
||||
if($('#menu-install-pwa-android, .add-to-home').length){
|
||||
log('Triggering PWA Menu for Android');
|
||||
log('[pwa] Triggering PWA Menu for Android');
|
||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||
setTimeout(function(){
|
||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
|
||||
@@ -80,9 +78,9 @@ $(document).ready(function(){
|
||||
deferredPrompt.userChoice
|
||||
.then((choiceResult) => {
|
||||
if (choiceResult.outcome === 'accepted') {
|
||||
log('User accepted the A2HS prompt');
|
||||
log('[pwa] User accepted the A2HS prompt');
|
||||
} else {
|
||||
log('User dismissed the A2HS prompt');
|
||||
log('[pwa] User dismissed the A2HS prompt');
|
||||
}
|
||||
deferredPrompt = null;
|
||||
});
|
||||
@@ -94,15 +92,14 @@ $(document).ready(function(){
|
||||
|
||||
if (isMobile.iOS()) {
|
||||
if(!isInWebAppiOS){
|
||||
log('iOS Detected');
|
||||
log('[pwa] iOS Detected');
|
||||
if($('#menu-install-pwa-ios, .add-to-home').length){
|
||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||
function triggerPwaInstallIos() {
|
||||
log('Triggering PWA / Add to Home Screen Menu for iOS');
|
||||
setTimeout(function(){
|
||||
function triggerPwaInstallIos() {
|
||||
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
||||
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
|
||||
},3000);
|
||||
}
|
||||
var welcomActive = $('#menu-welcome').hasClass('menu-active');
|
||||
if (welcomActive) {
|
||||
@@ -110,88 +107,10 @@ $(document).ready(function(){
|
||||
} else {
|
||||
triggerPwaInstallIos();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Creating Update Modal
|
||||
function updateModal(){
|
||||
var body = $('body');
|
||||
var updateModal = $('#menu-update');
|
||||
var mt = new Date();
|
||||
var menuUpdate = mt.getHours() + ":" + mt.getMinutes() + ":" + mt.getSeconds();
|
||||
if(!updateModal.length){
|
||||
body.append('<div id="menu-update"></div>');
|
||||
setTimeout(function(){
|
||||
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
|
||||
},250);
|
||||
}
|
||||
};
|
||||
//Update Version in 5 Seconds After New Version Detected
|
||||
function updateButton(){
|
||||
var counter = 3;
|
||||
var interval = setInterval(function() {
|
||||
counter--;
|
||||
log(counter);
|
||||
$('.page-update').html('Aktuallisierung in ... '+ counter + ' Sekunden');
|
||||
if (counter == 0) {
|
||||
clearInterval(interval);
|
||||
window.location.reload(true)
|
||||
}
|
||||
}, 1000);
|
||||
caches.delete('workbox-runtime').then(function() {
|
||||
log('Content Updated - Cache Removed!');
|
||||
});
|
||||
//localStorage.clear();
|
||||
sessionStorage.clear()
|
||||
caches.keys().then(cacheNames => {
|
||||
cacheNames.forEach(cacheName => {
|
||||
caches.delete(cacheName);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//Check Version
|
||||
function check_version(){
|
||||
if($('link[data-pwa-version]').length){
|
||||
function versionCheck(){
|
||||
var dt = new Date();
|
||||
var maniTimeVersion = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
|
||||
var localVersionNumber = $('link[rel="manifest"]').data('pwa-version');
|
||||
var onlineVersionJSON = "<?php echo SERVER_ADDR; ?>/manifest.json.php?ver=" + maniTimeVersion;
|
||||
var onlineVersionNumber = "Connection Offline. Waiting to Reconect";
|
||||
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
|
||||
setTimeout(function(){
|
||||
//console.log(' Checking PWA Content for updates...\n PWA Server Version: ' + onlineVersionNumber + '\n' + ' PWA Cached Version: ' + localVersionNumber);
|
||||
if(onlineVersionNumber != localVersionNumber && onlineVersionNumber != "Connection Offline. Waiting to Reconect"){
|
||||
updateModal();
|
||||
log('New Version of Content Available. Refreshing. On Desktop Browsers a manual refresh maybe required.')
|
||||
setTimeout(function(){
|
||||
$('body').find('#menu-update').addClass('menu-active');
|
||||
$('.menu-hider').addClass('menu-active-no-click');
|
||||
updateButton();
|
||||
},500);
|
||||
}
|
||||
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
|
||||
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
|
||||
if(onlineVersionNumber === "Finding Online Version..."){
|
||||
$('.reloadme').addClass('disabled');
|
||||
$('body').find('#menu-update').removeClass('menu-active');
|
||||
$('.menu-hider').removeClass('menu-active-no-click');
|
||||
}
|
||||
},3000);
|
||||
}
|
||||
//Checking for new version every 60 seconds
|
||||
setInterval(function(){versionCheck()}, 50000);
|
||||
//Initial Load Version Check in 10 Second After Load
|
||||
setTimeout(function(){versionCheck();}, 10000);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if(pwaCookie == false){
|
||||
eraseCookie('Sticky_pwa_rejected_install');
|
||||
}
|
||||
|
||||
//Reload To Clear Button
|
||||
@@ -199,9 +118,6 @@ $(document).ready(function(){
|
||||
location.reload();
|
||||
});
|
||||
|
||||
//Check for Version Change if Online If not Kill the Function
|
||||
if (navigator.onLine) {check_version();} else {function check_version(){}}
|
||||
|
||||
//Adding Offline Alerts
|
||||
var offlineAlerts = $('.offline-message');
|
||||
|
||||
@@ -224,47 +140,19 @@ $(document).ready(function(){
|
||||
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
||||
}
|
||||
|
||||
$('.simulate-offline').on('click',function(){isOffline();})
|
||||
$('.simulate-online').on('click',function(){isOnline();})
|
||||
|
||||
//Disable links to other pages if offline.
|
||||
//Warning! Enabling offline for iOS can cause issues
|
||||
//To allow offline functionality delete the next 7 lines
|
||||
function returnFalse(){
|
||||
var detectHREF = $(this).attr('href');
|
||||
if(detectHREF.match(/.html/)){
|
||||
isOffline();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if Online / Offline
|
||||
function updateOnlineStatus(event) {
|
||||
var condition = navigator.onLine ? "online" : "offline";
|
||||
isOnline();
|
||||
log( 'Connection: Online');
|
||||
$("a").off( "click", returnFalse );
|
||||
log('[pwa] Connection: Online');
|
||||
}
|
||||
function updateOfflineStatus(event) {
|
||||
isOffline();
|
||||
$("a").on( "click", returnFalse );
|
||||
log( 'Connection: Offline');
|
||||
log('[pwa] Connection: Offline');
|
||||
}
|
||||
window.addEventListener('online', updateOnlineStatus);
|
||||
window.addEventListener('offline', updateOfflineStatus);
|
||||
|
||||
|
||||
if(pwaNoCache == true){
|
||||
caches.delete('workbox-runtime').then(function() {
|
||||
});
|
||||
localStorage.clear();
|
||||
sessionStorage.clear()
|
||||
caches.keys().then(cacheNames => {
|
||||
cacheNames.forEach(cacheName => {
|
||||
caches.delete(cacheName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -131,6 +131,47 @@ function findGetParameter(parameterName) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var signup = function() {
|
||||
var username = $('#input-signup-username').val();
|
||||
var email = $('#input-signup-email').val();
|
||||
var password = $('#input-signup-password').val();
|
||||
if (username == '') { $('#input-signup-username').focus(); return; }
|
||||
if (email == '') { $('#input-signup-email').focus(); return; }
|
||||
if (password == '') { $('#input-signup-password').focus(); return; }
|
||||
showLoader();
|
||||
$('#input-signup-username').val('').trigger('focusin').trigger('focusout');
|
||||
$('#input-signup-email').val('').trigger('focusin').trigger('focusout');
|
||||
$('#input-signup-password').val('').trigger('focusin').trigger('focusout');
|
||||
$.ajax({
|
||||
url: QUERY_URL + 'signup',
|
||||
method: 'POST',
|
||||
data: {
|
||||
username: username,
|
||||
email: email,
|
||||
password: password
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 409) {
|
||||
toastError('Benutzername bereits vergeben');
|
||||
$('#input-signup-email').val(email).trigger('focusin').trigger('focusout');
|
||||
} else if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
||||
$('#menu-signup').hideMenu();
|
||||
} else {
|
||||
log('[app] Signup: unbekannter Fehler', status, error);
|
||||
log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
$('#input-login-username').val(username);
|
||||
$('#input-login-password').val(password);
|
||||
login();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var login = function() {
|
||||
showLoader();
|
||||
var username = $('#input-login-username').val();
|
||||
@@ -153,7 +194,7 @@ var login = function() {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
||||
$('#menu-login').hideMenu();
|
||||
} else {
|
||||
log('Login: unbekannter Fehler', status, error);
|
||||
log('[app] Login: unbekannter Fehler', status, error);
|
||||
log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
@@ -186,7 +227,7 @@ var logout = function() {
|
||||
hash: localStorage.getItem('auth_hash')
|
||||
}
|
||||
if ((auth.id === null) || (auth.hash === null)) {
|
||||
log('Not logged in');
|
||||
log('[app] Not logged in');
|
||||
logoutClearStorage();
|
||||
return;
|
||||
}
|
||||
@@ -198,13 +239,13 @@ var logout = function() {
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 401) {
|
||||
log('Not logged in');
|
||||
log('[app] Not logged in');
|
||||
logoutClearStorage();
|
||||
} else if (xhr.status == 0) {
|
||||
log('Could not delete auth from server');
|
||||
log('[app] Could not delete auth from server');
|
||||
logoutClearStorage();
|
||||
} else {
|
||||
log('Logout: unbekannter Fehler', status, error);
|
||||
log('[app] Logout: unbekannter Fehler', status, error);
|
||||
log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
hideLoader();
|
||||
@@ -222,12 +263,12 @@ function deleteDb() {
|
||||
showLoader();
|
||||
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
|
||||
request.onerror = function (event) {
|
||||
log('Cannot delete DB: ', event.target.errorCode);
|
||||
log('[app] Cannot delete DB: ', event.target.errorCode);
|
||||
toastError('Beim Löschen der Datenbank ist ein Fehler aufgetreten.<br>Bitte melde diesen Fehler. (Dev-Menu => Problem melden)', 5000);
|
||||
hideLoader();
|
||||
}
|
||||
request.onsuccess = function (event) {
|
||||
log('DB deleted');
|
||||
log('[app] DB deleted');
|
||||
toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
|
||||
hideLoader();
|
||||
setTimeout(function(){ location.reload(); }, 3000);
|
||||
@@ -241,13 +282,13 @@ function deleteCache() {
|
||||
$('#menu-developer').hideMenu();
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
log('Unregister sW:', registration);
|
||||
log('[app] Unregister sW:', registration);
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
caches.keys().then((keyList) => {
|
||||
return Promise.all(keyList.map((key) => {
|
||||
log('Cache deleted:', key);
|
||||
log('[app] Cache deleted:', key);
|
||||
return caches.delete(key);
|
||||
}));
|
||||
});
|
||||
@@ -273,7 +314,7 @@ function urlB64ToUint8Array(base64String) {
|
||||
}
|
||||
|
||||
function pushesSubscribe() {
|
||||
log('Subscribing');
|
||||
log('[app] Subscribing');
|
||||
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
|
||||
swRegistration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
@@ -285,14 +326,14 @@ function pushesSubscribe() {
|
||||
updatePushBadge();
|
||||
})
|
||||
.catch(function(err) {
|
||||
log('Failed to subscribe the user: ', err);
|
||||
log('[app] Failed to subscribe the user: ', err);
|
||||
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
|
||||
pushesUnSubscribe(true);
|
||||
});
|
||||
}
|
||||
|
||||
function pushesUnSubscribe(silent = false) {
|
||||
log('Unsubscribing');
|
||||
log('[app] Unsubscribing');
|
||||
swRegistration.pushManager.getSubscription()
|
||||
.then(function(subscription) {
|
||||
if (subscription) {
|
||||
@@ -304,7 +345,7 @@ function pushesUnSubscribe(silent = false) {
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
log('Error unsubscribing', error);
|
||||
log('[app] Error unsubscribing', error);
|
||||
$('#menu-pushes').hideMenu();
|
||||
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
|
||||
updatePushBadge();
|
||||
@@ -313,7 +354,7 @@ function pushesUnSubscribe(silent = false) {
|
||||
}
|
||||
|
||||
function pushesUpdateServerSubscription(subscription, enabled) {
|
||||
log('updateServer', enabled, subscription);
|
||||
log('[app] updateServer', enabled, subscription);
|
||||
$.ajax({
|
||||
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||
type: 'POST',
|
||||
@@ -406,6 +447,7 @@ function pushesOpenMenu() {
|
||||
}
|
||||
|
||||
function updatePushBadge() {
|
||||
if (typeof onUpdatePushBadge === 'function') onUpdatePushBadge();
|
||||
if (!pushesPossible) return;
|
||||
if (Notification.permission == 'denied') {
|
||||
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
|
||||
@@ -429,7 +471,7 @@ async function updateNewsBadge() {
|
||||
var sum = 0;
|
||||
for (var n in news) {
|
||||
var newsEntry = news[n];
|
||||
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||
newsEntry.date = parseDbTimestamp(newsEntry.date);
|
||||
if (newsEntry.date > now) continue;
|
||||
if (newsEntry.date < newsRead) continue;
|
||||
sum ++;
|
||||
@@ -440,8 +482,12 @@ async function updateNewsBadge() {
|
||||
var initRegatten = function() {
|
||||
showLoader();
|
||||
|
||||
log('[app] Initializing DB...');
|
||||
|
||||
initDatabase();
|
||||
|
||||
log('[app] Loading app specific code...');
|
||||
|
||||
if (isLoggedIn()) {
|
||||
$('.show-loggedin').show();
|
||||
$('.show-notloggedin').hide();
|
||||
@@ -461,7 +507,8 @@ var initRegatten = function() {
|
||||
}
|
||||
|
||||
var onServiceWorkerLoaded = function() {
|
||||
if ((swRegistration !== null) && canUseLocalDB) {
|
||||
log('[app] sW loaded');
|
||||
if ((swRegistration !== null) && (swRegistration.pushManager) && canUseLocalDB) {
|
||||
pushesPossible = true;
|
||||
updatePushBadge();
|
||||
} else {
|
||||
@@ -470,6 +517,7 @@ var onServiceWorkerLoaded = function() {
|
||||
}
|
||||
|
||||
var onDatabaseLoaded = function() {
|
||||
log('[app] DB loaded');
|
||||
if (!canUseLocalDB && !$('#menu-welcome').hasClass('menu-active')) {
|
||||
function NoDbWarningOk() {
|
||||
createCookie('regatten_nodb_banner', true, 1);
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
|
||||
// Favorites
|
||||
$content = '<h2>Deine Favoriten</h2>';
|
||||
$thead = '<tr><th>Segler</th><th id="th-ranking">Rangliste</th></tr>';
|
||||
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-favorites', 'css-class' => 'mb-0 mt-3']);
|
||||
$content .= '<div id="div-favorites" class="normal-list mb-0"></div>';
|
||||
$content .= '<p id="p-favorites" class="mt-3">';
|
||||
$content .= 'Du folgst <b>keinen</b> Seglern.<br>';
|
||||
$content .= 'Um jemandem zu folgen, gehe zur <a href="' . LINK_PRE . 'sailors">Segler-Liste</a> und wähle bis zu fünf Segler aus.';
|
||||
@@ -38,6 +37,18 @@
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notloggedin']);
|
||||
|
||||
// Notification Info
|
||||
$content = '<h2 class="color-white">Push-Benachrichtigungen</h2>';
|
||||
$content .= '<p class="mt-3 mb-3 color-white">';
|
||||
$content .= '<b>Bleibe immer auf dem Laufendem!</b><br>';
|
||||
$content .= 'Aktiviere einfach unsere Push-Benachrichtigungen und wir informieren Dich über alle Änderungen.<br>';
|
||||
$content .= 'Du bestimmst natürlich, welche Benachrichtigungen Du bekommen möchtest.';
|
||||
$content .= '</p>';
|
||||
$content .= $tpl->load('button', ['Jetzt aktivieren', '#', 'html-id' => 'button-notifications-activate', 'css-class' => 'bg-green2-dark']);
|
||||
$content .= '<p class="text-center mt-3"><a id="a-notifications-later" class="color-grey2-light text-uppercase font-900">Vielleicht später</a></p>';
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notifications', 'css-class' => 'bg-blue2-dark']);
|
||||
|
||||
// Next
|
||||
$content = '<h2>Nächste Regatten</h2>';
|
||||
$content .= '<div id="div-next" class="regattas-list mb-0"></div>';
|
||||
@@ -79,6 +90,10 @@
|
||||
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
|
||||
|
||||
// Favorites Menu
|
||||
$items = $tpl->load('menu/item-icon', ['Nicht mehr folgen', '#', 'html-id' => 'menu-item-unfollow', 'icon' => 'fa-heart', 'css-class' => ' border-0']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-favorite', 'title' => 'Favorit', 'height' => 200]);
|
||||
|
||||
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
||||
$sp['scripts'] .= $scripts->load('index');
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// Title
|
||||
$content = '<h1>Saison-Planung</h1>';
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-list"></i> Saison-Planungen anderer', LINK_PRE . 'planning_list', 'css-class' => 'mt-2 mb-2']);
|
||||
$content .= '<p class="mb-1"><b>Hinweis:</b> Diese Seite kannst nur Du sehen.<br>Wenn Du Deine Saison-Planung teilen möchtest, <a id="a-share-planning">klicke hier</a></p>';
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-edit"></i> bearbeiten', LINK_PRE . 'planning_edit']);
|
||||
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||
|
||||
// Menu
|
||||
$items = $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-year', 'icon' => 'fa-edit']);
|
||||
$items = $tpl->load('menu/item-switch', ['Favorit', 'html-id' => 'menu-item-follow', 'icon' => 'fa-heart']);
|
||||
$items .= $tpl->load('menu/item-icon-badge', ['Favorit', '#', 'html-id' => 'menu-item-follow-disabled', 'icon' => 'fa-heart', 'badge-value' => 'MAX REACHED']);
|
||||
$items .= $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-year', 'icon' => 'fa-edit']);
|
||||
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe', 'css-class' => 'border-0']);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-sailor', 'title' => 'Segler-Details', 'height' => 200]);
|
||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-sailor', 'title' => 'Segler-Details', 'height' => 260]);
|
||||
|
||||
$items = '<p class="mb-2 mt-1" style="line-height: 1.5em;">Bitte trage hier den Jahrgang ein:</p>';
|
||||
$items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="menu-share" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="345" data-menu-effect="menu-over">
|
||||
<div class="menu-title mt-n1"><h1>Share the Love</h1><p class="color-highlight">Just Tap the Social Icon. We'll add the Link</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||
<div class="menu-title mt-n1"><h1>Seite Teilen</h1><p class="color-highlight">Teile diese Seite mit Deinen Freunden!</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||
<div class="content mb-0">
|
||||
<div class="divider mb-0"></div>
|
||||
<div class="list-group list-custom-small list-icon-0">
|
||||
@@ -92,11 +92,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
|
||||
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="260">
|
||||
<div class="menu-title"><h1>Einstellungen</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||
<div class="divider divider-margins mb-n2"></div>
|
||||
<div class="content">
|
||||
<div class="list-group list-custom-small">
|
||||
<?php if (false) { /* DARK MODE DISABLED (set menu height to 310) */ ?>
|
||||
<a href="#" data-toggle-theme data-trigger-switch="switch-dark" class="pb-2">
|
||||
<i class="fa font-14 fa-moon rounded-s bg-dark1-dark color-white"></i>
|
||||
<span>Dark Mode</span>
|
||||
@@ -105,6 +106,7 @@
|
||||
<label class="custom-control-label" for="switch-dark"></label>
|
||||
</div>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a href="#" data-menu="menu-login" class="show-notloggedin">
|
||||
<i class="fa font-14 fa-sign-in-alt rounded-s bg-highlight color-white"></i>
|
||||
<span>Login</span>
|
||||
@@ -243,7 +245,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-login" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="270">
|
||||
<div id="menu-login" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="320">
|
||||
<div class="content bottom-0">
|
||||
<h1 class="text-center mt-5 font-900">Login</h1>
|
||||
<div class="input-style input-style-2 has-icon input-required">
|
||||
@@ -257,18 +259,29 @@
|
||||
<input id="input-login-password" class="form-control" type="password" placeholder="Passwort" />
|
||||
</div>
|
||||
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="login();">Login</a>
|
||||
<p class="text-center mt-3"><a class="text-uppercase font-900" href="https://regatten.net/reset">Benutzername oder Passwort vergessen</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-signup" class="menu menu-box-modal menu-box-detached rounded-m" data-menu-height="300">
|
||||
<div id="menu-signup" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="340">
|
||||
<div class="content bottom-0">
|
||||
<h1 class="text-center mt-5 font-900">Registrieren</h1>
|
||||
<p class="text-center">
|
||||
Momentan kannst Du Dich leider nicht in der App registrieren.<br>
|
||||
Das ist aber kein Problem, registriere Dich einfach kostenlos auf unserer Website!
|
||||
</p>
|
||||
<a href="https://regatten.net/de/signup" class="btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Registrieren</a>
|
||||
<p class="text-center font-10 bottom-0">Du kannst Dich danach in dieser App anmelden.</p>
|
||||
<div class="input-style input-style-2 has-icon input-required">
|
||||
<i class="input-icon fa fa-user color-theme"></i>
|
||||
<span class="color-highlight">Benutzername</span>
|
||||
<input id="input-signup-username" class="form-control" type="name" placeholder="Benutzername" />
|
||||
</div>
|
||||
<div class="input-style input-style-2 has-icon input-required">
|
||||
<i class="input-icon fa fa-envelope color-theme"></i>
|
||||
<span class="color-highlight">Email</span>
|
||||
<input id="input-signup-email" class="form-control" type="email" placeholder="Email" />
|
||||
</div>
|
||||
<div class="input-style input-style-2 has-icon input-required">
|
||||
<i class="input-icon fa fa-lock color-theme"></i>
|
||||
<span class="color-highlight">Passwort</span>
|
||||
<input id="input-signup-password" class="form-control" type="password" placeholder="Passwort" />
|
||||
</div>
|
||||
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="signup();">Registrieren</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -305,15 +318,3 @@
|
||||
<a id="menu-nodb-warning-okay" class="btn btn-m mt-2 mb-3 btn-full bg-highlight text-uppercase font-900" href="#">Nicht erneut anzeigen</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-update">
|
||||
<div class="content bottom-0">
|
||||
<p class="text-center mt-5"><i class="fa fa-sync-alt fa-7x color-highlight fa-spin"></i></p>
|
||||
<h1 class="text-center mt-5 font-900">Update Verfügbar</h1>
|
||||
<p class="text-center">
|
||||
Eine neue Version unserer App ist verfügbar. Keine Sorge, Du musst nichts machen. Wir aktuallisieren den Inhalt in wenigen Sekunden.
|
||||
</p>
|
||||
<a href="#" class="page-update btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Update</a>
|
||||
<p class="text-center font-10 bottom-0">Die App wird neu laden und das Update ist abgeschlossen.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
||||
</head>
|
||||
|
||||
<body class="detect-theme" data-background="none" data-highlight="blue2">
|
||||
<body class="theme-light" data-background="none" data-highlight="blue2"><?php /* DARK MODE DISABLED: set class to "detect-theme" */ ?>
|
||||
|
||||
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
|
||||
|
||||
|
||||
@@ -1,8 +1,84 @@
|
||||
var firstCall = true;
|
||||
var today;
|
||||
var onUpdatePushBadge;
|
||||
|
||||
var onUnfollowClicked = async function() {
|
||||
var id = $('#menu-item-unfollow').attr('data-sailor-id');
|
||||
showLoader();
|
||||
$('#menu-favorite').hideMenu();
|
||||
var auth = {
|
||||
id: localStorage.getItem('auth_id'),
|
||||
hash: localStorage.getItem('auth_hash')
|
||||
}
|
||||
$.ajax({
|
||||
url: QUERY_URL + 'sailor_unfollow',
|
||||
method: 'POST',
|
||||
data: {
|
||||
auth: auth,
|
||||
sailor: id
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Deine Favoriten zu bearbeiten.');
|
||||
} else {
|
||||
log('Unfollow: unbekannter Fehler', status, error);
|
||||
log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: async function (data, status, xhr) {
|
||||
await sync();
|
||||
toastOk('Erfolgreich');
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var onFavoriteClicked = async function(id) {
|
||||
var sailor = await dbGetData('sailors', id);
|
||||
|
||||
$('#menu-favorite').find('.menu-title').find('p').text(sailor.name);
|
||||
|
||||
$('#menu-item-unfollow').attr('data-sailor-id', sailor.id);
|
||||
|
||||
$('#menu-favorite').showMenu();
|
||||
}
|
||||
|
||||
var siteScript = async function() {
|
||||
today = getToday();
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
$('#button-notifications-activate').click(function(){
|
||||
$('#menu-pushes').showMenu();
|
||||
});
|
||||
$('#a-notifications-later').click(function(){
|
||||
createCookie('regatten_app_' + BOATCLASS + '_rejected_push', true, 1);
|
||||
$('#card-notifications').hide();
|
||||
});
|
||||
if (readCookie('regatten_app_' + BOATCLASS + '_rejected_push')) {
|
||||
$('#card-notifications').hide();
|
||||
} else {
|
||||
onUpdatePushBadge = function () {
|
||||
if (!pushesPossible || (Notification.permission == 'denied')) {
|
||||
$('#card-notifications').hide();
|
||||
} else {
|
||||
swRegistration.pushManager.getSubscription().then(function(subscription) {
|
||||
var isSub = (subscription !== null);
|
||||
if (isSub) {
|
||||
$('#card-notifications').hide();
|
||||
} else {
|
||||
$('#card-notifications').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
onUpdatePushBadge();
|
||||
}
|
||||
$('#menu-item-unfollow').click(onUnfollowClicked);
|
||||
}
|
||||
|
||||
if (isLoggedIn()) {
|
||||
$('#card-notloggedin').hide();
|
||||
|
||||
@@ -18,31 +94,41 @@ var siteScript = async function() {
|
||||
}
|
||||
if (watched.length > 0) {
|
||||
var year = (new Date()).getFullYear();
|
||||
$('#th-ranking').html('Rangliste ' + year);
|
||||
var ranking = (await dbGetRanking(parseDate('01.12.' + (year - 1)), parseDate('30.11.' + year), false, false))[0];
|
||||
tbody = '';
|
||||
var list = '';
|
||||
for (i in watched) {
|
||||
sailor = watched[i];
|
||||
tbody += '<tr><td>' + sailor.name + '</td><td>';
|
||||
var club = null;
|
||||
if (sailor.club != null)
|
||||
club = await dbGetData('clubs', sailor.club);
|
||||
var rank = null;
|
||||
for (r in ranking) {
|
||||
if (ranking[r].id == sailor.id) {
|
||||
rank = ranking[r].rank;
|
||||
rank = ranking[r];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list += '<div onclick="onFavoriteClicked(' + sailor.id + ');">';
|
||||
list += '<div>';
|
||||
// Name
|
||||
list += '<div><b>' + sailor.name + '</b></div>';
|
||||
list += '</div><div>';
|
||||
if (rank == null) {
|
||||
tbody += '<i>nicht in der Rangliste</i>';
|
||||
list += '<div>Nicht in der Rangliste</div>';
|
||||
} else {
|
||||
tbody += '<b>' + rank + '.</b> Platz';
|
||||
// Rank
|
||||
list += '<div>Platz <b>' + rank.rank + '</b></div>';
|
||||
// rlp
|
||||
list += '<div>' + rank.rlp.toFixed(3) + ' Punkte</div>';
|
||||
}
|
||||
tbody += '</td></tr>';
|
||||
list += '</div></div>';
|
||||
}
|
||||
$('#table-favorites').find('tbody').html(tbody);
|
||||
$('#div-favorites').html(list);
|
||||
$('#p-favorites').hide();
|
||||
$('#table-favorites').show();
|
||||
$('#div-favorites').show();
|
||||
} else {
|
||||
$('#table-favorites').hide();
|
||||
$('#div-favorites').hide();
|
||||
$('#p-favorites').show();
|
||||
}
|
||||
$('#card-favorites').show();
|
||||
@@ -273,12 +359,9 @@ var siteScript = async function() {
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() - 1);
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
var regattaResults = [];
|
||||
for (id in regattas) {
|
||||
var entry = regattas[id];
|
||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
||||
regattaResults[entry['id']] = (results.length > 0);
|
||||
}
|
||||
regattas.sort(function(a,b){
|
||||
return b.date.localeCompare(a.date);
|
||||
});
|
||||
if (regattas.length > 0) {
|
||||
list = '';
|
||||
for (i in regattas) {
|
||||
@@ -320,7 +403,7 @@ var siteScript = async function() {
|
||||
icons.push('<i class="fas fa-book"></i>');
|
||||
if (regatta['canceled'] == '1') {
|
||||
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||
} else if (regattaResults[regatta['id']]) {
|
||||
} else if (regatta['results'] == '1') {
|
||||
icons.push('<i class="fas fa-poll"></i>');
|
||||
}
|
||||
list += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||
|
||||
@@ -66,7 +66,7 @@ var siteScript = async function() {
|
||||
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
||||
for (var n in news) {
|
||||
var newsEntry = news[n];
|
||||
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||
newsEntry.date = parseDbTimestamp(newsEntry.date);
|
||||
if (newsEntry.date > now) continue;
|
||||
if (newsEntry.date < lastYear) break;
|
||||
newsEntry.unread = (newsEntry.date > newsRead);
|
||||
|
||||
@@ -61,8 +61,7 @@ async function onRegattaClicked(id) {
|
||||
}
|
||||
|
||||
// Results
|
||||
var results = await dbGetDataIndex('results', 'regatta', regatta['id']);
|
||||
if (results.length > 0) {
|
||||
if (regatta['results'] == '1') {
|
||||
$('#menu-item-results').show();
|
||||
$('#menu-item-results').attr('href', LINK_PRE + 'result?regatta=' + regatta['id']);
|
||||
} else {
|
||||
|
||||
@@ -68,6 +68,7 @@ function selectChange() {
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
@@ -136,12 +137,6 @@ var siteScript = async function() {
|
||||
regattas.splice(i, 1);
|
||||
}
|
||||
}
|
||||
var regattaResults = [];
|
||||
for (id in regattas) {
|
||||
var entry = regattas[id];
|
||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
||||
regattaResults[entry['id']] = (results.length > 0);
|
||||
}
|
||||
|
||||
var years = await dbGetData('years');
|
||||
years.sort(function (a, b) {
|
||||
@@ -261,7 +256,7 @@ var siteScript = async function() {
|
||||
icons.push('<i class="fas fa-book"></i>');
|
||||
if (entry['canceled'] == '1') {
|
||||
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||
} else if (regattaResults[entry['id']]) {
|
||||
} else if (entry['results'] == '1') {
|
||||
icons.push('<i class="fas fa-poll"></i>');
|
||||
}
|
||||
if (entry.planning.gemeldet == '1') {
|
||||
|
||||
@@ -261,6 +261,7 @@ function selectChange() {
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ function selectChange() {
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ function selectChange() {
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,8 @@ async function selectChange(callSiteScript = true) {
|
||||
$('#input-jugstrict').prop('checked', jugstrict);
|
||||
|
||||
if (callSiteScript && (typeof siteScript === 'function')) {
|
||||
history.replaceState(null, '', '?type=' + type + '&year=' + year)
|
||||
history.replaceState(null, '', '?type=' + type + '&year=' + year);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
@@ -187,6 +188,7 @@ function buttonShowPressed() {
|
||||
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
|
||||
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
|
||||
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ function selectChange(callSiteScript = true) {
|
||||
|
||||
if (callSiteScript && (typeof siteScript === 'function')) {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +22,8 @@ function selectChange(callSiteScript = true) {
|
||||
|
||||
function buttonShowPressed() {
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val())
|
||||
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val());
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
@@ -77,12 +79,6 @@ var siteScript = async function() {
|
||||
var minDate = parseDate($('#input-from').val());
|
||||
var maxDate = parseDate($('#input-to').val());
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
var regattaResults = [];
|
||||
for (id in regattas) {
|
||||
var entry = regattas[id];
|
||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
||||
regattaResults[entry['id']] = (results.length > 0);
|
||||
}
|
||||
|
||||
var selectedYear = $('#select-year').val();
|
||||
|
||||
@@ -194,7 +190,7 @@ var siteScript = async function() {
|
||||
icons.push('<i class="fas fa-book"></i>');
|
||||
if (entry['canceled'] == '1') {
|
||||
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||
} else if (regattaResults[entry['id']]) {
|
||||
} else if (entry['results'] == '1') {
|
||||
icons.push('<i class="fas fa-poll"></i>');
|
||||
}
|
||||
row.content += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||
|
||||
@@ -4,6 +4,40 @@ var displayed = [];
|
||||
var page = 1;
|
||||
var pageCount = 0;
|
||||
const showCount = 25;
|
||||
var followedSailors = [];
|
||||
|
||||
async function onFollowChange() {
|
||||
var id = $('#menu-item-follow').attr('data-sailor-id');
|
||||
showLoader();
|
||||
$('#menu-sailor').hideMenu();
|
||||
var auth = {
|
||||
id: localStorage.getItem('auth_id'),
|
||||
hash: localStorage.getItem('auth_hash')
|
||||
}
|
||||
$.ajax({
|
||||
url: QUERY_URL + ($('#menu-item-follow').prop('checked') ? 'sailor_follow' : 'sailor_unfollow'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
auth: auth,
|
||||
sailor: id
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (xhr.status == 0) {
|
||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Deine Favoriten zu bearbeiten.');
|
||||
} else {
|
||||
log('Un/Follow: unbekannter Fehler', status, error);
|
||||
log(xhr);
|
||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||
}
|
||||
hideLoader();
|
||||
},
|
||||
success: async function (data, status, xhr) {
|
||||
await sync();
|
||||
toastOk('Erfolgreich');
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onEditYearClick() {
|
||||
var id = $('#button-edityear').attr('data-sailor-id');
|
||||
@@ -50,6 +84,26 @@ async function onListClicked(id) {
|
||||
|
||||
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
|
||||
|
||||
// Follow
|
||||
if (isLoggedIn()) {
|
||||
var found = false;
|
||||
for (var i in followedSailors) {
|
||||
if (followedSailors[i].id == sailor.id) found = true;
|
||||
}
|
||||
if (found || (followedSailors.length < 5)) {
|
||||
$('#menu-item-follow').attr('data-sailor-id', sailor.id);
|
||||
$('#menu-item-follow').prop('checked', found);
|
||||
$('#menu-item-follow').parent().parent().show();
|
||||
$('#menu-item-follow-disabled').hide();
|
||||
} else {
|
||||
$('#menu-item-follow').parent().parent().hide();
|
||||
$('#menu-item-follow-disabled').show();
|
||||
}
|
||||
} else {
|
||||
$('#menu-item-follow').parent().parent().hide();
|
||||
$('#menu-item-follow-disabled').hide();
|
||||
}
|
||||
|
||||
// Edit Year
|
||||
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
||||
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
|
||||
@@ -134,6 +188,19 @@ var siteScript = async function() {
|
||||
$('#input-search').on('input', reSearch);
|
||||
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
||||
$('#button-edityear').click(onEditYearClick);
|
||||
$('#menu-item-follow').parent().parent().click(onFollowChange);
|
||||
$('#menu-item-follow-disabled').click(function(){ $('#menu-sailor').hideMenu(); toastInfo('Du kannst maximal 5 Seglern folgen. Entferne erst einen Segler aus Deinen Favoriten, bevor Du andere aufnimmst.', 5000); });
|
||||
}
|
||||
|
||||
if (isLoggedIn()) {
|
||||
var user = await dbGetData('users', USER_ID);
|
||||
followedSailors = [];
|
||||
for (var i = 1; i <= 5; i ++) {
|
||||
sailor_id = user['sailor' + i];
|
||||
if (sailor_id != null) {
|
||||
followedSailors.push(await dbGetData('sailors', sailor_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var results = await dbGetData('sailors');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<nav id="$$html-id;">
|
||||
<nav id="$$html-id;" class="$$css-class;">
|
||||
<ul class="pagination justify-content-center">
|
||||
<li id="$$html-id;-1" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">1</a></li>
|
||||
<li id="$$html-id;-2" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">2</a></li>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
define('PWA_VERSION', '1.10.3h1');
|
||||
define('PWA_VERSION', '1.11h3');
|
||||
|
||||
?>
|
||||
|
||||
@@ -233,11 +233,11 @@ self.addEventListener('push', async function(event) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.log('Unknown channel:', data.channel);
|
||||
console.log('[sW] Unknown channel:', data.channel);
|
||||
break;
|
||||
}
|
||||
if (!okay) {
|
||||
console.log('Notification channel not subscribed');
|
||||
console.log('[sW] Notification channel not subscribed');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ self.addEventListener('push', async function(event) {
|
||||
var db = await openDb();
|
||||
if (db != null) {
|
||||
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
var request = os.put({ table: 'last_sync', time: 0 });
|
||||
var request = os.put({ table: 'last_sync', time: 1 });
|
||||
request.onerror = function (event) {
|
||||
console.log('[sW] Error while saving data to DB:', e);
|
||||
db.close();
|
||||
@@ -268,7 +268,7 @@ self.addEventListener('push', async function(event) {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Showing notification');
|
||||
console.log('[sW] Showing notification');
|
||||
self.registration.showNotification(data.title, options);
|
||||
break;
|
||||
|
||||
@@ -277,7 +277,7 @@ self.addEventListener('push', async function(event) {
|
||||
var db = await openDb();
|
||||
if (db != null) {
|
||||
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||
var request = os.put({ table: 'last_sync', time: 0 });
|
||||
var request = os.put({ table: 'last_sync', time: 1 });
|
||||
request.onerror = function (event) {
|
||||
console.log('[sW] Error while saving data to DB:', e);
|
||||
db.close();
|
||||
@@ -311,3 +311,16 @@ self.addEventListener('notificationclick', function(event) {
|
||||
clients.openWindow(url)
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('pushsubscriptionchange', function(event) {
|
||||
var formData = new URLSearchParams();
|
||||
formData.append('old', JSON.stringify(event.oldSubscription));
|
||||
formData.append('new', JSON.stringify(event.newSubscription));
|
||||
event.waitUntil(
|
||||
fetch('<?php echo QUERY_URL; ?>update_subscription', {
|
||||
method: 'POST',
|
||||
cache: 'no-cache',
|
||||
body: formData
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user