function selectChange(callSiteScript = true) {
var val = $('#select-year').val();
if (val == "user") {
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#button-show').show();
} else {
$('#input-from').parent().hide();
$('#input-to').parent().hide();
$('#button-show').hide();
$('#input-from').val(val + '-01-01');
$('#input-to').val(val + '-12-31');
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?year=' + val);
showLoader();
siteScript();
}
}
}
function buttonShowPressed() {
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val());
showLoader();
siteScript();
}
}
function initYear() {
return new Promise(async function (resolve) {
var year = findGetParameter('year');
if (year === null) year = await dbGetCurrentYear();
$('#select-year').html('');
$('#select-year').val(year);
if (year == "user") {
var from = findGetParameter('from');
var to = findGetParameter('to');
if (from === null) from = formatDate('Y-m-d')
if (to === null) to = formatDate('Y-m-d')
$('#input-from').val(from).trigger('focusin').trigger('focusout');
$('#input-to').val(to).trigger('focusin').trigger('focusout');
}
selectChange(false);
resolve();
});
}
var firstCall = true;
var rows = [];
var today;
async function drawList () {
window.setTimeout(function () {
var list = '';
rows.forEach(function (entry) {
if (entry == null) {
list += '
';
// ZEILE 1
// Name
row.content += '
' + (entry['canceled'] == 1 ? '' : '') + entry['name'] + (entry['canceled'] == 1 ? '' : '') + '
';
// ZEILE 2
row.content += '
';
// Number
row.content += '
' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '
';
// Club
row.content += '
' + ((club != null) ? club['kurz'] : '') + '
';
// Special
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';
}
}
row.content += '
' + entry.special + '
';
// Icons
var icons = [];
if (entry['info'] != '')
icons.push('
');
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) {
var color = '';
var planning = null;
if (isLoggedIn()) {
var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
for (id in plannings) {
if (plannings[id]['user'] == USER_ID) {
planning = plannings[id];
break;
}
}
}
if (entry['meldungSchluss'] != null) {
if ((planning == null) || (planning['gemeldet'] == '0')) {
var ms = 0;
if (entry['meldungEarly'] != null) {
ms = parseDate(entry['meldungEarly']);
}
if (ms < today) {
ms = parseDate(entry['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
}
if ((planning != null) && (planning['gemeldet'] == '0')) {
color += ' fa-blink';
}
icons.push('
');
}
if (entry['bericht'] != '')
icons.push('
');
if (entry['canceled'] == '1') {
icons.push('
');
} else if (entry['results'] == '1') {
icons.push('
');
}
row.content += '
' + icons.join(' ') + '
';
row.content += '
';
// ZEILE 3
row.content += '
';
// Date
if (entry['length'] < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
row.content += '
Datum noch unklar
';
} else {
row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - Datum nicht final
';
}
} else {
row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '
';
}
// RLF
row.content += '
' + parseFloat(entry['rlf']).toFixed(2) + '
';
row.content += '
';
rows.push(row);
}
if (!heute) {
rows.push(null);
}
if (Object.keys(specialShown).length > 0) {
var specialText = '';
for (key in specialShown) {
specialText += '* ' + key + ': ' + specialShown[key] + '