first commit
This commit is contained in:
		
							
								
								
									
										143
									
								
								index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								index.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,143 @@
 | 
			
		||||
<?php
 | 
			
		||||
function fetch_api($url) {
 | 
			
		||||
    $context = stream_context_create([
 | 
			
		||||
        "http" => [
 | 
			
		||||
            "ignore_errors" => true
 | 
			
		||||
        ]
 | 
			
		||||
    ]);
 | 
			
		||||
    $json = @file_get_contents($url, false, $context);
 | 
			
		||||
    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/");
 | 
			
		||||
 | 
			
		||||
$results = $resultsData['ergebnisse'] ?? [];
 | 
			
		||||
$rennplan = $rennplanData['rennplan'] ?? [];
 | 
			
		||||
$lastResultUUIDs = array_column($results, 'uuid');
 | 
			
		||||
 | 
			
		||||
$nextRaces = [];
 | 
			
		||||
foreach ($rennplan as $lauf) {
 | 
			
		||||
    foreach ($lauf as $rennen) {
 | 
			
		||||
        if (!in_array($rennen['uuid'], $lastResultUUIDs)) {
 | 
			
		||||
            $nextRaces[] = $rennen;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
$nextRaces = array_slice($nextRaces, 0, 3);
 | 
			
		||||
 | 
			
		||||
function render_message_box($message) {
 | 
			
		||||
    $typeMap = [
 | 
			
		||||
        'info' => 'success',
 | 
			
		||||
        'warning' => 'warning',
 | 
			
		||||
        'danger' => 'danger'
 | 
			
		||||
    ];
 | 
			
		||||
    $type = $typeMap[$message['type']] ?? 'secondary';
 | 
			
		||||
    return "<div class='alert alert-{$type}' role='alert'>{$message['message']}</div>";
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="de">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
    <title>Regatta Übersicht</title>
 | 
			
		||||
    <link href="/res/css/bootstrap.min.css" rel="stylesheet">
 | 
			
		||||
    <style>
 | 
			
		||||
        #resultsBox {
 | 
			
		||||
            height: 400px;
 | 
			
		||||
            overflow: hidden;
 | 
			
		||||
            position: relative;
 | 
			
		||||
        }
 | 
			
		||||
        #resultsBox .inner {
 | 
			
		||||
            position: absolute;
 | 
			
		||||
            animation: scroll 30s linear infinite;
 | 
			
		||||
        }
 | 
			
		||||
        @keyframes scroll {
 | 
			
		||||
            0% { top: 0; }
 | 
			
		||||
            100% { top: -100%; }
 | 
			
		||||
        }
 | 
			
		||||
    </style>
 | 
			
		||||
</head>
 | 
			
		||||
<body class="bg-light">
 | 
			
		||||
<div class="container-fluid py-2 bg-white border-bottom">
 | 
			
		||||
    <div class="d-flex justify-content-between align-items-center">
 | 
			
		||||
        <img src="/res/img/regattatech_logo.png" height="50">
 | 
			
		||||
        <h4 id="clock" class="m-0"></h4>
 | 
			
		||||
        <img src="/res/img/sat_logo.png" height="50">
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
<div class="container mt-3">
 | 
			
		||||
    <div id="messages">
 | 
			
		||||
        <?php
 | 
			
		||||
        if (!empty($messages)) {
 | 
			
		||||
            echo render_message_box($messages);
 | 
			
		||||
        }
 | 
			
		||||
        ?>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="row mt-3">
 | 
			
		||||
        <!-- Ergebnisse -->
 | 
			
		||||
        <div class="col-md-6">
 | 
			
		||||
            <h5>Letzte Ergebnisse</h5>
 | 
			
		||||
            <div id="resultsBox" class="bg-white border rounded p-2">
 | 
			
		||||
                <div class="inner">
 | 
			
		||||
                <?php
 | 
			
		||||
                $lauf = null;
 | 
			
		||||
                $latest = array_reverse(array_slice($results, -10));
 | 
			
		||||
                foreach ($latest as $res) {
 | 
			
		||||
                    if ($lauf !== $res['lauf']) {
 | 
			
		||||
                        echo "<h6 class='mt-3'>Lauf {$res['lauf']}</h6>";
 | 
			
		||||
                        $lauf = $res['lauf'];
 | 
			
		||||
                    }
 | 
			
		||||
                    echo "<div class='mb-2'><strong>{$res['title']}</strong><br>";
 | 
			
		||||
                    foreach (['bahn1', 'bahn2', 'bahn3'] as $bahn) {
 | 
			
		||||
                        $boot = $res[$bahn]['boot'];
 | 
			
		||||
                        $zeit = $res[$bahn]['zeit'];
 | 
			
		||||
                        echo "$bahn: $boot - $zeit<br>";
 | 
			
		||||
                    }
 | 
			
		||||
                    echo "</div>";
 | 
			
		||||
                }
 | 
			
		||||
                ?>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <!-- Nächste Rennen -->
 | 
			
		||||
        <div class="col-md-6">
 | 
			
		||||
            <h5>Nächste Rennen</h5>
 | 
			
		||||
            <div class="bg-white border rounded p-2">
 | 
			
		||||
                <?php
 | 
			
		||||
                foreach ($nextRaces as $rennen) {
 | 
			
		||||
                    echo "<div class='mb-3'>
 | 
			
		||||
                        <strong>{$rennen['name']} ({$rennen['zeit']})</strong><br>
 | 
			
		||||
                        Bahn 1: {$rennen['bahn1']}<br>
 | 
			
		||||
                        Bahn 2: {$rennen['bahn2']}<br>
 | 
			
		||||
                        Bahn 3: {$rennen['bahn3']}<br>
 | 
			
		||||
                    </div>";
 | 
			
		||||
                }
 | 
			
		||||
                ?>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="row mt-4 align-items-center">
 | 
			
		||||
        <div class="col-md-10">
 | 
			
		||||
            <div class="p-3 bg-white rounded border">
 | 
			
		||||
                <strong>Alle Ergebnisse & Rennpläne Live unter <a href="https://app.sport-am-tankumsee.de" target="_blank">https://app.sport-am-tankumsee.de</a></strong>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="col-md-2 text-end">
 | 
			
		||||
            <img src="/res/img/qrcode.png" class="img-fluid" alt="QR Code">
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
<script>
 | 
			
		||||
    function updateClock() {
 | 
			
		||||
        const now = new Date();
 | 
			
		||||
        document.getElementById('clock').innerText = now.toLocaleTimeString('de-DE');
 | 
			
		||||
    }
 | 
			
		||||
    setInterval(updateClock, 1000);
 | 
			
		||||
    updateClock();
 | 
			
		||||
    setInterval(() => location.reload(), 15000);
 | 
			
		||||
</script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										6
									
								
								res/css/bootstrap.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								res/css/bootstrap.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								res/img/qrcode.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								res/img/qrcode.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 267 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								res/img/regattatech_logo.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								res/img/regattatech_logo.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 90 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								res/img/sat_logo.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								res/img/sat_logo.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 268 KiB  | 
		Reference in New Issue
	
	Block a user