modified: templates/quiz_buzzer_multiplayer.html

This commit is contained in:
2025-11-28 22:54:35 +01:00
parent 0d49cbc974
commit 7cb53a3526

View File

@@ -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');