diff --git a/index.php b/index.php index 706fc1a..f41ad05 100644 --- a/index.php +++ b/index.php @@ -9,9 +9,9 @@ function fetch_api($url) { return $json ? json_decode($json, true) : []; } -$messages = fetch_api("http://127.0.0.1:8000/api/v1/messages"); -$resultsData = fetch_api("http://127.0.0.1:8000/api/v1/results/current/"); -$rennplanData = fetch_api("http://127.0.0.1:8000/api/v1/rennplan/current/"); +$messages = fetch_api("https://api.sat.regattatech.de/api/v1/messages"); +$resultsData = fetch_api("https://api.sat.regattatech.de/api/v1/results/current/"); +$rennplanData = fetch_api("https://api.sat.regattatech.de/api/v1/rennplan/current/"); $results = $resultsData['ergebnisse'] ?? []; $rennplan = $rennplanData['rennplan'] ?? []; @@ -34,7 +34,7 @@ function render_message_box($message) { 'danger' => 'danger' ]; $type = $typeMap[$message['type']] ?? 'secondary'; - return ""; + return ""; } ?> @@ -42,33 +42,32 @@ function render_message_box($message) { - Regatta Übersicht + RegattaTech.DE Ergebnis TV - + + -
+
- -

- + +

+
-
+
-
+
-
-
Letzte Ergebnisse
-
-
+
+
Letzte Ergebnisse
+
Lauf {$res['lauf']}"; - $lauf = $res['lauf']; + if (empty($results)) { + echo "

Noch keine Ergebnisse vorhanden

"; + } else { + $lauf = null; + $latest = array_reverse(array_slice($results, -10)); + foreach ($latest as $res) { + if ($lauf !== $res['lauf']) { + echo "

Lauf {$res['lauf']}

"; + $lauf = $res['lauf']; + } + echo "
{$res['title']}
"; + foreach (['bahn1', 'bahn2', 'bahn3'] as $bahn) { + $boot = $res[$bahn]['boot']; + $zeit = $res[$bahn]['zeit']; + echo ucfirst($bahn) . ": $boot - $zeit
"; + } + echo "
"; } - echo "
{$res['title']}
"; - foreach (['bahn1', 'bahn2', 'bahn3'] as $bahn) { - $boot = $res[$bahn]['boot']; - $zeit = $res[$bahn]['zeit']; - echo "$bahn: $boot - $zeit
"; - } - echo "
"; } ?> -
-
-
Nächste Rennen
-
+
+
Nächste Rennen
+
+ echo "
{$rennen['name']} ({$rennen['zeit']})
Bahn 1: {$rennen['bahn1']}
Bahn 2: {$rennen['bahn2']}
@@ -119,13 +120,13 @@ function render_message_box($message) {
-
-
-
- Alle Ergebnisse & Rennpläne Live unter https://app.sport-am-tankumsee.de +
+
+
+ Alle Ergebnisse & Rennpläne Live unter https://app.sport-am-tankumsee.de oder im iOS AppStore
-
+
QR Code
@@ -138,6 +139,15 @@ function render_message_box($message) { setInterval(updateClock, 1000); updateClock(); setInterval(() => location.reload(), 15000); +let scrollDirection = 1; +setInterval(() => { + const box = document.getElementById('resultsBox'); + if (box.scrollHeight > box.clientHeight) { + if (box.scrollTop + box.clientHeight >= box.scrollHeight) scrollDirection = -1; + if (box.scrollTop <= 0) scrollDirection = 1; + box.scrollTop += scrollDirection * 1; +}, 100); +