';
+ }
+ });
+ $('#table-regattas').find('tbody').html(tbody);
+
+ //setLoading(false, 'loading');
+ }, 0);
+}
+
+var siteScript = async function() {
+ if (firstCall) {
+ firstCall = false;
+ initYear();
+ $('#select-year').change(selectChange);
+ $('#button-show').click(siteScript);
+ $('#input-search').on('input', drawTable);
+ }
+
+ today = getToday();
+
+ var minDate = parseDate($('#input-from').val());
+ var maxDate = parseDate($('#input-to').val());
+ var regattas = await dbGetRegattasRange(minDate, maxDate);
+ var regattaResults = [];
+ var showNumbers = false;
+ for (id in regattas) {
+ var entry = regattas[id];
+ var results = await dbGetDataIndex('results', 'regatta', entry['id']);
+ regattaResults[entry['id']] = (results.length > 0);
+ if (entry['number'] != null)
+ showNumbers = true;
+ }
+
+ 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 += '';
+ }
+ $('#select-year').html(options);
+ $('#select-year').val(selectedYear);
+
+ var count = regattas.length;
+ if (count > 0) {
+ if (count == 1) {
+ $('#p-count').html('Es wurde 1 Regatta gefunden!');
+ } else {
+ $('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
+ }
+ $('#table-regattas').show();
+ $('#input-search').show();
+ if (showNumbers) {
+ $('#th-number').show();
+ } else {
+ $('#th-number').hide();
+ }
+
+ var heute = false;
+ heuteLen = 5;
+ if (showNumbers) heuteLen ++;
+ if (showSpecial) heuteLen ++;
+
+ rows = [];
+
+ for (id in regattas) {
+ var entry = regattas[id];
+ var club = null;
+ if (entry['club'] != null)
+ club = await dbGetData('clubs', entry['club']);
+ var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
+
+ var dateFrom = entry['dateFrom'];
+ var dateTo = entry['dateTo'];
+
+ var row = { keywords: [], cells: [] };
+ row.keywords.push(entry['name']);
+ if (entry['number'] != null) row.keywords.push(entry['number']);
+ if (club != null) row.keywords.push(club['kurz'], club['name']);
+
+ if (!heute && (today <= dateFrom)) {
+ rows.push(null);
+ heute = true;
+ }
+
+ if (showNumbers) {
+ row.cells.push(entry['number'] != null ? ('' + entry['number'] + '') : '');
+ }
+
+ row.cells.push('' + formatDate("j. M 'y", dateFrom) + ' ' + formatDate("j. M 'y", dateTo) + '');
+
+ var content = '';
+ if (club != null) {
+ content = club['kurz'];
+ if (club['website'] != '') {
+ content = '' + content + '';
+ }
+ }
+ row.cells.push(content + ' ' + (entry['canceled'] == 1 ? '' : '') + entry['name']) + (entry['canceled'] == 1 ? '' : '');
+
+ if (showSpecial) {
+ row.cells.push('' + entry['special'] + '');
+ }
+
+ var buf = '';
+ if (entry['info'] != '') {
+ buf += 'Informationen';
+ }
+ if ((entry['meldung'] != '') && (dateTo >= today)) {
+ buf += ' Meldung';
+ var planning = null;
+ if (isLoggedIn()) {
+ for (id in plannings) {
+ if (plannings[id]['user'] == USER_ID) {
+ planning = plannings[id];
+ break;
+ }
+ }
+ }
+
+ if ((planning != null) && (planning['gemeldet'] == "1")) {
+ buf += ' (du hast gemeldet)';
+ } else if (entry['meldungOffen'] == "0") {
+ buf += ' (geschlossen)';
+ } else if (entry['meldungSchluss'] != null) {
+ early = false;
+ if (entry['meldungEarly'] != null) {
+ ms = parseDate(entry['meldungEarly']);
+ if (ms >= today) {
+ early = true;
+ }
+ }
+ if (!early)
+ ms = parseDate(entry['meldungSchluss']);
+ if (ms >= today) {
+ diff = Math.round((ms - today) / 86400000);
+ red = (diff < 7);
+ if (diff <= 14) {
+ txt = 'noch ' + diff + ' Tag' + (diff != 1 ? 'e' : '');
+ } else if (diff < 35) {
+ diff = Math.floor(diff / 7);
+ txt = 'noch ' + diff + ' Woche' + (diff != 1 ? 'n' : '');
+ } else {
+ diff = Math.floor(diff / 30.5);
+ txt = 'noch ' + diff + ' Monat' + (diff != 1 ? 'e' : '');
+ }
+ buf += ' ' + (red ? '(' : '(') + txt + (early ? ' vergünstigt' : '') + (red ? ')' : ')') + '';
+ } else {
+ buf += ' (Meldeschluss abgelaufen)';
+ }
+ }
+ }
+ if (entry['bericht'] != '') {
+ buf += ' Bericht';
+ }
+ if (entry['oresults'] != '') {
+ buf += ' off. Ergebnisse';
+ }
+ row.cells.push(buf);
+
+ buf = '';
+ if (entry['canceled'] == "1") {
+ buf = ' Ausgefallen';
+ } else {
+ if (regattaResults[entry['id']]) {
+ buf = ' Ergebnisse';
+ } else {
+ var pC = plannings.length;
+ buf = ' In der Saison-Planung von ' + pC + ' Seglern.';
+ if (pC > 0) {
+ buf += ' Ansehen';
+ }
+ }
+ }
+ row.cells.push(buf);
+
+ row.cells.push('' + parseFloat(entry['rlf']).toFixed(2) + '');
+
+ rows.push(row);
+ }
+
+ if (!heute) {
+ rows.push(null);
+ }
+
+ drawTable();
+
+ } else {
+ $('#p-count').html('Keine Regatten gefunden!');
+ $('#table-regattas').hide();
+ $('#input-search').hide();
+ }
+
+ hideLoader();
+}
\ No newline at end of file
diff --git a/server/templates/input.html b/server/templates/input.html
new file mode 100644
index 0000000..14302d2
--- /dev/null
+++ b/server/templates/input.html
@@ -0,0 +1,4 @@
+
+ $$placeholder;
+
+
\ No newline at end of file
diff --git a/server/templates/select.html b/server/templates/select.html
new file mode 100644
index 0000000..816ec58
--- /dev/null
+++ b/server/templates/select.html
@@ -0,0 +1,6 @@
+
+ $$placeholder;
+
+
\ No newline at end of file
diff --git a/server/templates/textarea.html b/server/templates/textarea.html
new file mode 100644
index 0000000..d3fd3ae
--- /dev/null
+++ b/server/templates/textarea.html
@@ -0,0 +1,4 @@
+