Lane difficulty added

This commit is contained in:
Carsten Graf
2025-09-11 13:56:07 +02:00
parent 3aac843736
commit 4f0fc68d41
7 changed files with 279 additions and 1 deletions

View File

@@ -98,6 +98,11 @@
let name1 = "";
let name2 = "";
// Lane Configuration
let laneConfigType = 0; // 0=Identical, 1=Different
let lane1DifficultyType = 0; // 0=Light, 1=Heavy
let lane2DifficultyType = 0; // 0=Light, 1=Heavy
// Batterie-Banner State
let lowBatteryDevices = new Set();
let batteryBannerDismissed = false;
@@ -467,6 +472,40 @@
);
}
function loadLaneConfig() {
fetch("/api/get-lane-config")
.then((response) => response.json())
.then((data) => {
laneConfigType = data.type === "different" ? 1 : 0;
lane1DifficultyType = data.lane1Difficulty === "heavy" ? 1 : 0;
lane2DifficultyType = data.lane2Difficulty === "heavy" ? 1 : 0;
updateLaneDisplay();
})
.catch((error) =>
console.error("Fehler beim Laden der Lane-Schwierigkeits-Konfiguration:", error)
);
}
function updateLaneDisplay() {
const lane1Title = document.querySelector('.lane h2');
const lane2Title = document.querySelectorAll('.lane h2')[1];
if (laneConfigType === 0) {
// Identische Lanes
lane1Title.textContent = "🏊‍♀️ Bahn 1";
lane2Title.textContent = "🏊‍♂️ Bahn 2";
} else {
// Unterschiedliche Lanes
const lane1Icon = lane1DifficultyType === 0 ? "🟢" : "🔴";
const lane2Icon = lane2DifficultyType === 0 ? "🟢" : "🔴";
const lane1Difficulty = lane1DifficultyType === 0 ? "Leicht" : "Schwer";
const lane2Difficulty = lane2DifficultyType === 0 ? "Leicht" : "Schwer";
lane1Title.textContent = `${lane1Icon} Bahn 1 (${lane1Difficulty})`;
lane2Title.textContent = `${lane2Icon} Bahn 2 (${lane2Difficulty})`;
}
}
// Sync with backend every 1 second
setInterval(syncFromBackend, 1000);
@@ -490,6 +529,7 @@
// Initial load
syncFromBackend();
loadLaneConfig();
</script>
</body>
</html>