rank can idjm

This commit is contained in:
Timon Ostertun
2020-09-26 18:58:29 +02:00
parent 4143545117
commit 364fd6fea0

View File

@@ -106,7 +106,7 @@ async function onRankingClicked(id) {
$('#menu-rank').scrollTop(0); $('#menu-rank').scrollTop(0);
} }
function selectChange(callSiteScript = true) { async function selectChange(callSiteScript = true) {
var type = $('#select-type').val(); var type = $('#select-type').val();
var year = parseInt($('#select-year').val()); var year = parseInt($('#select-year').val());
if (type == "user") { if (type == "user") {
@@ -137,11 +137,35 @@ function selectChange(callSiteScript = true) {
jugend = jugstrict = true; jugend = jugstrict = true;
break; break;
case 'idjm': case 'idjm':
// TODO var beginn = null;
from = (year - 1) + '-12-01'; var regattas = await dbGetData('regattas');
to = year + '-11-30'; regattas.sort(function(a,b){ return b.date.localeCompare(a.date); });
jugend = true; for (var r in regattas) {
jugstrict = false; 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; break;
} }