Compare commits
162 Commits
v_1.10.4
...
fix_expend
| Author | SHA1 | Date | |
|---|---|---|---|
| b63b4c6714 | |||
| 595c684e23 | |||
| 3c0c2a3f2e | |||
| ac9b5ef652 | |||
| 099fb6deb6 | |||
| f3e1620057 | |||
| b52eea79c2 | |||
| 8972d2d72a | |||
| 49ed27e58f | |||
| 9a5d90a703 | |||
| bceca97c98 | |||
| 52c6914d41 | |||
| 0a323be5bf | |||
| 2242cedfea | |||
| 69dcb13f50 | |||
| 5dc88a78a2 | |||
| a221c86431 | |||
| 839f668b08 | |||
| 8f597051dd | |||
| dd587f7603 | |||
| 0e501e8ba4 | |||
| 42e68e5511 | |||
| 2971fdd259 | |||
| 9360f0e943 | |||
| 47718318ef | |||
| bd4fc4c255 | |||
| 1ab0e9185f | |||
| 027abe5364 | |||
|
|
29f83814ee | ||
|
|
deb23a5f7f | ||
|
|
744be24410 | ||
|
|
633e39ce5d | ||
|
|
bd2aafe67c | ||
|
|
2e6eb25e68 | ||
|
|
dc2ead3a07 | ||
|
|
ccc8731394 | ||
|
|
6b89acf422 | ||
|
|
54ceae6ce0 | ||
|
|
fe02f8707b | ||
|
|
a6f0c8e0f5 | ||
|
|
fe90438cb3 | ||
|
|
8c4d2f00cd | ||
|
|
34ae418598 | ||
|
|
d59b384e1a | ||
|
|
25df9995dd | ||
|
|
12538aaa3f | ||
|
|
e087e137ff | ||
|
|
e5dc107a7d | ||
|
|
fefd3c8929 | ||
|
|
dcc5428615 | ||
|
|
a37cf0ea46 | ||
|
|
49f2923a97 | ||
|
|
b2c57839c4 | ||
|
|
eddf0f151b | ||
|
|
0dd83a47cb | ||
|
|
3c07c67a1a | ||
|
|
dd7d8731e8 | ||
|
|
2caf6c4339 | ||
|
|
866d3ab3c1 | ||
|
|
6b503eeae0 | ||
|
|
a88c8356c2 | ||
|
|
ba09698ece | ||
|
|
ea3ac5f329 | ||
|
|
abe412d8ed | ||
|
|
e25ca534ec | ||
|
|
4f01262eba | ||
|
|
314792b09e | ||
|
|
a9464c382b | ||
|
|
d204acd365 | ||
|
|
00dc405158 | ||
|
|
b87f557a62 | ||
|
|
689845d02a | ||
|
|
ae8aed446b | ||
|
|
343d898afd | ||
|
|
c88a512ff8 | ||
|
|
1fc7b8fe6d | ||
|
|
2014303fae | ||
|
|
7b6ad832a9 | ||
|
|
eaf0fd5a95 | ||
|
|
6c547d43c5 | ||
|
|
e9e56b66ab | ||
|
|
143755a50f | ||
|
|
8ba463c8fe | ||
|
|
13927fb769 | ||
|
|
90075ceb4f | ||
|
|
526b338e41 | ||
|
|
aa60df83db | ||
|
|
58505a0f53 | ||
|
|
37c584e525 | ||
|
|
1010e4ffdd | ||
|
|
c17c2b64cf | ||
|
|
0658a44516 | ||
|
|
2f2d94bab4 | ||
|
|
dd854b7df5 | ||
|
|
c91dc57736 | ||
|
|
c8cef6ee95 | ||
|
|
3f7d7a40ec | ||
|
|
19f561ffde | ||
|
|
84677ef4dd | ||
|
|
4dfa2d7bd5 | ||
|
|
1e0052f629 | ||
|
|
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 | ||
|
|
f617fa7923 | ||
|
|
3ff17a63e0 | ||
|
|
c66dc96598 | ||
|
|
f5d059202e | ||
|
|
5962e1cc90 | ||
|
|
9f3019b4c5 | ||
|
|
326ba4a6bd | ||
|
|
4228ec739d | ||
|
|
a38c48dab4 | ||
|
|
da48e79a36 | ||
|
|
de5abcdfaf | ||
|
|
6b1e35cc14 | ||
|
|
89e24f69b7 | ||
|
|
554b810e85 | ||
|
|
fbd1eaaae8 | ||
|
|
ce42f87227 | ||
|
|
fcd791ed65 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ server/config.php
|
|||||||
api/config.php
|
api/config.php
|
||||||
.htaccess
|
.htaccess
|
||||||
!.keepfolder
|
!.keepfolder
|
||||||
|
.idea
|
||||||
|
|||||||
@@ -9,19 +9,29 @@
|
|||||||
log('[tpl] Script "custom.js" loaded');
|
log('[tpl] Script "custom.js" loaded');
|
||||||
|
|
||||||
var loaderCount = 2;
|
var loaderCount = 2;
|
||||||
|
var showConsoleButtonTimeout = setTimeout(function(){
|
||||||
|
$('#button-show-console').show();
|
||||||
|
}, 10000);
|
||||||
var showLoader = function() {
|
var showLoader = function() {
|
||||||
|
log('[tpl] showLoader called, loaderCount:', loaderCount);
|
||||||
if (loaderCount < 1) {
|
if (loaderCount < 1) {
|
||||||
$('#preloader').removeClass('preloader-hide');
|
$('#preloader').removeClass('preloader-hide');
|
||||||
loaderCount = 0;
|
loaderCount = 0;
|
||||||
|
showConsoleButtonTimeout = setTimeout(function(){
|
||||||
|
$('#button-show-console').show();
|
||||||
|
}, 10000);
|
||||||
log('[tpl] Loader shown');
|
log('[tpl] Loader shown');
|
||||||
}
|
}
|
||||||
loaderCount ++;
|
loaderCount ++;
|
||||||
}
|
}
|
||||||
var hideLoader = function() {
|
var hideLoader = function() {
|
||||||
|
log('[tpl] hideLoader called, loaderCount:', loaderCount);
|
||||||
loaderCount --;
|
loaderCount --;
|
||||||
if (loaderCount < 1) {
|
if (loaderCount < 1) {
|
||||||
$('#preloader').addClass('preloader-hide');
|
$('#preloader').addClass('preloader-hide');
|
||||||
loaderCount = 0;
|
loaderCount = 0;
|
||||||
|
clearTimeout(showConsoleButtonTimeout);
|
||||||
|
$('#button-show-console').hide();
|
||||||
log('[tpl] Loader hidden');
|
log('[tpl] Loader hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,29 +126,22 @@ $(document).ready(function(){
|
|||||||
//Adding Background for Gradient
|
//Adding Background for Gradient
|
||||||
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
||||||
|
|
||||||
var menuOpened = function() {
|
history.pushState(null, '');
|
||||||
log('[tpl] Menu opened', history.state);
|
|
||||||
if ((history.state === null) || (history.state.menu !== 'opened')) {
|
|
||||||
history.pushState({ menu: 'opened' }, '');
|
|
||||||
log('[tpl] state pushed');
|
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')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Menu Extender Function*/
|
/*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.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');menuClosed();};
|
$.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) {
|
window.onpopstate = function(event) {
|
||||||
log('[tpl] popstate event fired. location:' + document.location + ', state:' + JSON.stringify(event.state));
|
var menuOpened = $('body').hasClass('modal-open');
|
||||||
if ((event.state === null) || (event.state.menu !== 'opened')) {
|
log('[tpl] popstate event fired. location:' + document.location + ', state:' + JSON.stringify(event.state) + ', menuOpened:' + menuOpened);
|
||||||
|
if (menuOpened) {
|
||||||
$('.menu').hideMenu();
|
$('.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%)");}
|
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX(-100%)");}
|
||||||
}
|
}
|
||||||
menuActivate();
|
menuActivate();
|
||||||
menuOpened();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Allows clicking even if menu is loaded externally.
|
//Allows clicking even if menu is loaded externally.
|
||||||
@@ -213,7 +215,6 @@ $(document).ready(function(){
|
|||||||
menuHider.css('transform','translate(0,0)');
|
menuHider.css('transform','translate(0,0)');
|
||||||
$('#footer-bar').removeClass('footer-menu-hidden');
|
$('#footer-bar').removeClass('footer-menu-hidden');
|
||||||
$('body').removeClass('modal-open');
|
$('body').removeClass('modal-open');
|
||||||
menuClosed();
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ $(document).ready(function(){
|
|||||||
//Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance.
|
//Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance.
|
||||||
function allowTransitions(){$('body').find('#transitions-remove').remove();}
|
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);}
|
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
|
//Dark Mode
|
||||||
var darkSwitch = $('[data-toggle-theme-switch], [data-toggle-theme], [data-toggle-theme-switch] input, [data-toggle-theme] input');
|
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(){
|
$('[data-toggle-theme], [data-toggle-theme-switch]').on('click',function(){
|
||||||
@@ -264,10 +265,6 @@ $(document).ready(function(){
|
|||||||
if($('body').hasClass('detect-theme')){setColorScheme();}
|
if($('body').hasClass('detect-theme')){setColorScheme();}
|
||||||
$('.detect-dark-mode').on('click',function(){ $('body').addClass('detect-theme'); setColorScheme(); return false;});
|
$('.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;});
|
$('.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');
|
log('[tpl] init other ui elements');
|
||||||
|
|
||||||
@@ -346,6 +343,31 @@ eraseCookie('sticky_dark_mode');
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
log('[tpl] Init inputs');
|
||||||
|
|
||||||
|
$('.input-required input, .input-required select, .input-required textarea').on('focusin keyup',function(){
|
||||||
|
var spanValue = $(this).parent().find('span').text();
|
||||||
|
if($(this).val() != spanValue && $(this).val() != ""){
|
||||||
|
$(this).parent().find('span').addClass('input-style-1-active').removeClass('input-style-1-inactive');
|
||||||
|
}
|
||||||
|
if($(this).val() === ""){
|
||||||
|
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.input-required input, .input-required select, .input-required textarea').on('focusout',function(){
|
||||||
|
var spanValue = $(this).parent().find('span').text();
|
||||||
|
if($(this).val() === ""){
|
||||||
|
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
||||||
|
}
|
||||||
|
$(this).parent().find('span').addClass('input-style-1-inactive')
|
||||||
|
});
|
||||||
|
$('.input-required select').on('focusout',function(){
|
||||||
|
var getValue = $(this)[0].value;
|
||||||
|
if(getValue === "default"){
|
||||||
|
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
log('[tpl] init a2h');
|
log('[tpl] init a2h');
|
||||||
|
|
||||||
//Adding added-to-homescreen class to be targeted when used as PWA.
|
//Adding added-to-homescreen class to be targeted when used as PWA.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const DB_VERSION = 6;
|
const DB_VERSION = 10;
|
||||||
|
|
||||||
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');
|
||||||
@@ -44,6 +44,7 @@ function search(string, fields) {
|
|||||||
var keywords = string.split(' ');
|
var keywords = string.split(' ');
|
||||||
for (kid in keywords) {
|
for (kid in keywords) {
|
||||||
var keyword = keywords[kid].toLowerCase();
|
var keyword = keywords[kid].toLowerCase();
|
||||||
|
if (keyword != '') {
|
||||||
var found = false;
|
var found = false;
|
||||||
for (fid in fields) {
|
for (fid in fields) {
|
||||||
var field = fields[fid].toLowerCase();
|
var field = fields[fid].toLowerCase();
|
||||||
@@ -54,6 +55,7 @@ function search(string, fields) {
|
|||||||
}
|
}
|
||||||
if (!found) return false;
|
if (!found) return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,9 +147,9 @@ var compareResultsRaceCount;
|
|||||||
function compareResults (a, b) {
|
function compareResults (a, b) {
|
||||||
if (a['netto'] != b['netto']) return (a['netto'] < b['netto']) ? -1 : 1;
|
if (a['netto'] != b['netto']) return (a['netto'] < b['netto']) ? -1 : 1;
|
||||||
var tempA = [...a['values']];
|
var tempA = [...a['values']];
|
||||||
tempA.sort();
|
tempA.sort(function(a,b){return a-b;});
|
||||||
var tempB = [...b['values']];
|
var tempB = [...b['values']];
|
||||||
tempB.sort();
|
tempB.sort(function(a,b){return a-b;});
|
||||||
for (var i = 0; i < compareResultsRaceCount; i ++) {
|
for (var i = 0; i < compareResultsRaceCount; i ++) {
|
||||||
if (tempA[i] != tempB[i]) return (tempA[i] < tempB[i]) ? -1 : 1;
|
if (tempA[i] != tempB[i]) return (tempA[i] < tempB[i]) ? -1 : 1;
|
||||||
}
|
}
|
||||||
@@ -163,6 +165,15 @@ function dbGetResultCalculated(regatta) {
|
|||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
|
|
||||||
var gemeldet = results.length;
|
var gemeldet = results.length;
|
||||||
|
var started = [];
|
||||||
|
for (var i = 0; i < regatta['races']; i++) {
|
||||||
|
started[i] = 0;
|
||||||
|
for (id in results) {
|
||||||
|
if (results[id]['race' + (i + 1)] != 'DNC') {
|
||||||
|
started[i]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (id in results) {
|
for (id in results) {
|
||||||
results[id]['finished'] = false;
|
results[id]['finished'] = false;
|
||||||
@@ -179,22 +190,25 @@ function dbGetResultCalculated(regatta) {
|
|||||||
results[id]['texts'][i] = race;
|
results[id]['texts'][i] = race;
|
||||||
results[id]['finished'] = true;
|
results[id]['finished'] = true;
|
||||||
} else {
|
} else {
|
||||||
|
var p1points = (regatta.a53 ? started[i] : gemeldet) + 1;
|
||||||
switch (race.toUpperCase()) {
|
switch (race.toUpperCase()) {
|
||||||
// Nicht gestartet
|
// Nicht gestartet
|
||||||
case 'DNC': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not come
|
case 'DNC': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not come
|
||||||
case 'DNS': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not started
|
case 'DNS': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Did not started
|
||||||
// Startfehler
|
// Startfehler
|
||||||
case 'OCS': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // On course site
|
case 'OCS': results[id]['values'][i] = p1points; copy[i] = p1points; break; // On course site
|
||||||
case 'UFD': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Uniform Flag Disqualified (disqu. nach 30.3)
|
case 'UFD': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Uniform Flag Disqualified (disqu. nach 30.3)
|
||||||
case 'BFD': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Black Flag Disqualified (disqu. nach 30.4)
|
case 'BFD': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Black Flag Disqualified (disqu. nach 30.4)
|
||||||
// Nicht durch Ziel gegangen
|
// Nicht durch Ziel gegangen
|
||||||
case 'DNF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not finish
|
case 'DNF': results[id]['values'][i] = p1points; copy[i] = p1points; 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] = p1points; copy[i] = p1points; 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] = p1points; copy[i] = p1points; break; // Retired after finish
|
||||||
|
// Kursfehler
|
||||||
|
case 'NSC': results[id]['values'][i] = p1points; copy[i] = p1points; 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] = p1points; copy[i] = p1points; 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] = p1points; copy[i] = -1; break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden)
|
||||||
case 'DGM': results[id]['values'][i] = gemeldet + 1; copy[i] = -2; break; // Disqualification Gross Missconduct (kann nach 69.1(b)(2) nicht gestr. werden, grobes Fehlverhalten)
|
case 'DGM': results[id]['values'][i] = p1points; copy[i] = -2; break; // Disqualification Gross Missconduct (kann nach 69.1(b)(2) nicht gestr. werden, grobes Fehlverhalten)
|
||||||
// Unbekannt
|
// Unbekannt
|
||||||
default: results[id]['values'][i] = 0; copy[i] = 0; break;
|
default: results[id]['values'][i] = 0; copy[i] = 0; break;
|
||||||
}
|
}
|
||||||
@@ -222,9 +236,10 @@ function dbGetResultCalculated(regatta) {
|
|||||||
var netto = 0;
|
var netto = 0;
|
||||||
for (var i = 0; i < regatta['races']; i ++) {
|
for (var i = 0; i < regatta['races']; i ++) {
|
||||||
brutto += results[id]['values_all'][i];
|
brutto += results[id]['values_all'][i];
|
||||||
if (copy[i] == -1) { results[id]['values'][i] = gemeldet + 1; }
|
/*if (copy[i] == -1) { results[id]['values'][i] = gemeldet + 1; }
|
||||||
else if (copy[i] == -2) { results[id]['values'][i] = gemeldet + 1; }
|
else if (copy[i] == -2) { results[id]['values'][i] = gemeldet + 1; }
|
||||||
else { results[id]['values'][i] = copy[i]; }
|
else { results[id]['values'][i] = copy[i]; }*/
|
||||||
|
if (copy[i] == 0) results[id]['values'][i] = 0;
|
||||||
if (results[id]['values'][i] == 0) {
|
if (results[id]['values'][i] == 0) {
|
||||||
results[id]['texts'][i] = '[' + results[id]['texts'][i] + ']';
|
results[id]['texts'][i] = '[' + results[id]['texts'][i] + ']';
|
||||||
}
|
}
|
||||||
@@ -256,10 +271,13 @@ function dbGetResultCalculated(regatta) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
function dbGetRanking(minDate, maxDate, maxAge, ageStrict, altM = 9, ageCrew = false, personMode = 0) {
|
||||||
return new Promise(async function(resolve) {
|
return new Promise(async function(resolve) {
|
||||||
var rankNoResults = [];
|
var rankNoResults = [];
|
||||||
|
|
||||||
|
// TODO: remove / Abwärtskompatibilität
|
||||||
|
//if (maxAge === true) maxAge = await dbGetClassProp('youth-age');
|
||||||
|
|
||||||
var sailors = await dbGetData('sailors');
|
var sailors = await dbGetData('sailors');
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
|
||||||
@@ -275,10 +293,15 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
|
|
||||||
for (var i in regattas) {
|
for (var i in regattas) {
|
||||||
var regatta = regattas[i];
|
var regatta = regattas[i];
|
||||||
|
var date = parseDate(regatta.date);
|
||||||
|
|
||||||
// regatta has to be min. 2 days to be ranking regatta
|
// regatta has to be min. 2 days to be ranking regatta
|
||||||
if (regatta.length < 2) continue;
|
if (regatta.length < 2) continue;
|
||||||
|
|
||||||
|
// regatta has to have rlf
|
||||||
|
if (regatta.rlf == 0) continue;
|
||||||
|
|
||||||
|
// get results
|
||||||
var results = await dbGetDataIndex('results', 'regatta', regatta.id);
|
var results = await dbGetDataIndex('results', 'regatta', regatta.id);
|
||||||
if (results.length <= 0) {
|
if (results.length <= 0) {
|
||||||
if (regatta.dateTo <= getToday()) {
|
if (regatta.dateTo <= getToday()) {
|
||||||
@@ -328,11 +351,28 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
if (result.rlp == 0) continue;
|
if (result.rlp == 0) continue;
|
||||||
|
|
||||||
// check if crew is youth
|
// check if crew is youth
|
||||||
// TODO: not used
|
if ((maxAge != false) && ageCrew) {
|
||||||
|
var crew = result.crew.split(',');
|
||||||
|
crew.push(result.steuermann);
|
||||||
|
var okay = true;
|
||||||
|
for (var ci in crew) {
|
||||||
|
var c = crew[ci];
|
||||||
|
if ((c == '') || !(c in sailorIds)) continue;
|
||||||
|
var sailor = sailors[sailorIds[c]];
|
||||||
|
if (((sailor.year != null) && (sailor.year < (formatDate('Y', date) - maxAge))) ||
|
||||||
|
((sailor.year == null) && (ageStrict))) {
|
||||||
|
okay = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!okay) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (personMode == 0 || personMode == 2) { // add to helmsman
|
||||||
sailors[sailorIds[result.steuermann]].regattas[regatta.id] = {
|
sailors[sailorIds[result.steuermann]].regattas[regatta.id] = {
|
||||||
regatta: regatta.id,
|
regatta: regatta.id,
|
||||||
boat: result.boat,
|
boat: result.boat,
|
||||||
|
helm: result.steuermann,
|
||||||
crew: result.crew,
|
crew: result.crew,
|
||||||
place: result.place,
|
place: result.place,
|
||||||
fb: fb,
|
fb: fb,
|
||||||
@@ -344,15 +384,37 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
sailors[sailorIds[result.steuermann]].tmp_rlp.push([regatta.id, result.rlp]);
|
sailors[sailorIds[result.steuermann]].tmp_rlp.push([regatta.id, result.rlp]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (personMode == 1 || personMode == 2) { // add to crew
|
||||||
|
var crew = result.crew.split(',');
|
||||||
|
for (var ci in crew) {
|
||||||
|
var c = crew[ci];
|
||||||
|
if ((c == '') || !(c in sailorIds)) continue;
|
||||||
|
sailors[sailorIds[c]].regattas[regatta.id] = {
|
||||||
|
regatta: regatta.id,
|
||||||
|
boat: result.boat,
|
||||||
|
helm: result.steuermann,
|
||||||
|
crew: result.crew,
|
||||||
|
place: result.place,
|
||||||
|
fb: fb,
|
||||||
|
rlp: result.rlp,
|
||||||
|
used: 0,
|
||||||
|
m: m
|
||||||
|
};
|
||||||
|
for (var j = 0; j < m; j ++) {
|
||||||
|
sailors[sailorIds[c]].tmp_rlp.push([regatta.id, result.rlp]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove not german or not youth sailors
|
// remove not german or not youth sailors
|
||||||
for (var i = sailors.length - 1; i >= 0; i --) {
|
for (var i = sailors.length - 1; i >= 0; i --) {
|
||||||
if (sailors[i].german == '0') {
|
if (sailors[i].german == '0') {
|
||||||
sailors.splice(i, 1);
|
sailors.splice(i, 1);
|
||||||
} else if (jugend) {
|
} else if (maxAge != false) {
|
||||||
if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - YOUTH_AGE))) ||
|
if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - maxAge))) ||
|
||||||
((sailors[i].year == null) && (jugstrict))) {
|
((sailors[i].year == null) && (ageStrict))) {
|
||||||
sailors.splice(i, 1);
|
sailors.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,7 +434,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
sum += parseFloat(r[1]);
|
sum += parseFloat(r[1]);
|
||||||
sailors[i].regattas[r[0]].used ++;
|
sailors[i].regattas[r[0]].used ++;
|
||||||
cnt ++;
|
cnt ++;
|
||||||
if (cnt >= 9) break;
|
if (cnt >= altM) break;
|
||||||
}
|
}
|
||||||
delete sailors[i].tmp_rlp;
|
delete sailors[i].tmp_rlp;
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
@@ -389,14 +451,49 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
return b.rlp - a.rlp;
|
return b.rlp - a.rlp;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var lastPoints = 0;
|
||||||
|
var lastRank = 1;
|
||||||
for (var i = 0; i < sailors.length; i ++) {
|
for (var i = 0; i < sailors.length; i ++) {
|
||||||
|
if (lastPoints == sailors[i].rlp) {
|
||||||
|
sailors[i].rank = lastRank;
|
||||||
|
} else {
|
||||||
sailors[i].rank = (i + 1);
|
sailors[i].rank = (i + 1);
|
||||||
|
lastRank = (i + 1);
|
||||||
|
lastPoints = sailors[i].rlp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve([sailors, rankNoResults]);
|
resolve([sailors, rankNoResults]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 +514,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);
|
||||||
@@ -459,8 +577,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') {
|
||||||
@@ -495,7 +621,7 @@ function sync() {
|
|||||||
localTimes[entry['table']] = entry['time'];
|
localTimes[entry['table']] = entry['time'];
|
||||||
});
|
});
|
||||||
|
|
||||||
syncInProgress = 11;
|
syncInProgress = 15;
|
||||||
var syncOkay = true;
|
var syncOkay = true;
|
||||||
log("[db] Sync Start");
|
log("[db] Sync Start");
|
||||||
$('#i-sync').addClass('fa-spin');
|
$('#i-sync').addClass('fa-spin');
|
||||||
@@ -525,6 +651,51 @@ 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// RANKINGS
|
||||||
|
getJSON(QUERY_URL + 'get_rankings', function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('rankings', 'readwrite').objectStore('rankings');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] rankings synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("[db] rankings: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] rankings 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) {
|
||||||
@@ -839,8 +1010,68 @@ function sync() {
|
|||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FOLLOWS
|
||||||
|
getJSON(QUERY_URL + 'get_follows', function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('follows', 'readwrite').objectStore('follows');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
syncInProgress -= 3;
|
syncInProgress --;
|
||||||
|
log('[db] follows synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("[db] follows: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] follows failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// EXPENDITURES
|
||||||
|
if (localTimes['expenditures'] < serverTimes['expenditures']) {
|
||||||
|
getJSON(QUERY_URL + 'get_expenditures?changed-after=' + localTimes['expenditures'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('expenditures', 'readwrite').objectStore('expenditures');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
} else {
|
||||||
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
|
osUpdateTimes.put({ table: 'expenditures', time: serverTimes['expenditures'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] expenditures synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("[db] expenditures: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] expenditures failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
syncInProgress -= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEWS
|
// NEWS
|
||||||
@@ -909,8 +1140,13 @@ function sync() {
|
|||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (code == 401) {
|
||||||
|
log("[db] Auth invalid. Logout initiated");
|
||||||
|
logoutClearStorage();
|
||||||
} else {
|
} else {
|
||||||
log("[db] Something went wrong (HTTP " + code + ")");
|
log("[db] Something went wrong (HTTP " + code + ")");
|
||||||
|
}
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress = 0;
|
syncInProgress = 0;
|
||||||
}
|
}
|
||||||
@@ -949,7 +1185,7 @@ function initDatabase() {
|
|||||||
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;
|
||||||
@@ -965,11 +1201,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 --;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1051,6 +1288,29 @@ function initDatabase() {
|
|||||||
osUpdateTimes.add({ table: 'news', time: 0 });
|
osUpdateTimes.add({ table: 'news', time: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 7) && (newVersion >= 7)) {
|
||||||
|
log('[db] to version 7');
|
||||||
|
var osClass = db.createObjectStore('class', { keyPath: 'key' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 8) && (newVersion >= 8)) {
|
||||||
|
log('[db] to version 8');
|
||||||
|
var osRankings = db.createObjectStore('rankings', { keyPath: 'id' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 9) && (newVersion >= 9)) {
|
||||||
|
log('[db] to version 9');
|
||||||
|
var osFollows = db.createObjectStore('follows', { keyPath: 'id' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 10) && (newVersion >= 10)) {
|
||||||
|
log('[db] to version 10');
|
||||||
|
var osExpenditures = db.createObjectStore('expenditures', { keyPath: 'id' });
|
||||||
|
osExpenditures.createIndex('user', 'user', { unique: false });
|
||||||
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
|
osUpdateTimes.add({ table: 'expenditures', time: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
// Force resync after db update
|
// Force resync after db update
|
||||||
if (oldVersion >= 1) {
|
if (oldVersion >= 1) {
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
@@ -1067,7 +1327,30 @@ function initDatabase() {
|
|||||||
function resetDb() {
|
function resetDb() {
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
showLoader();
|
showLoader();
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
db.transaction('clubs', 'readwrite').objectStore('clubs').clear();
|
||||||
|
db.transaction('boats', 'readwrite').objectStore('boats').clear();
|
||||||
|
db.transaction('sailors', 'readwrite').objectStore('sailors').clear();
|
||||||
|
db.transaction('regattas', 'readwrite').objectStore('regattas').clear();
|
||||||
|
db.transaction('results', 'readwrite').objectStore('results').clear();
|
||||||
|
db.transaction('plannings', 'readwrite').objectStore('plannings').clear();
|
||||||
|
db.transaction('trim_boats', 'readwrite').objectStore('trim_boats').clear();
|
||||||
|
db.transaction('trim_users', 'readwrite').objectStore('trim_users').clear();
|
||||||
|
db.transaction('trim_trims', 'readwrite').objectStore('trim_trims').clear();
|
||||||
|
db.transaction('users', 'readwrite').objectStore('users').clear();
|
||||||
|
db.transaction('years', 'readwrite').objectStore('years').clear();
|
||||||
|
db.transaction('news', 'readwrite').objectStore('news').clear();
|
||||||
|
db.transaction('class', 'readwrite').objectStore('class').clear();
|
||||||
|
db.transaction('rankings', 'readwrite').objectStore('rankings').clear();
|
||||||
|
db.transaction('follows', 'readwrite').objectStore('follows').clear();
|
||||||
|
db.transaction('expenditures', 'readwrite').objectStore('expenditures').clear();
|
||||||
|
var ta = db.transaction('update_times', 'readwrite');
|
||||||
|
ta.oncomplete = (event) => {
|
||||||
|
log('[db] resetDb: Transaction complete');
|
||||||
|
};
|
||||||
|
ta.onerror = (event) => {
|
||||||
|
log('[db] resetDb: Transaction failed');
|
||||||
|
};
|
||||||
|
var osUpdateTimes = ta.objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'last_sync', time: 1 });
|
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 });
|
||||||
@@ -1080,6 +1363,9 @@ 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 });
|
||||||
|
osUpdateTimes.put({ table: 'expenditures', time: 0 });
|
||||||
|
osUpdateTimes.put({ table: 'loggedin', status: isLoggedIn() });
|
||||||
|
ta.commit();
|
||||||
log('[db] DB update times reset');
|
log('[db] DB update times reset');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()));
|
||||||
|
|||||||
@@ -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,7 +1166,17 @@ 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);
|
||||||
|
|||||||
@@ -95,12 +95,11 @@ $(document).ready(function(){
|
|||||||
log('[pwa] 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')) {
|
||||||
|
setTimeout(function(){
|
||||||
function triggerPwaInstallIos() {
|
function triggerPwaInstallIos() {
|
||||||
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
||||||
setTimeout(function(){
|
|
||||||
$('.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) {
|
||||||
@@ -108,6 +107,7 @@ $(document).ready(function(){
|
|||||||
} else {
|
} else {
|
||||||
triggerPwaInstallIos();
|
triggerPwaInstallIos();
|
||||||
}
|
}
|
||||||
|
},3000);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,42 @@
|
|||||||
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');
|
||||||
|
|
||||||
|
// QUERY_URL changed in config.php (this is to update this file on client devices)
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
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();
|
||||||
@@ -36,6 +62,10 @@ var badges = {
|
|||||||
news: {
|
news: {
|
||||||
id: 'badge-more-news',
|
id: 'badge-more-news',
|
||||||
cnt: 0
|
cnt: 0
|
||||||
|
},
|
||||||
|
expenditures: {
|
||||||
|
id: 'badge-more-expenditures',
|
||||||
|
cnt: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +162,7 @@ function findGetParameter(parameterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 +177,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');
|
||||||
@@ -160,6 +192,7 @@ var login = function() {
|
|||||||
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,6 +213,7 @@ 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'),
|
||||||
@@ -197,6 +231,7 @@ 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('[app] Not logged in');
|
log('[app] Not logged in');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
@@ -211,12 +246,14 @@ var logout = function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
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();
|
||||||
@@ -233,11 +270,13 @@ function deleteDb() {
|
|||||||
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) {
|
||||||
@@ -275,16 +314,28 @@ function urlB64ToUint8Array(base64String) {
|
|||||||
function pushesSubscribe() {
|
function pushesSubscribe() {
|
||||||
log('[app] 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:', JSON.stringify(subscription));
|
||||||
|
if (await pushesUpdateServerSubscription(subscription, true)) {
|
||||||
|
log('[app] Subscription: Sent to server, updating UI');
|
||||||
|
dbSettingsSet('notify_endpoint_' + BOATCLASS, subscription.endpoint);
|
||||||
updatePushSwitches();
|
updatePushSwitches();
|
||||||
updatePushBadge();
|
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) {
|
||||||
|
$('#menu-pushes').hideMenu();
|
||||||
log('[app] Failed to subscribe the user: ', err);
|
log('[app] Failed to subscribe the user: ', err);
|
||||||
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
|
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);
|
||||||
@@ -294,13 +345,22 @@ function pushesSubscribe() {
|
|||||||
function pushesUnSubscribe(silent = false) {
|
function pushesUnSubscribe(silent = false) {
|
||||||
log('[app] Unsubscribing');
|
log('[app] Unsubscribing');
|
||||||
swRegistration.pushManager.getSubscription()
|
swRegistration.pushManager.getSubscription()
|
||||||
.then(function(subscription) {
|
.then(async function(subscription) {
|
||||||
|
log('[app] Subscription:', JSON.stringify(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) {
|
||||||
@@ -313,21 +373,22 @@ function pushesUnSubscribe(silent = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushesUpdateServerSubscription(subscription, enabled) {
|
function pushesUpdateServerSubscription(subscription, enabled) {
|
||||||
log('[app] updateServer', enabled, subscription);
|
return new Promise(function(resolve){
|
||||||
|
log('[app] updateServer', enabled, JSON.stringify(subscription));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { subscription: JSON.stringify(subscription) },
|
data: { subscription: JSON.stringify(subscription) },
|
||||||
success: function (data, textStatus, jqXHR) {
|
success: function (data, textStatus, jqXHR) {
|
||||||
if (!enabled) {
|
log('[app] Subscription sent to server');
|
||||||
toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
|
resolve(true);
|
||||||
}
|
|
||||||
hideLoader();
|
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
throw 'Cannot update server subscription';
|
log('[app] Error sending subscription to server');
|
||||||
|
resolve(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initPushSettings() {
|
async function initPushSettings() {
|
||||||
@@ -406,17 +467,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:', JSON.stringify(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 +508,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 ++;
|
||||||
@@ -437,6 +516,24 @@ async function updateNewsBadge() {
|
|||||||
updateBadge('more/news', sum);
|
updateBadge('more/news', sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateExpendituresBadge() {
|
||||||
|
let allExps = await dbGetData('expenditures');
|
||||||
|
let sum = 0;
|
||||||
|
for (let i in allExps) {
|
||||||
|
let exp = allExps[i];
|
||||||
|
if (exp.approved == 0) {
|
||||||
|
if (exp.direction < 0 && exp.canceled == 0) sum++;
|
||||||
|
if (exp.direction > 0 && exp.canceled == 1) sum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateBadge('more/expenditures', sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateBadges() {
|
||||||
|
updateNewsBadge();
|
||||||
|
updateExpendituresBadge();
|
||||||
|
}
|
||||||
|
|
||||||
var initRegatten = function() {
|
var initRegatten = function() {
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
||||||
@@ -466,7 +563,7 @@ var initRegatten = function() {
|
|||||||
|
|
||||||
var onServiceWorkerLoaded = function() {
|
var onServiceWorkerLoaded = function() {
|
||||||
log('[app] sW loaded');
|
log('[app] sW loaded');
|
||||||
if ((swRegistration !== null) && canUseLocalDB) {
|
if ((swRegistration !== null) && (swRegistration.pushManager) && canUseLocalDB) {
|
||||||
pushesPossible = true;
|
pushesPossible = true;
|
||||||
updatePushBadge();
|
updatePushBadge();
|
||||||
} else {
|
} else {
|
||||||
@@ -493,11 +590,35 @@ var onDatabaseLoaded = function() {
|
|||||||
onServiceWorkerLoaded();
|
onServiceWorkerLoaded();
|
||||||
initPushSettings();
|
initPushSettings();
|
||||||
|
|
||||||
updateNewsBadge();
|
updateBadges();
|
||||||
}
|
}
|
||||||
|
|
||||||
var onAfterSync = function() {
|
var onAfterSync = function() {
|
||||||
updateNewsBadge();
|
updateBadges();
|
||||||
|
}
|
||||||
|
|
||||||
|
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: JSON.stringify(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
|
||||||
@@ -505,19 +626,52 @@ 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 = '</>';
|
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);
|
||||||
}, 5000);
|
$(button).hide();
|
||||||
}
|
}
|
||||||
addConsoleOpenerToPreloader();
|
addConsoleOpenerToPreloader();
|
||||||
|
|
||||||
|
function m2s_getLink(type, eventId, classId) {
|
||||||
|
switch (type) {
|
||||||
|
case 'entrylist':
|
||||||
|
return 'https://manage2sail.com/de-DE/event/' + eventId + '#!/entries?classId=' + classId;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
function ro_getLink(type, eventId, classId) {
|
||||||
|
switch (type) {
|
||||||
|
case 'entrylist':
|
||||||
|
return 'http://www.raceoffice.org/entrylist.php?eid=' + eventId;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
function wfn_getLink(type, eventId, classId) {
|
||||||
|
switch (type) {
|
||||||
|
case 'entrylist':
|
||||||
|
return 'https://wettfahrten.net/event/' + eventId + '/entrylist?class=' + classId;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
function extServiceGetLink(serviceName, type, eventId = '', classId = '') {
|
||||||
|
switch (serviceName) {
|
||||||
|
case 'm2s':
|
||||||
|
return m2s_getLink(type, eventId, classId);
|
||||||
|
case 'ro':
|
||||||
|
return ro_getLink(type, eventId, classId);
|
||||||
|
case 'wfn':
|
||||||
|
return wfn_getLink(type, eventId, classId);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|||||||
@@ -144,6 +144,72 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** EXPENDITURES LIST ***/
|
||||||
|
.expenditures-list.display-border > div {
|
||||||
|
border-bottom: 1px solid #dee2e6;
|
||||||
|
}
|
||||||
|
.expenditures-list > div {
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list > div:last-child {
|
||||||
|
border: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list div {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list > div > div > div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list > div > div:nth-child(1) > div:nth-child(1) {
|
||||||
|
width: calc(75% - 1.5em);
|
||||||
|
}
|
||||||
|
.expenditures-list > div > div:nth-child(1) > div:nth-child(2) {
|
||||||
|
width: 25%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.expenditures-list > div > div:nth-child(1) > div:nth-child(3) {
|
||||||
|
width: 1.5em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list > div > div:nth-child(2) > div:nth-child(1) {
|
||||||
|
width: 6em;
|
||||||
|
}
|
||||||
|
.expenditures-list > div > div:nth-child(2) > div:nth-child(2) {
|
||||||
|
width: calc(70% - 6em);
|
||||||
|
overflow-x: visible;
|
||||||
|
}
|
||||||
|
.expenditures-list > div > div:nth-child(2) > div:nth-child(3) {
|
||||||
|
width: 30%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expenditures-list > div.sum {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.expenditures-list > div.sum > div:nth-child(1) {
|
||||||
|
background: #dee2e6;
|
||||||
|
height: 1px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.expenditures-list > div.sum > div:nth-child(1) > div:nth-child(1) {
|
||||||
|
background: #fff;
|
||||||
|
width: initial;
|
||||||
|
margin-top: -1em;
|
||||||
|
padding: 0 .5em;
|
||||||
|
}
|
||||||
|
.theme-dark .expenditures-list > div.sum > div:nth-child(1) > div:nth-child(1) {
|
||||||
|
background-color: #0f1117;
|
||||||
|
}
|
||||||
|
|
||||||
/*** NORMAL LIST ***/
|
/*** NORMAL LIST ***/
|
||||||
.normal-list > div {
|
.normal-list > div {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$sp['title'] = 'Boote - Regatten.net ' . $_CLASS['name'];
|
$sp['title'] = 'Boote - Regatten.net ' . $_CLASS['name'];
|
||||||
$sp['backbutton'] = 'index';
|
$sp['backbutton'] = 'index';
|
||||||
$sp['activenav'] = 4;
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = "<h1>Boote</h1>";
|
$content = "<h1>Boote</h1>";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$sp['title'] = 'Vereine - Regatten.net ' . $_CLASS['name'];
|
$sp['title'] = 'Vereine - Regatten.net ' . $_CLASS['name'];
|
||||||
$sp['backbutton'] = 'index';
|
$sp['backbutton'] = 'index';
|
||||||
$sp['activenav'] = 4;
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = "<h1>Vereine</h1>";
|
$content = "<h1>Vereine</h1>";
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
$content .= 'Egal was es ist, lass es uns wissen! Schreibe uns eine Mail an <a href="mailto:info@regatten.net">info@regatten.net</a> oder nutze einfach dieses Kontakt-Formular.<br>';
|
$content .= 'Egal was es ist, lass es uns wissen! Schreibe uns eine Mail an <a href="mailto:info@regatten.net">info@regatten.net</a> oder nutze einfach dieses Kontakt-Formular.<br>';
|
||||||
$content .= 'Wir werden Deine Anfrage so schnell wie möglich bearbeiten.';
|
$content .= 'Wir werden Deine Anfrage so schnell wie möglich bearbeiten.';
|
||||||
$content .= '</p>';
|
$content .= '</p>';
|
||||||
$content .= '<p>';
|
//$content .= '<p>';
|
||||||
$content .= 'Alternativ erreichst Du uns auch telefonisch unter <a href="tel:+4941039659768">+49 (0) 4103 965 976 8</a><br>';
|
//$content .= 'Alternativ erreichst Du uns auch telefonisch unter <a href="tel:+4941039659768">+49 (0) 4103 965 976 8</a><br>';
|
||||||
$content .= 'Mo-Fr: 7-20 Uhr<br>';
|
//$content .= 'Mo-Fr: 7-20 Uhr<br>';
|
||||||
$content .= 'Sa: 9-17 Uhr';
|
//$content .= 'Sa: 9-17 Uhr';
|
||||||
$content .= '</p>';
|
//$content .= '</p>';
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
|||||||
80
server/content/expenditures-user.php
Normal file
80
server/content/expenditures-user.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sp['title'] = 'Ausgaben-Verwaltung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'expenditures';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
|
// Title
|
||||||
|
$content = "<h1>Ausgaben-Verwaltung</h1>";
|
||||||
|
$content .= '<p id="p-username" class="mb-1"></p>';
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-plus"></i> Neue Ausgabe', '#', 'html-id' => 'button-add', 'css-class' => 'mt-3 mb-2']);
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-plus"></i> Neuer Geldtransfer', '#', 'html-id' => 'button-add-transfer', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Not loggedin
|
||||||
|
$content = '<h1>Ausgaben-Verwaltung</h1>';
|
||||||
|
$content .= '<p>Um die Ausgaben-Verwaltung nutzen zu können, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="https://regatten.net/#signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
|
// List
|
||||||
|
$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-list" class="expenditures-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-list', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Legend
|
||||||
|
$content = '<p>';
|
||||||
|
$content .= '<i class="fas fa-check"></i> genehmigt<br>';
|
||||||
|
$content .= '<i class="fas fa-times"></i> storniert<br>';
|
||||||
|
$content .= '<i class="fas fa-hourglass-half"></i> wartet auf Zustimmung von <span class="span-username"></span><br>';
|
||||||
|
$content .= '<i class="fas fa-exclamation"></i> wartet auf Deine Zustimmung';
|
||||||
|
$content .= '</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
$items = $tpl->load('menu/item-icon', ['Akzeptieren', '#', 'html-id' => 'menu-item-approve', 'icon' => 'fa-check']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Ablehnen', '#', 'html-id' => 'menu-item-decline', 'icon' => 'fa-times']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Stornieren', '#', 'html-id' => 'menu-item-cancel', 'icon' => 'fa-times']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-expenditure', 'title' => 'Ausgabe', 'height' => 200]);
|
||||||
|
|
||||||
|
// Menu Add
|
||||||
|
$items = $tpl->load('menu/item-simple', ['bezahlt von: ', '#', 'html-id' => 'item-add-user-from']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-date', 'placeholder' => 'Datum des Transfers', 'type' => 'date', 'css-class' => 'mt-3']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-amount', 'placeholder' => 'Betrag in Euro', 'type' => 'number" min="0.01" step="0.01']);
|
||||||
|
$options = '<option value="entryfee">Meldegeld</option>';
|
||||||
|
$options .= '<option value="camping">Camping</option>';
|
||||||
|
$options .= '<option value="food">Essen</option>';
|
||||||
|
$options .= '<option value="other">andere</option>';
|
||||||
|
$items .= $tpl->load('select', ['html-id' => 'select-add-purpose', 'placeholder' => 'Verwendung', 'options' => $options]);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-regatta-name', 'placeholder' => 'Name der Regatta (optional)', 'type' => 'text']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-purpose-text', 'placeholder' => 'Verwendungszweck (optional)', 'type' => 'text']);
|
||||||
|
$items .= '<p style="line-height: normal; margin-bottom: 0;">Für wen wurde das Geld ausgegeben? (z.B. Du und Dein Segelpartner)<br>Hinweis: Der angegebene Betrag wird durch die Personen geteilt, die Du hier auswählst.</p>';
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['<span style="font-style:italic;">Weiteren Benutzer hinzufügen</span>', '#', 'html-id' => 'item-add-user-to']);
|
||||||
|
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-add-save', 'css-class' => 'mb-3']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-add', 'title' => 'Neue Ausgabe', 'height' => '90vh', 'width' => '90vw']);
|
||||||
|
|
||||||
|
// Menu Add Transfer
|
||||||
|
$items = $tpl->load('menu/item-switch', ['Geld bekommen', 'html-id' => 'switch-add-transfer-received', 'icon' => 'fa-arrow-left']);
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['von: <font style="font-style:italic;">bitte auswählen</font>', '#', 'html-id' => 'item-add-transfer-user']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-date', 'placeholder' => 'Datum des Transfers', 'type' => 'date', 'css-class' => 'mt-3']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-amount', 'placeholder' => 'Betrag in Euro', 'type' => 'number" min="0.01" step="0.01']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-purpose-text', 'placeholder' => 'Verwendungszweck (optional)', 'type' => 'text']);
|
||||||
|
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-add-transfer-save']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-add-transfer', 'title' => 'Neuer Geldtransfer', 'height' => 470, 'width' => '90vw']);
|
||||||
|
|
||||||
|
// Select user
|
||||||
|
$items = $tpl->load('input', ['html-id' => 'input-user-search', 'placeholder' => 'Suche...', 'type' => 'text']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-select-user', 'title' => 'Benutzer auswählen', 'height' => 500, 'width' => '90vw']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||||
|
$sp['scripts'] .= $scripts->load('expenditures-add');
|
||||||
|
$sp['scripts'] .= $scripts->load('expenditures-user');
|
||||||
|
|
||||||
|
?>
|
||||||
63
server/content/expenditures.php
Normal file
63
server/content/expenditures.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sp['title'] = 'Ausgaben-Verwaltung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'index';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
|
// Title
|
||||||
|
$content = "<h1>Ausgaben-Verwaltung</h1>";
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-plus"></i> Neue Ausgabe', '#', 'html-id' => 'button-add', 'css-class' => 'mt-3 mb-2']);
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-plus"></i> Neuer Geldtransfer', '#', 'html-id' => 'button-add-transfer', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Not loggedin
|
||||||
|
$content = '<h1>Ausgaben-Verwaltung</h1>';
|
||||||
|
$content .= '<p>Um die Ausgaben-Verwaltung nutzen zu können, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="https://regatten.net/#signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
|
// List
|
||||||
|
$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-list" class="normal-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-list', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Menu Add
|
||||||
|
$items = $tpl->load('menu/item-simple', ['bezahlt von: ', '#', 'html-id' => 'item-add-user-from']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-date', 'placeholder' => 'Datum des Transfers', 'type' => 'date', 'css-class' => 'mt-3']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-amount', 'placeholder' => 'Betrag in Euro', 'type' => 'number" min="0.01" step="0.01']);
|
||||||
|
$options = '<option value="entryfee">Meldegeld</option>';
|
||||||
|
$options .= '<option value="camping">Camping</option>';
|
||||||
|
$options .= '<option value="food">Essen</option>';
|
||||||
|
$options .= '<option value="other">andere</option>';
|
||||||
|
$items .= $tpl->load('select', ['html-id' => 'select-add-purpose', 'placeholder' => 'Verwendung', 'options' => $options]);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-regatta-name', 'placeholder' => 'Name der Regatta (optional)', 'type' => 'text']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-purpose-text', 'placeholder' => 'Verwendungszweck (optional)', 'type' => 'text']);
|
||||||
|
$items .= '<p style="line-height: normal; margin-bottom: 0;">Für wen wurde das Geld ausgegeben? (z.B. Du und Dein Segelpartner)<br>Hinweis: Der angegebene Betrag wird durch die Personen geteilt, die Du hier auswählst.</p>';
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['<span style="font-style:italic;">Weiteren Benutzer hinzufügen</span>', '#', 'html-id' => 'item-add-user-to']);
|
||||||
|
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-add-save', 'css-class' => 'mb-3']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-add', 'title' => 'Neue Ausgabe', 'height' => '90vh', 'width' => '90vw']);
|
||||||
|
|
||||||
|
// Menu Add Transfer
|
||||||
|
$items = $tpl->load('menu/item-switch', ['Geld bekommen', 'html-id' => 'switch-add-transfer-received', 'icon' => 'fa-arrow-left']);
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['von: <font style="font-style:italic;">bitte auswählen</font>', '#', 'html-id' => 'item-add-transfer-user']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-date', 'placeholder' => 'Datum des Transfers', 'type' => 'date', 'css-class' => 'mt-3']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-amount', 'placeholder' => 'Betrag in Euro', 'type' => 'number" min="0.01" step="0.01']);
|
||||||
|
$items .= $tpl->load('input', ['html-id' => 'input-add-transfer-purpose-text', 'placeholder' => 'Verwendungszweck (optional)', 'type' => 'text']);
|
||||||
|
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-add-transfer-save']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-add-transfer', 'title' => 'Neuer Geldtransfer', 'height' => 470, 'width' => '90vw']);
|
||||||
|
|
||||||
|
// Select user
|
||||||
|
$items = $tpl->load('input', ['html-id' => 'input-user-search', 'placeholder' => 'Suche...', 'type' => 'text']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-select-user', 'title' => 'Benutzer auswählen', 'height' => 500, 'width' => '90vw']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||||
|
$sp['scripts'] .= $scripts->load('expenditures-add');
|
||||||
|
$sp['scripts'] .= $scripts->load('expenditures');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
// 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ähle bis zu fünf Segler aus.';
|
$content .= 'Um jemandem zu folgen, gehe zur <a href="' . LINK_PRE . 'sailors">Segler-Liste</a> und wähle bis zu fünf Segler aus.';
|
||||||
@@ -33,11 +32,23 @@
|
|||||||
$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önnen, <a href="#" data-menu="menu-login">logge Dich bitte ein</a>.<br>';
|
$content .= 'Um alle Funktionen dieser Seite nutzen zu kö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="https://regatten.net/#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 über alle Änderungen.<br>';
|
||||||
|
$content .= 'Du bestimmst natürlich, welche Benachrichtigungen Du bekommen möchtest.';
|
||||||
|
$content .= '</p>';
|
||||||
|
$content .= $tpl->load('button', ['Jetzt aktivieren', '#', 'html-id' => 'button-notifications-activate', 'css-class' => 'bg-green2-dark']);
|
||||||
|
$content .= '<p class="text-center mt-3"><a id="a-notifications-later" class="color-grey2-light text-uppercase font-900">Vielleicht später</a></p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notifications', 'css-class' => 'bg-blue2-dark']);
|
||||||
|
|
||||||
// Next
|
// Next
|
||||||
$content = '<h2>Nächste Regatten</h2>';
|
$content = '<h2>Nä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>';
|
||||||
@@ -61,23 +72,30 @@
|
|||||||
$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>';
|
||||||
$content .= '<p><b>Nur die Regatten, zu denen Du gehst?</b><br>Auch kein Problem! ';
|
$content .= '<p><b>Nur die Regatten, zu denen Du gehst?</b><br>Auch kein Problem! ';
|
||||||
$content .= '<font class="show-loggedin">Erstelle einfach eine <a href="' . LINK_PRE . 'planning">Saison-Planung</a> und abonniere Deinen persönlichen Kalender.</font>';
|
$content .= '<font class="show-loggedin">Erstelle einfach eine <a href="' . LINK_PRE . 'planning">Saison-Planung</a> und abonniere Deinen persönlichen Kalender.</font>';
|
||||||
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-signup">Registriere Dich einfach kostenlos</a>, erstelle eine Saison-Planung und wir erstellen Dir einen persönlichen Kalender.</font>';
|
$content .= '<font class="show-notloggedin"><a href="https://regatten.net/#signup">Registriere Dich einfach kostenlos</a>, erstelle eine Saison-Planung und wir erstellen Dir einen persönlichen Kalender.</font>';
|
||||||
$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://ranglisten.net/client/calendar/' . BOATCLASS . '/everything.ics', 'css-class' => 'mb-2']);
|
||||||
$content .= $tpl->load('button', ['<i class="fas fa-calendar-alt"></i> Kalender fü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ür <font class="replace-username"></font>', 'https://ranglisten.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', ['Fakten', '', 'html-id' => 'menu-item-facts', 'icon' => 'fa-list']);
|
||||||
$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']);
|
||||||
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
$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' => 400]);
|
||||||
|
|
||||||
|
// 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');
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
|
|
||||||
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||||
$sp['backbutton'] = 'index';
|
$sp['backbutton'] = 'index';
|
||||||
$sp['activenav'] = 5;
|
$sp['activenav'] = 4;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = '<h1>Saison-Planung</h1>';
|
$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 .= '<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']);
|
$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']);
|
||||||
|
|
||||||
// Not loggedin
|
// Not loggedin
|
||||||
$content = '<h1>Saison-Planung</h1>';
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
$content .= '<p>Um Deine Saison-Planung zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
|
$content .= '<p>Um Deine Saison-Planung zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="https://regatten.net/#signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
@@ -26,16 +27,19 @@
|
|||||||
$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', ['Fakten', '', 'html-id' => 'menu-item-facts', 'icon' => 'fa-list']);
|
||||||
$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']);
|
||||||
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
$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' => 400]);
|
||||||
|
|
||||||
// Menu Edit status
|
// Menu Edit status
|
||||||
$items = $tpl->load('menu/item-switch', ['Gemeldet', 'html-id' => 'switch-status-gemeldet', 'icon' => 'fa-file-signature']);
|
$items = $tpl->load('menu/item-switch', ['Gemeldet', 'html-id' => 'switch-status-gemeldet', 'icon' => 'fa-file-signature']);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?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'] = 4;
|
||||||
|
|
||||||
// Title, Inputs
|
// Title, Inputs
|
||||||
$content = "<h1>Saison-Planung bearbeiten</h1>";
|
$content = "<h1>Saison-Planung bearbeiten</h1>";
|
||||||
@@ -19,8 +19,13 @@
|
|||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
$items = $tpl->load('menu/item-switch', ['In die Saison-Planung aufnehmen', 'html-id' => 'switch-planning-include', 'icon' => 'fa-check']);
|
$items = $tpl->load('menu/item-switch', ['In die Saison-Planung aufnehmen', 'html-id' => 'switch-planning-include', 'icon' => 'fa-check']);
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['', '#', 'html-id' => 'item-boat']);
|
||||||
$items .= $tpl->load('menu/item-simple', ['', '#', 'html-id' => 'item-steuermann']);
|
$items .= $tpl->load('menu/item-simple', ['', '#', 'html-id' => 'item-steuermann']);
|
||||||
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edit', 'title' => 'Regatta bearbeiten', 'height' => 320]);
|
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edit', 'title' => 'Regatta bearbeiten', 'height' => 400]);
|
||||||
|
|
||||||
|
// Select boat
|
||||||
|
$items = $tpl->load('input', ['html-id' => 'input-edit-boat-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-boat', 'height' => 500, 'width' => 350]);
|
||||||
|
|
||||||
// Select sailor
|
// Select sailor
|
||||||
$items = $tpl->load('input', ['html-id' => 'input-edit-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
$items = $tpl->load('input', ['html-id' => 'input-edit-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?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'] = 4;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = '<h1>Saison-Planungen</h1>';
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
// Not loggedin
|
// Not loggedin
|
||||||
$content = '<h1>Saison-Planungen</h1>';
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
$content .= '<p>Um die Saison-Planungen anderer zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
|
$content .= '<p>Um die Saison-Planungen anderer zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="https://regatten.net/#signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?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'] = 4;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = '<h1>Saison-Planung</h1>';
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
@@ -20,15 +20,18 @@
|
|||||||
$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', ['Fakten', '', 'html-id' => 'menu-item-facts', 'icon' => 'fa-list']);
|
||||||
$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']);
|
||||||
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
$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' => 400]);
|
||||||
|
|
||||||
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
||||||
$sp['scripts'] .= $scripts->load('planning_view');
|
$sp['scripts'] .= $scripts->load('planning_view');
|
||||||
|
|||||||
@@ -7,22 +7,22 @@
|
|||||||
// Title, Inputs
|
// Title, Inputs
|
||||||
$content = "<h1>Ranglisten</h1>";
|
$content = "<h1>Ranglisten</h1>";
|
||||||
|
|
||||||
$options = '<option value="year">Jahres-Rangliste</option>';
|
|
||||||
$options .= '<option value="youth">Jugend-Rangliste</option>';
|
|
||||||
$options .= '<option value="idjm">' . $_CLASS['youth-german-name'] . '-Rangliste</option>';
|
|
||||||
$options .= '<option value="user">Benutzerdefiniert</option>';
|
|
||||||
$content .= $tpl->load('select', ['html-id' => 'select-type', 'placeholder' => 'Rangliste', 'options' => $options, '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('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
$content .= $tpl->load('select', ['html-id' => 'select-type', 'placeholder' => 'Rangliste', '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']);
|
||||||
$chbox = $tpl->load('checkbox', ['html-id' => 'input-jugend', 'placeholder' => 'Jugend']);
|
$content .= $tpl->load('input', ['html-id' => 'input-altm', 'placeholder' => 'alt. m', 'type' => 'number']);
|
||||||
$content .= '<div class="mb-3" style="display:inline-block; width:50%;">' . $chbox . '</div>';
|
$content .= $tpl->load('input', ['html-id' => 'input-maxage', 'placeholder' => 'max. Alter (leer = nicht prüfen)', 'type' => 'number']);
|
||||||
$chbox = $tpl->load('checkbox', ['html-id' => 'input-jugstrict', 'placeholder' => 'Streng']);
|
$content .= $tpl->load('checkbox', ['html-id' => 'input-agestrict', 'placeholder' => 'unb. Jahrgänge ausschließen']);
|
||||||
$content .= '<div class="mb-3" style="display:inline-block; width:50%;">' . $chbox . '</div>';
|
$content .= $tpl->load('checkbox', ['html-id' => 'input-agecrew', 'placeholder' => 'Crew auch prüfen']);
|
||||||
$content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show']);
|
$content .= $tpl->load('select', ['html-id' => 'select-personmode', 'placeholder' => 'nach', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
$content .= $tpl->load('button', ['Anzeigen', '#', 'html-id' => 'button-show', 'css-class' => 'mt-3']);
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
// Sepcial ranks
|
||||||
|
$sp['output'] .= $tpl->load('card', ['', 'html-id' => 'card-special-ranks']);
|
||||||
|
|
||||||
// No Results
|
// No Results
|
||||||
$content = '<h2 class="color-white">ACHTUNG</h2>';
|
$content = '<h2 class="color-white">ACHTUNG</h2>';
|
||||||
$content .= '<p class="color-white">Zu folgenden Regatten wurden noch keine Ergebnisse hinterlegt:</p>';
|
$content .= '<p class="color-white">Zu folgenden Regatten wurden noch keine Ergebnisse hinterlegt:</p>';
|
||||||
|
|||||||
49
server/content/regatta_facts.php
Normal file
49
server/content/regatta_facts.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sp['title'] = 'Fakten - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = true;
|
||||||
|
$sp['activenav'] = 2;
|
||||||
|
|
||||||
|
// Title, Inputs
|
||||||
|
$content = '<h1 id="h1-title"></h1>';
|
||||||
|
$content .= '<p id="p-title"></p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
// NO FACTS INFO
|
||||||
|
$content = '<p>Es sind keine Fakten zu dieser Veranstaltung hinterlegt. Bitte lies die Ausschreibung.</p>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-nofactsinfo']);
|
||||||
|
|
||||||
|
// Meldegeld
|
||||||
|
$content = '<h2>Meldegeld</h2>';
|
||||||
|
$content .= '<p></p>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-entryfee']);
|
||||||
|
|
||||||
|
// Wettfahrten
|
||||||
|
$content = '<h2>Wettfahrten</h2>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-races']);
|
||||||
|
|
||||||
|
// Zeitplan
|
||||||
|
$content = '<h2>Zeitplan</h2>';
|
||||||
|
$content .= $tpl->load('table', ['css-class' => 'mb-0 text-nowrap']);
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-times']);
|
||||||
|
|
||||||
|
// Camping
|
||||||
|
$content = '<h2>Camping</h2>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-camping']);
|
||||||
|
|
||||||
|
// Verpflegung
|
||||||
|
$content = '<h2>Verpflegung</h2>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-food']);
|
||||||
|
|
||||||
|
// Weitere Infos
|
||||||
|
$content = '<h2>Weitere Informationen</h2><p></p>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-text']);
|
||||||
|
|
||||||
|
// Disclaimer
|
||||||
|
$content = '<p><i>Alle Angaben ohne Gewähr. Änderungen vorbehalten. Am Ende gilt, was in der Ausschreibung / Segelanweisung steht!</i></p>';
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('regatta_facts');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
// Plannings
|
// Plannings
|
||||||
$content = '<p id="p-info" class="mb-0"></p>';
|
$content = '<p id="p-info" class="mb-0"></p>';
|
||||||
$thead = '<tr><th>Benutzer</th><th>Steuermann/-frau</th><th>Crew</th></tr>';
|
$thead = '<tr><th>Benutzer</th><th>Boot</th><th>Steuermann/-frau</th><th>Crew</th></tr>';
|
||||||
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-plannings', 'css-class' => 'mb-0 text-nowrap']);
|
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-plannings', 'css-class' => 'mb-0 text-nowrap']);
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-plannings']);
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-plannings']);
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
$content = '<p>Du planst, hier hinzufahren, aber stehst nicht auf dieser Liste?<br>';
|
$content = '<p>Du planst, hier hinzufahren, aber stehst nicht auf dieser Liste?<br>';
|
||||||
$content .= 'Das kannst Du ändern! ';
|
$content .= 'Das kannst Du ändern! ';
|
||||||
$content .= '<font class="show-loggedin">Erstelle einfach <a href="' . LINK_PRE . 'planning">hier</a> Deine eigene Saison-Planung.</font>';
|
$content .= '<font class="show-loggedin">Erstelle einfach <a href="' . LINK_PRE . 'planning">hier</a> Deine eigene Saison-Planung.</font>';
|
||||||
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-login">Melde Dich an</a> oder <a href="#" data-menu="menu-signup">registriere Dich kostenlos</a> und erstelle Deine eigene Saison-Planung.</font>';
|
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-login">Melde Dich an</a> oder <a href="https://regatten.net/#signup">registriere Dich kostenlos</a> und erstelle Deine eigene Saison-Planung.</font>';
|
||||||
$content .= '</p>';
|
$content .= '</p>';
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
// To today
|
||||||
|
$content = $tpl->load('button', ['<i class="fas fa-arrow-down"></i> Heute <i class="fas fa-arrow-down"></i>', '#', 'html-id' => 'button-totoday']);
|
||||||
|
|
||||||
|
$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']);
|
||||||
@@ -21,16 +26,21 @@
|
|||||||
|
|
||||||
$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', ['Fakten', '', 'html-id' => 'menu-item-facts', 'icon' => 'fa-list']);
|
||||||
$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']);
|
||||||
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
$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' => 400]);
|
||||||
|
|
||||||
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
||||||
$sp['scripts'] .= $scripts->load('regattas');
|
$sp['scripts'] .= $scripts->load('regattas');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$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'] = 5;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = "<h1>Segler</h1>";
|
$content = "<h1>Segler</h1>";
|
||||||
@@ -31,9 +31,11 @@
|
|||||||
$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']);
|
||||||
|
|||||||
@@ -15,6 +15,6 @@
|
|||||||
<a href="<?php echo LINK_PRE; ?>index"<?php if ($sp['activenav'] == 1) echo ' class="active-nav"'; ?>><i class="fa fa-home"></i><span>Start</span></a>
|
<a href="<?php echo LINK_PRE; ?>index"<?php if ($sp['activenav'] == 1) echo ' class="active-nav"'; ?>><i class="fa fa-home"></i><span>Start</span></a>
|
||||||
<a href="<?php echo LINK_PRE; ?>regattas"<?php if ($sp['activenav'] == 2) echo ' class="active-nav"'; ?>><i class="fa fa-flag-checkered"></i><span>Regatten</span></a>
|
<a href="<?php echo LINK_PRE; ?>regattas"<?php if ($sp['activenav'] == 2) echo ' class="active-nav"'; ?>><i class="fa fa-flag-checkered"></i><span>Regatten</span></a>
|
||||||
<a href="<?php echo LINK_PRE; ?>rank"<?php if ($sp['activenav'] == 3) echo ' class="active-nav"'; ?>><i class="fa fa-trophy"></i><span>Ranglisten</span></a>
|
<a href="<?php echo LINK_PRE; ?>rank"<?php if ($sp['activenav'] == 3) echo ' class="active-nav"'; ?>><i class="fa fa-trophy"></i><span>Ranglisten</span></a>
|
||||||
<a href="#" data-menu="menu-lists"<?php if ($sp['activenav'] == 4) echo ' class="active-nav"'; ?>><i class="fa fa-list"></i><span>Listen</span></a>
|
<a href="<?php echo LINK_PRE; ?>planning"<?php if ($sp['activenav'] == 4) echo ' class="active-nav"'; ?>><i class="fa fa-calendar-alt"></i><span>Planung</span></a>
|
||||||
<a href="#" data-menu="menu-more"<?php if ($sp['activenav'] == 5) echo ' class="active-nav"'; ?>><i class="fa fa-ellipsis-h"></i><span>Mehr</span><em id="badge-footer-more" class="badge bg-highlight"></em></a>
|
<a href="#" data-menu="menu-more"<?php if ($sp['activenav'] == 5) echo ' class="active-nav"'; ?>><i class="fa fa-ellipsis-h"></i><span>Mehr</span><em id="badge-footer-more" class="badge bg-highlight"></em></a>
|
||||||
</div>
|
</div>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-more" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="360" >
|
<div id="menu-more" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="410" >
|
||||||
<div class="menu-title"><h1>Mehr</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
<div class="menu-title"><h1>Mehr</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="divider divider-margins mb-n2"></div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@@ -68,9 +68,10 @@
|
|||||||
<span id="badge-more-news" class="badge bg-highlight color-white"></span>
|
<span id="badge-more-news" class="badge bg-highlight color-white"></span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="<?php echo LINK_PRE; ?>planning">
|
<a href="<?php echo LINK_PRE; ?>expenditures" class="show-loggedin">
|
||||||
<i class="fa font-14 fa-calendar-alt rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-money-bill-wave rounded-s bg-highlight color-white"></i>
|
||||||
<span>Saison-Planung</span>
|
<span>Ausgaben-Verwaltung</span>
|
||||||
|
<span id="badge-more-expenditures" class="badge bg-highlight color-white"></span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="<?php echo LINK_PRE; ?>trim_list">
|
<a href="<?php echo LINK_PRE; ?>trim_list">
|
||||||
@@ -83,6 +84,11 @@
|
|||||||
<span>RLP-Rechner</span>
|
<span>RLP-Rechner</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="#" data-menu="menu-lists">
|
||||||
|
<i class="fa font-14 fa-list rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Listen</span>
|
||||||
|
<i class="fa fa-angle-right"></i>
|
||||||
|
</a>
|
||||||
<a href="<?php echo LINK_PRE; ?>contact" class="border-0">
|
<a href="<?php echo LINK_PRE; ?>contact" class="border-0">
|
||||||
<i class="fa font-14 fa-phone rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-phone rounded-s bg-highlight color-white"></i>
|
||||||
<span>Kontakt</span>
|
<span>Kontakt</span>
|
||||||
@@ -92,12 +98,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</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="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="divider divider-margins mb-n2"></div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="list-group list-custom-small">
|
<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">
|
<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>
|
<i class="fa font-14 fa-moon rounded-s bg-dark1-dark color-white"></i>
|
||||||
<span>Dark Mode</span>
|
<span>Dark Mode</span>
|
||||||
@@ -106,13 +111,12 @@
|
|||||||
<label class="custom-control-label" for="switch-dark"></label>
|
<label class="custom-control-label" for="switch-dark"></label>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
|
||||||
<a href="#" data-menu="menu-login" class="show-notloggedin">
|
<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>
|
<i class="fa font-14 fa-sign-in-alt rounded-s bg-highlight color-white"></i>
|
||||||
<span>Login</span>
|
<span>Login</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" data-menu="menu-signup" class="show-notloggedin">
|
<a href="https://regatten.net/#signup" class="show-notloggedin">
|
||||||
<i class="fa font-14 fa-user-plus rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-user-plus rounded-s bg-highlight color-white"></i>
|
||||||
<span>Registrieren</span>
|
<span>Registrieren</span>
|
||||||
<span class="badge bg-red2-dark color-white">FREE</span>
|
<span class="badge bg-red2-dark color-white">FREE</span>
|
||||||
@@ -211,7 +215,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">
|
||||||
@@ -231,11 +235,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>
|
||||||
@@ -245,7 +254,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">
|
||||||
@@ -259,18 +268,7 @@
|
|||||||
<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>
|
||||||
</div>
|
<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 id="menu-signup" class="menu menu-box-modal menu-box-detached rounded-m" data-menu-height="300">
|
|
||||||
<div class="content bottom-0">
|
|
||||||
<h1 class="text-center mt-5 font-900">Registrieren</h1>
|
|
||||||
<p class="text-center">
|
|
||||||
Momentan kannst Du Dich leider nicht in der App registrieren.<br>
|
|
||||||
Das ist aber kein Problem, registriere Dich einfach kostenlos auf unserer Website!
|
|
||||||
</p>
|
|
||||||
<a href="https://regatten.net/de/signup" class="btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Registrieren</a>
|
|
||||||
<p class="text-center font-10 bottom-0">Du kannst Dich danach in dieser App anmelden.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -286,9 +284,6 @@
|
|||||||
<p>
|
<p>
|
||||||
Mehr Informationen findest Du <a href="https://info.ostertun.net/regatten/beta">hier</a>.
|
Mehr Informationen findest Du <a href="https://info.ostertun.net/regatten/beta">hier</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
|
||||||
Mit der Nutzung dieser App erklärst Du Dich außerdem damit einverstanden, dass wir Cookies einsetzen.
|
|
||||||
</p>
|
|
||||||
<a id="menu-welcome-a-okay" class="btn btn-m mt-2 mb-3 btn-full bg-green2-dark text-uppercase font-900" href="#">Alles klar</a>
|
<a id="menu-welcome-a-okay" class="btn btn-m mt-2 mb-3 btn-full bg-green2-dark text-uppercase font-900" href="#">Alles klar</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -303,7 +298,7 @@
|
|||||||
Das Nachladen kann außerdem gerade bei großen Datenmengen (wie Ranglisten) sehr lange dauern.
|
Das Nachladen kann außerdem gerade bei großen Datenmengen (wie Ranglisten) sehr lange dauern.
|
||||||
Wir empfehlen Dir daher, auf diesem Gerät unsere normale Website zu benutzen. Diese ist auch für Mobil-Geräte optimiert.
|
Wir empfehlen Dir daher, auf diesem Gerät unsere normale Website zu benutzen. Diese ist auch für Mobil-Geräte optimiert.
|
||||||
</p>
|
</p>
|
||||||
<a class="btn btn-m mt-2 btn-full bg-highlight text-uppercase font-900" href="https://regatten.net/">Zur Website</a>
|
<a class="btn btn-m mt-2 btn-full bg-highlight text-uppercase font-900" href="https://ranglisten.net/">Zur Website</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>
|
<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>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
||||||
</head>
|
</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>
|
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
|
||||||
|
|
||||||
|
|||||||
338
server/scripts/expenditures-add.js
Normal file
338
server/scripts/expenditures-add.js
Normal file
@@ -0,0 +1,338 @@
|
|||||||
|
let users = [];
|
||||||
|
let known = [];
|
||||||
|
let userSelectedCallback = null;
|
||||||
|
let excludeUsers = {};
|
||||||
|
|
||||||
|
function userSelected(id) {
|
||||||
|
if (typeof userSelectedCallback === 'function') {
|
||||||
|
userSelectedCallback(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function usersSearch() {
|
||||||
|
$('.item-user-search').remove();
|
||||||
|
if ($('#input-user-search').val().length == 0) {
|
||||||
|
known.forEach(function (entry) {
|
||||||
|
if (!(entry.id in excludeUsers)) {
|
||||||
|
$('#menu-select-user').find('.content').find('.list-group').append(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ($('#input-user-search').val().length >= 3) {
|
||||||
|
let cnt = 0;
|
||||||
|
users.forEach(function (entry) {
|
||||||
|
if (!(entry.id in excludeUsers) && search($('#input-user-search').val(), entry.keywords)) {
|
||||||
|
$('#menu-select-user').find('.content').find('.list-group').append(entry.content);
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (cnt == 0) {
|
||||||
|
let item = '<p class="item-user-search">Keine Benutzer gefunden.</p>';
|
||||||
|
$('#menu-select-user').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let item = '<p class="item-user-search">Zum Suchen mindestens 3 Zeichen eingeben</p>';
|
||||||
|
$('#menu-select-user').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addRemoveToUser(userid) {
|
||||||
|
$('.item-user-to[data-userid=' + userid + ']').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function expendituresInitModals() {
|
||||||
|
$('#button-add-save').click(function () {
|
||||||
|
showLoader();
|
||||||
|
const jqUserFrom = $('#item-add-user-from');
|
||||||
|
const userFrom = jqUserFrom.data('userid');
|
||||||
|
const jqDate = $('#input-add-date');
|
||||||
|
const purposeDate = jqDate.val();
|
||||||
|
if (purposeDate == '') {
|
||||||
|
hideLoader();
|
||||||
|
toastError('Es wurde kein Datum ausgewählt!');
|
||||||
|
jqDate.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const jqAmount = $('#input-add-amount');
|
||||||
|
const amount = jqAmount.val();
|
||||||
|
if (amount == '') {
|
||||||
|
hideLoader();
|
||||||
|
toastError('Es wurde kein Betrag ausgewählt!');
|
||||||
|
jqAmount.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const purpose = $('#select-add-purpose').val();
|
||||||
|
const regattaName = $('#input-add-regatta-name').val();
|
||||||
|
const purposeText = $('#input-add-purpose-text').val();
|
||||||
|
let usersTo = [];
|
||||||
|
$('.item-user-to[data-userid]').each(function (index) {
|
||||||
|
usersTo.push($(this).data('userid'));
|
||||||
|
});
|
||||||
|
let auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'expenditures_add',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
user_from: userFrom,
|
||||||
|
date: purposeDate,
|
||||||
|
amount: Math.round(parseFloat(amount) * 100),
|
||||||
|
purpose: purpose,
|
||||||
|
regatta_name: regattaName,
|
||||||
|
purpose_text: purposeText,
|
||||||
|
users_to: usersTo
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Ausgabe zu speichern');
|
||||||
|
} else {
|
||||||
|
log('expenditures_add: 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();
|
||||||
|
updateExpendituresBadge();
|
||||||
|
$('#menu-add').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
toastOk('Ausgabe gespeichert. Betrag wurde durch ' + data.count + ' Personen geteilt.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#item-add-user-from').click(async function () {
|
||||||
|
excludeUsers = {};
|
||||||
|
$('#input-user-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
usersSearch();
|
||||||
|
userSelectedCallback = async function (userid) {
|
||||||
|
$('#item-add-user-from').data('userid', userid).find('span').html('bezahlt von: ' + (await dbGetData('users', userid)).username);
|
||||||
|
$('#menu-select-user').hideMenu();
|
||||||
|
$('#menu-add').showMenu();
|
||||||
|
}
|
||||||
|
$('#menu-add').hideMenu();
|
||||||
|
$('#menu-select-user').showMenu();
|
||||||
|
$('#input-user-search').focus();
|
||||||
|
});
|
||||||
|
$('#item-add-user-to').click(async function () {
|
||||||
|
excludeUsers = {};
|
||||||
|
$('.item-user-to[data-userid]').each(function (index) {
|
||||||
|
excludeUsers[$(this).data('userid')] = true;
|
||||||
|
});
|
||||||
|
$('#input-user-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
usersSearch();
|
||||||
|
userSelectedCallback = async function (userid) {
|
||||||
|
let item = '<a class="item-user-to" data-userid="' + userid + '" onclick="addRemoveToUser(' + userid + ')">';
|
||||||
|
item += '<span>' + (await dbGetData('users', userid)).username + '</span>';
|
||||||
|
item += '<i class="fa fa-times"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#item-add-user-to').before(item);
|
||||||
|
$('#menu-select-user').hideMenu();
|
||||||
|
$('#menu-add').showMenu();
|
||||||
|
}
|
||||||
|
$('#menu-add').hideMenu();
|
||||||
|
$('#menu-select-user').showMenu();
|
||||||
|
$('#input-user-search').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#button-add-transfer-save').click(function () {
|
||||||
|
showLoader();
|
||||||
|
const jqUser = $('#item-add-transfer-user');
|
||||||
|
const selectedUser = jqUser.data('userid');
|
||||||
|
if (selectedUser == 0) {
|
||||||
|
hideLoader();
|
||||||
|
toastError('Es wurde keine Person ausgewählt!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const jqDate = $('#input-add-transfer-date');
|
||||||
|
const selectedDate = jqDate.val();
|
||||||
|
if (selectedDate == '') {
|
||||||
|
hideLoader();
|
||||||
|
toastError('Es wurde kein Datum ausgewählt!');
|
||||||
|
jqDate.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const jqAmount = $('#input-add-transfer-amount');
|
||||||
|
const selectedAmount = jqAmount.val();
|
||||||
|
if (selectedAmount == '') {
|
||||||
|
hideLoader();
|
||||||
|
toastError('Es wurde kein Betrag ausgewählt!');
|
||||||
|
jqAmount.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const jqPurposeText = $('#input-add-transfer-purpose-text');
|
||||||
|
const selectedPurposeText = jqPurposeText.val();
|
||||||
|
const jqSwitch = $('#switch-add-transfer-received');
|
||||||
|
const direction = jqSwitch.prop('checked');
|
||||||
|
let auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'expenditures_add_transfer',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
direction: direction ? 1 : -1,
|
||||||
|
userid: selectedUser,
|
||||||
|
date: selectedDate,
|
||||||
|
amount: Math.round(parseFloat(selectedAmount) * 100),
|
||||||
|
purpose_text: selectedPurposeText
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Geldtransfer zu speichern');
|
||||||
|
} else {
|
||||||
|
log('expenditures_add_transfer: 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();
|
||||||
|
updateExpendituresBadge();
|
||||||
|
$('#menu-add-transfer').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
toastOk(direction ? 'Geldtransfer gespeichert. ' + (await dbGetData('users', selectedUser)).username + ' muss dies noch bestätigen' : 'Geldtransfer wurde gespeichert');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#switch-add-transfer-received').parent().parent().click(async function () {
|
||||||
|
const jqSwitch = $('#switch-add-transfer-received');
|
||||||
|
const jqUser = $('#item-add-transfer-user');
|
||||||
|
const direction = jqSwitch.prop('checked');
|
||||||
|
jqSwitch.parent().prev().text(direction ? 'Geld gegeben' : 'Geld bekommen').prev().removeClass('fa-arrow-' + (direction ? 'left' : 'right')).addClass('fa-arrow-' + (direction ? 'right' : 'left'));
|
||||||
|
const selectedUser = jqUser.data('userid');
|
||||||
|
if (selectedUser == 0) {
|
||||||
|
jqUser.find('span').html((direction ? 'an: ' : 'von: ') + '<font style="font-style:italic;">bitte auswählen</font>');
|
||||||
|
} else {
|
||||||
|
jqUser.find('span').text((direction ? 'an: ' : 'von: ') + (await dbGetData('users', selectedUser)).username);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#item-add-transfer-user').click(async function () {
|
||||||
|
excludeUsers = {};
|
||||||
|
excludeUsers[USER_ID] = true;
|
||||||
|
$('#input-user-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
usersSearch();
|
||||||
|
userSelectedCallback = async function (userid) {
|
||||||
|
const direction = $('#switch-add-transfer-received').prop('checked');
|
||||||
|
$('#item-add-transfer-user').data('userid', userid).find('span').html((direction ? 'an: ' : 'von: ') + (await dbGetData('users', userid)).username);
|
||||||
|
$('#menu-select-user').hideMenu();
|
||||||
|
$('#menu-add-transfer').showMenu();
|
||||||
|
}
|
||||||
|
$('#menu-add-transfer').hideMenu();
|
||||||
|
$('#menu-select-user').showMenu();
|
||||||
|
$('#input-user-search').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#input-user-search').on('input', usersSearch);
|
||||||
|
|
||||||
|
users = [];
|
||||||
|
known = [];
|
||||||
|
let itemMe = '<a class="item-user-search" onclick="userSelected(' + USER_ID + ')">';
|
||||||
|
itemMe += '<span>ICH (' + USER_NAME + ')</span>';
|
||||||
|
itemMe += '<i class="fa fa-angle-right"></i>';
|
||||||
|
itemMe += '</a>';
|
||||||
|
known.push({id: USER_ID, content: itemMe});
|
||||||
|
let knownIds = {};
|
||||||
|
let allExps = await dbGetData('expenditures');
|
||||||
|
let expUsers = {};
|
||||||
|
for (let i in allExps) {
|
||||||
|
let exp = allExps[i];
|
||||||
|
let eUId = exp.user;
|
||||||
|
if (!(eUId in expUsers)) {
|
||||||
|
expUsers[eUId] = {
|
||||||
|
userId: eUId,
|
||||||
|
username: (await dbGetData('users', eUId)).username,
|
||||||
|
cnt: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
expUsers[eUId].cnt++;
|
||||||
|
}
|
||||||
|
expUsers = Object.values(expUsers);
|
||||||
|
expUsers.sort(function (a, b) {
|
||||||
|
return a.username.localeCompare(b.username);
|
||||||
|
});
|
||||||
|
for (let i in expUsers) {
|
||||||
|
knownIds[expUsers[i].userId] = true;
|
||||||
|
}
|
||||||
|
const dbUsers = await dbGetData('users');
|
||||||
|
dbUsers.sort(function (a, b) {
|
||||||
|
return a.username.localeCompare(b.username);
|
||||||
|
});
|
||||||
|
for (let i in dbUsers) {
|
||||||
|
let item = '<a class="item-user-search" onclick="userSelected(' + dbUsers[i].id + ')">';
|
||||||
|
item += '<span>' + dbUsers[i].username + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
users.push({
|
||||||
|
keywords: [dbUsers[i].username],
|
||||||
|
id: dbUsers[i].id,
|
||||||
|
content: item
|
||||||
|
});
|
||||||
|
if (dbUsers[i].id in knownIds) known.push({id: dbUsers[i].id, content: item});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#input-add-regatta-name').attr('list', 'list-regattas');
|
||||||
|
let listRegattas = $('<datalist id="list-regattas">').appendTo('body');
|
||||||
|
let plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||||
|
let regattas = [];
|
||||||
|
for (let i in plannings) {
|
||||||
|
let regatta = await dbGetData('regattas', plannings[i].regatta);
|
||||||
|
regatta.year = formatDate('Y', parseDate(regatta.date));
|
||||||
|
regattas.push(regatta);
|
||||||
|
}
|
||||||
|
regattas.sort(function (a, b) {
|
||||||
|
if (a.year != b.year) return b.year - a.year;
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
for (let i in regattas) {
|
||||||
|
$('<option>').attr('value', regattas[i].name).appendTo(listRegattas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function expendituresShowAdd(defaultUser = 0) {
|
||||||
|
$('#item-add-user-from').data('userid', USER_ID).find('span').html('bezahlt von: ' + USER_NAME);
|
||||||
|
$('#input-add-date').val(formatDate('Y-m-d')).trigger('focusin');
|
||||||
|
$('#input-add-amount').val('');
|
||||||
|
$('#select-add-purpose').val('entryfee');
|
||||||
|
$('#input-add-regatta-name').val('');
|
||||||
|
$('#input-add-purpose-text').val('');
|
||||||
|
$('.item-user-to').remove();
|
||||||
|
let item = '<a class="item-user-to" data-userid="' + USER_ID + '" onclick="addRemoveToUser(' + USER_ID + ')">';
|
||||||
|
item += '<span>' + USER_NAME + '</span>';
|
||||||
|
item += '<i class="fa fa-times"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#item-add-user-to').before(item);
|
||||||
|
if (defaultUser > 0) {
|
||||||
|
item = '<a class="item-user-to" data-userid="' + defaultUser + '" onclick="addRemoveToUser(' + defaultUser + ')">';
|
||||||
|
item += '<span>' + (await dbGetData('users', defaultUser)).username + '</span>';
|
||||||
|
item += '<i class="fa fa-times"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#item-add-user-to').before(item);
|
||||||
|
}
|
||||||
|
$('#menu-add').showMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function expendituresShowAddTransfer(defaultUser = 0, defaultDirection = true, defaultAmount = '') {
|
||||||
|
$('#switch-add-transfer-received').prop('checked', defaultDirection).parent().prev().text(defaultDirection ? 'Geld gegeben' : 'Geld bekommen').prev().removeClass(defaultDirection ? 'fa-arrow-left' : 'fa-arrow-right').addClass(defaultDirection ? 'fa-arrow-right' : 'fa-arrow-left');
|
||||||
|
if (defaultUser == 0) {
|
||||||
|
$('#item-add-transfer-user').data('userid', 0).find('span').html((defaultDirection ? 'an: ' : 'von: ') + '<font style="font-style:italic;">bitte auswählen</font>');
|
||||||
|
} else {
|
||||||
|
$('#item-add-transfer-user').data('userid', defaultUser).find('span').html((defaultDirection ? 'an: ' : 'von: ') + (await dbGetData('users', defaultUser)).username);
|
||||||
|
}
|
||||||
|
$('#input-add-transfer-date').val(formatDate('Y-m-d')).trigger('focusin');
|
||||||
|
$('#input-add-transfer-amount').val(defaultAmount).trigger('focusin').trigger('focusout');
|
||||||
|
$('#input-add-transfer-purpose-text').val('');
|
||||||
|
$('#menu-add-transfer').showMenu();
|
||||||
|
}
|
||||||
326
server/scripts/expenditures-user.js
Normal file
326
server/scripts/expenditures-user.js
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
let firstCall = true;
|
||||||
|
let rows = [];
|
||||||
|
let displayed = [];
|
||||||
|
let page = 1;
|
||||||
|
let pageCount = 0;
|
||||||
|
const showCount = 25;
|
||||||
|
let sumsDisplayed = true;
|
||||||
|
|
||||||
|
function createPurpose(exp) {
|
||||||
|
let purpose = '';
|
||||||
|
let extraText = ': ';
|
||||||
|
switch (exp.purpose) {
|
||||||
|
case 'transfer': purpose = 'Geldtransfer'; break;
|
||||||
|
case 'entryfee': purpose = 'Meldegeld'; break;
|
||||||
|
case 'camping': purpose = 'Camping'; break;
|
||||||
|
case 'food': purpose = 'Essen'; break;
|
||||||
|
case 'other': extraText = ''; break;
|
||||||
|
}
|
||||||
|
if (exp.purpose_text != '') {
|
||||||
|
purpose += extraText + exp.purpose_text;
|
||||||
|
}
|
||||||
|
return purpose;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onListClicked(id) {
|
||||||
|
let exp = await dbGetData('expenditures', id);
|
||||||
|
console.log(exp);
|
||||||
|
|
||||||
|
$('#menu-expenditure').find('.menu-title').find('p').text(createPurpose(exp) + ' (' + (exp.direction * exp.amount / 100).toFixed(2) + ' €)');
|
||||||
|
|
||||||
|
if (exp.approved == 0 && (exp.direction < 0) == (exp.canceled == 0)) {
|
||||||
|
$('#menu-item-approve').show();
|
||||||
|
$('#menu-item-approve').attr('onclick', 'expenditureAction("approve", ' + exp['id'] + ', "' + (exp.canceled == 1 ? 'Stornierung' : 'Ausgabe') + ' genehmigt")');
|
||||||
|
$('#menu-item-approve').find('span').text(exp.canceled == 1 ? 'Storno akzeptieren' : 'Akzeptieren');
|
||||||
|
$('#menu-item-decline').show();
|
||||||
|
$('#menu-item-decline').attr('onclick', 'expenditureAction("decline", ' + exp['id'] + ', "Ausgabe ' + (exp.canceled == 1 ? 'erneut angefragt' : 'abgelehnt') + '")');
|
||||||
|
$('#menu-item-decline').find('span').text(exp.canceled == 1 ? 'Erneut anfragen' : 'Ablehnen');
|
||||||
|
} else {
|
||||||
|
$('#menu-item-approve').hide();
|
||||||
|
$('#menu-item-decline').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exp.canceled == 0 && (exp.approved == 1 || exp.direction > 0)) {
|
||||||
|
$('#menu-item-cancel').show();
|
||||||
|
$('#menu-item-cancel').attr('onclick', 'expenditureAction("cancel", ' + exp['id'] + ', "' + (exp.direction > 0 ? 'Ausgabe storniert' : 'Stornierung beantragt') + '")');
|
||||||
|
} else {
|
||||||
|
$('#menu-item-cancel').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#menu-expenditure').showMenu();
|
||||||
|
$('#menu-expenditure').scrollTop(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function expenditureAction(action, expId, successStr) {
|
||||||
|
$('#menu-expenditure').hideMenu();
|
||||||
|
showLoader();
|
||||||
|
let auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'expenditure_' + action,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
expenditure: expId
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Ausgabe zu stornieren.');
|
||||||
|
} else {
|
||||||
|
log('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();
|
||||||
|
updateExpendituresBadge();
|
||||||
|
hideLoader();
|
||||||
|
toastOk(successStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageChange() {
|
||||||
|
$('#p-count')[0].scrollIntoView({ behavior: "smooth" });
|
||||||
|
drawList();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function drawList() {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
let list = '';
|
||||||
|
|
||||||
|
if (displayed.length > 0) {
|
||||||
|
let offset = (page - 1) * (sumsDisplayed ? showCount * 2 : showCount);
|
||||||
|
let count = (page == pageCount ? (displayed.length - offset) : (sumsDisplayed ? showCount * 2 + 1 : showCount));
|
||||||
|
|
||||||
|
for (i = 0; i < count; i ++) {
|
||||||
|
list += displayed[i + offset];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#div-list').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reSearch() {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
displayed = [];
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
displayed.push(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sumsDisplayed = displayed.length == rows.length;
|
||||||
|
$('#div-list').toggleClass('display-border', !sumsDisplayed);
|
||||||
|
pageCount = Math.ceil((displayed.length - (sumsDisplayed ? 1 : 0)) / (sumsDisplayed ? showCount * 2 : showCount));
|
||||||
|
if ((page < 1) || (page > pageCount)) {
|
||||||
|
if (page < 1) {
|
||||||
|
page = 1;
|
||||||
|
} else {
|
||||||
|
page = pageCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawPagination();
|
||||||
|
drawList();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelCause(cancel_cause) {
|
||||||
|
switch (cancel_cause) {
|
||||||
|
case 'not approved':
|
||||||
|
return 'nicht genehmigt';
|
||||||
|
case 'canceled':
|
||||||
|
return 'storniert';
|
||||||
|
}
|
||||||
|
return 'unbekannter Grund';
|
||||||
|
}
|
||||||
|
|
||||||
|
let siteScript = async function() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
userid = findGetParameter('user');
|
||||||
|
let user = null;
|
||||||
|
if (userid !== null) {
|
||||||
|
user = await dbGetData('users', userid);
|
||||||
|
}
|
||||||
|
if (user === null) {
|
||||||
|
location.href = LINK_PRE + 'expenditures';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#p-username').text(user.username);
|
||||||
|
$('.span-username').text(user.username);
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initPagination();
|
||||||
|
$('#input-search').on('input', reSearch);
|
||||||
|
$('#button-add').click((e) => expendituresShowAdd(userid));
|
||||||
|
$('#button-add-transfer').click((e) => expendituresShowAddTransfer(userid));
|
||||||
|
expendituresInitModals();
|
||||||
|
}
|
||||||
|
|
||||||
|
let exps = await dbGetDataIndex('expenditures', 'user', user.id);
|
||||||
|
exps.sort(function (a, b) {
|
||||||
|
return a.created - b.created;
|
||||||
|
});
|
||||||
|
|
||||||
|
let sum = 0;
|
||||||
|
for (i in exps) {
|
||||||
|
let exp = exps[i];
|
||||||
|
if (exp.canceled == 0) {
|
||||||
|
sum += exp.direction * exp.amount;
|
||||||
|
}
|
||||||
|
exps[i].sum = sum;
|
||||||
|
exps[i].purpose_html = createPurpose(exp);
|
||||||
|
exps[i].purpose_date = formatDate("d.m.Y", parseDate(exp.purpose_date));
|
||||||
|
}
|
||||||
|
|
||||||
|
let sumText = '';
|
||||||
|
let sumButton = '';
|
||||||
|
if (sum == 0) {
|
||||||
|
sumText = 'Du und ' + user.username + ' seid quitt.';
|
||||||
|
} else if (sum > 0) {
|
||||||
|
sumText = user.username + ' schuldet Dir noch ' + (sum / 100).toFixed(2) + ' €.';
|
||||||
|
sumButton = ' <a href="#" onclick="expendituresShowAddTransfer(' + user.id + ', false, ' + (sum/100) + '); return false;">Ausgleichen</a>';
|
||||||
|
} else {
|
||||||
|
sumText = 'Du schuldest ' + user.username + ' noch ' + (-sum / 100).toFixed(2) + ' €.';
|
||||||
|
sumButton = ' <a href="#" onclick="expendituresShowAddTransfer(' + user.id + ', true, ' + (-sum/100) + '); return false;">Ausgleichen</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
results = exps.reverse();
|
||||||
|
|
||||||
|
// TODO: open approvals
|
||||||
|
|
||||||
|
let count = results.length;
|
||||||
|
if (count > 0) {
|
||||||
|
$('#p-count').text(sumText);
|
||||||
|
$('#p-count').html($('#p-count').html() + sumButton);
|
||||||
|
$('#div-list').show();
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in results) {
|
||||||
|
let entry = results[id];
|
||||||
|
|
||||||
|
let rowSum = { keywords: [], content: '' };
|
||||||
|
|
||||||
|
rowSum.content += '<div class="sum">';
|
||||||
|
|
||||||
|
// ZEILE SUM
|
||||||
|
rowSum.content += '<div>';
|
||||||
|
|
||||||
|
// sum
|
||||||
|
rowSum.content += '<div>';
|
||||||
|
if (entry.sum < 0) rowSum.content += '<font style="color:red;">';
|
||||||
|
rowSum.content += (entry.sum / 100).toFixed(2);
|
||||||
|
if (entry.sum < 0) rowSum.content += '</font>';
|
||||||
|
rowSum.content += ' €</div>';
|
||||||
|
|
||||||
|
rowSum.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(rowSum);
|
||||||
|
|
||||||
|
|
||||||
|
let row = { keywords: [], content: '' };
|
||||||
|
|
||||||
|
row.keywords.push((entry.amount / 100).toFixed(2));
|
||||||
|
row.keywords.push(entry.purpose_html);
|
||||||
|
row.keywords.push(entry.purpose_date);
|
||||||
|
row.keywords.push(entry.regatta_name);
|
||||||
|
|
||||||
|
row.content += '<div onclick="onListClicked(' + entry.id + ');" style="';
|
||||||
|
if (entry.canceled == 1) {
|
||||||
|
row.content += 'opacity:0.5;';
|
||||||
|
}
|
||||||
|
if (entry.approved == 0) {
|
||||||
|
row.content += 'font-style:italic;';
|
||||||
|
}
|
||||||
|
row.content += '">';
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// purpose
|
||||||
|
row.content += '<div' + ((entry.canceled == 1) ? ' style="text-decoration: line-through;"' : '') + '>' + entry.purpose_html + '</div>';
|
||||||
|
|
||||||
|
// amount
|
||||||
|
row.content += '<div>';
|
||||||
|
if (entry.canceled == 1) row.content += '(';
|
||||||
|
if (entry.direction < 0) row.content += '<font style="color:red;">';
|
||||||
|
row.content += (entry.direction * entry.amount / 100).toFixed(2);
|
||||||
|
if (entry.direction < 0) row.content += '</font>';
|
||||||
|
if (entry.canceled == 1) row.content += ')';
|
||||||
|
row.content += ' €</div>';
|
||||||
|
|
||||||
|
// icons
|
||||||
|
if (entry.approved == 1) {
|
||||||
|
if (entry.canceled == 1) {
|
||||||
|
row.content += '<div><i class="fas fa-times"></i></div>';
|
||||||
|
} else {
|
||||||
|
row.content += '<div><i class="fas fa-check"></i></div>';
|
||||||
|
}
|
||||||
|
} else if ((entry.direction < 0) == (entry.canceled == 1)) {
|
||||||
|
row.content += '<div><i class="fas fa-hourglass-half"></i></div>';
|
||||||
|
} else {
|
||||||
|
row.content += '<div><i class="fas fa-exclamation fa-blink"></i></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// date
|
||||||
|
row.content += '<div>' + entry.purpose_date + '</div>';
|
||||||
|
|
||||||
|
// regatta
|
||||||
|
row.content += '<div>' + entry.regatta_name + '</div>';
|
||||||
|
|
||||||
|
// cancel_cause
|
||||||
|
row.content += '<div>' + (entry.canceled == 1 ? cancelCause(entry.cancel_cause) : '') + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
let rowSum = { keywords: [], content: '' };
|
||||||
|
|
||||||
|
rowSum.content += '<div class="sum">';
|
||||||
|
|
||||||
|
// ZEILE SUM
|
||||||
|
rowSum.content += '<div>';
|
||||||
|
|
||||||
|
// sum
|
||||||
|
rowSum.content += '<div>';
|
||||||
|
rowSum.content += (0).toFixed(2);
|
||||||
|
rowSum.content += ' €</div>';
|
||||||
|
|
||||||
|
rowSum.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(rowSum);
|
||||||
|
|
||||||
|
reSearch();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Keine Ausgaben gefunden!');
|
||||||
|
$('#div-list').hide();
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
149
server/scripts/expenditures.js
Normal file
149
server/scripts/expenditures.js
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var displayed = [];
|
||||||
|
var page = 1;
|
||||||
|
var pageCount = 0;
|
||||||
|
const showCount = 25;
|
||||||
|
|
||||||
|
async function onListClicked(id) {
|
||||||
|
window.location = LINK_PRE + 'expenditures-user?user=' + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageChange() {
|
||||||
|
$('#p-count')[0].scrollIntoView({ behavior: "smooth" });
|
||||||
|
drawList();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function drawList() {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var list = '';
|
||||||
|
|
||||||
|
if (displayed.length > 0) {
|
||||||
|
var offset = (page - 1) * showCount;
|
||||||
|
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
|
||||||
|
if (count == 0) count = showCount;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i ++) {
|
||||||
|
list += displayed[i + offset];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#div-list').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reSearch() {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
displayed = [];
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
displayed.push(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pageCount = Math.ceil(displayed.length / showCount);
|
||||||
|
if ((page < 1) || (page > pageCount)) {
|
||||||
|
if (page < 1) {
|
||||||
|
page = 1;
|
||||||
|
} else {
|
||||||
|
page = pageCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawPagination();
|
||||||
|
drawList();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initPagination();
|
||||||
|
$('#input-search').on('input', reSearch);
|
||||||
|
$('#button-add').click((e) => expendituresShowAdd());
|
||||||
|
$('#button-add-transfer').click((e) => expendituresShowAddTransfer());
|
||||||
|
expendituresInitModals();
|
||||||
|
}
|
||||||
|
|
||||||
|
let allExps = await dbGetData('expenditures');
|
||||||
|
let expUsers = {};
|
||||||
|
for (let i in allExps) {
|
||||||
|
let exp = allExps[i];
|
||||||
|
let eUId = exp.user;
|
||||||
|
if (!(eUId in expUsers)) {
|
||||||
|
expUsers[eUId] = {
|
||||||
|
userId: eUId,
|
||||||
|
username: (await dbGetData('users', eUId)).username,
|
||||||
|
balance: 0,
|
||||||
|
openApprovals: 0,
|
||||||
|
cnt: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (exp.canceled == 0) {
|
||||||
|
expUsers[eUId].balance += exp.direction * parseInt(exp.amount);
|
||||||
|
}
|
||||||
|
if (exp.approved == 0) {
|
||||||
|
if (exp.direction < 0 && exp.canceled == 0) expUsers[eUId].openApprovals++;
|
||||||
|
if (exp.direction > 0 && exp.canceled == 1) expUsers[eUId].openApprovals++;
|
||||||
|
}
|
||||||
|
expUsers[eUId].cnt++;
|
||||||
|
}
|
||||||
|
let results = Object.values(expUsers);
|
||||||
|
|
||||||
|
let count = results.length;
|
||||||
|
if (count > 0) {
|
||||||
|
$('#p-count').hide();
|
||||||
|
$('#div-list').show();
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
results.sort(function (a, b) {
|
||||||
|
return b.cnt - a.cnt;
|
||||||
|
});
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in results) {
|
||||||
|
var entry = results[id];
|
||||||
|
|
||||||
|
var row = { keywords: [], content: '' };
|
||||||
|
row.keywords.push(entry.username);
|
||||||
|
|
||||||
|
row.content += '<div onclick="onListClicked(' + entry.userId + ');">';
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
// Username
|
||||||
|
row.content += '<div><b>' + entry.username + '</b></div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// open approvals
|
||||||
|
row.content += '<div>' + ((entry.openApprovals > 0) ? (entry.openApprovals + ' offene Genehmigung' + (entry.openApprovals > 1 ? 'en' : '')) : '') + '</div>';
|
||||||
|
|
||||||
|
// balance
|
||||||
|
row.content += '<div>';
|
||||||
|
if (entry.balance < 0) row.content += '<font style="color:red;">';
|
||||||
|
row.content += (entry.balance / 100).toFixed(2);
|
||||||
|
if (entry.balance < 0) row.content += '</font>';
|
||||||
|
row.content += ' €</div>';
|
||||||
|
|
||||||
|
row.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
reSearch();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#p-count').show().html('Keine Ausgaben gefunden!');
|
||||||
|
$('#div-list').hide();
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
@@ -1,48 +1,132 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
var user = await dbGetData('users', localStorage.getItem('auth_user'));
|
var user = await dbGetData('users', localStorage.getItem('auth_user'));
|
||||||
|
|
||||||
// Favorites
|
// Favorites
|
||||||
|
var follows = await dbGetData('follows');
|
||||||
var watched = [];
|
var watched = [];
|
||||||
for (var i = 1; i <= 5; i ++) {
|
for (var i in follows) {
|
||||||
sailor_id = user['sailor' + i];
|
watched.push(await dbGetData('sailors', follows[i].sailor));
|
||||||
if (sailor_id != null) {
|
|
||||||
watched.push(await dbGetData('sailors', sailor_id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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 +143,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 +160,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 +184,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 +272,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 +309,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,11 +401,13 @@ 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){
|
regattas.sort(function(a,b){
|
||||||
return b.date.localeCompare(a.date);
|
return b.date.localeCompare(a.date);
|
||||||
@@ -287,8 +417,6 @@ var siteScript = async function() {
|
|||||||
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']);
|
||||||
@@ -313,6 +441,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
|
||||||
@@ -323,7 +471,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(' ') + '</div>';
|
list += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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()) {
|
||||||
@@ -20,11 +57,18 @@ async function onRegattaClicked(id) {
|
|||||||
// Your Planning
|
// Your Planning
|
||||||
if (planning != null) {
|
if (planning != null) {
|
||||||
$('#menu-item-yourplanning').show();
|
$('#menu-item-yourplanning').show();
|
||||||
|
var boat = null;
|
||||||
|
if (planning.boat != null) {
|
||||||
|
boat = (await dbGetData('boats', planning.boat)).sailnumber;
|
||||||
|
}
|
||||||
var steuermann = null;
|
var steuermann = null;
|
||||||
if (planning.steuermann != null) {
|
if (planning.steuermann != null) {
|
||||||
steuermann = (await dbGetData('sailors', planning.steuermann)).name;
|
steuermann = (await dbGetData('sailors', planning.steuermann)).name;
|
||||||
}
|
}
|
||||||
var crew = [steuermann == null ? '[noch unklar]' : steuermann];
|
var crew = [
|
||||||
|
boat == null ? '[Boot unklar]' : boat,
|
||||||
|
steuermann == null ? '[St.mann unklar]' : steuermann
|
||||||
|
];
|
||||||
crewA = planning.crew.split(',');
|
crewA = planning.crew.split(',');
|
||||||
for (i in crewA) {
|
for (i in crewA) {
|
||||||
var sailor = await dbGetData('sailors', crewA[i]);
|
var sailor = await dbGetData('sailors', crewA[i]);
|
||||||
@@ -54,15 +98,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, extServiceData.classId)); // 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 {
|
||||||
@@ -78,6 +137,14 @@ async function onRegattaClicked(id) {
|
|||||||
$('#menu-item-bericht').hide();
|
$('#menu-item-bericht').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fakten
|
||||||
|
if ('facts' in regatta && regatta['facts'] != null) {
|
||||||
|
$('#menu-item-facts').show();
|
||||||
|
$('#menu-item-facts').attr('href', LINK_PRE + 'regatta_facts?regatta=' + regatta['id']);
|
||||||
|
} else {
|
||||||
|
$('#menu-item-facts').hide();
|
||||||
|
}
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
if (regatta['info'] != '') {
|
if (regatta['info'] != '') {
|
||||||
$('#menu-item-info').show();
|
$('#menu-item-info').show();
|
||||||
@@ -92,10 +159,10 @@ async function onRegattaClicked(id) {
|
|||||||
$('#menu-item-meldung').show();
|
$('#menu-item-meldung').show();
|
||||||
$('#menu-item-meldung').attr('href', regatta['meldung']);
|
$('#menu-item-meldung').attr('href', regatta['meldung']);
|
||||||
$('#menu-item-meldung').attr('target', '_blank');
|
$('#menu-item-meldung').attr('target', '_blank');
|
||||||
if ((planning != null) && (planning['gemeldet'] == '1')) {
|
/*if ((planning != null) && (planning['gemeldet'] == '1')) {
|
||||||
$('#badge-regatta-meldung').text('schon gemeldet');
|
$('#badge-regatta-meldung').text('schon gemeldet');
|
||||||
$('#badge-regatta-meldung').addClass('bg-green2-dark').removeClass('bg-highlight bg-red2-dark bg-yellow2-dark');
|
$('#badge-regatta-meldung').addClass('bg-green2-dark').removeClass('bg-highlight bg-red2-dark bg-yellow2-dark');
|
||||||
} else if (regatta['meldungOffen'] == '0') {
|
} else*/ if (regatta['meldungOffen'] == '0') {
|
||||||
$('#badge-regatta-meldung').text('geschlossen');
|
$('#badge-regatta-meldung').text('geschlossen');
|
||||||
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
||||||
} else if (regatta['meldungSchluss'] != null) {
|
} else if (regatta['meldungSchluss'] != null) {
|
||||||
@@ -135,7 +202,7 @@ async function onRegattaClicked(id) {
|
|||||||
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$('#badge-regatta-meldung').text('Meldeschluss abgelaufen');
|
$('#badge-regatta-meldung').text('Meldeschluss abgelaufen, Nachmeldung möglich');
|
||||||
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
$('#badge-regatta-meldung').addClass('bg-highlight').removeClass('bg-green2-dark bg-red2-dark bg-yellow2-dark');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -74,11 +74,15 @@ function selectChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initYear() {
|
function initYear() {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (year === null) year = new Date().getFullYear();
|
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;
|
||||||
@@ -107,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);
|
||||||
@@ -137,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) {
|
||||||
@@ -177,6 +178,9 @@ var siteScript = async function() {
|
|||||||
var club = null;
|
var club = null;
|
||||||
if (entry['club'] != null)
|
if (entry['club'] != null)
|
||||||
club = await dbGetData('clubs', entry['club']);
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
if (entry.planning.boat !== null) {
|
||||||
|
entry.planning.boat = (await dbGetData('boats', entry.planning.boat)).sailnumber;
|
||||||
|
}
|
||||||
if (entry.planning.steuermann !== null) {
|
if (entry.planning.steuermann !== null) {
|
||||||
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
}
|
}
|
||||||
@@ -196,6 +200,7 @@ var siteScript = async function() {
|
|||||||
row.keywords.push(entry['name']);
|
row.keywords.push(entry['name']);
|
||||||
if (entry['number'] != null) row.keywords.push(entry['number']);
|
if (entry['number'] != null) row.keywords.push(entry['number']);
|
||||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
if (entry.planning.boat != null) row.keywords.push(entry.planning.boat);
|
||||||
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
||||||
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
||||||
|
|
||||||
@@ -220,6 +225,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
|
||||||
@@ -262,7 +287,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') {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
if ((sid === null) || (sid in knownIds)) {
|
||||||
planningEdit(rid);
|
planningEdit(rid);
|
||||||
hideLoader();
|
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,29 +136,11 @@ 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() {
|
|
||||||
sailors = [];
|
|
||||||
var dbSailors = await dbGetData('sailors');
|
|
||||||
dbSailors.sort(function(a,b){
|
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
});
|
|
||||||
for (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>';
|
|
||||||
item += '</a>';
|
|
||||||
sailors.push({
|
|
||||||
keywords: [dbSailors[s].name],
|
|
||||||
content: item
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function planningChangeCrew(sid = null) {
|
async function planningChangeCrew(sid = null) {
|
||||||
if (sid !== null) {
|
if (sid !== null) {
|
||||||
showLoader();
|
showLoader();
|
||||||
@@ -206,6 +199,136 @@ async function planningChangeSteuermann() {
|
|||||||
$('#input-edit-search').focus();
|
$('#input-edit-search').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var boats = [];
|
||||||
|
var boatKnownIds = [];
|
||||||
|
var boatKnown = [];
|
||||||
|
|
||||||
|
async function boatSelected(bid) {
|
||||||
|
$('#menu-boat').hideMenu();
|
||||||
|
showLoader();
|
||||||
|
var rid = $('#switch-planning-include').data('regatta');
|
||||||
|
var action = 'planning_set_boat';
|
||||||
|
// add boat
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + action,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: rid,
|
||||||
|
boat: bid
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log(action + ': 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();
|
||||||
|
if ((bid === null) || (bid in boatKnownIds)) {
|
||||||
|
planningEdit(rid);
|
||||||
|
hideLoader();
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function boatsSearch() {
|
||||||
|
$('.item-boat-search').remove();
|
||||||
|
var item = '<a class="item-boat-search" onclick="boatSelected(null)">';
|
||||||
|
item += '<span style="font-style:italic;">noch unklar</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-boat').find('.content').find('.list-group').append(item);
|
||||||
|
if ($('#input-edit-boat-search').val().length == 0) {
|
||||||
|
boatKnown.forEach(function (entry) {
|
||||||
|
$('#menu-boat').find('.content').find('.list-group').append(entry);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ($('#input-edit-boat-search').val().length >= 3) {
|
||||||
|
boats.forEach(function (entry) {
|
||||||
|
if (search($('#input-edit-boat-search').val(), entry.keywords)) {
|
||||||
|
$('#menu-boat').find('.content').find('.list-group').append(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var item = '<p class="item-boat-search">Zum Suchen mindestens 3 Zeichen eingeben</p>';
|
||||||
|
$('#menu-boat').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningChangeBoat() {
|
||||||
|
$('#input-edit-boat-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
boatsSearch();
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
$('#menu-boat').find('.menu-title').find('h1').text('Boot bearbeiten');
|
||||||
|
$('#menu-boat').showMenu();
|
||||||
|
$('#input-edit-boat-search').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initBoatsSailors() {
|
||||||
|
boats = [];
|
||||||
|
sailors = [];
|
||||||
|
boatKnown = [];
|
||||||
|
known = [];
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||||
|
boatKnownIds = {};
|
||||||
|
knownIds = {};
|
||||||
|
for (var p in plannings) {
|
||||||
|
p = plannings[p];
|
||||||
|
if (p.boat !== null) boatKnownIds[p.boat] = true;
|
||||||
|
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 dbBoats = await dbGetData('boats');
|
||||||
|
dbBoats.sort(function(a,b){
|
||||||
|
return a.sailnumber.localeCompare(b.sailnumber);
|
||||||
|
});
|
||||||
|
for (var b in dbBoats) {
|
||||||
|
var item = '<a class="item-boat-search" onclick="boatSelected(' + dbBoats[b].id + ')">';
|
||||||
|
item += '<span>' + dbBoats[b].sailnumber + ' - ' + dbBoats[b].name + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
boats.push({
|
||||||
|
keywords: [dbBoats[b].sailnumber, dbBoats[b].name],
|
||||||
|
content: item
|
||||||
|
});
|
||||||
|
if (dbBoats[b].id in boatKnownIds) boatKnown.push(item);
|
||||||
|
}
|
||||||
|
var dbSailors = await dbGetData('sailors');
|
||||||
|
dbSailors.sort(function(a,b){
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
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>';
|
||||||
|
item += '</a>';
|
||||||
|
sailors.push({
|
||||||
|
keywords: [dbSailors[s].name],
|
||||||
|
content: item
|
||||||
|
});
|
||||||
|
if (dbSailors[s].id in knownIds) known.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function planningEdit(id) {
|
async function planningEdit(id) {
|
||||||
var regatta = await dbGetData('regattas', id);
|
var regatta = await dbGetData('regattas', id);
|
||||||
|
|
||||||
@@ -225,7 +348,13 @@ async function planningEdit(id) {
|
|||||||
$('#switch-planning-include').data('regatta', id);
|
$('#switch-planning-include').data('regatta', id);
|
||||||
if (planning !== null) {
|
if (planning !== null) {
|
||||||
$('#switch-planning-include').prop('checked', true);
|
$('#switch-planning-include').prop('checked', true);
|
||||||
|
$('#item-boat').show();
|
||||||
$('#item-steuermann').show();
|
$('#item-steuermann').show();
|
||||||
|
if (planning.boat !== null) {
|
||||||
|
$('#item-boat').find('span').text('Boot: ' + (await dbGetData('boats', planning.boat)).sailnumber);
|
||||||
|
} else {
|
||||||
|
$('#item-boat').find('span').html('Boot: <font style="font-style:italic;">noch unklar</font>');
|
||||||
|
}
|
||||||
if (planning.steuermann !== null) {
|
if (planning.steuermann !== null) {
|
||||||
$('#item-steuermann').find('span').text('Am Steuer: ' + (await dbGetData('sailors', planning.steuermann)).name);
|
$('#item-steuermann').find('span').text('Am Steuer: ' + (await dbGetData('sailors', planning.steuermann)).name);
|
||||||
} else {
|
} else {
|
||||||
@@ -238,7 +367,7 @@ async function planningEdit(id) {
|
|||||||
if (sailor !== null) {
|
if (sailor !== null) {
|
||||||
var item = '<a class="item-crew" onclick="planningChangeCrew(' + sailor.id + ')">';
|
var item = '<a class="item-crew" onclick="planningChangeCrew(' + sailor.id + ')">';
|
||||||
item += '<span>' + sailor.name + '</span>';
|
item += '<span>' + sailor.name + '</span>';
|
||||||
item += '<i class="fa fa-angle-right"></i>';
|
item += '<i class="fa fa-times"></i>';
|
||||||
item += '</a>';
|
item += '</a>';
|
||||||
$('#menu-edit').find('.content').find('.list-group').append(item);
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
}
|
}
|
||||||
@@ -250,6 +379,7 @@ async function planningEdit(id) {
|
|||||||
$('#menu-edit').find('.content').find('.list-group').append(item);
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
} else {
|
} else {
|
||||||
$('#switch-planning-include').prop('checked', false);
|
$('#switch-planning-include').prop('checked', false);
|
||||||
|
$('#item-boat').hide();
|
||||||
$('#item-steuermann').hide();
|
$('#item-steuermann').hide();
|
||||||
$('.item-crew').remove();
|
$('.item-crew').remove();
|
||||||
}
|
}
|
||||||
@@ -267,11 +397,15 @@ function selectChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initYear() {
|
function initYear() {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (year === null) year = new Date().getFullYear();
|
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;
|
||||||
@@ -300,13 +434,15 @@ 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);
|
||||||
|
$('#item-boat').click(planningChangeBoat);
|
||||||
$('#item-steuermann').click(planningChangeSteuermann);
|
$('#item-steuermann').click(planningChangeSteuermann);
|
||||||
$('#input-edit-search').on('input', sailorsSearch);
|
$('#input-edit-search').on('input', sailorsSearch);
|
||||||
initSailors();
|
$('#input-edit-boat-search').on('input', boatsSearch);
|
||||||
|
initBoatsSailors();
|
||||||
}
|
}
|
||||||
|
|
||||||
today = getToday();
|
today = getToday();
|
||||||
@@ -365,6 +501,9 @@ var siteScript = async function() {
|
|||||||
if (entry['club'] != null)
|
if (entry['club'] != null)
|
||||||
club = await dbGetData('clubs', entry['club']);
|
club = await dbGetData('clubs', entry['club']);
|
||||||
if (entry.planning !== null) {
|
if (entry.planning !== null) {
|
||||||
|
if (entry.planning.boat !== null) {
|
||||||
|
entry.planning.boat = (await dbGetData('boats', entry.planning.boat)).sailnumber;
|
||||||
|
}
|
||||||
if (entry.planning.steuermann !== null) {
|
if (entry.planning.steuermann !== null) {
|
||||||
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
}
|
}
|
||||||
@@ -408,6 +547,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
|
||||||
@@ -440,10 +599,15 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
// ZEILE 5
|
// ZEILE 5
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</div>';
|
row.content += '<div>' + (entry.planning.boat !== null ? entry.planning.boat : '<i>Boot unklar</i>') + '</div>';
|
||||||
row.content += '</div>';
|
row.content += '</div>';
|
||||||
|
|
||||||
// ZEILE 6...
|
// ZEILE 6
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : '<i>St.mann unklar</i>') + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 7...
|
||||||
for (var i in entry.planning.crew) {
|
for (var i in entry.planning.crew) {
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,11 +16,15 @@ function selectChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initYear() {
|
function initYear() {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (year === null) year = new Date().getFullYear();
|
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;
|
||||||
@@ -47,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +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();
|
showLoader();
|
||||||
siteScript();
|
siteScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initYear() {
|
function initYear() {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (year === null) year = new Date().getFullYear();
|
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;
|
||||||
@@ -35,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);
|
||||||
@@ -58,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);
|
||||||
}
|
}
|
||||||
@@ -118,6 +124,9 @@ var siteScript = async function() {
|
|||||||
var club = null;
|
var club = null;
|
||||||
if (entry['club'] != null)
|
if (entry['club'] != null)
|
||||||
club = await dbGetData('clubs', entry['club']);
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
if (entry.planning.boat !== null) {
|
||||||
|
entry.planning.boat = (await dbGetData('boats', entry.planning.boat)).sailnumber;
|
||||||
|
}
|
||||||
if (entry.planning.steuermann !== null) {
|
if (entry.planning.steuermann !== null) {
|
||||||
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
}
|
}
|
||||||
@@ -137,6 +146,7 @@ var siteScript = async function() {
|
|||||||
row.keywords.push(entry['name']);
|
row.keywords.push(entry['name']);
|
||||||
if (entry['number'] != null) row.keywords.push(entry['number']);
|
if (entry['number'] != null) row.keywords.push(entry['number']);
|
||||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
if (entry.planning.boat != null) row.keywords.push(entry.planning.boat);
|
||||||
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
||||||
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
||||||
|
|
||||||
@@ -158,6 +168,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
|
||||||
@@ -189,10 +219,15 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
// ZEILE 5
|
// ZEILE 5
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</div>';
|
row.content += '<div>' + (entry.planning.boat !== null ? entry.planning.boat : '<i>Boot unklar</i>') + '</div>';
|
||||||
row.content += '</div>';
|
row.content += '</div>';
|
||||||
|
|
||||||
// ZEILE 6...
|
// ZEILE 6
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : '<i>St.mann unklar</i>') + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 7...
|
||||||
for (var i in entry.planning.crew) {
|
for (var i in entry.planning.crew) {
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ async function onRankingClicked(id) {
|
|||||||
|
|
||||||
// ZEILE 5...
|
// ZEILE 5...
|
||||||
var crew = entry.crew.split(',');
|
var crew = entry.crew.split(',');
|
||||||
|
crew.unshift(entry.helm);
|
||||||
for (var c in crew) {
|
for (var c in crew) {
|
||||||
var cr = await dbGetData('sailors', crew[c]);
|
var cr = await dbGetData('sailors', crew[c]);
|
||||||
if (cr != null) {
|
if (cr != null) {
|
||||||
@@ -106,52 +107,118 @@ async function onRankingClicked(id) {
|
|||||||
$('#menu-rank').scrollTop(0);
|
$('#menu-rank').scrollTop(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectChange(callSiteScript = true) {
|
var rankings;
|
||||||
var type = $('#select-type').val();
|
|
||||||
var year = parseInt($('#select-year').val());
|
function selectChange(callSiteScript = true) {
|
||||||
if (type == "user") {
|
return new Promise(async function (resolve) {
|
||||||
$('#select-year').parent().hide();
|
var year = $('#select-year').val();
|
||||||
|
if (year == "user") {
|
||||||
|
$('#select-type').parent().hide();
|
||||||
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
|
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
|
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-jugend').parent().parent().show();
|
$('#input-altm').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-jugstrict').parent().parent().show();
|
$('#input-maxage').trigger('focusin').trigger('focusout').parent().show();
|
||||||
|
$('#input-agestrict').parent().show();
|
||||||
|
$('#input-agecrew').parent().show();
|
||||||
$('#button-show').show();
|
$('#button-show').show();
|
||||||
|
$('#card-special-ranks').hide();
|
||||||
} else {
|
} else {
|
||||||
$('#select-year').parent().show();
|
year = parseInt(year);
|
||||||
|
var type = $('#select-type').val();
|
||||||
|
console.log('[rank] selected', year, type);
|
||||||
|
$('#select-type').parent().show();
|
||||||
$('#input-from').parent().hide();
|
$('#input-from').parent().hide();
|
||||||
$('#input-to').parent().hide();
|
$('#input-to').parent().hide();
|
||||||
$('#input-jugend').parent().parent().hide();
|
$('#input-altm').parent().hide();
|
||||||
$('#input-jugstrict').parent().parent().hide();
|
$('#input-maxage').parent().hide();
|
||||||
|
$('#input-agestrict').parent().hide();
|
||||||
|
$('#input-agecrew').parent().hide();
|
||||||
$('#button-show').hide();
|
$('#button-show').hide();
|
||||||
|
$('#card-special-ranks').hide(); // first hide, show only when there are special ranks
|
||||||
|
|
||||||
var from, to, jugend, jugstrict;
|
var rankingsShow = {};
|
||||||
switch (type) {
|
var options = '';
|
||||||
|
for (var i in rankings) {
|
||||||
|
if (rankings[i].year_from !== null && rankings[i].year_from > year) continue;
|
||||||
|
if (rankings[i].year_to !== null && rankings[i].year_to < year) continue;
|
||||||
|
var alias = rankings[i].alias;
|
||||||
|
options += '<option value="' + alias + '">' + rankings[i].name + '</option>';
|
||||||
|
rankingsShow[alias] = rankings[i];
|
||||||
|
}
|
||||||
|
$('#select-type').html(options);
|
||||||
|
if (!(type in rankingsShow)) {
|
||||||
|
console.log('[rank] selected type', type, 'not found for year', year, '. Using `year`');
|
||||||
|
type = 'year';
|
||||||
|
}
|
||||||
|
$('#select-type').val(type).trigger('focusin').trigger('focusout');
|
||||||
|
|
||||||
|
// special ranks
|
||||||
|
getJSON(QUERY_URL + 'get_special_rankings', function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var specialRanks = [];
|
||||||
|
for (var i in data.data) {
|
||||||
|
var sr = data.data[i];
|
||||||
|
if (sr.to < (year + '-01-01')) continue;
|
||||||
|
if (sr.to > (year + '-12-31')) continue;
|
||||||
|
specialRanks.push(sr);
|
||||||
|
}
|
||||||
|
if (specialRanks.length > 0) {
|
||||||
|
var btns = '';
|
||||||
|
for (var i in specialRanks) {
|
||||||
|
var sr = specialRanks[i];
|
||||||
|
var link = 'https://ranglisten.net/frame.php?class=' + BOATCLASS + '&site=special_rank&rank_id=' + sr.id;
|
||||||
|
var name = sr.title;
|
||||||
|
var cssclass = i > 0 ? ' mt-3' : '';
|
||||||
|
btns += '<a class="btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight' + cssclass + '" href="' + link + '">' + name + '</a>';
|
||||||
|
}
|
||||||
|
$('#card-special-ranks').find('.content').html(btns);
|
||||||
|
$('#card-special-ranks').show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log("[rank] special_ranks: Something went wrong (HTTP " + code + ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var from, to, altm, maxage, agestrict, agecrew;
|
||||||
|
altm = 9; maxage = false; agestrict = false; agecrew = false;
|
||||||
|
var r = rankingsShow[type];
|
||||||
|
console.log('[rank] type', type, '=>', r);
|
||||||
|
if (r.max_age !== null) {
|
||||||
|
maxage = r.max_age;
|
||||||
|
agestrict = r.age_strict == 1;
|
||||||
|
agecrew = r.age_crew == 1;
|
||||||
|
}
|
||||||
|
if (r.alt_m !== null) {
|
||||||
|
altm = r.alt_m;
|
||||||
|
}
|
||||||
|
switch (r.type) {
|
||||||
case 'year':
|
case 'year':
|
||||||
from = (year - 1) + '-12-01';
|
from = (year - 1) + '-12-01';
|
||||||
to = year + '-11-30';
|
to = year + '-11-30';
|
||||||
jugend = jugstrict = false;
|
|
||||||
break;
|
break;
|
||||||
case 'youth':
|
case 'year2':
|
||||||
from = (year - 1) + '-12-01';
|
from = year + '-01-01';
|
||||||
to = year + '-11-30';
|
to = year + '-12-31';
|
||||||
jugend = jugstrict = true;
|
|
||||||
break;
|
break;
|
||||||
case 'idjm':
|
case 'quali':
|
||||||
|
// TODO: auslagern in function getRegattaBegin
|
||||||
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); });
|
||||||
for (var r in regattas) {
|
for (var ri in regattas) {
|
||||||
var regatta = regattas[r];
|
var regatta = regattas[ri];
|
||||||
var date = parseDate(regatta.date);
|
var date = parseDate(regatta.date);
|
||||||
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.toLowerCase().indexOf(r.quali_search.toLowerCase()) >= 0) {
|
||||||
|
console.log('FOUND', regatta);
|
||||||
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
|
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (beginn != null) {
|
// END OF TODO
|
||||||
|
if (beginn !== null) {
|
||||||
from = new Date(beginn);
|
from = new Date(beginn);
|
||||||
from.setFullYear(from.getFullYear() - 1);
|
from.setFullYear(from.getFullYear() - 1);
|
||||||
from.setDate(from.getDate() - 13);
|
from.setDate(from.getDate() - 13);
|
||||||
@@ -159,65 +226,108 @@ async function selectChange(callSiteScript = true) {
|
|||||||
to = new Date(beginn);
|
to = new Date(beginn);
|
||||||
to.setDate(to.getDate() - 14);
|
to.setDate(to.getDate() - 14);
|
||||||
to = formatDate('Y-m-d', to);
|
to = formatDate('Y-m-d', to);
|
||||||
jugend = true;
|
|
||||||
jugstrict = false;
|
|
||||||
} else {
|
} else {
|
||||||
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!');
|
console.log('[rank] no regatta found');
|
||||||
$('#input-search').parent().hide();
|
from = year + '-12-31'; // reverse => no regattas will be found => no ranking
|
||||||
return;
|
to = year + '-01-01';
|
||||||
|
break; // TODO: bessere Fehlermeldung - keine Regatta gefunden
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default: // TODO: bessere Fehlermeldung - tritt nur bei Fehlkonfiguration in DB auf
|
||||||
|
from = (year - 1) + '-12-01';
|
||||||
|
to = year + '-11-30';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var personMode = $('#select-personmode').val();
|
||||||
|
|
||||||
|
console.log('[rank] setting', from, to, altm, maxage, agestrict, agecrew);
|
||||||
$('#input-from').val(from);
|
$('#input-from').val(from);
|
||||||
$('#input-to').val(to);
|
$('#input-to').val(to);
|
||||||
$('#input-jugend').prop('checked', jugend);
|
$('#input-altm').val(altm);
|
||||||
$('#input-jugstrict').prop('checked', jugstrict);
|
$('#input-maxage').val(maxage == false ? '' : maxage);
|
||||||
|
$('#input-agestrict').prop('checked', agestrict);
|
||||||
|
$('#input-agecrew').prop('checked', agecrew);
|
||||||
|
|
||||||
if (callSiteScript && (typeof siteScript === 'function')) {
|
if (callSiteScript && (typeof siteScript === 'function')) {
|
||||||
history.replaceState(null, '', '?type=' + type + '&year=' + year);
|
history.replaceState(null, '', '?year=' + year + '&type=' + type + '&pm=' + personMode);
|
||||||
showLoader();
|
showLoader();
|
||||||
siteScript();
|
siteScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buttonShowPressed() {
|
function buttonShowPressed() {
|
||||||
if (typeof siteScript === 'function') {
|
if (typeof siteScript === 'function') {
|
||||||
var chboxes = '';
|
var additional = '';
|
||||||
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
|
if ($('#input-maxage').val() != '') additional += '&maxage=' + $('#input-maxage').val();
|
||||||
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
|
if ($('#input-agestrict').prop('checked')) additional += '&agestrict=on';
|
||||||
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
|
if ($('#input-agecrew').prop('checked')) additional += '&agecrew=on';
|
||||||
|
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + "&altm=" + $('#input-altm').val() + "&pm=" + $('#select-personmode').val() + additional)
|
||||||
showLoader();
|
showLoader();
|
||||||
siteScript();
|
siteScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSelects() {
|
function initSelects() {
|
||||||
var type = findGetParameter('type');
|
return new Promise(async function(resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (type === null) type = 'year';
|
var type = findGetParameter('type');
|
||||||
|
var personMode = parseInt(findGetParameter('pm'));
|
||||||
if (year === null) year = new Date().getFullYear();
|
if (year === null) year = new Date().getFullYear();
|
||||||
|
if (type === null) type = 'year';
|
||||||
|
if (isNaN(personMode) || personMode < 0 || personMode > 2) personMode = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
var yearFound = year == 'user';
|
||||||
|
var options = '<option value="user">Benutzerdefiniert</option>';
|
||||||
|
for (id in years) {
|
||||||
|
var y = years[id]['year'];
|
||||||
|
options += '<option value="' + y + '">' + y + '</option>';
|
||||||
|
if (year == y) yearFound = true;
|
||||||
|
}
|
||||||
|
$('#select-year').html(options);
|
||||||
|
$('#select-year').val(yearFound ? year : years[0]);
|
||||||
|
|
||||||
|
$('#select-type').html('<option value="' + type + '">' + type + '</option>');
|
||||||
$('#select-type').val(type);
|
$('#select-type').val(type);
|
||||||
|
|
||||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
if (year == "user") {
|
||||||
$('#select-year').val(year);
|
|
||||||
|
|
||||||
if (type == "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');
|
||||||
var jugend = findGetParameter('jugend');
|
var altm = findGetParameter('altm');
|
||||||
var jugstrict = findGetParameter('jugstrict');
|
if (altm === null) altm = 9;
|
||||||
$('#input-jugend').prop('checked', jugend !== null);
|
$('#input-altm').val(altm).trigger('focusin').trigger('focusout');
|
||||||
$('#input-jugstrict').prop('checked', jugstrict !== null);
|
var maxage = findGetParameter('maxage');
|
||||||
|
if (maxage === null) maxage = '';
|
||||||
|
$('#input-maxage').val(maxage).trigger('focusin').trigger('focusout');
|
||||||
|
var agestrict = findGetParameter('agestrict');
|
||||||
|
var agecrew = findGetParameter('agecrew');
|
||||||
|
$('#input-agestrict').prop('checked', agestrict !== null);
|
||||||
|
$('#input-agecrew').prop('checked', agecrew !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectChange(false);
|
options = '<option value="0">Steuerleuten</option>';
|
||||||
|
options += '<option value="1">Vorschotern</option>';
|
||||||
|
options += '<option value="2">allen Seglern</option>';
|
||||||
|
$('#select-personmode').html(options);
|
||||||
|
$('#select-personmode').val(personMode);
|
||||||
|
|
||||||
|
await selectChange(false);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstCall = true;
|
var firstCall = true;
|
||||||
@@ -230,7 +340,12 @@ async function drawList () {
|
|||||||
var list = '';
|
var list = '';
|
||||||
rows.forEach(function (entry) {
|
rows.forEach(function (entry) {
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
var altm = $('#input-altm').val(); if (altm == '') altm = 9; else altm = parseInt(altm);
|
||||||
|
if (altm == 9) {
|
||||||
list += '<div><div align="center" class="color-highlight" style="white-space:normal;"><b>Ende der Rangliste gemäß DSV-Ranglistenverordnung (min. m = 9 Wertungen)</b></div></div>';
|
list += '<div><div align="center" class="color-highlight" style="white-space:normal;"><b>Ende der Rangliste gemäß DSV-Ranglistenverordnung (min. m = 9 Wertungen)</b></div></div>';
|
||||||
|
} else {
|
||||||
|
list += '<div><div align="center" class="color-highlight" style="white-space:normal;"><b>Ende der Rangliste (min. m = ' + altm + ' Wertungen)</b></div></div>';
|
||||||
|
}
|
||||||
} else if (search($('#input-search').val(), entry.keywords)) {
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
list += entry.content;
|
list += entry.content;
|
||||||
}
|
}
|
||||||
@@ -242,27 +357,43 @@ async function drawList () {
|
|||||||
var siteScript = async function() {
|
var siteScript = async function() {
|
||||||
if (firstCall) {
|
if (firstCall) {
|
||||||
firstCall = false;
|
firstCall = false;
|
||||||
initSelects();
|
rankings = await dbGetData('rankings');
|
||||||
$('#select-type').change(selectChange);
|
await initSelects();
|
||||||
$('#select-year').change(selectChange);
|
$('#select-year').change(selectChange);
|
||||||
|
$('#select-type').change(selectChange);
|
||||||
|
$('#select-personmode').change(selectChange);
|
||||||
$('#button-show').click(buttonShowPressed);
|
$('#button-show').click(buttonShowPressed);
|
||||||
$('#input-search').on('input', drawList);
|
$('#input-search').on('input', drawList);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 jugend = $('#input-jugend').prop('checked');
|
var altm = $('#input-altm').val(); if (altm == '') altm = 9; else altm = parseInt(altm);
|
||||||
var jugstrict = $('#input-jugstrict').prop('checked');
|
var maxage = $('#input-maxage').val(); if (maxage == '') maxage = false; else maxage = parseInt(maxage);
|
||||||
var dbRanking = await dbGetRanking(minDate, maxDate, jugend, jugstrict);
|
var agestrict = $('#input-agestrict').prop('checked');
|
||||||
|
var agecrew = $('#input-agecrew').prop('checked');
|
||||||
|
var personMode = $('#select-personmode').val();
|
||||||
|
console.log('[rank] rank params:', minDate, maxDate, altm, maxage, agestrict, agecrew, personMode);
|
||||||
|
var dbRanking = await dbGetRanking(minDate, maxDate, maxage, agestrict, altm, agecrew, personMode);
|
||||||
ranking = dbRanking[0];
|
ranking = dbRanking[0];
|
||||||
|
|
||||||
lastRanking = null;
|
lastRanking = null; // TODO: also for quali ranks
|
||||||
if (($('#select-type').val() == 'year') || ($('#select-type').val() == 'youth')) {
|
if (($('#select-type').val() == 'year') || ($('#select-type').val() == 'youth')) {
|
||||||
lastRanking = {};
|
lastRanking = {};
|
||||||
var lYear = parseInt($('#select-year').val()) - 1;
|
var lYear = parseInt($('#select-year').val()) - 1;
|
||||||
var lMinDate = parseDate((lYear - 1) + '-12-01');
|
var lMinDate = parseDate((lYear - 1) + '-12-01');
|
||||||
var lMaxDate = parseDate(lYear + '-11-30');
|
var lMaxDate = parseDate(lYear + '-11-30');
|
||||||
var lDbRanking = (await dbGetRanking(lMinDate, lMaxDate, jugend, jugstrict))[0];
|
var lDbRanking = (await dbGetRanking(lMinDate, lMaxDate, maxage, agestrict, altm, agecrew, personMode))[0];
|
||||||
|
for (var i in lDbRanking) {
|
||||||
|
lastRanking[lDbRanking[i].id] = lDbRanking[i].rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($('#select-type').val() == 'year2') {
|
||||||
|
lastRanking = {};
|
||||||
|
var lYear = parseInt($('#select-year').val()) - 1;
|
||||||
|
var lMinDate = parseDate(lYear + '-01-01');
|
||||||
|
var lMaxDate = parseDate(lYear + '-12-31');
|
||||||
|
var lDbRanking = (await dbGetRanking(lMinDate, lMaxDate, maxage, agestrict, altm, agecrew, personMode))[0];
|
||||||
for (var i in lDbRanking) {
|
for (var i in lDbRanking) {
|
||||||
lastRanking[lDbRanking[i].id] = lDbRanking[i].rank;
|
lastRanking[lDbRanking[i].id] = lDbRanking[i].rank;
|
||||||
}
|
}
|
||||||
@@ -270,20 +401,6 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
var selectedYear = $('#select-year').val();
|
var selectedYear = $('#select-year').val();
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
var options = '';
|
|
||||||
for (id in years) {
|
|
||||||
var year = years[id]['year'];
|
|
||||||
options += '<option value="' + year + '">' + year + '</option>';
|
|
||||||
}
|
|
||||||
$('#select-year').html(options);
|
|
||||||
$('#select-year').val(selectedYear);
|
|
||||||
|
|
||||||
if (dbRanking[1].length > 0) {
|
if (dbRanking[1].length > 0) {
|
||||||
$('#card-noresults').show();
|
$('#card-noresults').show();
|
||||||
list = '';
|
list = '';
|
||||||
@@ -325,7 +442,7 @@ var siteScript = async function() {
|
|||||||
if (entry['year'] != null) row.keywords.push(entry['year']);
|
if (entry['year'] != null) row.keywords.push(entry['year']);
|
||||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
|
||||||
if (!dsvEnd && (entry.m < 9)) {
|
if (!dsvEnd && (entry.m < altm)) {
|
||||||
rows.push(null);
|
rows.push(null);
|
||||||
dsvEnd = true;
|
dsvEnd = true;
|
||||||
}
|
}
|
||||||
|
|||||||
258
server/scripts/regatta_facts.js
Normal file
258
server/scripts/regatta_facts.js
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
var siteScript = async function() {
|
||||||
|
$('#card-nofactsinfo').hide();
|
||||||
|
$('#card-entryfee').hide();
|
||||||
|
$('#card-races').hide();
|
||||||
|
$('#card-races').find('p').remove();
|
||||||
|
$('#card-races').find('table').remove();
|
||||||
|
$('#card-times').hide();
|
||||||
|
$('#card-camping').hide();
|
||||||
|
$('#card-food').hide();
|
||||||
|
$('#card-text').hide();
|
||||||
|
|
||||||
|
var regattaId = findGetParameter('regatta');
|
||||||
|
if (regattaId == null) {
|
||||||
|
$('#h1-title').text('Regatta nicht gefunden');
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var regatta = await dbGetData('regattas', regattaId);
|
||||||
|
if (regatta == null) {
|
||||||
|
$('#h1-title').text('Regatta nicht gefunden');
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dateFrom = parseDate(regatta['date']);
|
||||||
|
var dateTo = parseDate(regatta['date']);
|
||||||
|
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
|
||||||
|
|
||||||
|
$('#h1-title').text(regatta.name);
|
||||||
|
if (regatta.length < 1) {
|
||||||
|
if (formatDate('d.m', dateFrom) == '01.01') {
|
||||||
|
$('#p-title').html('<font class="color-red2-dark">Datum noch unklar</font>');
|
||||||
|
} else {
|
||||||
|
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font>');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regatta.facts != null) {
|
||||||
|
var facts = JSON.parse(regatta.facts);
|
||||||
|
|
||||||
|
// Meldegeld
|
||||||
|
if ('entry' in facts && 'price' in facts.entry) {
|
||||||
|
$('#card-entryfee').show();
|
||||||
|
var content = 'Meldegeld: <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.entry.price)) + '</b>';
|
||||||
|
if ('early' in facts.entry) {
|
||||||
|
content += '<br />vergünstigt: <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.entry.early)) + '</b> (bis ' + formatDate('d.m.Y', parseDate(regatta.meldungEarly)) + ')';
|
||||||
|
}
|
||||||
|
if ('late' in facts.entry) {
|
||||||
|
content += '<br />nach Meldeschluss (' + formatDate('d.m.Y', parseDate(regatta.meldungSchluss)) + '): <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.entry.late)) + '</b>';
|
||||||
|
}
|
||||||
|
$('#card-entryfee').find('p').html(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wettfahrten / Anzahl
|
||||||
|
if ('races' in facts && 'cnt' in facts.races) {
|
||||||
|
$('#card-races').show();
|
||||||
|
$('#card-races').find('.content').append('<p>Anzahl Wettfahrten: <b>' + facts.races.cnt + '</b></p>');
|
||||||
|
if ('days' in facts.races) {
|
||||||
|
var table = $('<table class="table table-striped table-bordered text-nowrap">');
|
||||||
|
var tbody = $('<tbody>');
|
||||||
|
for (var day in facts.races.days) {
|
||||||
|
var cnt = facts.races.days[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td><b>' + cnt + '</b></td></tr>')
|
||||||
|
}
|
||||||
|
table.append(tbody);
|
||||||
|
$('#card-races').find('.content').append(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wettfahrten / Racetimes
|
||||||
|
if ('racetimes' in facts) {
|
||||||
|
$('#card-races').show();
|
||||||
|
var table = $('<table class="table table-striped table-bordered mb-0 text-nowrap">');
|
||||||
|
var tbody = $('<tbody>');
|
||||||
|
if ('sollzeit' in facts.racetimes) {
|
||||||
|
tbody.append('<tr><td>Sollzeit</td><td>' + facts.racetimes.sollzeit + ' min</td></tr>');
|
||||||
|
}
|
||||||
|
if ('zeitlimit' in facts.racetimes) {
|
||||||
|
tbody.append('<tr><td>Zeitlimit</td><td>' + facts.racetimes.zeitlimit + ' min</td></tr>');
|
||||||
|
}
|
||||||
|
if ('zielzeitfenster' in facts.racetimes) {
|
||||||
|
tbody.append('<tr><td>Zielzeitfenster</td><td>' + facts.racetimes.zielzeitfenster + ' min</td></tr>');
|
||||||
|
}
|
||||||
|
table.append(tbody);
|
||||||
|
$('#card-races').find('.content').append(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zeitplan
|
||||||
|
if ('times' in facts) {
|
||||||
|
$('#card-times').show();
|
||||||
|
var tbody = $('#card-times').find('table').find('tbody');
|
||||||
|
tbody.html('');
|
||||||
|
if ('checkin' in facts.times) {
|
||||||
|
tbody.append('<tr><td colspan="2" style="text-align: center; font-weight: bold;">Registrierung</td></tr>');
|
||||||
|
for (var day in facts.times.checkin) {
|
||||||
|
var times = facts.times.checkin[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
var content = '';
|
||||||
|
if ('from' in times && 'to' in times) content = times.from + ' bis ' + times.to; // TODO:
|
||||||
|
else if ('from' in times) content = 'ab ' + times.from;
|
||||||
|
else if ('to' in times) content = 'bis ' + times.to;
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td>' + content + '</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ('measurements' in facts.times) {
|
||||||
|
tbody.append('<tr><td colspan="2" style="text-align: center; font-weight: bold;">Vermessung</td></tr>');
|
||||||
|
for (var day in facts.times.measurements) {
|
||||||
|
var times = facts.times.measurements[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
var content = '';
|
||||||
|
if ('from' in times && 'to' in times) content = times.from + ' bis ' + times.to; // TODO:
|
||||||
|
else if ('from' in times) content = 'ab ' + times.from;
|
||||||
|
else if ('to' in times) content = 'bis ' + times.to;
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td>' + content + '</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ('helmmeeting' in facts.times) {
|
||||||
|
tbody.append('<tr><td colspan="2" style="text-align: center; font-weight: bold;">Steuerleutebesprechung</td></tr>');
|
||||||
|
for (var day in facts.times.helmmeeting) {
|
||||||
|
var time = facts.times.helmmeeting[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td>' + time + '</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ('firststart' in facts.times) {
|
||||||
|
tbody.append('<tr><td colspan="2" style="text-align: center; font-weight: bold;">Erster Start</td></tr>');
|
||||||
|
for (var day in facts.times.firststart) {
|
||||||
|
var time = facts.times.firststart[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td>' + time + '</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ('laststart' in facts.times) {
|
||||||
|
tbody.append('<tr><td colspan="2" style="text-align: center; font-weight: bold;">Letzter Start</td></tr>');
|
||||||
|
for (var day in facts.times.laststart) {
|
||||||
|
var time = facts.times.laststart[day];
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
tbody.append('<tr><td>' + day + '</td><td>' + time + '</td></tr>')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Camping
|
||||||
|
if ('camping' in facts) {
|
||||||
|
$('#card-camping').show();
|
||||||
|
$('#card-camping').find('p').remove();
|
||||||
|
if ('tent' in facts.camping) {
|
||||||
|
var content = '';
|
||||||
|
if ('price' in facts.camping.tent && facts.camping.tent.price > 0) {
|
||||||
|
content += 'Zelten möglich für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.tent.price)) + '</b>';
|
||||||
|
}
|
||||||
|
else if ('pricepernight' in facts.camping.tent) {
|
||||||
|
content += 'Zelten möglich für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.tent.pricepernight)) + ' pro Nacht</b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content += 'Zelten möglich und im Preis enthalten';
|
||||||
|
}
|
||||||
|
if ('electricity' in facts.camping.tent) {
|
||||||
|
content += '<br />';
|
||||||
|
if (facts.camping.tent.electricity > 0) {
|
||||||
|
content += 'Strom: <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.tent.electricity)) + '</b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content += 'Strom inklusive';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#card-camping').find('.content').append('<p>' + content + '</p>');
|
||||||
|
}
|
||||||
|
if ('van' in facts.camping) {
|
||||||
|
var content = '';
|
||||||
|
if ('price' in facts.camping.van && facts.camping.van.price > 0) {
|
||||||
|
content += 'Wohnwagen/-mobil möglich für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.van.price)) + '</b>';
|
||||||
|
}
|
||||||
|
else if ('pricepernight' in facts.camping.van) {
|
||||||
|
content += 'Wohnwagen/-mobil möglich für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.van.pricepernight)) + ' pro Nacht</b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content += 'Wohnwagen/-mobil möglich und im Preis enthalten';
|
||||||
|
}
|
||||||
|
if ('electricity' in facts.camping.van) {
|
||||||
|
content += '<br />';
|
||||||
|
if (facts.camping.van.electricity > 0) {
|
||||||
|
content += 'Strom: <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.van.electricity)) + '</b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content += 'Strom inklusive';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#card-camping').find('.content').append('<p>' + content + '</p>');
|
||||||
|
}
|
||||||
|
if ('beds' in facts.camping) {
|
||||||
|
var content = '';
|
||||||
|
if ('price' in facts.camping.beds && facts.camping.beds.price > 0) {
|
||||||
|
content += 'Betten im Clubhaus vorhanden für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.beds.price)) + '</b>';
|
||||||
|
}
|
||||||
|
else if ('pricepernight' in facts.camping.beds) {
|
||||||
|
content += 'Betten im Clubhaus vorhanden für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(facts.camping.beds.pricepernight)) + ' pro Nacht</b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content += 'Betten im Clubhaus vorhanden und im Preis enthalten';
|
||||||
|
}
|
||||||
|
$('#card-camping').find('.content').append('<p>' + content + '</p>');
|
||||||
|
}
|
||||||
|
if ('text' in facts.camping) {
|
||||||
|
var p = $('<p>');
|
||||||
|
p.text(facts.camping.text);
|
||||||
|
p.html(p.html().replace(/\n/g, '<br />'));
|
||||||
|
$('#card-camping').find('.content').append(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verpflegung
|
||||||
|
if ('food' in facts) {
|
||||||
|
$('#card-food').show();
|
||||||
|
$('#card-food').find('p').remove();
|
||||||
|
for (var day in facts.food) {
|
||||||
|
var food = facts.food[day];
|
||||||
|
if (day == 'text') {
|
||||||
|
var p = $('<p>');
|
||||||
|
p.text(food);
|
||||||
|
p.html(p.html().replace(/\n/g, '<br />'));
|
||||||
|
$('#card-food').find('.content').append(p);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
day = formatDate('D, j.', parseDate(day));
|
||||||
|
var content = '';
|
||||||
|
if ('breakfast' in food) {
|
||||||
|
content += 'Frühstück am ' + day;
|
||||||
|
if (food.breakfast > 0) content += ' für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(food.breakfast)) + '</b><br />';
|
||||||
|
else content += ' inklusive<br />';
|
||||||
|
}
|
||||||
|
if ('dinner' in food) {
|
||||||
|
content += 'Abendessen';
|
||||||
|
if ('dinnerdesc' in food) content += ' (' + food.dinnerdesc + ')';
|
||||||
|
content += ' am ' + day;
|
||||||
|
if (food.dinner > 0) content += ' für <b>' + (new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(food.dinner)) + '</b><br />';
|
||||||
|
else content += ' inklusive<br />';
|
||||||
|
}
|
||||||
|
$('#card-food').find('.content').append('<p>' + content + '</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weitere Informationen
|
||||||
|
if ('text' in facts) {
|
||||||
|
$('#card-text').show();
|
||||||
|
var p = $('#card-text').find('p');
|
||||||
|
p.text(facts.text);
|
||||||
|
p.html(p.html().replace(/\n/g, '<br />'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#card-nofactsinfo').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
@@ -38,6 +38,12 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
tbody += '<td>' + (await dbGetData('users', planning.user)).username + '</td>';
|
tbody += '<td>' + (await dbGetData('users', planning.user)).username + '</td>';
|
||||||
|
|
||||||
|
if (planning.boat != null) {
|
||||||
|
tbody += '<td>' + (await dbGetData('boats', planning.boat)).sailnumber + '</td>';
|
||||||
|
} else {
|
||||||
|
tbody += '<td>(noch unklar)</td>';
|
||||||
|
}
|
||||||
|
|
||||||
if (planning.steuermann != null) {
|
if (planning.steuermann != null) {
|
||||||
tbody += '<td>' + (await dbGetData('sailors', planning.steuermann)).name + '</td>';
|
tbody += '<td>' + (await dbGetData('sailors', planning.steuermann)).name + '</td>';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
Element.prototype.documentOffsetTop = function() {
|
||||||
|
return this.offsetTop + (this.offsetParent ? this.offsetParent.documentOffsetTop() : 0);
|
||||||
|
};
|
||||||
|
function scrollToToday() {
|
||||||
|
window.scrollTo({ top: document.getElementById('div-today').documentOffsetTop() - (window.innerHeight / 2), behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
|
||||||
function selectChange(callSiteScript = true) {
|
function selectChange(callSiteScript = true) {
|
||||||
var val = $('#select-year').val();
|
var val = $('#select-year').val();
|
||||||
if (val == "user") {
|
if (val == "user") {
|
||||||
@@ -29,8 +36,9 @@ function buttonShowPressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initYear() {
|
function initYear() {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
var year = findGetParameter('year');
|
var year = findGetParameter('year');
|
||||||
if (year === null) year = new Date().getFullYear();
|
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);
|
||||||
@@ -45,6 +53,9 @@ function initYear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectChange(false);
|
selectChange(false);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstCall = true;
|
var firstCall = true;
|
||||||
@@ -56,7 +67,7 @@ async function drawList () {
|
|||||||
var list = '';
|
var list = '';
|
||||||
rows.forEach(function (entry) {
|
rows.forEach(function (entry) {
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
list += '<div><div id="div-today" align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
||||||
} else if (search($('#input-search').val(), entry.keywords)) {
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
list += entry.content;
|
list += entry.content;
|
||||||
}
|
}
|
||||||
@@ -68,10 +79,11 @@ 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);
|
||||||
|
$('#button-totoday').click(scrollToToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
today = getToday();
|
today = getToday();
|
||||||
@@ -79,12 +91,9 @@ 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) {
|
if (minDate <= today && maxDate >= today) $('#button-totoday').parent().parent().show();
|
||||||
var entry = regattas[id];
|
else $('#button-totoday').parent().parent().hide();
|
||||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
|
||||||
regattaResults[entry['id']] = (results.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedYear = $('#select-year').val();
|
var selectedYear = $('#select-year').val();
|
||||||
|
|
||||||
@@ -115,6 +124,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];
|
||||||
@@ -152,7 +164,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 = [];
|
||||||
@@ -196,7 +238,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(' ') + '</div>';
|
row.content += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||||
@@ -229,12 +271,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();
|
||||||
|
|||||||
@@ -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,17 @@ 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);
|
||||||
|
var follows = await dbGetData('follows');
|
||||||
|
followedSailors = [];
|
||||||
|
for (var i in follows) {
|
||||||
|
followedSailors.push(await dbGetData('sailors', follows[i].sailor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = await dbGetData('sailors');
|
var results = await dbGetData('sailors');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<nav id="$$html-id;">
|
<nav id="$$html-id;" class="$$css-class;">
|
||||||
<ul class="pagination justify-content-center">
|
<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>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PWA_VERSION', '1.10.4');
|
define('PWA_VERSION', '1.13h6');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -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,8 +228,7 @@ 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:
|
||||||
|
|||||||
Reference in New Issue
Block a user