function onDetailClicked(regatta) {
location.href = LINK_PRE + 'result?regatta=' + regatta;
}
async function onRankingClicked(id) {
var sailor = null;
for (var i in ranking) {
if (ranking[i].id == id) {
sailor = ranking[i];
break;
}
}
if (sailor == null) return;
$('#menu-rank').find('.menu-title').find('p').text(sailor.name);
if (lastRanking != null) {
var lastRank;
if (sailor.id in lastRanking) {
lastRank = lastRanking[sailor.id] + '.';
} else {
lastRank = 'nicht in der Rangliste';
}
$('#menu-item-text').text('Vorheriges Jahr: ' + lastRank);
$('#menu-item-text').show();
} else {
$('#menu-item-text').hide();
}
list = '';
for (var i in sailor.regattas) {
var entry = sailor.regattas[i];
var regatta = entry.regatta;
var boat = await dbGetData('boats', entry.boat);
var dateFrom = parseDate(regatta.date);
var dateTo = parseDate(regatta.date);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta.length) - 1, 0));
list += '
';
// ZEILE 1
list += '
' + regatta.name + '
';
// ZEILE 2
list += '
';
// DATE
list += '
' + formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo) + '
';
// m
list += '
m: ' + entry.m + '
';
// rlf
list += '
RLF: ' + parseFloat(regatta.rlf).toFixed(2) + '
';
list += '
';
// ZEILE 3
list += '
';
// Place
list += '
Platz ' + entry.place + ' / ' + entry.fb + '
';
// rlp
var color;
if (entry.used == 0) { color = 'color-red2-dark'; }
else if (entry.used == entry.m) { color = 'color-green2-dark'; }
else { color = 'color-yellow2-dark'; }
list += '
Punkte: ' + entry.used + ' x ' + parseFloat(entry.rlp).toFixed(2) + '
';
list += '
';
// ZEILE 4
list += '
';
// Sailnumber
list += '
' + boat.sailnumber + '
';
// Boatname
list += '
' + boat.name + '
';
list += '
';
// ZEILE 5...
var crew = entry.crew.split(',');
for (var c in crew) {
var cr = await dbGetData('sailors', crew[c]);
if (cr != null) {
list += '
';
// Name
list += '
' + cr.name + '
';
// Year
list += '
' + ((cr.year != null) ? ('(' + cr.year + ')') : '') + '
';
list += '
';
}
}
list += '
';
}
$('#div-details').html(list);
$('#menu-rank').showMenu();
$('#menu-rank').scrollTop(0);
}
async function selectChange(callSiteScript = true) {
var type = $('#select-type').val();
var year = parseInt($('#select-year').val());
if (type == "user") {
$('#select-year').parent().hide();
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#input-jugend').parent().parent().show();
$('#input-jugstrict').parent().parent().show();
$('#button-show').show();
} else {
$('#select-year').parent().show();
$('#input-from').parent().hide();
$('#input-to').parent().hide();
$('#input-jugend').parent().parent().hide();
$('#input-jugstrict').parent().parent().hide();
$('#button-show').hide();
var from, to, jugend, jugstrict;
switch (type) {
case 'year':
from = (year - 1) + '-12-01';
to = year + '-11-30';
jugend = jugstrict = false;
break;
case 'youth':
from = (year - 1) + '-12-01';
to = year + '-11-30';
jugend = jugstrict = true;
break;
case 'idjm':
var beginn = null;
var regattas = await dbGetData('regattas');
regattas.sort(function(a,b){ return b.date.localeCompare(a.date); });
for (var r in regattas) {
var regatta = regattas[r];
var date = parseDate(regatta.date);
if ((date < parseDate('01.01.' + year)) || (date > parseDate('31.12.' + year))) {
continue;
}
if (regatta.name.indexOf(YOUTH_GERMAN_NAME) >= 0) {
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
break;
}
}
if (beginn != null) {
from = new Date(beginn);
from.setFullYear(from.getFullYear() - 1);
from.setDate(from.getDate() - 13);
from = formatDate('Y-m-d', from);
to = new Date(beginn);
to.setDate(to.getDate() - 14);
to = formatDate('Y-m-d', to);
jugend = true;
jugstrict = false;
} else {
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!');
$('#input-search').parent().hide();
return;
}
break;
}
$('#input-from').val(from);
$('#input-to').val(to);
$('#input-jugend').prop('checked', jugend);
$('#input-jugstrict').prop('checked', jugstrict);
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?type=' + type + '&year=' + year);
showLoader();
siteScript();
}
}
}
function buttonShowPressed() {
if (typeof siteScript === 'function') {
var chboxes = '';
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
showLoader();
siteScript();
}
}
function initSelects() {
var type = findGetParameter('type');
var year = findGetParameter('year');
if (type === null) type = 'year';
if (year === null) year = new Date().getFullYear();
$('#select-type').val(type);
$('#select-year').html('';
// ZEILE 1
row.content += '
';
// Rank
var icon = '';
if (lastRanking != null) {
if (entry.id in lastRanking) {
if (entry.rank < lastRanking[entry.id]) { icon = 'color-green2-dark fa-caret-up'; }
else if (entry.rank > lastRanking[entry.id]) { icon = 'color-red2-dark fa-caret-down'; }
else { icon = 'color-yellow2-dark fa-minus'; }
} else {
icon = 'color-green2-dark fa-caret-up';
}
icon = '
';
}
row.content += '
' + icon + '' + entry.rank + '.
';
// m
row.content += '
m = ' + entry.m + '
';
// rlp
row.content += '
' + entry.rlp.toFixed(3) + '
';
row.content += '
';
// ZEILE 2
row.content += '
';
// Name
row.content += '
' + entry.name + '
';
// Year
row.content += '
' + ((entry.year != null) ? ('(' + entry.year + ')') : '') + '
';
row.content += '
';
rows.push(row);
}
if (!dsvEnd) {
rows.push(null);
}
drawList();
} else {
$('#div-rank').html('Keine Ergebnisse gefunden!');
$('#input-search').parent().hide();
}
hideLoader();
}