Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8cef6ee95 | ||
|
|
19f561ffde | ||
|
|
4dfa2d7bd5 | ||
|
|
c983a1702f | ||
|
|
a1facbca85 | ||
|
|
fba8c8e958 | ||
|
|
8aa3e3ccb6 | ||
|
|
c319e568b6 | ||
|
|
748176159d | ||
|
|
053981175b | ||
|
|
7083b46831 | ||
|
|
2c8c99b8f0 | ||
|
|
07d01ae700 | ||
|
|
7da31729e9 | ||
|
|
08ab714a54 | ||
|
|
44c962b7b3 | ||
|
|
004280f3ea | ||
|
|
63a8d174d7 | ||
|
|
13f496f0a6 | ||
|
|
da553a8f8d | ||
|
|
69ef983c07 | ||
|
|
32473901d6 | ||
|
|
84320f3a67 | ||
|
|
cd30ba1ce6 | ||
|
|
1fb619d4ec | ||
|
|
0fd09c22a2 | ||
|
|
12ed412226 | ||
|
|
7fd1c1c6e7 | ||
|
|
4e85d3a993 | ||
|
|
5c22604896 | ||
|
|
a2fe4c2637 | ||
|
|
4a65b48520 | ||
|
|
4eb2970671 | ||
|
|
0298cefc8b | ||
|
|
e17f99d005 | ||
|
|
15d7060354 | ||
|
|
d38de287dd | ||
|
|
1cb6de2402 | ||
|
|
da2beac8d3 | ||
|
|
92a11bcfa5 | ||
|
|
2ddeac4ba4 | ||
|
|
fa4770e12a | ||
|
|
a845137873 | ||
|
|
a6f2568753 | ||
|
|
6d0fdea0e8 | ||
|
|
8bc0d9b15e | ||
|
|
1252c02d7c | ||
|
|
3ff17a63e0 |
@@ -9,19 +9,29 @@
|
||||
log('[tpl] Script "custom.js" loaded');
|
||||
|
||||
var loaderCount = 2;
|
||||
var showConsoleButtonTimeout = setTimeout(function(){
|
||||
$('#button-show-console').show();
|
||||
}, 10000);
|
||||
var showLoader = function() {
|
||||
log('[tpl] showLoader called, loaderCount:', loaderCount);
|
||||
if (loaderCount < 1) {
|
||||
$('#preloader').removeClass('preloader-hide');
|
||||
loaderCount = 0;
|
||||
showConsoleButtonTimeout = setTimeout(function(){
|
||||
$('#button-show-console').show();
|
||||
}, 10000);
|
||||
log('[tpl] Loader shown');
|
||||
}
|
||||
loaderCount ++;
|
||||
}
|
||||
var hideLoader = function() {
|
||||
log('[tpl] hideLoader called, loaderCount:', loaderCount);
|
||||
loaderCount --;
|
||||
if (loaderCount < 1) {
|
||||
$('#preloader').addClass('preloader-hide');
|
||||
loaderCount = 0;
|
||||
clearTimeout(showConsoleButtonTimeout);
|
||||
$('#button-show-console').hide();
|
||||
log('[tpl] Loader hidden');
|
||||
}
|
||||
}
|
||||
@@ -116,29 +126,22 @@ $(document).ready(function(){
|
||||
//Adding Background for Gradient
|
||||
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
||||
|
||||
var menuOpened = function() {
|
||||
log('[tpl] Menu opened', history.state);
|
||||
if ((history.state === null) || (history.state.menu !== 'opened')) {
|
||||
history.pushState({ menu: 'opened' }, '');
|
||||
log('[tpl] state pushed');
|
||||
}
|
||||
}
|
||||
var menuClosed = function() {
|
||||
log('[tpl] Menu closed', history.state);
|
||||
if ((history.state !== null) && (history.state.menu === 'opened')) {
|
||||
history.back();
|
||||
log('[tpl] history.back')
|
||||
}
|
||||
}
|
||||
history.pushState(null, '');
|
||||
log('[tpl] state pushed');
|
||||
|
||||
/*Menu Extender Function*/
|
||||
$.fn.showMenu = function() {$(this).addClass('menu-active'); $('#footer-bar').addClass('footer-menu-hidden');setTimeout(function(){$('.menu-hider').addClass('menu-active');},250);$('body').addClass('modal-open');menuOpened();};
|
||||
$.fn.hideMenu = function() {$(this).removeClass('menu-active'); $('#footer-bar').removeClass('footer-menu-hidden');$('.menu-hider').removeClass('menu-active menu-active-clear');$('body').removeClass('modal-open');menuClosed();};
|
||||
$.fn.showMenu = function() {$(this).addClass('menu-active'); $('#footer-bar').addClass('footer-menu-hidden');setTimeout(function(){$('.menu-hider').addClass('menu-active');},250);$('body').addClass('modal-open');};
|
||||
$.fn.hideMenu = function() {$(this).removeClass('menu-active'); $('#footer-bar').removeClass('footer-menu-hidden');$('.menu-hider').removeClass('menu-active menu-active-clear');$('body').removeClass('modal-open');};
|
||||
|
||||
window.onpopstate = function(event) {
|
||||
log('[tpl] popstate event fired. location:' + document.location + ', state:' + JSON.stringify(event.state));
|
||||
if ((event.state === null) || (event.state.menu !== 'opened')) {
|
||||
var menuOpened = $('body').hasClass('modal-open');
|
||||
log('[tpl] popstate event fired. location:' + document.location + ', state:' + JSON.stringify(event.state) + ', menuOpened:' + menuOpened);
|
||||
if (menuOpened) {
|
||||
$('.menu').hideMenu();
|
||||
log('Menu hidden');
|
||||
} else {
|
||||
log('history.back');
|
||||
history.back();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -201,7 +204,6 @@ $(document).ready(function(){
|
||||
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX(-100%)");}
|
||||
}
|
||||
menuActivate();
|
||||
menuOpened();
|
||||
});
|
||||
|
||||
//Allows clicking even if menu is loaded externally.
|
||||
@@ -213,7 +215,6 @@ $(document).ready(function(){
|
||||
menuHider.css('transform','translate(0,0)');
|
||||
$('#footer-bar').removeClass('footer-menu-hidden');
|
||||
$('body').removeClass('modal-open');
|
||||
menuClosed();
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -222,7 +223,7 @@ $(document).ready(function(){
|
||||
//Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance.
|
||||
function allowTransitions(){$('body').find('#transitions-remove').remove();}
|
||||
function removeTransitions(){$('body').append('<style id="transitions-remove">.btn, .header, #footer-bar, .menu-box, .menu-active{transition:all 0ms ease!important;}</style>'); setTimeout(function(){allowTransitions();},10);}
|
||||
/* DARK MODE DISABLED
|
||||
|
||||
//Dark Mode
|
||||
var darkSwitch = $('[data-toggle-theme-switch], [data-toggle-theme], [data-toggle-theme-switch] input, [data-toggle-theme] input');
|
||||
$('[data-toggle-theme], [data-toggle-theme-switch]').on('click',function(){
|
||||
@@ -264,10 +265,6 @@ $(document).ready(function(){
|
||||
if($('body').hasClass('detect-theme')){setColorScheme();}
|
||||
$('.detect-dark-mode').on('click',function(){ $('body').addClass('detect-theme'); setColorScheme(); return false;});
|
||||
$('.disable-auto-dark-mode').on('click',function(){ $('body').removeClass('detect-theme'); $(this).remove(); return false;});
|
||||
*/
|
||||
eraseCookie('sticky_light_mode');
|
||||
eraseCookie('sticky_dark_mode');
|
||||
// END
|
||||
|
||||
log('[tpl] init other ui elements');
|
||||
|
||||
@@ -370,7 +367,7 @@ eraseCookie('sticky_dark_mode');
|
||||
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
log('[tpl] init a2h');
|
||||
|
||||
//Adding added-to-homescreen class to be targeted when used as PWA.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const DB_VERSION = 6;
|
||||
const DB_VERSION = 7;
|
||||
|
||||
const USER_ID = localStorage.getItem('auth_user');
|
||||
const USER_NAME = localStorage.getItem('auth_username');
|
||||
@@ -191,6 +191,8 @@ function dbGetResultCalculated(regatta) {
|
||||
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 '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
|
||||
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)
|
||||
@@ -351,7 +353,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
||||
if (sailors[i].german == '0') {
|
||||
sailors.splice(i, 1);
|
||||
} 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.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) {
|
||||
return new Promise(function(resolve) {
|
||||
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() {
|
||||
var lastSync = await dbGetData('update_times', 'last_sync');
|
||||
lastSync = new Date(lastSync.time * 1000);
|
||||
@@ -459,8 +509,16 @@ async function runPageScript() {
|
||||
|
||||
if (isLoggedIn()) {
|
||||
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||
plannings = plannings.map(function (e) { return e.regatta; });
|
||||
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
|
||||
plannings_all = plannings.map(function (e) { return e.regatta; });
|
||||
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') {
|
||||
@@ -495,7 +553,7 @@ function sync() {
|
||||
localTimes[entry['table']] = entry['time'];
|
||||
});
|
||||
|
||||
syncInProgress = 11;
|
||||
syncInProgress = 12;
|
||||
var syncOkay = true;
|
||||
log("[db] Sync Start");
|
||||
$('#i-sync').addClass('fa-spin');
|
||||
@@ -525,6 +583,24 @@ function sync() {
|
||||
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
|
||||
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
|
||||
if (localTimes['clubs'] < serverTimes['clubs']) {
|
||||
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
||||
@@ -910,7 +986,12 @@ function sync() {
|
||||
}
|
||||
|
||||
} else {
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
if (code == 401) {
|
||||
log("[db] Auth invalid. Logout initiated");
|
||||
logoutClearStorage();
|
||||
} else {
|
||||
log("[db] Something went wrong (HTTP " + code + ")");
|
||||
}
|
||||
syncOkay = false;
|
||||
syncInProgress = 0;
|
||||
}
|
||||
@@ -949,7 +1030,7 @@ function initDatabase() {
|
||||
db.onversionchange = function (event) {
|
||||
if (syncTimer != null) window.clearInterval(syncTimer);
|
||||
if (updateSyncStatusTimer != null) window.clearInterval(updateSyncStatusTimer);
|
||||
// TODO document.getElementById('syncstatus').innerHTML = '';
|
||||
$('#syncstatus').html('');
|
||||
canUseLocalDB = false;
|
||||
db.close();
|
||||
location.reload;
|
||||
@@ -1052,6 +1133,11 @@ function initDatabase() {
|
||||
osUpdateTimes.add({ table: 'news', time: 0 });
|
||||
}
|
||||
|
||||
if ((oldVersion < 7) && (newVersion >= 7)) {
|
||||
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');
|
||||
|
||||
@@ -38,6 +38,16 @@ function parseDate(string) {
|
||||
return date;
|
||||
}
|
||||
|
||||
function parseDbTimestamp(string) {
|
||||
var year = string.substr(0, 4);
|
||||
var month = string.substr(5, 2);
|
||||
var day = string.substr(8, 2);
|
||||
var hour = string.substr(11, 2);
|
||||
var minute = string.substr(14, 2);
|
||||
var second = string.substr(17, 2);
|
||||
return new Date(year, month - 1, day, hour, minute, second);
|
||||
}
|
||||
|
||||
function getToday() {
|
||||
var date = new Date();
|
||||
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||
|
||||
@@ -1155,6 +1155,8 @@ var mobileConsole = (function () {
|
||||
if (!msgContainer.innerHTML) { return; }
|
||||
leftContainer.appendChild(msgContainer);
|
||||
|
||||
var errorReportEntry = { message: arguments[1].newMessage };
|
||||
|
||||
if (detailTable || stackTable) {
|
||||
setCSS(msgContainer, {cursor : 'pointer'});
|
||||
leftContainer.appendChild(detailTable || stackTable);
|
||||
@@ -1164,8 +1166,18 @@ var mobileConsole = (function () {
|
||||
//populate right side
|
||||
if (stackTrace && typeof stackTrace[stackTrace.length - 1] !== 'undefined') {
|
||||
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
|
||||
lineContainer.appendChild(leftContainer);
|
||||
lineContainer.appendChild(rightContainer);
|
||||
|
||||
@@ -95,19 +95,19 @@ $(document).ready(function(){
|
||||
log('[pwa] iOS Detected');
|
||||
if($('#menu-install-pwa-ios, .add-to-home').length){
|
||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||
function triggerPwaInstallIos() {
|
||||
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
||||
setTimeout(function(){
|
||||
setTimeout(function(){
|
||||
function triggerPwaInstallIos() {
|
||||
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
||||
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
|
||||
},3000);
|
||||
}
|
||||
var welcomActive = $('#menu-welcome').hasClass('menu-active');
|
||||
if (welcomActive) {
|
||||
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
|
||||
} else {
|
||||
triggerPwaInstallIos();
|
||||
}
|
||||
}
|
||||
var welcomActive = $('#menu-welcome').hasClass('menu-active');
|
||||
if (welcomActive) {
|
||||
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
|
||||
} else {
|
||||
triggerPwaInstallIos();
|
||||
}
|
||||
},3000);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,40 @@
|
||||
header('Content-Type: text/javascript');
|
||||
|
||||
require_once(__DIR__ . '/../../server/config.php');
|
||||
require_once(__DIR__ . '/../../server/version.php');
|
||||
|
||||
?>
|
||||
|
||||
const QUERY_URL = '<?php echo QUERY_URL; ?>';
|
||||
const BOATCLASS = '<?php echo BOATCLASS; ?>';
|
||||
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; ?>';
|
||||
|
||||
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() {
|
||||
var now = new Date();
|
||||
var hour = now.getHours().toString();
|
||||
@@ -132,12 +156,14 @@ function findGetParameter(parameterName) {
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -151,6 +177,7 @@ var signup = function() {
|
||||
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');
|
||||
@@ -165,6 +192,7 @@ var signup = function() {
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
log('[app] Signup successful, logging in');
|
||||
$('#input-login-username').val(username);
|
||||
$('#input-login-password').val(password);
|
||||
login();
|
||||
@@ -173,6 +201,7 @@ var signup = function() {
|
||||
}
|
||||
|
||||
var login = function() {
|
||||
log('[app] Login');
|
||||
showLoader();
|
||||
var username = $('#input-login-username').val();
|
||||
var password = $('#input-login-password').val();
|
||||
@@ -187,6 +216,7 @@ var login = function() {
|
||||
device: navigator.userAgent
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
log('[app] Login: error:', xhr.status, status);
|
||||
if (xhr.status == 401) {
|
||||
toastError('Benutzername oder Passwort falsch');
|
||||
$('#input-login-username').val(username).trigger('focusin').trigger('focusout');
|
||||
@@ -201,6 +231,7 @@ var login = function() {
|
||||
hideLoader();
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
log('[app] Login successful');
|
||||
localStorage.setItem('auth_id', data.id);
|
||||
localStorage.setItem('auth_hash', data.auth);
|
||||
localStorage.setItem('auth_user', data.user);
|
||||
@@ -221,6 +252,7 @@ var logoutClearStorage = function() {
|
||||
}
|
||||
|
||||
var logout = function() {
|
||||
log('[app] Logout');
|
||||
showLoader();
|
||||
var auth = {
|
||||
id: localStorage.getItem('auth_id'),
|
||||
@@ -238,6 +270,7 @@ var logout = function() {
|
||||
auth: auth
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
log('[app] Logout: error:', xhr.status, status);
|
||||
if (xhr.status == 401) {
|
||||
log('[app] Not logged in');
|
||||
logoutClearStorage();
|
||||
@@ -252,12 +285,14 @@ var logout = function() {
|
||||
}
|
||||
},
|
||||
success: function (data, status, xhr) {
|
||||
log('[app] Logout successful');
|
||||
logoutClearStorage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDb() {
|
||||
log('[app] Deleting DB');
|
||||
$('#menu-developer').hideMenu();
|
||||
if (canUseLocalDB) {
|
||||
showLoader();
|
||||
@@ -274,11 +309,13 @@ function deleteDb() {
|
||||
setTimeout(function(){ location.reload(); }, 3000);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteCache() {
|
||||
log('[app] Deleting cache');
|
||||
$('#menu-developer').hideMenu();
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
@@ -316,16 +353,28 @@ function urlB64ToUint8Array(base64String) {
|
||||
function pushesSubscribe() {
|
||||
log('[app] Subscribing');
|
||||
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
|
||||
log('[app] Subscription app server key:', applicationServerKey);
|
||||
swRegistration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: applicationServerKey
|
||||
})
|
||||
.then(function(subscription) {
|
||||
pushesUpdateServerSubscription(subscription, true);
|
||||
updatePushSwitches();
|
||||
updatePushBadge();
|
||||
.then(async function(subscription) {
|
||||
log('[app] Subscription:', subscription);
|
||||
if (await pushesUpdateServerSubscription(subscription, true)) {
|
||||
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) {
|
||||
$('#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);
|
||||
pushesUnSubscribe(true);
|
||||
@@ -335,13 +384,22 @@ function pushesSubscribe() {
|
||||
function pushesUnSubscribe(silent = false) {
|
||||
log('[app] Unsubscribing');
|
||||
swRegistration.pushManager.getSubscription()
|
||||
.then(function(subscription) {
|
||||
.then(async function(subscription) {
|
||||
log('[app] Subscription:', 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();
|
||||
log('[app] Subscription: Updating UI');
|
||||
$('#menu-pushes').hideMenu();
|
||||
dbSettingsSet('notify_endpoint_' + BOATCLASS, false);
|
||||
updatePushBadge();
|
||||
hideLoader();
|
||||
if (!silent) toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
@@ -354,20 +412,21 @@ function pushesUnSubscribe(silent = false) {
|
||||
}
|
||||
|
||||
function pushesUpdateServerSubscription(subscription, enabled) {
|
||||
log('[app] updateServer', enabled, subscription);
|
||||
$.ajax({
|
||||
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||
type: 'POST',
|
||||
data: { subscription: JSON.stringify(subscription) },
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (!enabled) {
|
||||
toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
|
||||
return new Promise(function(resolve){
|
||||
log('[app] updateServer', enabled, subscription);
|
||||
$.ajax({
|
||||
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||
type: 'POST',
|
||||
data: { subscription: JSON.stringify(subscription) },
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
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';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -453,12 +512,29 @@ function updatePushBadge() {
|
||||
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
|
||||
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);
|
||||
log('[app] DB Subscription:', dbSub);
|
||||
log('[app] Real Subscription:', subscription);
|
||||
if (isSub) {
|
||||
$('#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 {
|
||||
$('#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -471,7 +547,7 @@ async function updateNewsBadge() {
|
||||
var sum = 0;
|
||||
for (var n in news) {
|
||||
var newsEntry = news[n];
|
||||
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||
newsEntry.date = parseDbTimestamp(newsEntry.date);
|
||||
if (newsEntry.date > now) continue;
|
||||
if (newsEntry.date < newsRead) continue;
|
||||
sum ++;
|
||||
@@ -508,7 +584,7 @@ var initRegatten = function() {
|
||||
|
||||
var onServiceWorkerLoaded = function() {
|
||||
log('[app] sW loaded');
|
||||
if ((swRegistration !== null) && canUseLocalDB) {
|
||||
if ((swRegistration !== null) && (swRegistration.pushManager) && canUseLocalDB) {
|
||||
pushesPossible = true;
|
||||
updatePushBadge();
|
||||
} else {
|
||||
@@ -542,24 +618,72 @@ var onAfterSync = function() {
|
||||
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
|
||||
var addConsoleOpenerToPreloader = function() {
|
||||
addConsoleOpenerToPreloader = function(){};
|
||||
var preloader = document.getElementById('preloader');
|
||||
var button = document.createElement('a');
|
||||
button.id = 'button-show-console';
|
||||
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.bottom = 0;
|
||||
button.style.left = 0;
|
||||
button.style.right = 0;
|
||||
button.innerHTML = '</>';
|
||||
button.innerHTML = 'Fehlerbericht senden';
|
||||
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.');
|
||||
mobileConsole.displayConsole();
|
||||
sendErrorReport();
|
||||
return false;
|
||||
}
|
||||
setTimeout(function(){
|
||||
preloader.appendChild(button);
|
||||
}, 5000);
|
||||
preloader.appendChild(button);
|
||||
$(button).hide();
|
||||
}
|
||||
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 '';
|
||||
}
|
||||
|
||||
20
index.php
20
index.php
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once(__DIR__ . '/server/version.php');
|
||||
require_once(__DIR__ . '/server/config.php');
|
||||
require_once(__DIR__ . '/server/log.php');
|
||||
require_once(__DIR__ . '/server/templates.php');
|
||||
require_once(__DIR__ . '/server/scripts.php');
|
||||
|
||||
|
||||
define('LINK_PRE', SERVER_ADDR . '/');
|
||||
|
||||
|
||||
$request = false;
|
||||
if (isset($_GET['request'])) {
|
||||
$request = explode('/', $_GET['request']);
|
||||
@@ -24,11 +24,11 @@
|
||||
header('Location: ' . LINK_PRE . 'index');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (!file_exists(__DIR__ . '/server/content/' . $site . '.php')) {
|
||||
$site = '404';
|
||||
}
|
||||
|
||||
|
||||
$sp = [
|
||||
'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.
|
||||
@@ -37,12 +37,12 @@
|
||||
'menus' => '', // Additional menus go here
|
||||
'scripts' => '' // Site specific scripts
|
||||
];
|
||||
|
||||
|
||||
$tpl = new Templates(__DIR__ . '/server/templates/');
|
||||
$scripts = new Scripts(__DIR__ . '/server/scripts/');
|
||||
|
||||
|
||||
require_once(__DIR__ . '/server/content/' . $site . '.php');
|
||||
|
||||
|
||||
require_once(__DIR__ . '/server/buildpage.php');
|
||||
|
||||
?>
|
||||
|
||||
?>
|
||||
|
||||
@@ -80,8 +80,10 @@
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
// Regattas Menu
|
||||
$items = '<p id="menu-item-yourplanning" 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-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-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', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
// Title
|
||||
$content = '<h1>Saison-Planung</h1>';
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-list"></i> 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 .= $tpl->load('button', ['<i class="fas fa-edit"></i> bearbeiten', LINK_PRE . 'planning_edit']);
|
||||
$content .= $tpl->load('button', ['<i class="fas fa-edit"></i> bearbeiten', 'html-id' => 'a-edit-planning']);
|
||||
$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']);
|
||||
@@ -26,9 +27,11 @@
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
|
||||
|
||||
// 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', ['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', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Saison-Planung bearbeiten - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'planning';
|
||||
$sp['backbutton'] = true;
|
||||
$sp['activenav'] = 5;
|
||||
|
||||
// Title, Inputs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'planning';
|
||||
$sp['backbutton'] = true;
|
||||
$sp['activenav'] = 5;
|
||||
|
||||
// Title
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'planning_list';
|
||||
$sp['backbutton'] = true;
|
||||
$sp['activenav'] = 5;
|
||||
|
||||
// Title
|
||||
@@ -20,8 +20,10 @@
|
||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
|
||||
|
||||
// Menu
|
||||
$items = '<p id="menu-item-yourplanning" 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-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-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', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
$sp['title'] = 'Regatten - Regatten.net ' . $_CLASS['name'];
|
||||
$sp['backbutton'] = 'index';
|
||||
$sp['activenav'] = 2;
|
||||
|
||||
|
||||
// Title, Inputs
|
||||
$content = "<h1>Regatten</h1>";
|
||||
|
||||
|
||||
$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-to', 'placeholder' => 'Bis', 'type' => 'date']);
|
||||
$content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']);
|
||||
|
||||
|
||||
$sp['output'] .= $tpl->load('card', [$content]);
|
||||
|
||||
|
||||
// Regattas
|
||||
$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 .= '<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', ['<p></p>', 'html-id' => 'card-special']);
|
||||
|
||||
// Menu
|
||||
$items = '<p id="menu-item-yourplanning" 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-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-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', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||
$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', ['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['scripts'] .= $scripts->load('onRegattaClicked');
|
||||
$sp['scripts'] .= $scripts->load('regattas');
|
||||
|
||||
?>
|
||||
|
||||
?>
|
||||
|
||||
@@ -92,12 +92,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="260">
|
||||
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
|
||||
<div class="menu-title"><h1>Einstellungen</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||
<div class="divider divider-margins mb-n2"></div>
|
||||
<div class="content">
|
||||
<div class="list-group list-custom-small">
|
||||
<?php if (false) { /* DARK MODE DISABLED (set menu height to 310) */ ?>
|
||||
<a href="#" data-toggle-theme data-trigger-switch="switch-dark" class="pb-2">
|
||||
<i class="fa font-14 fa-moon rounded-s bg-dark1-dark color-white"></i>
|
||||
<span>Dark Mode</span>
|
||||
@@ -106,7 +105,6 @@
|
||||
<label class="custom-control-label" for="switch-dark"></label>
|
||||
</div>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<a href="#" data-menu="menu-login" class="show-notloggedin">
|
||||
<i class="fa font-14 fa-sign-in-alt rounded-s bg-highlight color-white"></i>
|
||||
<span>Login</span>
|
||||
@@ -211,7 +209,7 @@
|
||||
</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="divider divider-margins mb-n2"></div>
|
||||
<div class="content">
|
||||
@@ -231,11 +229,16 @@
|
||||
<span>Reset Cache</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</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>
|
||||
<span>Problem melden</span>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</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">
|
||||
<i class="fa font-14 fa-terminal rounded-s bg-highlight color-white"></i>
|
||||
<span>Console anzeigen</span>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
||||
</head>
|
||||
|
||||
<body class="theme-light" data-background="none" data-highlight="blue2"><?php /* DARK MODE DISABLED: set class to "detect-theme" */ ?>
|
||||
<body class="detect-theme" data-background="none" data-highlight="blue2">
|
||||
|
||||
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ var siteScript = async function() {
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
$('#button-notifications-activate').click(function(){
|
||||
$('#menu-pushes').showMenu();
|
||||
pushesOpenMenu();
|
||||
});
|
||||
$('#a-notifications-later').click(function(){
|
||||
createCookie('regatten_app_' + BOATCLASS + '_rejected_push', true, 1);
|
||||
@@ -145,7 +145,7 @@ var siteScript = async function() {
|
||||
var planning = planningsDB[i];
|
||||
for (j in regattas) {
|
||||
var regatta = regattas[j];
|
||||
if (regatta.id == planning.regatta) {
|
||||
if ((regatta.id == planning.regatta) && (regatta.length > 0)) {
|
||||
planning.regatta = regatta;
|
||||
plannings.push(planning);
|
||||
}
|
||||
@@ -162,8 +162,6 @@ var siteScript = async function() {
|
||||
var planning = plannings[i];
|
||||
var regatta = planning.regatta;
|
||||
|
||||
if (regatta['length'] < 1) continue;
|
||||
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
@@ -188,6 +186,26 @@ var siteScript = async function() {
|
||||
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Icons
|
||||
@@ -256,13 +274,19 @@ var siteScript = async function() {
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() + 14);
|
||||
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) {
|
||||
list = '';
|
||||
for (i in regattas) {
|
||||
var regatta = regattas[i];
|
||||
|
||||
if (regatta['length'] < 1) continue;
|
||||
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
@@ -287,6 +311,26 @@ var siteScript = async function() {
|
||||
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Icons
|
||||
@@ -359,6 +403,14 @@ var siteScript = async function() {
|
||||
var maxDate = getToday();
|
||||
maxDate.setDate(maxDate.getDate() - 1);
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
i = 0;
|
||||
while (i < regattas.length) {
|
||||
if (regattas[i].length < 1) {
|
||||
regattas.splice(i, 1);
|
||||
} else {
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
regattas.sort(function(a,b){
|
||||
return b.date.localeCompare(a.date);
|
||||
});
|
||||
@@ -367,8 +419,6 @@ var siteScript = async function() {
|
||||
for (i in regattas) {
|
||||
var regatta = regattas[i];
|
||||
|
||||
if (regatta['length'] < 1) continue;
|
||||
|
||||
var club = null;
|
||||
if (regatta['club'] != null)
|
||||
club = await dbGetData('clubs', regatta['club']);
|
||||
@@ -393,6 +443,26 @@ var siteScript = async function() {
|
||||
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Icons
|
||||
|
||||
@@ -66,7 +66,7 @@ var siteScript = async function() {
|
||||
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
||||
for (var n in news) {
|
||||
var newsEntry = news[n];
|
||||
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||
newsEntry.date = parseDbTimestamp(newsEntry.date);
|
||||
if (newsEntry.date > now) continue;
|
||||
if (newsEntry.date < lastYear) break;
|
||||
newsEntry.unread = (newsEntry.date > newsRead);
|
||||
|
||||
@@ -6,6 +6,43 @@ async function onRegattaClicked(id) {
|
||||
var dateTo = parseDate(regatta['date']);
|
||||
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 planning = null;
|
||||
if (isLoggedIn()) {
|
||||
@@ -54,12 +91,28 @@ async function onRegattaClicked(id) {
|
||||
|
||||
// Planning
|
||||
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').show();
|
||||
} else {
|
||||
$('#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
|
||||
if (regatta['results'] == '1') {
|
||||
$('#menu-item-results').show();
|
||||
|
||||
@@ -74,11 +74,15 @@ function selectChange() {
|
||||
}
|
||||
|
||||
function initYear() {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
return new Promise(async function (resolve) {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = await dbGetCurrentYear();
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
@@ -107,18 +111,21 @@ var siteScript = async function() {
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initYear();
|
||||
await initYear();
|
||||
$('#select-year').change(selectChange);
|
||||
$('#input-search').on('input', drawList);
|
||||
$('#switch-status-gemeldet').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();
|
||||
|
||||
var selectedYear = $('#select-year').val();
|
||||
var minDate = parseDate(selectedYear + '-01-01');
|
||||
var maxDate = parseDate(selectedYear + '-12-31');
|
||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||
@@ -214,6 +221,26 @@ var siteScript = async function() {
|
||||
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Icons
|
||||
|
||||
@@ -69,6 +69,8 @@ async function planningSwitchChanged() {
|
||||
|
||||
var sailorIsSteuermann;
|
||||
var sailors = [];
|
||||
var knownIds = [];
|
||||
var known = [];
|
||||
|
||||
async function sailorSelected(sid) {
|
||||
$('#menu-sailor').hideMenu();
|
||||
@@ -103,8 +105,12 @@ async function sailorSelected(sid) {
|
||||
},
|
||||
success: async function (data, status, xhr) {
|
||||
await sync();
|
||||
planningEdit(rid);
|
||||
hideLoader();
|
||||
if ((sid === null) || (sid in knownIds)) {
|
||||
planningEdit(rid);
|
||||
hideLoader();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,6 +124,11 @@ async function sailorsSearch() {
|
||||
item += '</a>';
|
||||
$('#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) {
|
||||
sailors.forEach(function (entry) {
|
||||
if (search($('#input-edit-search').val(), entry.keywords)) {
|
||||
@@ -125,18 +136,30 @@ async function sailorsSearch() {
|
||||
}
|
||||
});
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
async function initSailors() {
|
||||
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');
|
||||
dbSailors.sort(function(a,b){
|
||||
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 + ')">';
|
||||
item += '<span>' + dbSailors[s].name + '</span>';
|
||||
item += '<i class="fa fa-angle-right"></i>';
|
||||
@@ -145,6 +168,7 @@ async function initSailors() {
|
||||
keywords: [dbSailors[s].name],
|
||||
content: item
|
||||
});
|
||||
if (dbSailors[s].id in knownIds) known.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,11 +291,15 @@ function selectChange() {
|
||||
}
|
||||
|
||||
function initYear() {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
return new Promise(async function (resolve) {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = await dbGetCurrentYear();
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
@@ -300,7 +328,7 @@ var siteScript = async function() {
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initYear();
|
||||
await initYear();
|
||||
$('#select-year').change(selectChange);
|
||||
$('#input-search').on('input', drawList);
|
||||
$('#switch-planning-include').parent().parent().click(planningSwitchChanged);
|
||||
@@ -408,6 +436,26 @@ var siteScript = async function() {
|
||||
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Club
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
async function onUserClicked(id) {
|
||||
var user = await dbGetData('users', id);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,15 @@ function selectChange() {
|
||||
}
|
||||
|
||||
function initYear() {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
return new Promise(async function (resolve) {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = await dbGetCurrentYear();
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
@@ -47,7 +51,7 @@ var siteScript = async function() {
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initYear();
|
||||
await initYear();
|
||||
$('#select-year').change(selectChange);
|
||||
$('#input-search').on('input', drawList);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
var userid;
|
||||
|
||||
function selectChange() {
|
||||
var val = $('#select-year').val();
|
||||
|
||||
if (typeof siteScript === 'function') {
|
||||
history.replaceState(null, '', '?year=' + val);
|
||||
history.replaceState(null, '', '?user=' + userid + '&year=' + val);
|
||||
showLoader();
|
||||
siteScript();
|
||||
}
|
||||
}
|
||||
|
||||
function initYear() {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
return new Promise(async function (resolve) {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = await dbGetCurrentYear();
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
@@ -35,7 +41,7 @@ async function drawList () {
|
||||
}
|
||||
|
||||
var siteScript = async function() {
|
||||
var userid = findGetParameter('user');
|
||||
userid = findGetParameter('user');
|
||||
var user = null;
|
||||
if (userid !== null) {
|
||||
user = await dbGetData('users', userid);
|
||||
@@ -58,7 +64,7 @@ var siteScript = async function() {
|
||||
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initYear();
|
||||
await initYear();
|
||||
$('#select-year').change(selectChange);
|
||||
$('#input-search').on('input', drawList);
|
||||
}
|
||||
@@ -158,6 +164,26 @@ var siteScript = async function() {
|
||||
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
|
||||
|
||||
// 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>';
|
||||
|
||||
// Club
|
||||
|
||||
@@ -137,6 +137,7 @@ async function selectChange(callSiteScript = true) {
|
||||
jugend = jugstrict = true;
|
||||
break;
|
||||
case 'idjm':
|
||||
var youthGermanName = await dbGetClassProp('youth-german-name');
|
||||
var beginn = null;
|
||||
var regattas = await dbGetData('regattas');
|
||||
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))) {
|
||||
continue;
|
||||
}
|
||||
if (regatta.name.indexOf(YOUTH_GERMAN_NAME) >= 0) {
|
||||
if (regatta.name.indexOf(youthGermanName) >= 0) {
|
||||
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
|
||||
break;
|
||||
}
|
||||
@@ -162,7 +163,7 @@ async function selectChange(callSiteScript = true) {
|
||||
jugend = true;
|
||||
jugstrict = false;
|
||||
} else {
|
||||
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!');
|
||||
$('#div-rank').html('Keine ' + youthGermanName + ' gefunden!');
|
||||
$('#input-search').parent().hide();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,22 +29,26 @@ function buttonShowPressed() {
|
||||
}
|
||||
|
||||
function initYear() {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = new Date().getFullYear();
|
||||
return new Promise(async function (resolve) {
|
||||
var year = findGetParameter('year');
|
||||
if (year === null) year = await dbGetCurrentYear();
|
||||
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||
$('#select-year').val(year);
|
||||
|
||||
if (year == "user") {
|
||||
var from = findGetParameter('from');
|
||||
var to = findGetParameter('to');
|
||||
if (from === null) from = formatDate('Y-m-d')
|
||||
if (to === null) to = formatDate('Y-m-d')
|
||||
$('#input-from').val(from).trigger('focusin').trigger('focusout');
|
||||
$('#input-to').val(to).trigger('focusin').trigger('focusout');
|
||||
}
|
||||
if (year == "user") {
|
||||
var from = findGetParameter('from');
|
||||
var to = findGetParameter('to');
|
||||
if (from === null) from = formatDate('Y-m-d')
|
||||
if (to === null) to = formatDate('Y-m-d')
|
||||
$('#input-from').val(from).trigger('focusin').trigger('focusout');
|
||||
$('#input-to').val(to).trigger('focusin').trigger('focusout');
|
||||
}
|
||||
|
||||
selectChange(false);
|
||||
selectChange(false);
|
||||
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
var firstCall = true;
|
||||
@@ -68,7 +72,7 @@ async function drawList () {
|
||||
var siteScript = async function() {
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
initYear();
|
||||
await initYear();
|
||||
$('#select-year').change(selectChange);
|
||||
$('#button-show').click(buttonShowPressed);
|
||||
$('#input-search').on('input', drawList);
|
||||
@@ -109,6 +113,9 @@ var siteScript = async function() {
|
||||
var heute = false;
|
||||
|
||||
rows = [];
|
||||
var specialFields = await dbGetClassProp('special-fields');
|
||||
if (specialFields === null) specialFields = {};
|
||||
var specialShown = {};
|
||||
|
||||
for (id in regattas) {
|
||||
var entry = regattas[id];
|
||||
@@ -146,7 +153,37 @@ var siteScript = async function() {
|
||||
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||
|
||||
// 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
|
||||
var icons = [];
|
||||
@@ -223,12 +260,27 @@ var siteScript = async function() {
|
||||
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();
|
||||
|
||||
} else {
|
||||
$('#p-count').html('Keine Regatten gefunden!');
|
||||
$('#div-regattas').hide();
|
||||
$('#input-search').parent().hide();
|
||||
$('#card-special').hide();
|
||||
}
|
||||
|
||||
hideLoader();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
define('PWA_VERSION', '1.11');
|
||||
define('PWA_VERSION', '1.11.5h1');
|
||||
|
||||
?>
|
||||
|
||||
@@ -182,9 +182,9 @@ function getEntry(data, index, defaultValue) {
|
||||
return ((typeof data[index] !== "undefined") ? data[index] : defaultValue);
|
||||
}
|
||||
|
||||
function isMyRegatta(id) {
|
||||
function isMyRegatta(id, suffix = '') {
|
||||
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);
|
||||
else resolve(regattas.includes(id.toString()));
|
||||
});
|
||||
@@ -228,8 +228,7 @@ self.addEventListener('push', async function(event) {
|
||||
break;
|
||||
case 'meldeschluss':
|
||||
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
||||
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||
// TODO: only if not already registered
|
||||
if (await isMyRegatta(getEntry(data, 'id', ''), '_meldung_off')) okay = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user