Compare commits

...

86 Commits

Author SHA1 Message Date
ostertun
c8cef6ee95 Merge branch 'hotfix/state_NSC' 2021-06-13 23:24:05 +02:00
ostertun
19f561ffde gitflow-hotfix-stash: state_NSC 2021-06-13 23:23:25 +02:00
ostertun
4dfa2d7bd5 Merge branch 'release/v_1.11.5' 2020-12-24 11:08:35 +01:00
ostertun
c983a1702f Fix Altersklassen & no_regattas_on_index 2020-12-23 15:08:36 +01:00
ostertun
a1facbca85 Altersklassen 2020-12-22 18:44:05 +01:00
ostertun
fba8c8e958 v_1.11.5 Dark Mode 2020-12-21 12:01:59 +01:00
ostertun
8aa3e3ccb6 Merge branch 'hotfix/no_regattas_on_index' 2020-12-11 17:27:49 +01:00
ostertun
c319e568b6 Merge branch 'hotfix/no_regattas_on_index' into develop 2020-12-11 17:27:48 +01:00
ostertun
748176159d v_1.11.4h2 no_regattas_on_index 2020-12-11 17:27:44 +01:00
ostertun
053981175b Merge branch 'hotfix/notify_android_lost_subscription' 2020-12-09 13:53:37 +01:00
ostertun
7083b46831 Merge branch 'hotfix/notify_android_lost_subscription' into develop 2020-12-09 13:53:37 +01:00
ostertun
2c8c99b8f0 v_1.11.4h1 notify_android_lost_subscription 2020-12-09 13:53:17 +01:00
ostertun
07d01ae700 Merge branch 'release/V_1.11.4' 2020-12-07 16:48:32 +01:00
ostertun
7da31729e9 Merge branch 'release/V_1.11.4' into develop 2020-12-07 16:48:32 +01:00
ostertun
08ab714a54 Release v_1.11.4 2020-12-07 16:48:08 +01:00
ostertun
44c962b7b3 Show next year in regattas lists 2020-12-07 16:47:24 +01:00
ostertun
004280f3ea Merge branch 'hotfix/pushsubscription_onerror' 2020-11-19 13:20:41 +01:00
ostertun
63a8d174d7 Merge branch 'hotfix/pushsubscription_onerror' into develop 2020-11-19 13:20:41 +01:00
ostertun
13f496f0a6 gitflow-hotfix-stash: pushsubscription_onerror 2020-11-19 13:20:29 +01:00
ostertun
da553a8f8d Merge branch 'release/v_1.11.3' 2020-11-01 17:00:27 +01:00
ostertun
69ef983c07 Merge branch 'release/v_1.11.3' into develop 2020-11-01 17:00:26 +01:00
ostertun
32473901d6 Release v_1.11.3 2020-11-01 17:00:04 +01:00
ostertun
84320f3a67 Planning-edit: Show known sailors 2020-11-01 16:58:47 +01:00
ostertun
cd30ba1ce6 Menu close on back improved 2020-11-01 16:45:00 +01:00
ostertun
1fb619d4ec Planning: keep year 2020-11-01 16:38:06 +01:00
ostertun
0fd09c22a2 Link to entryList incl count 2020-10-29 14:52:36 +01:00
ostertun
12ed412226 Merge branch 'hotfix/error_report_button' 2020-10-22 14:54:24 +02:00
ostertun
7fd1c1c6e7 Merge branch 'hotfix/error_report_button' into develop 2020-10-22 14:54:23 +02:00
ostertun
4e85d3a993 gitflow-hotfix-stash: error_report_button 2020-10-22 14:54:18 +02:00
ostertun
5c22604896 Merge branch 'release/v_1.11.2' 2020-10-22 11:38:44 +02:00
ostertun
a2fe4c2637 Merge branch 'release/v_1.11.2' into develop 2020-10-22 11:38:43 +02:00
ostertun
4a65b48520 Release v_1.11.2 2020-10-22 11:38:28 +02:00
ostertun
4eb2970671 Special fields 2020-10-22 11:37:19 +02:00
ostertun
0298cefc8b Merge branch 'hotfix/error_reporting' 2020-10-22 01:17:11 +02:00
ostertun
e17f99d005 Merge branch 'hotfix/error_reporting' into develop 2020-10-22 01:17:11 +02:00
ostertun
15d7060354 gitflow-hotfix-stash: error_reporting 2020-10-22 01:10:37 +02:00
ostertun
d38de287dd Merge branch 'hotfix/ios_problems' 2020-10-21 16:27:02 +02:00
ostertun
1cb6de2402 Merge branch 'hotfix/ios_problems' into develop 2020-10-21 16:27:01 +02:00
ostertun
da2beac8d3 hotfix 2020-10-21 16:26:40 +02:00
ostertun
92a11bcfa5 gitflow-hotfix-stash: ios_problems 2020-10-21 16:26:02 +02:00
ostertun
2ddeac4ba4 sW: melde-erinnerungen only for regattas not registered 2020-10-16 13:45:02 +02:00
ostertun
fa4770e12a Merge branch 'hotfix/remote_logout' 2020-10-16 13:01:24 +02:00
ostertun
a845137873 Merge branch 'hotfix/remote_logout' into develop 2020-10-16 13:01:24 +02:00
ostertun
a6f2568753 gitflow-hotfix-stash: remote_logout 2020-10-16 13:01:06 +02:00
ostertun
6d0fdea0e8 Merge branch 'hotfix/add_planning_list_button' 2020-10-16 10:19:20 +02:00
ostertun
8bc0d9b15e Merge branch 'hotfix/add_planning_list_button' into develop 2020-10-16 10:19:20 +02:00
ostertun
1252c02d7c gitflow-hotfix-stash: add_planning_list_button 2020-10-16 10:19:05 +02:00
ostertun
f617fa7923 Merge branch 'release/v_1.11' 2020-10-15 19:41:34 +02:00
ostertun
3ff17a63e0 Merge branch 'release/v_1.11' into develop 2020-10-15 19:41:33 +02:00
ostertun
c66dc96598 Release v_1.11 2020-10-15 19:40:57 +02:00
ostertun
f5d059202e RA-#9 Signup 2020-10-15 19:39:47 +02:00
ostertun
5962e1cc90 RA-#29 Follow Sailors 2020-10-15 19:02:25 +02:00
ostertun
9f3019b4c5 Notification info banner 2020-10-15 15:19:04 +02:00
ostertun
326ba4a6bd Merge branch 'hotfix/fix_inputs_forcesync' 2020-10-15 14:04:06 +02:00
ostertun
4228ec739d Merge branch 'hotfix/fix_inputs_forcesync' into develop 2020-10-15 14:04:06 +02:00
ostertun
a38c48dab4 hotfix v_1.10.5h1 2020-10-15 14:03:55 +02:00
ostertun
da48e79a36 gitflow-hotfix-stash: fix_inputs_forcesync 2020-10-15 14:03:17 +02:00
ostertun
de5abcdfaf Merge branch 'release/v_1.10.5' 2020-10-14 14:18:03 +02:00
ostertun
6b1e35cc14 Merge branch 'release/v_1.10.5' into develop 2020-10-14 14:18:03 +02:00
ostertun
89e24f69b7 Release v_1.10.5 2020-10-14 14:17:40 +02:00
ostertun
554b810e85 Merge branch 'feature/RA-29-runtime-analysis' into develop 2020-10-14 14:16:39 +02:00
ostertun
fbd1eaaae8 Fix: hide loader on first visit 2020-10-14 13:44:34 +02:00
ostertun
ce42f87227 Cache if regatta has results 2020-10-14 13:37:47 +02:00
ostertun
e66f95ff50 Merge branch 'release/v_1.10.4' 2020-10-14 12:59:58 +02:00
ostertun
fcd791ed65 Merge branch 'release/v_1.10.4' into develop 2020-10-14 12:59:57 +02:00
ostertun
439679bbbe Release v_1.10.4 2020-10-14 12:59:35 +02:00
ostertun
9a8d6892f2 Merge branch 'feature/RA-29-runtime-analysis' into develop 2020-10-14 12:57:35 +02:00
ostertun
3b71f3d707 Better logging 2020-10-14 12:35:15 +02:00
ostertun
94c6a42106 RA-#29 remove unused code from scripts 2020-10-14 12:07:40 +02:00
ostertun
0c9eb9c013 RA-#27 back button on menu opened 2020-10-14 11:52:22 +02:00
ostertun
2034e8b659 RA-#24: dont show info after force resync 2020-10-14 11:24:36 +02:00
ostertun
e57bf4a426 RA-#25 Show loader after sync 2020-10-14 11:19:32 +02:00
ostertun
3c8289d11c index: Sort last regattas desc. 2020-10-14 11:08:27 +02:00
ostertun
63de725ebd Disable dark mode 2020-10-14 11:05:39 +02:00
ostertun
69efb93646 Merge branch 'hotfix/site_build_logging' 2020-10-11 17:01:23 +02:00
ostertun
6f302d6527 Merge branch 'hotfix/site_build_logging' into develop 2020-10-11 17:01:23 +02:00
ostertun
bfc2f84f0f Fix 2020-10-11 17:01:19 +02:00
ostertun
0660b2b6b3 Merge branch 'hotfix/site_build_logging' into develop 2020-10-11 16:57:55 +02:00
ostertun
3ee722f6c2 Merge branch 'hotfix/site_build_logging' 2020-10-11 16:57:17 +02:00
ostertun
0ce58aeacc Merge branch 'hotfix/site_build_logging' into develop 2020-10-11 16:57:17 +02:00
ostertun
28ba380cca gitflow-hotfix-stash: site_build_logging 2020-10-11 16:57:09 +02:00
ostertun
357449c1c6 Merge branch 'hotfix/update_subscription' 2020-10-09 12:59:35 +02:00
ostertun
e84eaa2562 Merge branch 'hotfix/update_subscription' into develop 2020-10-09 12:59:35 +02:00
ostertun
de70522850 gitflow-hotfix-stash: update_subscription 2020-10-09 12:59:20 +02:00
ostertun
775a7bd27a Merge branch 'hotfix/hide_preloader_console_button' into develop 2020-10-08 12:56:41 +02:00
ostertun
4106a177f8 Merge branch 'release/v_1.10.3' into develop 2020-10-08 12:48:11 +02:00
29 changed files with 1169 additions and 1410 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
const DB_VERSION = 6; const DB_VERSION = 7;
const USER_ID = localStorage.getItem('auth_user'); const USER_ID = localStorage.getItem('auth_user');
const USER_NAME = localStorage.getItem('auth_username'); const USER_NAME = localStorage.getItem('auth_username');
@@ -20,11 +20,11 @@ var getJSON = function(url, callback) {
callback(xhr.status, xhr.response); callback(xhr.status, xhr.response);
}; };
xhr.ontimeout = function () { xhr.ontimeout = function () {
log("getJSON: timeout"); log("[db] getJSON: timeout");
callback(0, null); callback(0, null);
} }
xhr.onerror = function () { xhr.onerror = function () {
log("getJSON: error"); log("[db] getJSON: error");
callback(0, null); callback(0, null);
} }
if (USER_ID != null) { if (USER_ID != null) {
@@ -76,7 +76,7 @@ function dbGetData(table, id = null) {
if (code == 200) { if (code == 200) {
resolve(data.data); resolve(data.data);
} else { } else {
log("Something went wrong (HTTP " + code + ")"); log("[db] Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000); fail(strings.error_network, 5000);
resolve([]); resolve([]);
} }
@@ -86,7 +86,7 @@ function dbGetData(table, id = null) {
if (code == 200) { if (code == 200) {
resolve(data.data); resolve(data.data);
} else { } else {
log("Something went wrong (HTTP " + code + ")"); log("[db] Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000); fail(strings.error_network, 5000);
resolve(null); resolve(null);
} }
@@ -108,7 +108,7 @@ function dbGetDataIndex(table, indexName, value) {
if (code == 200) { if (code == 200) {
resolve(data.data); resolve(data.data);
} else { } else {
log("Something went wrong (HTTP " + code + ")"); log("[db] Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000); fail(strings.error_network, 5000);
resolve([]); resolve([]);
} }
@@ -191,6 +191,8 @@ function dbGetResultCalculated(regatta) {
case 'DNF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not finish case 'DNF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not finish
case 'RET': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired (Aufgegeben) case 'RET': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired (Aufgegeben)
case 'RAF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired after finish case 'RAF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired after finish
// Kursfehler
case 'NSC': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Not sailed course
// Disqualifizierun // Disqualifizierun
case 'DSQ': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Disqualified case 'DSQ': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Disqualified
case 'DNE': results[id]['values'][i] = gemeldet + 1; copy[i] = -1; break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden) case 'DNE': results[id]['values'][i] = gemeldet + 1; copy[i] = -1; break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden)
@@ -351,7 +353,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
if (sailors[i].german == '0') { if (sailors[i].german == '0') {
sailors.splice(i, 1); sailors.splice(i, 1);
} else if (jugend) { } else if (jugend) {
if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - YOUTH_AGE))) || if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - (await dbGetClassProp('youth-age'))))) ||
((sailors[i].year == null) && (jugstrict))) { ((sailors[i].year == null) && (jugstrict))) {
sailors.splice(i, 1); sailors.splice(i, 1);
} }
@@ -397,6 +399,33 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
}); });
} }
function dbGetCurrentYear() {
return new Promise(async function (resolve) {
var date = new Date();
var year = date.getFullYear();
if (date.getMonth() == 11) {
year ++; // In DECEMBER show next year
} else {
// if there are no more regattas until end of the year, show next year
var regattas = dbGetRegattasRange(parseDate(date.getDate() + '.' + (date.getMonth() + 1) + '.' + year), parseDate('31.12.' + year));
if (regattas.length == 0) {
year ++;
}
}
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
if (a['year'] < b['year']) return 1;
return 0;
});
for (id in years) {
if (years[id].year < year) year = years[id].year;
if (years[id].year == year) break;
}
resolve(year);
});
}
function dbSettingsGet(key) { function dbSettingsGet(key) {
return new Promise(function(resolve) { return new Promise(function(resolve) {
if (canUseLocalDB) { if (canUseLocalDB) {
@@ -417,6 +446,27 @@ function dbSettingsSet(key, value) {
} }
} }
function dbGetClassProp(key) {
return new Promise(function(resolve) {
if (canUseLocalDB) {
var request = db.transaction('class').objectStore('class').get(key);
request.onsuccess = function (event) {
resolve(typeof request.result != 'undefined' ? request.result.value : null);
}
} else {
getJSON(QUERY_URL + 'get_class_prop?key=' + key, function (code, data) {
if (code == 200) {
resolve(data.value);
} else {
log("[db] Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000);
resolve(null);
}
});
}
});
}
async function updateSyncStatus() { async function updateSyncStatus() {
var lastSync = await dbGetData('update_times', 'last_sync'); var lastSync = await dbGetData('update_times', 'last_sync');
lastSync = new Date(lastSync.time * 1000); lastSync = new Date(lastSync.time * 1000);
@@ -445,6 +495,7 @@ async function updateSyncStatus() {
} }
async function runPageScript() { async function runPageScript() {
log('[db] running page script...')
if (canUseLocalDB) { if (canUseLocalDB) {
var osUpdateTimes = db.transaction('update_times').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
osUpdateTimes.get('loggedin').onsuccess = function (event) { osUpdateTimes.get('loggedin').onsuccess = function (event) {
@@ -458,8 +509,16 @@ async function runPageScript() {
if (isLoggedIn()) { if (isLoggedIn()) {
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID); var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
plannings = plannings.map(function (e) { return e.regatta; }); plannings_all = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS, plannings); dbSettingsSet('myregattas_' + BOATCLASS, plannings_all);
for (var i = plannings.length - 1; i >= 0; i --) {
if (plannings[i].gemeldet == '1') plannings.splice(i, 1);
}
plannings_meldung_off = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS + '_meldung_off', plannings_meldung_off);
} else {
dbSettingsSet('myregattas_' + BOATCLASS, null);
dbSettingsSet('myregattas_' + BOATCLASS + '_meldung_off', null);
} }
} }
if (typeof updateSyncStatusTimer == 'undefined') { if (typeof updateSyncStatusTimer == 'undefined') {
@@ -473,8 +532,10 @@ async function runPageScript() {
} }
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {
log('[db] loading site script');
siteScript(); siteScript();
} else { } else {
log('[db] no site script');
hideLoader(); hideLoader();
} }
} }
@@ -492,9 +553,9 @@ function sync() {
localTimes[entry['table']] = entry['time']; localTimes[entry['table']] = entry['time'];
}); });
syncInProgress = 11; syncInProgress = 12;
var syncOkay = true; var syncOkay = true;
log("Sync Start"); log("[db] Sync Start");
$('#i-sync').addClass('fa-spin'); $('#i-sync').addClass('fa-spin');
var interval = window.setInterval(function () { var interval = window.setInterval(function () {
@@ -504,7 +565,7 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'last_sync', time: now }); osUpdateTimes.put({ table: 'last_sync', time: now });
} }
log("Sync Stop"); log("[db] Sync Stop");
setTimeout(function(){ setTimeout(function(){
$('#i-sync').removeClass('fa-spin'); $('#i-sync').removeClass('fa-spin');
}, 500); }, 500);
@@ -513,6 +574,7 @@ function sync() {
onAfterSync(); onAfterSync();
} }
removeSyncInfoToPreloader(); removeSyncInfoToPreloader();
showLoader();
runPageScript(); runPageScript();
resolve(); resolve();
} }
@@ -521,6 +583,24 @@ function sync() {
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) { getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
if (code == 200) { if (code == 200) {
// CLASS
getJSON(QUERY_URL + 'get_class', function (code, data) {
if (code == 200) {
var os = db.transaction('class', 'readwrite').objectStore('class');
log(data);
for (key in data) {
os.put({ key: key, value: data[key] });
}
syncInProgress --;
log('[db] class synced, remaining:', syncInProgress);
} else {
log("[db] class: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('[db] class failed, remaining:', syncInProgress);
}
});
// CLUBS // CLUBS
if (localTimes['clubs'] < serverTimes['clubs']) { if (localTimes['clubs'] < serverTimes['clubs']) {
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) { getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
@@ -540,14 +620,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] }); osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
syncInProgress --; syncInProgress --;
log('clubs synced, remaining:', syncInProgress); log('[db] clubs synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("clubs: Something went wrong (HTTP " + code + ")"); log("[db] clubs: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('clubs failed, remaining:', syncInProgress); log('[db] clubs failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -573,14 +653,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] }); osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
syncInProgress --; syncInProgress --;
log('boats synced, remaining:', syncInProgress); log('[db] boats synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("boats: Something went wrong (HTTP " + code + ")"); log("[db] boats: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('boats failed, remaining:', syncInProgress); log('[db] boats failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -606,14 +686,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] }); osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
syncInProgress --; syncInProgress --;
log('sailors synced, remaining:', syncInProgress); log('[db] sailors synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("sailors: Something went wrong (HTTP " + code + ")"); log("[db] sailors: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('sailors failed, remaining:', syncInProgress); log('[db] sailors failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -655,14 +735,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] }); osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
syncInProgress --; syncInProgress --;
log('regattas synced, remaining:', syncInProgress); log('[db] regattas synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("regattas: Something went wrong (HTTP " + code + ")"); log("[db] regattas: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('regattas failed, remaining:', syncInProgress); log('[db] regattas failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -688,14 +768,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'results', time: serverTimes['results'] }); osUpdateTimes.put({ table: 'results', time: serverTimes['results'] });
syncInProgress --; syncInProgress --;
log('results synced, remaining:', syncInProgress); log('[db] results synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("results: Something went wrong (HTTP " + code + ")"); log("[db] results: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('results failed, remaining:', syncInProgress); log('[db] results failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -721,14 +801,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] }); osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] });
syncInProgress --; syncInProgress --;
log('plannings synced, remaining:', syncInProgress); log('[db] plannings synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("plannings: Something went wrong (HTTP " + code + ")"); log("[db] plannings: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('plannings failed, remaining:', syncInProgress); log('[db] plannings failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -755,14 +835,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] }); osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
syncInProgress --; syncInProgress --;
log('trim_boats synced, remaining:', syncInProgress); log('[db] trim_boats synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("trim_boats: Something went wrong (HTTP " + code + ")"); log("[db] trim_boats: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('trim_boats failed, remaining:', syncInProgress); log('[db] trim_boats failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -788,14 +868,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] }); osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
syncInProgress --; syncInProgress --;
log('trim_users synced, remaining:', syncInProgress); log('[db] trim_users synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("trim_users: Something went wrong (HTTP " + code + ")"); log("[db] trim_users: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('trim_users failed, remaining:', syncInProgress); log('[db] trim_users failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -821,14 +901,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] }); osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
syncInProgress --; syncInProgress --;
log('trim_trims synced, remaining:', syncInProgress); log('[db] trim_trims synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("trim_trims: Something went wrong (HTTP " + code + ")"); log("[db] trim_trims: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('trim_trims failed, remaining:', syncInProgress); log('[db] trim_trims failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -858,14 +938,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'news', time: serverTimes['news'] }); osUpdateTimes.put({ table: 'news', time: serverTimes['news'] });
syncInProgress --; syncInProgress --;
log('news synced, remaining:', syncInProgress); log('[db] news synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("news: Something went wrong (HTTP " + code + ")"); log("[db] news: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('news failed, remaining:', syncInProgress); log('[db] news failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -891,14 +971,14 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'users', time: serverTimes['users'] }); osUpdateTimes.put({ table: 'users', time: serverTimes['users'] });
syncInProgress --; syncInProgress --;
log('users synced, remaining:', syncInProgress); log('[db] users synced, remaining:', syncInProgress);
} }
}; };
} else { } else {
log("users: Something went wrong (HTTP " + code + ")"); log("[db] users: Something went wrong (HTTP " + code + ")");
syncOkay = false; syncOkay = false;
syncInProgress --; syncInProgress --;
log('users failed, remaining:', syncInProgress); log('[db] users failed, remaining:', syncInProgress);
} }
}); });
} else { } else {
@@ -906,7 +986,12 @@ function sync() {
} }
} else { } 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; syncOkay = false;
syncInProgress = 0; syncInProgress = 0;
} }
@@ -928,30 +1013,31 @@ function checkSync() {
} }
function initDatabase() { function initDatabase() {
log('[db] Initializing DB...');
if (window.indexedDB) { if (window.indexedDB) {
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION); var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
request.onerror = function (event) { request.onerror = function (event) {
log("Cannot open DB: " + event.target); log("[db] Cannot open DB: " + event.target);
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded(); if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
runPageScript(); runPageScript();
}; };
request.onsuccess = function (event) { request.onsuccess = function (event) {
log("Database loaded"); log("[db] Database loaded");
db = event.target.result; db = event.target.result;
db.onversionchange = function (event) { db.onversionchange = function (event) {
if (syncTimer != null) window.clearInterval(syncTimer); if (syncTimer != null) window.clearInterval(syncTimer);
if (updateSyncStatusTimer != null) window.clearInterval(updateSyncStatusTimer); if (updateSyncStatusTimer != null) window.clearInterval(updateSyncStatusTimer);
// TODO document.getElementById('syncstatus').innerHTML = ''; $('#syncstatus').html('');
canUseLocalDB = false; canUseLocalDB = false;
db.close(); db.close();
location.reload; location.reload;
} }
db.onerror = function (event) { db.onerror = function (event) {
log("DB Error: " + event.target); log("[db] DB Error: " + event.target);
}; };
canUseLocalDB = true; canUseLocalDB = true;
@@ -960,11 +1046,12 @@ function initDatabase() {
db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) { db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) {
var lastSync = event.target.result.time; var lastSync = event.target.result.time;
if (lastSync > 0) { if (lastSync > 1) {
runPageScript(); runPageScript();
} else { } else {
addSyncInfoToPreloader(); if (lastSync < 1) addSyncInfoToPreloader();
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() }); db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
loaderCount --;
} }
}; };
@@ -982,10 +1069,10 @@ function initDatabase() {
var oldVersion = event.oldVersion; var oldVersion = event.oldVersion;
var newVersion = event.newVersion; 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)) { if ((oldVersion < 1) && (newVersion >= 1)) {
log('to version 1'); log('[db] to version 1');
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' }); var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
var osBoats = db.createObjectStore('boats', { keyPath: 'id' }); var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' }); var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
@@ -1014,7 +1101,7 @@ function initDatabase() {
} }
if ((oldVersion < 2) && (newVersion >= 2)) { if ((oldVersion < 2) && (newVersion >= 2)) {
log('to version 2'); log('[db] to version 2');
var osUsers = db.createObjectStore('users', { keyPath: 'id' }); var osUsers = db.createObjectStore('users', { keyPath: 'id' });
osUsers.createIndex('username', 'username', { unique: true }); osUsers.createIndex('username', 'username', { unique: true });
var osUpdateTimes = upgradeTransaction.objectStore('update_times'); var osUpdateTimes = upgradeTransaction.objectStore('update_times');
@@ -1022,32 +1109,40 @@ function initDatabase() {
} }
if ((oldVersion < 3) && (newVersion >= 3)) { if ((oldVersion < 3) && (newVersion >= 3)) {
log('to version 3'); log('[db] to version 3');
var osYears = db.createObjectStore('years', { keyPath: 'year' }); var osYears = db.createObjectStore('years', { keyPath: 'year' });
var osUpdateTimes = upgradeTransaction.objectStore('update_times'); var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.put({ table: 'regattas', time: 0 }); osUpdateTimes.put({ table: 'regattas', time: 0 });
} }
if ((oldVersion < 4) && (newVersion >= 4)) { if ((oldVersion < 4) && (newVersion >= 4)) {
log('to version 4'); log('[db] to version 4');
var osUpdateTimes = upgradeTransaction.objectStore('update_times'); var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() }); osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
} }
if ((oldVersion < 5) && (newVersion >= 5)) { if ((oldVersion < 5) && (newVersion >= 5)) {
log('to version 5'); log('[db] to version 5');
var osPushes = db.createObjectStore('settings', { keyPath: 'key' }); var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
} }
if ((oldVersion < 6) && (newVersion >= 6)) { if ((oldVersion < 6) && (newVersion >= 6)) {
log('to version 6'); log('[db] to version 6');
var osNews = db.createObjectStore('news', { keyPath: 'id' }); var osNews = db.createObjectStore('news', { keyPath: 'id' });
var osUpdateTimes = upgradeTransaction.objectStore('update_times'); var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.add({ table: 'news', time: 0 }); osUpdateTimes.add({ table: 'news', time: 0 });
} }
var osUpdateTimes = upgradeTransaction.objectStore('update_times'); if ((oldVersion < 7) && (newVersion >= 7)) {
osUpdateTimes.put({ table: 'last_sync', time: 0 }); log('[db] to version 7');
var osClass = db.createObjectStore('class', { keyPath: 'key' });
}
// Force resync after db update
if (oldVersion >= 1) {
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.put({ table: 'last_sync', time: 1 });
}
} }
} else { } else {
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded(); if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
@@ -1060,7 +1155,7 @@ function resetDb() {
if (canUseLocalDB) { if (canUseLocalDB) {
showLoader(); showLoader();
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times'); 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: 'clubs', time: 0 });
osUpdateTimes.put({ table: 'boats', time: 0 }); osUpdateTimes.put({ table: 'boats', time: 0 });
osUpdateTimes.put({ table: 'sailors', time: 0 }); osUpdateTimes.put({ table: 'sailors', time: 0 });
@@ -1072,7 +1167,7 @@ function resetDb() {
osUpdateTimes.put({ table: 'trim_trims', time: 0 }); osUpdateTimes.put({ table: 'trim_trims', time: 0 });
osUpdateTimes.put({ table: 'news', time: 0 }); osUpdateTimes.put({ table: 'news', time: 0 });
osUpdateTimes.put({ table: 'users', time: 0 }); osUpdateTimes.put({ table: 'users', time: 0 });
log('DB update times reset'); log('[db] DB update times reset');
hideLoader(); hideLoader();
} }
} }

View File

@@ -38,6 +38,16 @@ function parseDate(string) {
return date; 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() { function getToday() {
var date = new Date(); var date = new Date();
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));

View File

@@ -1155,6 +1155,8 @@ var mobileConsole = (function () {
if (!msgContainer.innerHTML) { return; } if (!msgContainer.innerHTML) { return; }
leftContainer.appendChild(msgContainer); leftContainer.appendChild(msgContainer);
var errorReportEntry = { message: arguments[1].newMessage };
if (detailTable || stackTable) { if (detailTable || stackTable) {
setCSS(msgContainer, {cursor : 'pointer'}); setCSS(msgContainer, {cursor : 'pointer'});
leftContainer.appendChild(detailTable || stackTable); leftContainer.appendChild(detailTable || stackTable);
@@ -1164,8 +1166,18 @@ var mobileConsole = (function () {
//populate right side //populate right side
if (stackTrace && typeof stackTrace[stackTrace.length - 1] !== 'undefined') { if (stackTrace && typeof stackTrace[stackTrace.length - 1] !== 'undefined') {
rightContainer.appendChild(setCSS(getLink(stackTrace[0].url, stackTrace[0].linkText), {color: '#808080'})); rightContainer.appendChild(setCSS(getLink(stackTrace[0].url, stackTrace[0].linkText), {color: '#808080'}));
errorReportEntry.stack = { caller: stackTrace[0].caller, file: stackTrace[0].url, line: stackTrace[0].line, col: stackTrace[0].col };
if ((typeof LINK_PRE !== 'undefined') && (errorReportEntry.stack.file.startsWith(LINK_PRE))) {
errorReportEntry.stack.file = errorReportEntry.stack.file.substr(LINK_PRE.length);
}
var pos = errorReportEntry.stack.file.indexOf('?');
if (pos >= 0) {
errorReportEntry.stack.file = errorReportEntry.stack.file.substr(0, pos);
}
} }
if (typeof onConsoleOutput === 'function') onConsoleOutput(errorReportEntry);
//add to line //add to line
lineContainer.appendChild(leftContainer); lineContainer.appendChild(leftContainer);
lineContainer.appendChild(rightContainer); lineContainer.appendChild(rightContainer);

View File

@@ -20,8 +20,6 @@ $(document).ready(function(){
'use strict' 'use strict'
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop 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); $('[data-pwa-version]').data('pwa-version', pwaVersion);
@@ -35,7 +33,7 @@ $(document).ready(function(){
//Enabling dismiss button //Enabling dismiss button
setTimeout(function(){ setTimeout(function(){
$('.pwa-dismiss').on('click',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); createCookie('Sticky_pwa_rejected_install', true, 1);
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active'); $('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. //Firing PWA prompts for specific versions and when not on home screen.
if (isMobile.Android()) { if (isMobile.Android()) {
log('Android Detected'); log('[pwa] Android Detected');
function showInstallPromotion(){ function showInstallPromotion(){
if($('#menu-install-pwa-android, .add-to-home').length){ 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')) { if (!readCookie('Sticky_pwa_rejected_install')) {
setTimeout(function(){ setTimeout(function(){
$('.add-to-home').addClass('add-to-home-visible add-to-home-android'); $('.add-to-home').addClass('add-to-home-visible add-to-home-android');
@@ -80,9 +78,9 @@ $(document).ready(function(){
deferredPrompt.userChoice deferredPrompt.userChoice
.then((choiceResult) => { .then((choiceResult) => {
if (choiceResult.outcome === 'accepted') { if (choiceResult.outcome === 'accepted') {
log('User accepted the A2HS prompt'); log('[pwa] User accepted the A2HS prompt');
} else { } else {
log('User dismissed the A2HS prompt'); log('[pwa] User dismissed the A2HS prompt');
} }
deferredPrompt = null; deferredPrompt = null;
}); });
@@ -94,114 +92,32 @@ $(document).ready(function(){
if (isMobile.iOS()) { if (isMobile.iOS()) {
if(!isInWebAppiOS){ if(!isInWebAppiOS){
log('iOS Detected'); log('[pwa] iOS Detected');
if($('#menu-install-pwa-ios, .add-to-home').length){ if($('#menu-install-pwa-ios, .add-to-home').length){
if (!readCookie('Sticky_pwa_rejected_install')) { if (!readCookie('Sticky_pwa_rejected_install')) {
function triggerPwaInstallIos() { setTimeout(function(){
log('Triggering PWA / Add to Home Screen Menu for iOS'); function triggerPwaInstallIos() {
setTimeout(function(){ log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios'); $('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active'); $('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
},3000); }
} var welcomActive = $('#menu-welcome').hasClass('menu-active');
var welcomActive = $('#menu-welcome').hasClass('menu-active'); if (welcomActive) {
if (welcomActive) { $('#menu-welcome-a-okay').click(triggerPwaInstallIos);
$('#menu-welcome-a-okay').click(triggerPwaInstallIos); } else {
} else { triggerPwaInstallIos();
triggerPwaInstallIos(); }
} },3000);
}; };
} }
} }
} }
//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 //Reload To Clear Button
$('body').on('click', '.page-update, .reloadme', function() { $('body').on('click', '.page-update, .reloadme', function() {
location.reload(); 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 //Adding Offline Alerts
var offlineAlerts = $('.offline-message'); var offlineAlerts = $('.offline-message');
@@ -224,47 +140,19 @@ $(document).ready(function(){
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000); 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 //Check if Online / Offline
function updateOnlineStatus(event) { function updateOnlineStatus(event) {
var condition = navigator.onLine ? "online" : "offline"; var condition = navigator.onLine ? "online" : "offline";
isOnline(); isOnline();
log( 'Connection: Online'); log('[pwa] Connection: Online');
$("a").off( "click", returnFalse );
} }
function updateOfflineStatus(event) { function updateOfflineStatus(event) {
isOffline(); isOffline();
$("a").on( "click", returnFalse ); log('[pwa] Connection: Offline');
log( 'Connection: Offline');
} }
window.addEventListener('online', updateOnlineStatus); window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOfflineStatus); 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);
});
});
}
}); });

View File

@@ -3,16 +3,40 @@
header('Content-Type: text/javascript'); header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/config.php'); require_once(__DIR__ . '/../../server/config.php');
require_once(__DIR__ . '/../../server/version.php');
?> ?>
const QUERY_URL = '<?php echo QUERY_URL; ?>'; const QUERY_URL = '<?php echo QUERY_URL; ?>';
const BOATCLASS = '<?php echo BOATCLASS; ?>'; const BOATCLASS = '<?php echo BOATCLASS; ?>';
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/'; const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>'; const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>';
var consoleOutput = [];
function onConsoleOutput(entry) {
consoleOutput.push(entry);
}
window.onerror = function(message, source, lineno, colno, errorError) {
if (source.startsWith(LINK_PRE)) {
source = source.substr(LINK_PRE.length);
}
var pos = source.indexOf('?');
if (pos >= 0) {
source = source.substr(0, pos);
}
consoleOutput.push({
message: message,
stack: {
caller: '',
file: source,
line: lineno,
col: colno
}
});
}
function log() { function log() {
var now = new Date(); var now = new Date();
var hour = now.getHours().toString(); var hour = now.getHours().toString();
@@ -131,7 +155,53 @@ function findGetParameter(parameterName) {
return result; return result;
} }
var signup = function() {
log('[app] Signup');
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; }
log('[app] Signup: All fields okay');
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) {
log('[app] Signup: error:', xhr.status, status);
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) {
log('[app] Signup successful, logging in');
$('#input-login-username').val(username);
$('#input-login-password').val(password);
login();
}
});
}
var login = function() { var login = function() {
log('[app] Login');
showLoader(); showLoader();
var username = $('#input-login-username').val(); var username = $('#input-login-username').val();
var password = $('#input-login-password').val(); var password = $('#input-login-password').val();
@@ -146,6 +216,7 @@ var login = function() {
device: navigator.userAgent device: navigator.userAgent
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
log('[app] Login: error:', xhr.status, status);
if (xhr.status == 401) { if (xhr.status == 401) {
toastError('Benutzername oder Passwort falsch'); toastError('Benutzername oder Passwort falsch');
$('#input-login-username').val(username).trigger('focusin').trigger('focusout'); $('#input-login-username').val(username).trigger('focusin').trigger('focusout');
@@ -153,13 +224,14 @@ var login = function() {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden'); toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
$('#menu-login').hideMenu(); $('#menu-login').hideMenu();
} else { } else {
log('Login: unbekannter Fehler', status, error); log('[app] Login: unbekannter Fehler', status, error);
log(xhr); log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000); toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
} }
hideLoader(); hideLoader();
}, },
success: function (data, status, xhr) { success: function (data, status, xhr) {
log('[app] Login successful');
localStorage.setItem('auth_id', data.id); localStorage.setItem('auth_id', data.id);
localStorage.setItem('auth_hash', data.auth); localStorage.setItem('auth_hash', data.auth);
localStorage.setItem('auth_user', data.user); localStorage.setItem('auth_user', data.user);
@@ -180,13 +252,14 @@ var logoutClearStorage = function() {
} }
var logout = function() { var logout = function() {
log('[app] Logout');
showLoader(); showLoader();
var auth = { var auth = {
id: localStorage.getItem('auth_id'), id: localStorage.getItem('auth_id'),
hash: localStorage.getItem('auth_hash') hash: localStorage.getItem('auth_hash')
} }
if ((auth.id === null) || (auth.hash === null)) { if ((auth.id === null) || (auth.hash === null)) {
log('Not logged in'); log('[app] Not logged in');
logoutClearStorage(); logoutClearStorage();
return; return;
} }
@@ -197,57 +270,62 @@ var logout = function() {
auth: auth auth: auth
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
log('[app] Logout: error:', xhr.status, status);
if (xhr.status == 401) { if (xhr.status == 401) {
log('Not logged in'); log('[app] Not logged in');
logoutClearStorage(); logoutClearStorage();
} else if (xhr.status == 0) { } else if (xhr.status == 0) {
log('Could not delete auth from server'); log('[app] Could not delete auth from server');
logoutClearStorage(); logoutClearStorage();
} else { } else {
log('Logout: unbekannter Fehler', status, error); log('[app] Logout: unbekannter Fehler', status, error);
log(xhr); log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000); toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
hideLoader(); hideLoader();
} }
}, },
success: function (data, status, xhr) { success: function (data, status, xhr) {
log('[app] Logout successful');
logoutClearStorage(); logoutClearStorage();
} }
}); });
} }
function deleteDb() { function deleteDb() {
log('[app] Deleting DB');
$('#menu-developer').hideMenu(); $('#menu-developer').hideMenu();
if (canUseLocalDB) { if (canUseLocalDB) {
showLoader(); showLoader();
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS); var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
request.onerror = function (event) { 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); toastError('Beim Löschen der Datenbank ist ein Fehler aufgetreten.<br>Bitte melde diesen Fehler. (Dev-Menu => Problem melden)', 5000);
hideLoader(); hideLoader();
} }
request.onsuccess = function (event) { 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); toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
hideLoader(); hideLoader();
setTimeout(function(){ location.reload(); }, 3000); setTimeout(function(){ location.reload(); }, 3000);
} }
} else { } else {
log('[app] DB not supported');
toastWarn('Dein Gerät unterstützt kein lokales Speichern der Daten. Alle Daten werden direkt vom Server gezogen.<br>Entsprechend kannst Du die Datenbank auch nicht zurücksetzen.', 10000); toastWarn('Dein Gerät unterstützt kein lokales Speichern der Daten. Alle Daten werden direkt vom Server gezogen.<br>Entsprechend kannst Du die Datenbank auch nicht zurücksetzen.', 10000);
} }
} }
function deleteCache() { function deleteCache() {
log('[app] Deleting cache');
$('#menu-developer').hideMenu(); $('#menu-developer').hideMenu();
navigator.serviceWorker.getRegistrations().then(function (registrations) { navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) { for (let registration of registrations) {
log('Unregister sW:', registration); log('[app] Unregister sW:', registration);
registration.unregister(); registration.unregister();
} }
}); });
caches.keys().then((keyList) => { caches.keys().then((keyList) => {
return Promise.all(keyList.map((key) => { return Promise.all(keyList.map((key) => {
log('Cache deleted:', key); log('[app] Cache deleted:', key);
return caches.delete(key); return caches.delete(key);
})); }));
}); });
@@ -273,38 +351,59 @@ function urlB64ToUint8Array(base64String) {
} }
function pushesSubscribe() { function pushesSubscribe() {
log('Subscribing'); log('[app] Subscribing');
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY); const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
log('[app] Subscription app server key:', applicationServerKey);
swRegistration.pushManager.subscribe({ swRegistration.pushManager.subscribe({
userVisibleOnly: true, userVisibleOnly: true,
applicationServerKey: applicationServerKey applicationServerKey: applicationServerKey
}) })
.then(function(subscription) { .then(async function(subscription) {
pushesUpdateServerSubscription(subscription, true); log('[app] Subscription:', subscription);
updatePushSwitches(); if (await pushesUpdateServerSubscription(subscription, true)) {
updatePushBadge(); log('[app] Subscription: Sent to server, updating UI');
dbSettingsSet('notify_endpoint_' + BOATCLASS, subscription.endpoint);
updatePushSwitches();
updatePushBadge();
} else {
$('#menu-pushes').hideMenu();
log('[app] Failed to subscribe the user due to connection error');
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
pushesUnSubscribe(true);
}
hideLoader();
}) })
.catch(function(err) { .catch(function(err) {
log('Failed to subscribe the user: ', err); $('#menu-pushes').hideMenu();
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); toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
pushesUnSubscribe(true); pushesUnSubscribe(true);
}); });
} }
function pushesUnSubscribe(silent = false) { function pushesUnSubscribe(silent = false) {
log('Unsubscribing'); log('[app] Unsubscribing');
swRegistration.pushManager.getSubscription() swRegistration.pushManager.getSubscription()
.then(function(subscription) { .then(async function(subscription) {
log('[app] Subscription:', subscription);
if (subscription) { if (subscription) {
pushesUpdateServerSubscription(subscription, false); if (await pushesUpdateServerSubscription(subscription, false)) {
log('[app] Subscription: Removed from server');
} else {
log('[app] Failed to unsubscribe the user due to connection error');
}
log('[app] Removing subscription');
subscription.unsubscribe(); subscription.unsubscribe();
log('[app] Subscription: Updating UI');
$('#menu-pushes').hideMenu(); $('#menu-pushes').hideMenu();
dbSettingsSet('notify_endpoint_' + BOATCLASS, false);
updatePushBadge(); updatePushBadge();
hideLoader(); hideLoader();
if (!silent) toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
} }
}) })
.catch(function(error) { .catch(function(error) {
log('Error unsubscribing', error); log('[app] Error unsubscribing', error);
$('#menu-pushes').hideMenu(); $('#menu-pushes').hideMenu();
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000); if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
updatePushBadge(); updatePushBadge();
@@ -313,20 +412,21 @@ function pushesUnSubscribe(silent = false) {
} }
function pushesUpdateServerSubscription(subscription, enabled) { function pushesUpdateServerSubscription(subscription, enabled) {
log('updateServer', enabled, subscription); return new Promise(function(resolve){
$.ajax({ log('[app] updateServer', enabled, subscription);
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription', $.ajax({
type: 'POST', url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
data: { subscription: JSON.stringify(subscription) }, type: 'POST',
success: function (data, textStatus, jqXHR) { data: { subscription: JSON.stringify(subscription) },
if (!enabled) { success: function (data, textStatus, jqXHR) {
toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.'); log('[app] Subscription sent to server');
resolve(true);
},
error: function (jqXHR, textStatus, errorThrown) {
log('[app] Error sending subscription to server');
resolve(false);
} }
hideLoader(); });
},
error: function (jqXHR, textStatus, errorThrown) {
throw 'Cannot update server subscription';
}
}); });
} }
@@ -406,17 +506,35 @@ function pushesOpenMenu() {
} }
function updatePushBadge() { function updatePushBadge() {
if (typeof onUpdatePushBadge === 'function') onUpdatePushBadge();
if (!pushesPossible) return; if (!pushesPossible) return;
if (Notification.permission == 'denied') { if (Notification.permission == 'denied') {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED'); $('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
return; return;
} }
swRegistration.pushManager.getSubscription().then(function(subscription) { swRegistration.pushManager.getSubscription().then(async function(subscription) {
var dbSub = await dbSettingsGet('notify_endpoint_' + BOATCLASS);
var isSub = (subscription !== null); var isSub = (subscription !== null);
log('[app] DB Subscription:', dbSub);
log('[app] Real Subscription:', subscription);
if (isSub) { if (isSub) {
$('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN'); $('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN');
if (dbSub === null) dbSettingsSet('notify_endpoint_' + BOATCLASS, subscription.endpoint);
else if (dbSub !== subscription.endpoint) {
if (navigator.onLine) {
log('[app] Updating subscription');
pushesSubscribe();
}
}
} else { } else {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS'); $('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS');
if (dbSub === null) dbSettingsSet('notify_endpoint_' + BOATCLASS, false);
else if (dbSub !== false) {
if (navigator.onLine) {
log('[app] Re subscribe');
pushesSubscribe();
}
}
} }
}); });
} }
@@ -429,7 +547,7 @@ async function updateNewsBadge() {
var sum = 0; var sum = 0;
for (var n in news) { for (var n in news) {
var newsEntry = news[n]; 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 > now) continue;
if (newsEntry.date < newsRead) continue; if (newsEntry.date < newsRead) continue;
sum ++; sum ++;
@@ -440,8 +558,12 @@ async function updateNewsBadge() {
var initRegatten = function() { var initRegatten = function() {
showLoader(); showLoader();
log('[app] Initializing DB...');
initDatabase(); initDatabase();
log('[app] Loading app specific code...');
if (isLoggedIn()) { if (isLoggedIn()) {
$('.show-loggedin').show(); $('.show-loggedin').show();
$('.show-notloggedin').hide(); $('.show-notloggedin').hide();
@@ -461,7 +583,8 @@ var initRegatten = function() {
} }
var onServiceWorkerLoaded = function() { var onServiceWorkerLoaded = function() {
if ((swRegistration !== null) && canUseLocalDB) { log('[app] sW loaded');
if ((swRegistration !== null) && (swRegistration.pushManager) && canUseLocalDB) {
pushesPossible = true; pushesPossible = true;
updatePushBadge(); updatePushBadge();
} else { } else {
@@ -470,6 +593,7 @@ var onServiceWorkerLoaded = function() {
} }
var onDatabaseLoaded = function() { var onDatabaseLoaded = function() {
log('[app] DB loaded');
if (!canUseLocalDB && !$('#menu-welcome').hasClass('menu-active')) { if (!canUseLocalDB && !$('#menu-welcome').hasClass('menu-active')) {
function NoDbWarningOk() { function NoDbWarningOk() {
createCookie('regatten_nodb_banner', true, 1); createCookie('regatten_nodb_banner', true, 1);
@@ -494,24 +618,72 @@ var onAfterSync = function() {
updateNewsBadge(); updateNewsBadge();
} }
function sendErrorReport() {
alert('FEHLERBERICHT\nEs wird jetzt ein Fehlerbericht an die Entwickler geschickt.\nBitte stelle sicher, dass Du mit dem Internet verbunden bist und drücke dann auf OK.');
$.ajax({
url: QUERY_URL + 'error_report',
method: 'POST',
data: {
errors: consoleOutput,
device: navigator.userAgent,
version: '<?php echo PWA_VERSION; ?>'
},
error: function (xhr, status, error) {
if (xhr.status == 0) {
alert('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Fehlerbericht zu senden');
} else {
alert('Beim Senden ist ein unbekannter Fehler aufgetreten. Bitte versuche es noch einmal');
}
},
success: function (data, status, xhr) {
alert('Wir leiten Dich jetzt zum erstellten Fehlerbericht um, sodass Du ggf. weitere Informationen ergänzen kannst.');
location.href = 'https://github.com/ostertun/RegattenApp/issues/' + data.issueNumber;
}
});
}
// Add console opener to preloader // Add console opener to preloader
var addConsoleOpenerToPreloader = function() { var addConsoleOpenerToPreloader = function() {
addConsoleOpenerToPreloader = function(){}; addConsoleOpenerToPreloader = function(){};
var preloader = document.getElementById('preloader'); var preloader = document.getElementById('preloader');
var button = document.createElement('a'); var button = document.createElement('a');
button.id = 'button-show-console';
button.href = '#'; button.href = '#';
button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3'; button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3 bg-red2-dark bg-white';
button.style.position = 'fixed'; button.style.position = 'fixed';
button.style.bottom = 0; button.style.bottom = 0;
button.style.left = 0;
button.style.right = 0; button.style.right = 0;
button.innerHTML = '&lt;/&gt;'; button.innerHTML = 'Fehlerbericht senden';
button.onclick = function(){ button.onclick = function(){
alert('CONSOLE OPENED\nDir werden jetzt einige Entwickler-Informationen angezeigt. Du kannst die Console über das X oben rechts wieder schließen.'); sendErrorReport();
mobileConsole.displayConsole();
return false; return false;
} }
setTimeout(function(){ preloader.appendChild(button);
preloader.appendChild(button); $(button).hide();
}, 5000);
} }
addConsoleOpenerToPreloader(); addConsoleOpenerToPreloader();
function m2s_getLink(type, eventId) {
switch (type) {
case 'entrylist':
return 'https://manage2sail.com/de-DE/event/' + eventId + '#!/entries';
}
return '';
}
function ro_getLink(type, eventId) {
switch (type) {
case 'entrylist':
return 'http://www.raceoffice.org/entrylist.php?eid=' + eventId;
}
return '';
}
function extServiceGetLink(serviceName, type, eventId = '') {
switch (serviceName) {
case 'm2s':
return m2s_getLink(type, eventId);
case 'ro':
return ro_getLink(type, eventId);
}
return '';
}

View File

@@ -1,13 +1,13 @@
<?php <?php
require_once(__DIR__ . '/server/version.php'); require_once(__DIR__ . '/server/version.php');
require_once(__DIR__ . '/server/config.php'); require_once(__DIR__ . '/server/config.php');
require_once(__DIR__ . '/server/log.php'); require_once(__DIR__ . '/server/log.php');
require_once(__DIR__ . '/server/templates.php'); require_once(__DIR__ . '/server/templates.php');
require_once(__DIR__ . '/server/scripts.php'); require_once(__DIR__ . '/server/scripts.php');
define('LINK_PRE', SERVER_ADDR . '/'); define('LINK_PRE', SERVER_ADDR . '/');
$request = false; $request = false;
if (isset($_GET['request'])) { if (isset($_GET['request'])) {
$request = explode('/', $_GET['request']); $request = explode('/', $_GET['request']);
@@ -24,11 +24,11 @@
header('Location: ' . LINK_PRE . 'index'); header('Location: ' . LINK_PRE . 'index');
exit; exit;
} }
if (!file_exists(__DIR__ . '/server/content/' . $site . '.php')) { if (!file_exists(__DIR__ . '/server/content/' . $site . '.php')) {
$site = '404'; $site = '404';
} }
$sp = [ $sp = [
'title' => 'Regatten.net ' . $_CLASS['name'], // This is the page title 'title' => 'Regatten.net ' . $_CLASS['name'], // This is the page title
'backbutton' => false, // Show a back button (true, false, string). If a string is given, the back button is a link to this page. 'backbutton' => false, // Show a back button (true, false, string). If a string is given, the back button is a link to this page.
@@ -37,12 +37,12 @@
'menus' => '', // Additional menus go here 'menus' => '', // Additional menus go here
'scripts' => '' // Site specific scripts 'scripts' => '' // Site specific scripts
]; ];
$tpl = new Templates(__DIR__ . '/server/templates/'); $tpl = new Templates(__DIR__ . '/server/templates/');
$scripts = new Scripts(__DIR__ . '/server/scripts/'); $scripts = new Scripts(__DIR__ . '/server/scripts/');
require_once(__DIR__ . '/server/content/' . $site . '.php'); require_once(__DIR__ . '/server/content/' . $site . '.php');
require_once(__DIR__ . '/server/buildpage.php'); require_once(__DIR__ . '/server/buildpage.php');
?> ?>

View File

@@ -1,61 +1,72 @@
<?php <?php
$sp['title'] = 'Startseite - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Startseite - Regatten.net ' . $_CLASS['name'];
$sp['activenav'] = 1; $sp['activenav'] = 1;
// Title // Title
$content = "<h1>$_CLASS[name]</h1>"; $content = "<h1>$_CLASS[name]</h1>";
$content .= "<p>$_CLASS[desc]</p>"; $content .= "<p>$_CLASS[desc]</p>";
$sp['output'] .= $tpl->load('card', [$content]); $sp['output'] .= $tpl->load('card', [$content]);
// Favorites // Favorites
$content = '<h2>Deine Favoriten</h2>'; $content = '<h2>Deine Favoriten</h2>';
$thead = '<tr><th>Segler</th><th id="th-ranking">Rangliste</th></tr>'; $content .= '<div id="div-favorites" class="normal-list mb-0"></div>';
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-favorites', 'css-class' => 'mb-0 mt-3']);
$content .= '<p id="p-favorites" class="mt-3">'; $content .= '<p id="p-favorites" class="mt-3">';
$content .= 'Du folgst <b>keinen</b> Seglern.<br>'; $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&auml;hle bis zu f&uuml;nf Segler aus.'; $content .= 'Um jemandem zu folgen, gehe zur <a href="' . LINK_PRE . 'sailors">Segler-Liste</a> und w&auml;hle bis zu f&uuml;nf Segler aus.';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-favorites']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-favorites']);
// Planning next // Planning next
$content = '<h2>Deine n&auml;chsten Regatten</h2>'; $content = '<h2>Deine n&auml;chsten Regatten</h2>';
$content .= '<div id="div-yournext" class="regattas-list mb-0"></div>'; $content .= '<div id="div-yournext" class="regattas-list mb-0"></div>';
$content .= '<p id="p-yournext" class="mt-3">'; $content .= '<p id="p-yournext" class="mt-3">';
$content .= 'Du f&auml;hrst in den n&auml;chsten vier Wochen auf keine Regatta!'; $content .= 'Du f&auml;hrst in den n&auml;chsten vier Wochen auf keine Regatta!';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-yournext']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-yournext']);
// Not logged in // Not logged in
$content = '<h2>Nicht angemeldet</h2>'; $content = '<h2>Nicht angemeldet</h2>';
$content .= '<p class="mt-3">'; $content .= '<p class="mt-3">';
$content .= 'Um alle Funktionen dieser Seite nutzen zu k&ouml;nnen, <a href="#" data-menu="menu-login">logge Dich bitte ein</a>.<br>'; $content .= 'Um alle Funktionen dieser Seite nutzen zu k&ouml;nnen, <a href="#" data-menu="menu-login">logge Dich bitte ein</a>.<br>';
$content .= 'Solltest Du noch kein Benutzerkonto haben, kannst Du Dich kostenlos <a href="#" data-menu="menu-signup">registrieren</a>.'; $content .= 'Solltest Du noch kein Benutzerkonto haben, kannst Du Dich kostenlos <a href="#" data-menu="menu-signup">registrieren</a>.';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notloggedin']); $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 &uuml;ber alle &Auml;nderungen.<br>';
$content .= 'Du bestimmst nat&uuml;rlich, welche Benachrichtigungen Du bekommen m&ouml;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&auml;ter</a></p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notifications', 'css-class' => 'bg-blue2-dark']);
// Next // Next
$content = '<h2>N&auml;chste Regatten</h2>'; $content = '<h2>N&auml;chste Regatten</h2>';
$content .= '<div id="div-next" class="regattas-list mb-0"></div>'; $content .= '<div id="div-next" class="regattas-list mb-0"></div>';
$content .= '<p id="p-next" class="mt-3">'; $content .= '<p id="p-next" class="mt-3">';
$content .= 'Keine Regatten in den n&auml;chsten zwei Wochen!'; $content .= 'Keine Regatten in den n&auml;chsten zwei Wochen!';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-next']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-next']);
// Last // Last
$content = '<h2>Letzte Regatten</h2>'; $content = '<h2>Letzte Regatten</h2>';
$content .= '<div id="div-last" class="regattas-list mb-0"></div>'; $content .= '<div id="div-last" class="regattas-list mb-0"></div>';
$content .= '<p id="p-last" class="mt-3">'; $content .= '<p id="p-last" class="mt-3">';
$content .= 'Keine Regatten in den letzten zwei Wochen!'; $content .= 'Keine Regatten in den letzten zwei Wochen!';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-last']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-last']);
// Calendar // Calendar
$content = '<h2>Regatta-Kalender</h2>'; $content = '<h2>Regatta-Kalender</h2>';
$content .= '<p>Du willst alle Regatta-Termine in deinem Kalender, aber nicht alles abtippen?<br>Kein Problem! Abonniere einfach unseren ics-Kalender.</p>'; $content .= '<p>Du willst alle Regatta-Termine in deinem Kalender, aber nicht alles abtippen?<br>Kein Problem! Abonniere einfach unseren ics-Kalender.</p>';
@@ -65,12 +76,14 @@
$content .= '</p>'; $content .= '</p>';
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Regatta-Kalender', 'https://regatten.net/client/calendar/' . BOATCLASS . '/everything.ics', 'css-class' => 'mb-2']); $content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Regatta-Kalender', 'https://regatten.net/client/calendar/' . BOATCLASS . '/everything.ics', 'css-class' => 'mb-2']);
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Kalender f&uuml;r <font class="replace-username"></font>', 'https://regatten.net/client/calendar/' . BOATCLASS . '/user_%USERID%.ics', 'css-class' => 'show-loggedin replace-userid-href']); $content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Kalender f&uuml;r <font class="replace-username"></font>', 'https://regatten.net/client/calendar/' . BOATCLASS . '/user_%USERID%.ics', 'css-class' => 'show-loggedin replace-userid-href']);
$sp['output'] .= $tpl->load('card', [$content]); $sp['output'] .= $tpl->load('card', [$content]);
// Regattas Menu // Regattas Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>'; $items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon-badge', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt', 'badge-id' => 'badge-regatta-plannings']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldeliste', '', 'html-id' => 'menu-item-entrylist', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-entrylist']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']); $items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
@@ -78,8 +91,12 @@
$items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']); $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]); $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('onRegattaClicked');
$sp['scripts'] .= $scripts->load('index'); $sp['scripts'] .= $scripts->load('index');
?> ?>

View File

@@ -6,8 +6,9 @@
// Title // Title
$content = '<h1>Saison-Planung</h1>'; $content = '<h1>Saison-Planung</h1>';
$content .= $tpl->load('button', ['<i class="fas fa-list"></i>&ensp;Saison-Planungen anderer', 'html-id' => 'a-list-plannings', '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 .= '<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>&ensp;bearbeiten', LINK_PRE . 'planning_edit']); $content .= $tpl->load('button', ['<i class="fas fa-edit"></i>&ensp;bearbeiten', 'html-id' => 'a-edit-planning']);
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']); $content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']); $sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
@@ -26,9 +27,11 @@
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
// Menu // Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>'; $items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Status bearbeiten', '#', 'html-id' => 'menu-item-status', 'icon' => 'fa-edit']); $items .= $tpl->load('menu/item-icon', ['Status bearbeiten', '#', 'html-id' => 'menu-item-status', 'icon' => 'fa-edit']);
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= $tpl->load('menu/item-icon-badge', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt', 'badge-id' => 'badge-regatta-plannings']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldeliste', '', 'html-id' => 'menu-item-entrylist', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-entrylist']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']); $items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);

View File

@@ -1,7 +1,7 @@
<?php <?php
$sp['title'] = 'Saison-Planung bearbeiten - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Saison-Planung bearbeiten - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'planning'; $sp['backbutton'] = true;
$sp['activenav'] = 5; $sp['activenav'] = 5;
// Title, Inputs // Title, Inputs

View File

@@ -1,7 +1,7 @@
<?php <?php
$sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'planning'; $sp['backbutton'] = true;
$sp['activenav'] = 5; $sp['activenav'] = 5;
// Title // Title

View File

@@ -1,7 +1,7 @@
<?php <?php
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'planning_list'; $sp['backbutton'] = true;
$sp['activenav'] = 5; $sp['activenav'] = 5;
// Title // Title
@@ -20,8 +20,10 @@
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
// Menu // Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>'; $items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon-badge', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt', 'badge-id' => 'badge-regatta-plannings']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldeliste', '', 'html-id' => 'menu-item-entrylist', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-entrylist']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']); $items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);

View File

@@ -1,29 +1,33 @@
<?php <?php
$sp['title'] = 'Regatten - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Regatten - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'index'; $sp['backbutton'] = 'index';
$sp['activenav'] = 2; $sp['activenav'] = 2;
// Title, Inputs // Title, Inputs
$content = "<h1>Regatten</h1>"; $content = "<h1>Regatten</h1>";
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']); $content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
$content .= $tpl->load('input', ['html-id' => 'input-from', 'placeholder' => 'Von', 'type' => 'date', 'css-class' => 'mt-3']); $content .= $tpl->load('input', ['html-id' => 'input-from', 'placeholder' => 'Von', 'type' => 'date', 'css-class' => 'mt-3']);
$content .= $tpl->load('input', ['html-id' => 'input-to', 'placeholder' => 'Bis', 'type' => 'date']); $content .= $tpl->load('input', ['html-id' => 'input-to', 'placeholder' => 'Bis', 'type' => 'date']);
$content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']); $content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']);
$sp['output'] .= $tpl->load('card', [$content]); $sp['output'] .= $tpl->load('card', [$content]);
// Regattas // Regattas
$content = '<p id="p-count" class="mb-0"></p>'; $content = '<p id="p-count" class="mb-0"></p>';
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']); $content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '<div id="div-regattas" class="regattas-list mb-0"></div>'; $content .= '<div id="div-regattas" class="regattas-list mb-0"></div>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
$sp['output'] .= $tpl->load('card', ['<p></p>', 'html-id' => 'card-special']);
// Menu // Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>'; $items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']); $items .= '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon-badge', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt', 'badge-id' => 'badge-regatta-plannings']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldeliste', '', 'html-id' => 'menu-item-entrylist', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-entrylist']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']); $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']); $items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
@@ -31,8 +35,8 @@
$items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']); $items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']); $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]); $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
$sp['scripts'] .= $scripts->load('onRegattaClicked'); $sp['scripts'] .= $scripts->load('onRegattaClicked');
$sp['scripts'] .= $scripts->load('regattas'); $sp['scripts'] .= $scripts->load('regattas');
?> ?>

View File

@@ -1,14 +1,14 @@
<?php <?php
$sp['title'] = 'Segler - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Segler - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'index'; $sp['backbutton'] = 'index';
$sp['activenav'] = 4; $sp['activenav'] = 4;
// Title // Title
$content = "<h1>Segler</h1>"; $content = "<h1>Segler</h1>";
$sp['output'] .= $tpl->load('card', [$content]); $sp['output'] .= $tpl->load('card', [$content]);
// Info Years // Info Years
$content = '<h2>Jahrg&auml;nge</h2>'; $content = '<h2>Jahrg&auml;nge</h2>';
$content .= '<p>'; $content .= '<p>';
@@ -17,30 +17,32 @@
$content .= 'Klicke dazu einfach auf den entsprechenden Segler und w&auml;hle Jahrgang bearbeiten aus.<br>'; $content .= 'Klicke dazu einfach auf den entsprechenden Segler und w&auml;hle Jahrgang bearbeiten aus.<br>';
$content .= 'Vielen Dank f&uuml;r Deine Unterst&uuml;tzung!'; $content .= 'Vielen Dank f&uuml;r Deine Unterst&uuml;tzung!';
$content .= '</p>'; $content .= '</p>';
$sp['output'] .= $tpl->load('card', [$content]); $sp['output'] .= $tpl->load('card', [$content]);
// List // List
$content = '<p id="p-count" class="mb-0"></p>'; $content = '<p id="p-count" class="mb-0"></p>';
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']); $content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '<div id="div-list" class="normal-list mb-0"></div>'; $content .= '<div id="div-list" class="normal-list mb-0"></div>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-list']); $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-list']);
// Pagination // Pagination
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']); $sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
// Menu // 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']); $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 = '<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']); $items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-edityear']); $items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-edityear']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edityear', 'height' => 240]); $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edityear', 'height' => 240]);
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']); $sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
$sp['scripts'] .= $scripts->load('sailors'); $sp['scripts'] .= $scripts->load('sailors');
?> ?>

View File

@@ -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 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="content mb-0">
<div class="divider mb-0"></div> <div class="divider mb-0"></div>
<div class="list-group list-custom-small list-icon-0"> <div class="list-group list-custom-small list-icon-0">
@@ -209,7 +209,7 @@
</div> </div>
</div> </div>
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="360"> <div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="400">
<div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div> <div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
<div class="divider divider-margins mb-n2"></div> <div class="divider divider-margins mb-n2"></div>
<div class="content"> <div class="content">
@@ -229,11 +229,16 @@
<span>Reset Cache</span> <span>Reset Cache</span>
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<a href="https://github.com/ostertun/RegattenApp/issues"> <a href="https://github.com/ostertun/RegattenApp/issues/new">
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i> <i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
<span>Problem melden</span> <span>Problem melden</span>
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<a href="#" onclick="sendErrorReport(); return false;" class="menu-close">
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
<span>Fehlerbericht senden</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" onclick="mobileConsole.displayConsole(); return false;" class="border-0 menu-close"> <a href="#" onclick="mobileConsole.displayConsole(); return false;" class="border-0 menu-close">
<i class="fa font-14 fa-terminal rounded-s bg-highlight color-white"></i> <i class="fa font-14 fa-terminal rounded-s bg-highlight color-white"></i>
<span>Console anzeigen</span> <span>Console anzeigen</span>
@@ -243,7 +248,7 @@
</div> </div>
</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"> <div class="content bottom-0">
<h1 class="text-center mt-5 font-900">Login</h1> <h1 class="text-center mt-5 font-900">Login</h1>
<div class="input-style input-style-2 has-icon input-required"> <div class="input-style input-style-2 has-icon input-required">
@@ -257,18 +262,29 @@
<input id="input-login-password" class="form-control" type="password" placeholder="Passwort" /> <input id="input-login-password" class="form-control" type="password" placeholder="Passwort" />
</div> </div>
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="login();">Login</a> <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> </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"> <div class="content bottom-0">
<h1 class="text-center mt-5 font-900">Registrieren</h1> <h1 class="text-center mt-5 font-900">Registrieren</h1>
<p class="text-center"> <div class="input-style input-style-2 has-icon input-required">
Momentan kannst Du Dich leider nicht in der App registrieren.<br> <i class="input-icon fa fa-user color-theme"></i>
Das ist aber kein Problem, registriere Dich einfach kostenlos auf unserer Website! <span class="color-highlight">Benutzername</span>
</p> <input id="input-signup-username" class="form-control" type="name" placeholder="Benutzername" />
<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> </div>
<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-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>
</div> </div>
@@ -305,15 +321,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> <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> </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&uuml;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>

View File

@@ -1,8 +1,84 @@
var firstCall = true;
var today; 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() { var siteScript = async function() {
today = getToday(); today = getToday();
if (firstCall) {
firstCall = false;
$('#button-notifications-activate').click(function(){
pushesOpenMenu();
});
$('#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()) { if (isLoggedIn()) {
$('#card-notloggedin').hide(); $('#card-notloggedin').hide();
@@ -18,31 +94,41 @@ var siteScript = async function() {
} }
if (watched.length > 0) { if (watched.length > 0) {
var year = (new Date()).getFullYear(); 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]; var ranking = (await dbGetRanking(parseDate('01.12.' + (year - 1)), parseDate('30.11.' + year), false, false))[0];
tbody = ''; var list = '';
for (i in watched) { for (i in watched) {
sailor = watched[i]; 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; var rank = null;
for (r in ranking) { for (r in ranking) {
if (ranking[r].id == sailor.id) { if (ranking[r].id == sailor.id) {
rank = ranking[r].rank; rank = ranking[r];
break; break;
} }
} }
list += '<div onclick="onFavoriteClicked(' + sailor.id + ');">';
list += '<div>';
// Name
list += '<div><b>' + sailor.name + '</b></div>';
list += '</div><div>';
if (rank == null) { if (rank == null) {
tbody += '<i>nicht in der Rangliste</i>'; list += '<div>Nicht in der Rangliste</div>';
} else { } 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(); $('#p-favorites').hide();
$('#table-favorites').show(); $('#div-favorites').show();
} else { } else {
$('#table-favorites').hide(); $('#div-favorites').hide();
$('#p-favorites').show(); $('#p-favorites').show();
} }
$('#card-favorites').show(); $('#card-favorites').show();
@@ -59,7 +145,7 @@ var siteScript = async function() {
var planning = planningsDB[i]; var planning = planningsDB[i];
for (j in regattas) { for (j in regattas) {
var regatta = regattas[j]; var regatta = regattas[j];
if (regatta.id == planning.regatta) { if ((regatta.id == planning.regatta) && (regatta.length > 0)) {
planning.regatta = regatta; planning.regatta = regatta;
plannings.push(planning); plannings.push(planning);
} }
@@ -76,8 +162,6 @@ var siteScript = async function() {
var planning = plannings[i]; var planning = plannings[i];
var regatta = planning.regatta; var regatta = planning.regatta;
if (regatta['length'] < 1) continue;
var club = null; var club = null;
if (regatta['club'] != null) if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']); club = await dbGetData('clubs', regatta['club']);
@@ -102,6 +186,26 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>'; list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special // Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = regatta.special.indexOf('$')) >= 0) {
var pos2 = regatta.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = regatta.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
regatta.special = regatta.special.replace('$' + key + '$', value);
}
list += '<div>' + regatta['special'] + '</div>'; list += '<div>' + regatta['special'] + '</div>';
// Icons // Icons
@@ -170,13 +274,19 @@ var siteScript = async function() {
var maxDate = getToday(); var maxDate = getToday();
maxDate.setDate(maxDate.getDate() + 14); maxDate.setDate(maxDate.getDate() + 14);
var regattas = await dbGetRegattasRange(minDate, maxDate); var regattas = await dbGetRegattasRange(minDate, maxDate);
i = 0;
while (i < regattas.length) {
if (regattas[i].length < 1) {
regattas.splice(i, 1);
} else {
i ++;
}
}
if (regattas.length > 0) { if (regattas.length > 0) {
list = ''; list = '';
for (i in regattas) { for (i in regattas) {
var regatta = regattas[i]; var regatta = regattas[i];
if (regatta['length'] < 1) continue;
var club = null; var club = null;
if (regatta['club'] != null) if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']); club = await dbGetData('clubs', regatta['club']);
@@ -201,6 +311,26 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>'; list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special // Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = regatta.special.indexOf('$')) >= 0) {
var pos2 = regatta.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = regatta.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
regatta.special = regatta.special.replace('$' + key + '$', value);
}
list += '<div>' + regatta['special'] + '</div>'; list += '<div>' + regatta['special'] + '</div>';
// Icons // Icons
@@ -273,19 +403,22 @@ var siteScript = async function() {
var maxDate = getToday(); var maxDate = getToday();
maxDate.setDate(maxDate.getDate() - 1); maxDate.setDate(maxDate.getDate() - 1);
var regattas = await dbGetRegattasRange(minDate, maxDate); var regattas = await dbGetRegattasRange(minDate, maxDate);
var regattaResults = []; i = 0;
for (id in regattas) { while (i < regattas.length) {
var entry = regattas[id]; if (regattas[i].length < 1) {
var results = await dbGetDataIndex('results', 'regatta', entry['id']); regattas.splice(i, 1);
regattaResults[entry['id']] = (results.length > 0); } else {
i ++;
}
} }
regattas.sort(function(a,b){
return b.date.localeCompare(a.date);
});
if (regattas.length > 0) { if (regattas.length > 0) {
list = ''; list = '';
for (i in regattas) { for (i in regattas) {
var regatta = regattas[i]; var regatta = regattas[i];
if (regatta['length'] < 1) continue;
var club = null; var club = null;
if (regatta['club'] != null) if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']); club = await dbGetData('clubs', regatta['club']);
@@ -310,6 +443,26 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>'; list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special // Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = regatta.special.indexOf('$')) >= 0) {
var pos2 = regatta.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = regatta.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
regatta.special = regatta.special.replace('$' + key + '$', value);
}
list += '<div>' + regatta['special'] + '</div>'; list += '<div>' + regatta['special'] + '</div>';
// Icons // Icons
@@ -320,7 +473,7 @@ var siteScript = async function() {
icons.push('<i class="fas fa-book"></i>'); icons.push('<i class="fas fa-book"></i>');
if (regatta['canceled'] == '1') { if (regatta['canceled'] == '1') {
icons.push('<i class="fas fa-times color-red2-dark"></i>'); 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>'); icons.push('<i class="fas fa-poll"></i>');
} }
list += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>'; list += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';

View File

@@ -66,7 +66,7 @@ var siteScript = async function() {
lastYear.setFullYear(lastYear.getFullYear() - 1); lastYear.setFullYear(lastYear.getFullYear() - 1);
for (var n in news) { for (var n in news) {
var newsEntry = news[n]; 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 > now) continue;
if (newsEntry.date < lastYear) break; if (newsEntry.date < lastYear) break;
newsEntry.unread = (newsEntry.date > newsRead); newsEntry.unread = (newsEntry.date > newsRead);

View File

@@ -6,6 +6,43 @@ async function onRegattaClicked(id) {
var dateTo = parseDate(regatta['date']); var dateTo = parseDate(regatta['date']);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0)); dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
var text = [];
var specialFields = await dbGetClassProp('special-fields');
if (specialFields === null) specialFields = {};
if (regatta.special.substr(0, 1) == '#') {
regatta.special = regatta.special.substr(1);
if (typeof specialFields[regatta.special] !== 'undefined') {
text.push(specialFields[regatta.special]);
}
}
var pos;
while ((pos = regatta.special.indexOf('$')) >= 0) {
var pos2 = regatta.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = regatta.special.substring(pos + 1, pos2);
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
var year = parseDate(regatta.date).getFullYear();
year = year - value + 1;
text.push('Jahrgänge ' + year + ' und jünger');
} else {
break;
}
regatta.special = regatta.special.replace('$' + key + '$', '');
}
if (text.length > 0) {
text.sort();
for (i in text) {
text[i] = $('<div />').text(text[i]).html();
}
$('#menu-item-special').html(text.join('<br>'));
$('#menu-item-special').show();
} else {
$('#menu-item-special').hide();
}
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']); var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
var planning = null; var planning = null;
if (isLoggedIn()) { if (isLoggedIn()) {
@@ -54,15 +91,30 @@ async function onRegattaClicked(id) {
// Planning // Planning
if ((plannings.length > 0) && (dateTo >= today)) { if ((plannings.length > 0) && (dateTo >= today)) {
$('#menu-item-plannings').show(); $('#badge-regatta-plannings').text(plannings.length);
$('#menu-item-plannings').attr('href', LINK_PRE + 'regatta_plan?regatta=' + regatta['id']); $('#menu-item-plannings').attr('href', LINK_PRE + 'regatta_plan?regatta=' + regatta['id']);
$('#menu-item-plannings').show();
} else { } else {
$('#menu-item-plannings').hide(); $('#menu-item-plannings').hide();
} }
// Entrylist
var extServiceData;
try {
extServiceData = JSON.parse(regatta.extServiceData);
} catch {
extServiceData = {};
}
if ((regatta.extService !== null) && ('entryCount' in extServiceData)) {
$('#badge-regatta-entrylist').text(extServiceData.entryCount);
$('#menu-item-entrylist').attr('href', extServiceGetLink(regatta.extService, 'entrylist', extServiceData.eventId)); // TODO
$('#menu-item-entrylist').show();
} else {
$('#menu-item-entrylist').hide();
}
// Results // Results
var results = await dbGetDataIndex('results', 'regatta', regatta['id']); if (regatta['results'] == '1') {
if (results.length > 0) {
$('#menu-item-results').show(); $('#menu-item-results').show();
$('#menu-item-results').attr('href', LINK_PRE + 'result?regatta=' + regatta['id']); $('#menu-item-results').attr('href', LINK_PRE + 'result?regatta=' + regatta['id']);
} else { } else {

View File

@@ -68,16 +68,21 @@ function selectChange() {
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val); history.replaceState(null, '', '?year=' + val);
showLoader();
siteScript(); siteScript();
} }
} }
function initYear() { function initYear() {
var year = findGetParameter('year'); return new Promise(async function (resolve) {
if (year === null) year = new Date().getFullYear(); var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>'); $('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year); $('#select-year').val(year);
resolve();
});
} }
var firstCall = true; var firstCall = true;
@@ -106,18 +111,21 @@ var siteScript = async function() {
if (firstCall) { if (firstCall) {
firstCall = false; firstCall = false;
initYear(); await initYear();
$('#select-year').change(selectChange); $('#select-year').change(selectChange);
$('#input-search').on('input', drawList); $('#input-search').on('input', drawList);
$('#switch-status-gemeldet').parent().parent().click(planningSwitchChanged); $('#switch-status-gemeldet').parent().parent().click(planningSwitchChanged);
$('#switch-status-bezahlt').parent().parent().click(planningSwitchChanged); $('#switch-status-bezahlt').parent().parent().click(planningSwitchChanged);
} }
$('#a-share-planning').attr('href', LINK_PRE + 'planning_view?user=' + USER_ID); var selectedYear = $('#select-year').val();
$('#a-share-planning').attr('href', LINK_PRE + 'planning_view?user=' + USER_ID + '&year=' + selectedYear);
$('#a-edit-planning').attr('href', LINK_PRE + 'planning_edit?year=' + selectedYear);
$('#a-list-plannings').attr('href', LINK_PRE + 'planning_list?year=' + selectedYear);
today = getToday(); today = getToday();
var selectedYear = $('#select-year').val();
var minDate = parseDate(selectedYear + '-01-01'); var minDate = parseDate(selectedYear + '-01-01');
var maxDate = parseDate(selectedYear + '-12-31'); var maxDate = parseDate(selectedYear + '-12-31');
var regattas = await dbGetRegattasRange(minDate, maxDate); var regattas = await dbGetRegattasRange(minDate, maxDate);
@@ -136,12 +144,6 @@ var siteScript = async function() {
regattas.splice(i, 1); 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'); var years = await dbGetData('years');
years.sort(function (a, b) { years.sort(function (a, b) {
@@ -219,6 +221,26 @@ var siteScript = async function() {
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>'; row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special // Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = entry.special.indexOf('$')) >= 0) {
var pos2 = entry.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = entry.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
entry.special = entry.special.replace('$' + key + '$', value);
}
row.content += '<div>' + entry['special'] + '</div>'; row.content += '<div>' + entry['special'] + '</div>';
// Icons // Icons
@@ -261,7 +283,7 @@ var siteScript = async function() {
icons.push('<i class="fas fa-book"></i>'); icons.push('<i class="fas fa-book"></i>');
if (entry['canceled'] == '1') { if (entry['canceled'] == '1') {
icons.push('<i class="fas fa-times color-red2-dark"></i>'); 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>'); icons.push('<i class="fas fa-poll"></i>');
} }
if (entry.planning.gemeldet == '1') { if (entry.planning.gemeldet == '1') {

View File

@@ -69,6 +69,8 @@ async function planningSwitchChanged() {
var sailorIsSteuermann; var sailorIsSteuermann;
var sailors = []; var sailors = [];
var knownIds = [];
var known = [];
async function sailorSelected(sid) { async function sailorSelected(sid) {
$('#menu-sailor').hideMenu(); $('#menu-sailor').hideMenu();
@@ -103,8 +105,12 @@ async function sailorSelected(sid) {
}, },
success: async function (data, status, xhr) { success: async function (data, status, xhr) {
await sync(); await sync();
planningEdit(rid); if ((sid === null) || (sid in knownIds)) {
hideLoader(); planningEdit(rid);
hideLoader();
} else {
location.reload();
}
} }
}); });
} }
@@ -118,6 +124,11 @@ async function sailorsSearch() {
item += '</a>'; item += '</a>';
$('#menu-sailor').find('.content').find('.list-group').append(item); $('#menu-sailor').find('.content').find('.list-group').append(item);
} }
if ($('#input-edit-search').val().length == 0) {
known.forEach(function (entry) {
$('#menu-sailor').find('.content').find('.list-group').append(entry);
});
}
if ($('#input-edit-search').val().length >= 3) { if ($('#input-edit-search').val().length >= 3) {
sailors.forEach(function (entry) { sailors.forEach(function (entry) {
if (search($('#input-edit-search').val(), entry.keywords)) { if (search($('#input-edit-search').val(), entry.keywords)) {
@@ -125,18 +136,30 @@ async function sailorsSearch() {
} }
}); });
} else { } else {
var item = '<p class="item-sailor-search">Gib mindestens 3 Zeichen ein</p>'; var item = '<p class="item-sailor-search">Zum Suchen mindestens 3 Zeichen eingeben</p>';
$('#menu-sailor').find('.content').find('.list-group').append(item); $('#menu-sailor').find('.content').find('.list-group').append(item);
} }
} }
async function initSailors() { async function initSailors() {
sailors = []; sailors = [];
known = [];
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
knownIds = {};
for (var p in plannings) {
p = plannings[p];
if (p.steuermann !== null) knownIds[p.steuermann] = true;
var crew = p.crew.split(',');
for (var c in crew) {
c = crew[c];
if (c != '') knownIds[c] = true;
}
}
var dbSailors = await dbGetData('sailors'); var dbSailors = await dbGetData('sailors');
dbSailors.sort(function(a,b){ dbSailors.sort(function(a,b){
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}); });
for (s in dbSailors) { for (var s in dbSailors) {
var item = '<a class="item-sailor-search" onclick="sailorSelected(' + dbSailors[s].id + ')">'; var item = '<a class="item-sailor-search" onclick="sailorSelected(' + dbSailors[s].id + ')">';
item += '<span>' + dbSailors[s].name + '</span>'; item += '<span>' + dbSailors[s].name + '</span>';
item += '<i class="fa fa-angle-right"></i>'; item += '<i class="fa fa-angle-right"></i>';
@@ -145,6 +168,7 @@ async function initSailors() {
keywords: [dbSailors[s].name], keywords: [dbSailors[s].name],
content: item content: item
}); });
if (dbSailors[s].id in knownIds) known.push(item);
} }
} }
@@ -261,16 +285,21 @@ function selectChange() {
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val); history.replaceState(null, '', '?year=' + val);
showLoader();
siteScript(); siteScript();
} }
} }
function initYear() { function initYear() {
var year = findGetParameter('year'); return new Promise(async function (resolve) {
if (year === null) year = new Date().getFullYear(); var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>'); $('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year); $('#select-year').val(year);
resolve();
});
} }
var firstCall = true; var firstCall = true;
@@ -299,7 +328,7 @@ var siteScript = async function() {
if (firstCall) { if (firstCall) {
firstCall = false; firstCall = false;
initYear(); await initYear();
$('#select-year').change(selectChange); $('#select-year').change(selectChange);
$('#input-search').on('input', drawList); $('#input-search').on('input', drawList);
$('#switch-planning-include').parent().parent().click(planningSwitchChanged); $('#switch-planning-include').parent().parent().click(planningSwitchChanged);
@@ -407,6 +436,26 @@ var siteScript = async function() {
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>'; row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Special // Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = entry.special.indexOf('$')) >= 0) {
var pos2 = entry.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = entry.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
entry.special = entry.special.replace('$' + key + '$', value);
}
row.content += '<div>' + entry['special'] + '</div>'; row.content += '<div>' + entry['special'] + '</div>';
// Club // Club

View File

@@ -1,7 +1,7 @@
async function onUserClicked(id) { async function onUserClicked(id) {
var user = await dbGetData('users', id); var user = await dbGetData('users', id);
if (user !== null) { if (user !== null) {
location.href = LINK_PRE + 'planning_view?user=' + user.id; location.href = LINK_PRE + 'planning_view?user=' + user.id + '&year=' + $('#select-year').val();
} }
} }
@@ -10,16 +10,21 @@ function selectChange() {
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val); history.replaceState(null, '', '?year=' + val);
showLoader();
siteScript(); siteScript();
} }
} }
function initYear() { function initYear() {
var year = findGetParameter('year'); return new Promise(async function (resolve) {
if (year === null) year = new Date().getFullYear(); var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>'); $('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year); $('#select-year').val(year);
resolve();
});
} }
var firstCall = true; var firstCall = true;
@@ -46,7 +51,7 @@ var siteScript = async function() {
if (firstCall) { if (firstCall) {
firstCall = false; firstCall = false;
initYear(); await initYear();
$('#select-year').change(selectChange); $('#select-year').change(selectChange);
$('#input-search').on('input', drawList); $('#input-search').on('input', drawList);
} }

View File

@@ -1,18 +1,25 @@
var userid;
function selectChange() { function selectChange() {
var val = $('#select-year').val(); var val = $('#select-year').val();
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val); history.replaceState(null, '', '?user=' + userid + '&year=' + val);
showLoader();
siteScript(); siteScript();
} }
} }
function initYear() { function initYear() {
var year = findGetParameter('year'); return new Promise(async function (resolve) {
if (year === null) year = new Date().getFullYear(); var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>'); $('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year); $('#select-year').val(year);
resolve();
});
} }
var firstCall = true; var firstCall = true;
@@ -34,7 +41,7 @@ async function drawList () {
} }
var siteScript = async function() { var siteScript = async function() {
var userid = findGetParameter('user'); userid = findGetParameter('user');
var user = null; var user = null;
if (userid !== null) { if (userid !== null) {
user = await dbGetData('users', userid); user = await dbGetData('users', userid);
@@ -57,7 +64,7 @@ var siteScript = async function() {
if (firstCall) { if (firstCall) {
firstCall = false; firstCall = false;
initYear(); await initYear();
$('#select-year').change(selectChange); $('#select-year').change(selectChange);
$('#input-search').on('input', drawList); $('#input-search').on('input', drawList);
} }
@@ -157,6 +164,26 @@ var siteScript = async function() {
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>'; row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Special // Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
// replace placeholders
var pos;
while ((pos = entry.special.indexOf('$')) >= 0) {
var pos2 = entry.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = entry.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
value = 'U-' + value;
} else {
break;
}
entry.special = entry.special.replace('$' + key + '$', value);
}
row.content += '<div>' + entry['special'] + '</div>'; row.content += '<div>' + entry['special'] + '</div>';
// Club // Club

View File

@@ -137,6 +137,7 @@ async function selectChange(callSiteScript = true) {
jugend = jugstrict = true; jugend = jugstrict = true;
break; break;
case 'idjm': case 'idjm':
var youthGermanName = await dbGetClassProp('youth-german-name');
var beginn = null; var beginn = null;
var regattas = await dbGetData('regattas'); var regattas = await dbGetData('regattas');
regattas.sort(function(a,b){ return b.date.localeCompare(a.date); }); regattas.sort(function(a,b){ return b.date.localeCompare(a.date); });
@@ -146,7 +147,7 @@ async function selectChange(callSiteScript = true) {
if ((date < parseDate('01.01.' + year)) || (date > parseDate('31.12.' + year))) { if ((date < parseDate('01.01.' + year)) || (date > parseDate('31.12.' + year))) {
continue; continue;
} }
if (regatta.name.indexOf(YOUTH_GERMAN_NAME) >= 0) { if (regatta.name.indexOf(youthGermanName) >= 0) {
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date); beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
break; break;
} }
@@ -162,7 +163,7 @@ async function selectChange(callSiteScript = true) {
jugend = true; jugend = true;
jugstrict = false; jugstrict = false;
} else { } else {
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!'); $('#div-rank').html('Keine ' + youthGermanName + ' gefunden!');
$('#input-search').parent().hide(); $('#input-search').parent().hide();
return; return;
} }
@@ -175,7 +176,8 @@ async function selectChange(callSiteScript = true) {
$('#input-jugstrict').prop('checked', jugstrict); $('#input-jugstrict').prop('checked', jugstrict);
if (callSiteScript && (typeof siteScript === 'function')) { if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?type=' + type + '&year=' + year) history.replaceState(null, '', '?type=' + type + '&year=' + year);
showLoader();
siteScript(); siteScript();
} }
} }
@@ -187,6 +189,7 @@ function buttonShowPressed() {
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on' if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on' if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes) history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
showLoader();
siteScript(); siteScript();
} }
} }

View File

@@ -14,6 +14,7 @@ function selectChange(callSiteScript = true) {
if (callSiteScript && (typeof siteScript === 'function')) { if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?year=' + val); history.replaceState(null, '', '?year=' + val);
showLoader();
siteScript(); siteScript();
} }
} }
@@ -21,28 +22,33 @@ function selectChange(callSiteScript = true) {
function buttonShowPressed() { function buttonShowPressed() {
if (typeof siteScript === 'function') { 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(); siteScript();
} }
} }
function initYear() { function initYear() {
var year = findGetParameter('year'); return new Promise(async function (resolve) {
if (year === null) year = new Date().getFullYear(); var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>'); $('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year); $('#select-year').val(year);
if (year == "user") { if (year == "user") {
var from = findGetParameter('from'); var from = findGetParameter('from');
var to = findGetParameter('to'); var to = findGetParameter('to');
if (from === null) from = formatDate('Y-m-d') if (from === null) from = formatDate('Y-m-d')
if (to === null) to = formatDate('Y-m-d') if (to === null) to = formatDate('Y-m-d')
$('#input-from').val(from).trigger('focusin').trigger('focusout'); $('#input-from').val(from).trigger('focusin').trigger('focusout');
$('#input-to').val(to).trigger('focusin').trigger('focusout'); $('#input-to').val(to).trigger('focusin').trigger('focusout');
} }
selectChange(false); selectChange(false);
resolve();
});
} }
var firstCall = true; var firstCall = true;
@@ -66,7 +72,7 @@ async function drawList () {
var siteScript = async function() { var siteScript = async function() {
if (firstCall) { if (firstCall) {
firstCall = false; firstCall = false;
initYear(); await initYear();
$('#select-year').change(selectChange); $('#select-year').change(selectChange);
$('#button-show').click(buttonShowPressed); $('#button-show').click(buttonShowPressed);
$('#input-search').on('input', drawList); $('#input-search').on('input', drawList);
@@ -77,12 +83,6 @@ var siteScript = async function() {
var minDate = parseDate($('#input-from').val()); var minDate = parseDate($('#input-from').val());
var maxDate = parseDate($('#input-to').val()); var maxDate = parseDate($('#input-to').val());
var regattas = await dbGetRegattasRange(minDate, maxDate); 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(); var selectedYear = $('#select-year').val();
@@ -113,6 +113,9 @@ var siteScript = async function() {
var heute = false; var heute = false;
rows = []; rows = [];
var specialFields = await dbGetClassProp('special-fields');
if (specialFields === null) specialFields = {};
var specialShown = {};
for (id in regattas) { for (id in regattas) {
var entry = regattas[id]; var entry = regattas[id];
@@ -150,7 +153,37 @@ var siteScript = async function() {
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>'; row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special // Special
row.content += '<div>' + entry['special'] + '</div>'; if (entry.special.substr(0, 1) == '#') {
entry.special = entry.special.substr(1);
if (typeof specialFields[entry.special] !== 'undefined') {
specialShown[entry.special] = specialFields[entry.special];
entry.special = '* ' + entry.special;
} else {
entry.special = 'ERROR';
}
}
// replace placeholders
var pos;
while ((pos = entry.special.indexOf('$')) >= 0) {
var pos2 = entry.special.indexOf('$', pos + 1);
if (pos2 < 0) break;
var key = entry.special.substring(pos + 1, pos2);
var value = '';
// age class
if ((key.substr(0, 1) == 'U') && (!isNaN(value = parseInt(key.substr(1))))) {
var year = parseDate(entry.date).getFullYear();
year = year - value + 1;
var text = 'Jahrgänge ' + year + ' und jünger';
value = 'U-' + value;
specialShown[value] = text;
} else {
break;
}
entry.special = entry.special.replace('$' + key + '$', value);
}
row.content += '<div>' + entry.special + '</div>';
// Icons // Icons
var icons = []; var icons = [];
@@ -194,7 +227,7 @@ var siteScript = async function() {
icons.push('<i class="fas fa-book"></i>'); icons.push('<i class="fas fa-book"></i>');
if (entry['canceled'] == '1') { if (entry['canceled'] == '1') {
icons.push('<i class="fas fa-times color-red2-dark"></i>'); 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>'); icons.push('<i class="fas fa-poll"></i>');
} }
row.content += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>'; row.content += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
@@ -227,12 +260,27 @@ var siteScript = async function() {
rows.push(null); rows.push(null);
} }
var specialKeys = Object.keys(specialShown);
if (specialKeys.length > 0) {
specialKeys.sort();
var specialText = '';
for (i in specialKeys) {
var key = specialKeys[i];
specialText += '* ' + key + ': ' + specialShown[key] + '<br>';
}
$('#card-special').find('p').html(specialText);
$('#card-special').show();
} else {
$('#card-special').hide();
}
drawList(); drawList();
} else { } else {
$('#p-count').html('Keine Regatten gefunden!'); $('#p-count').html('Keine Regatten gefunden!');
$('#div-regattas').hide(); $('#div-regattas').hide();
$('#input-search').parent().hide(); $('#input-search').parent().hide();
$('#card-special').hide();
} }
hideLoader(); hideLoader();

View File

@@ -4,6 +4,40 @@ var displayed = [];
var page = 1; var page = 1;
var pageCount = 0; var pageCount = 0;
const showCount = 25; 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() { async function onEditYearClick() {
var id = $('#button-edityear').attr('data-sailor-id'); 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); $('#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 // Edit Year
$('#button-edityear').attr('data-sailor-id', sailor.id); $('#button-edityear').attr('data-sailor-id', sailor.id);
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name); $('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
@@ -134,6 +188,19 @@ var siteScript = async function() {
$('#input-search').on('input', reSearch); $('#input-search').on('input', reSearch);
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); }); $('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
$('#button-edityear').click(onEditYearClick); $('#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'); var results = await dbGetData('sailors');

View File

@@ -1,4 +1,4 @@
<nav id="$$html-id;"> <nav id="$$html-id;" class="$$css-class;">
<ul class="pagination justify-content-center"> <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;-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> <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>
@@ -8,4 +8,4 @@
<li id="$$html-id;-6" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">6</a></li> <li id="$$html-id;-6" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">6</a></li>
<li id="$$html-id;-7" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">7</a></li> <li id="$$html-id;-7" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">7</a></li>
</ul> </ul>
</nav> </nav>

View File

@@ -1,5 +1,5 @@
<?php <?php
define('PWA_VERSION', '1.10.3h1'); define('PWA_VERSION', '1.11.5h1');
?> ?>

View File

@@ -182,9 +182,9 @@ function getEntry(data, index, defaultValue) {
return ((typeof data[index] !== "undefined") ? data[index] : defaultValue); return ((typeof data[index] !== "undefined") ? data[index] : defaultValue);
} }
function isMyRegatta(id) { function isMyRegatta(id, suffix = '') {
return new Promise(async function (resolve) { return new Promise(async function (resolve) {
var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>'); var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>' + suffix);
if (regattas == null) resolve(false); if (regattas == null) resolve(false);
else resolve(regattas.includes(id.toString())); else resolve(regattas.includes(id.toString()));
}); });
@@ -228,16 +228,15 @@ self.addEventListener('push', async function(event) {
break; break;
case 'meldeschluss': case 'meldeschluss':
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) { if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true; if (await isMyRegatta(getEntry(data, 'id', ''), '_meldung_off')) okay = true;
// TODO: only if not already registered
} }
break; break;
default: default:
console.log('Unknown channel:', data.channel); console.log('[sW] Unknown channel:', data.channel);
break; break;
} }
if (!okay) { if (!okay) {
console.log('Notification channel not subscribed'); console.log('[sW] Notification channel not subscribed');
return; return;
} }
@@ -256,7 +255,7 @@ self.addEventListener('push', async function(event) {
var db = await openDb(); var db = await openDb();
if (db != null) { if (db != null) {
var os = db.transaction('update_times', 'readwrite').objectStore('update_times'); 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) { request.onerror = function (event) {
console.log('[sW] Error while saving data to DB:', e); console.log('[sW] Error while saving data to DB:', e);
db.close(); db.close();
@@ -268,7 +267,7 @@ self.addEventListener('push', async function(event) {
} }
} }
console.log('Showing notification'); console.log('[sW] Showing notification');
self.registration.showNotification(data.title, options); self.registration.showNotification(data.title, options);
break; break;
@@ -277,7 +276,7 @@ self.addEventListener('push', async function(event) {
var db = await openDb(); var db = await openDb();
if (db != null) { if (db != null) {
var os = db.transaction('update_times', 'readwrite').objectStore('update_times'); 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) { request.onerror = function (event) {
console.log('[sW] Error while saving data to DB:', e); console.log('[sW] Error while saving data to DB:', e);
db.close(); db.close();
@@ -311,3 +310,16 @@ self.addEventListener('notificationclick', function(event) {
clients.openWindow(url) 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
})
);
});