diff --git a/templates/quiz_buzzer_multiplayer.html b/templates/quiz_buzzer_multiplayer.html index 70d6f5c..a6f9d9f 100644 --- a/templates/quiz_buzzer_multiplayer.html +++ b/templates/quiz_buzzer_multiplayer.html @@ -264,18 +264,15 @@ { id: 4, name: teamNames[3] || 'Spieler 4', score: {{ player_scores[3] if player_scores else 0 }} } ]; - // Leertaste zum Buzzern + // Leertaste zum Starten und Buzzern document.addEventListener('keydown', function(e) { - if (e.code === 'Space' && canBuzz && !currentBuzzer) { + if (e.code === 'Space') { e.preventDefault(); - triggerBuzz(); - } - }); - - document.addEventListener('keydown', function(e) { - if (e.code === 'Space' && !gameStarted) { - e.preventDefault(); - startGame(); + if (!gameStarted) { + startGame(); + } else if (canBuzz && !currentBuzzer) { + triggerBuzz(); + } } }); @@ -353,12 +350,14 @@ function startGame() { if (gameStarted) return; - gameStarted = true; - document.getElementById('startButton').classList.add('disabled'); - document.getElementById('startButton').style.cursor = 'wait'; + var startBtn = document.getElementById('startButton'); + if (startBtn) { + startBtn.classList.add('disabled'); + startBtn.style.cursor = 'wait'; + startBtn.style.display = 'none'; + } document.getElementById('buzzerHint').style.display = 'block'; - const device_id = window.deviceId; const startPosition = getOption('startPosition', 'start'); let position_ms = 0; @@ -366,12 +365,10 @@ const duration = {{ track.duration_ms if track.duration_ms else 180000 }}; position_ms = Math.floor(Math.random() * (duration - 30000)); } - fetch(`/play_track?device_id=${device_id}&track_uri={{ track.uri }}&position_ms=${position_ms}`, { method: 'POST' }) .then(response => response.json()) .then(() => { console.log('Play command sent'); - document.getElementById('startButton').style.display = 'none'; canBuzz = true; }) .catch(error => console.error('Error starting playback:', error)); @@ -556,7 +553,7 @@ player_id: currentBuzzer, apply_points: false // Punkte NICHT sofort anwenden }) - ) + }) .then(response => response.json()) .then(data => { const resultContainer = document.getElementById('resultContainer');