first commit

This commit is contained in:
Carsten Graf
2025-06-01 11:51:02 +02:00
commit 2d2ee0a41a
22 changed files with 3241 additions and 0 deletions

453
data/index.html Normal file
View File

@@ -0,0 +1,453 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NinjaCross Timer</title>
<style>
html {
overflow: hidden;
height: 100%;
width: 100%;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Arial", sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
color: white;
position: relative;
overflow: hidden;
box-sizing: border-box;
}
.logo {
position: fixed;
top: 20px;
left: 20px;
width: 200px;
height: 60px;
z-index: 1000;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease;
text-decoration: none;
display: block;
cursor: pointer;
padding-left: 5px;
padding-right: 5px;
}
.logo:hover {
transform: scale(1.1);
}
.logo img {
width: 100%;
height: 100%;
object-fit: contain;
border-radius: 10px;
}
.settings-btn {
position: fixed;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
padding: 15px;
border-radius: 50%;
text-decoration: none;
font-size: 1.5rem;
transition: all 0.3s ease;
z-index: 1000;
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
.settings-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
transform: scale(1.1);
}
.header {
text-align: center;
margin-bottom: 2vh;
flex-shrink: 0;
}
.header h1 {
font-size: clamp(1.8rem, 4vw, 2.5rem);
margin-bottom: 0.5vh;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.header p {
font-size: clamp(0.8rem, 1.8vw, 1rem);
}
.timer-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: clamp(15px, 2vw, 30px);
width: 100%;
max-width: 100%;
flex-grow: 1;
padding: 0 2vw;
max-height: 60vh;
}
@media (max-width: 768px) {
.timer-container {
grid-template-columns: 1fr;
gap: clamp(15px, 3vw, 30px);
padding: 0 15px;
}
}
@media (max-width: 480px) {
.timer-container {
gap: 20px;
padding: 0 10px;
}
}
@media (min-width: 1400px) {
.timer-container {
max-width: 1400px;
padding: 0 60px;
}
}
.lane {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: clamp(15px, 2.5vh, 25px);
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
overflow: hidden;
}
.lane h2 {
font-size: clamp(1.2rem, 2.5vw, 1.8rem);
margin-bottom: clamp(10px, 1vh, 15px);
color: #fff;
}
.time-display {
font-size: clamp(3rem, 9vw, 10rem);
font-weight: bold;
margin: clamp(10px, 1vh, 15px) 0;
font-family: "Courier New", monospace;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
line-height: 1;
}
.status {
font-size: clamp(3rem, 1.8vw, 1.2rem);
margin: clamp(8px, 1vh, 12px) 0;
padding: clamp(6px, 1vh, 10px) clamp(12px, 2vw, 18px);
border-radius: 20px;
display: inline-block;
font-weight: 600;
}
.status.ready {
background-color: rgba(52, 152, 219, 0.3);
border: 2px solid #3498db;
}
.status.running {
background-color: rgba(46, 204, 113, 0.3);
border: 2px solid #2ecc71;
animation: pulse 1s infinite;
}
.status.finished {
background-color: rgba(231, 76, 60, 0.3);
border: 2px solid #e74c3c;
}
@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0.7;
}
100% {
opacity: 1;
}
}
.best-times {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: clamp(10px, 1.5vh, 15px);
margin: 1vh 0 0 0;
width: 50%;
max-width: 50%;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
flex-shrink: 0;
align-self: center;
}
.best-times h3 {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
margin-bottom: clamp(5px, 0.5vh, 8px);
}
.best-time-row {
display: flex;
justify-content: space-between;
margin: clamp(3px, 0.5vh, 5px) 0;
font-size: clamp(0.8rem, 1.5vw, 1rem);
font-weight: 500;
background: rgba(255, 255, 255, 0.1);
padding: clamp(5px, 1vh, 8px) clamp(8px, 1.5vw, 12px);
border-radius: 8px;
}
.learning-mode {
background: rgba(255, 193, 7, 0.2);
border: 2px solid #ffc107;
border-radius: 15px;
padding: clamp(15px, 2vh, 20px);
margin: 2vh 0;
text-align: center;
animation: pulse 2s infinite;
width: 100%;
position: absolute;
top: 15vh;
left: 50%;
transform: translateX(-50%);
z-index: 100;
}
.learning-mode h3 {
color: #ffc107;
margin-bottom: 10px;
font-size: clamp(1rem, 2vw, 1.3rem);
}
.learning-mode p {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
}
@media (max-width: 768px) {
.timer-container {
grid-template-columns: 1fr;
gap: clamp(10px, 2vh, 15px);
padding: 0 3vw;
max-height: 55vh;
}
.settings-btn {
top: 10px;
right: 10px;
width: 40px;
height: 40px;
font-size: 1rem;
padding: 8px;
}
.header h1 {
font-size: clamp(1.5rem, 4vw, 2rem);
}
.header p {
font-size: clamp(0.7rem, 2vw, 0.9rem);
}
body {
padding: 10px;
}
}
@media (max-width: 480px) {
.settings-btn {
top: 8px;
right: 8px;
width: 35px;
height: 35px;
font-size: 0.9rem;
padding: 6px;
}
body {
padding: 8px;
}
.timer-container {
padding: 0 2vw;
}
}
</style>
</head>
<body>
<a href="/about" class="logo" title="Über NinjaCross Timer">
<img src="logo.png" alt="NinjaCross Logo" />
</a>
<a href="/settings" class="settings-btn">⚙️</a>
<div class="header">
<h1>🏊‍♀️ NinjaCross Timer</h1>
<p>Professioneller Zeitmesser für Ninjacross Wettkämpfe</p>
</div>
<div id="learning-display" class="learning-mode" style="display: none">
<h3>📚 Lernmodus aktiv</h3>
<p>
Bitte drücken Sie den Button für: <span id="learning-button"></span>
</p>
</div>
<div class="timer-container">
<div class="lane">
<h2>🏊‍♀️ Bahn 1</h2>
<div id="time1" class="time-display">00.00</div>
<div id="status1" class="status ready">Bereit</div>
</div>
<div class="lane">
<h2>🏊‍♂️ Bahn 2</h2>
<div id="time2" class="time-display">00.00</div>
<div id="status2" class="status ready">Bereit</div>
</div>
</div>
<div class="best-times">
<h3>🏆 Beste Zeiten des Tages</h3>
<div class="best-time-row">
<span>Bahn 1:</span>
<span id="best1">--.-</span>
</div>
<div class="best-time-row">
<span>Bahn 2:</span>
<span id="best2">--.-</span>
</div>
</div>
<script>
// State variables
let timer1 = 0;
let timer2 = 0;
let status1 = "ready";
let status2 = "ready";
let best1 = 0;
let best2 = 0;
let lastSync = Date.now();
let learningMode = false;
let learningButton = "";
function formatTime(seconds) {
if (seconds === 0) return "00.00";
return seconds.toFixed(2);
}
function updateDisplay() {
// Calculate elapsed time since last sync
const now = Date.now();
let display1 = timer1;
let display2 = timer2;
if (status1 === "running") {
display1 += (now - lastSync) / 1000;
}
if (status2 === "running") {
display2 += (now - lastSync) / 1000;
}
document.getElementById("time1").textContent = formatTime(display1);
const s1 = document.getElementById("status1");
s1.className = `status ${status1}`;
s1.textContent =
status1 === "ready"
? "Bereit"
: status1 === "running"
? "Läuft..."
: "Beendet";
document.getElementById("time2").textContent = formatTime(display2);
const s2 = document.getElementById("status2");
s2.className = `status ${status2}`;
s2.textContent =
status2 === "ready"
? "Bereit"
: status2 === "running"
? "Läuft..."
: "Beendet";
document.getElementById("best1").textContent =
best1 > 0 ? formatTime(best1) + "s" : "--.-";
document.getElementById("best2").textContent =
best2 > 0 ? formatTime(best2) + "s" : "--.-";
// Lernmodus
const learningDisplay = document.getElementById("learning-display");
if (learningMode) {
document.getElementById("learning-button").textContent = learningButton;
learningDisplay.style.display = "block";
} else {
learningDisplay.style.display = "none";
}
}
function syncFromBackend() {
fetch("/api/data")
.then((response) => response.json())
.then((data) => {
timer1 = data.time1;
timer2 = data.time2;
status1 = data.status1;
status2 = data.status2;
best1 = data.best1;
best2 = data.best2;
learningMode = data.learningMode;
learningButton = data.learningButton || "";
lastSync = Date.now();
updateDisplay();
})
.catch((error) =>
console.error("Fehler beim Laden der Daten:", error)
);
}
// Sync with backend every 2 seconds
setInterval(syncFromBackend, 2000);
// Smooth update every 50ms
setInterval(updateDisplay, 50);
// Initial load
syncFromBackend();
</script>
</body>
</html>