modified: templates/quiz_buzzer_multiplayer.html
This commit is contained in:
@@ -244,19 +244,25 @@
|
||||
let gameStarted = false;
|
||||
let currentBuzzer = null;
|
||||
|
||||
// Lade Team-Daten aus localStorage
|
||||
let teamCount = parseInt(localStorage.getItem('team_count')) || 4;
|
||||
// Initialisierung verschoben nach unten
|
||||
let teamCount = 0;
|
||||
let players = [];
|
||||
let playerScoresData = {{ player_scores|tojson }} || [0, 0, 0, 0, 0, 0];
|
||||
|
||||
for (let i = 1; i <= teamCount; i++) {
|
||||
const teamName = localStorage.getItem(`team_${i}_name`) || `Team ${i}`;
|
||||
const scoreIndex = i - 1;
|
||||
const score = playerScoresData[scoreIndex] || 0;
|
||||
players.push({ id: i, name: teamName, score: score });
|
||||
function initializePlayers() {
|
||||
teamCount = parseInt(localStorage.getItem('team_count')) || 4;
|
||||
players = [];
|
||||
|
||||
for (let i = 1; i <= teamCount; i++) {
|
||||
const teamName = localStorage.getItem(`team_${i}_name`) || `Team ${i}`;
|
||||
const scoreIndex = i - 1;
|
||||
const score = playerScoresData[scoreIndex] || 0;
|
||||
players.push({ id: i, name: teamName, score: score });
|
||||
}
|
||||
|
||||
console.log('Loaded teams:', players);
|
||||
console.log('Team count:', teamCount);
|
||||
}
|
||||
|
||||
console.log('Loaded teams:', players);
|
||||
|
||||
window.onSpotifyWebPlaybackSDKReady = () => {
|
||||
const token = '{{ access_token }}';
|
||||
@@ -534,20 +540,31 @@
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
console.log('Page loaded, initializing...');
|
||||
document.getElementById('startPosition').value = getOption('startPosition', 'start');
|
||||
maxPoints = parseInt(localStorage.getItem('buzzer_max_points')) || 1000;
|
||||
gracePeriod = parseInt(localStorage.getItem('buzzer_grace_period')) || 5;
|
||||
decayRate = parseInt(localStorage.getItem('buzzer_decay_rate')) || 50;
|
||||
document.getElementById('pointsDisplay').textContent = maxPoints + ' Punkte';
|
||||
|
||||
// Initialisiere Spieler
|
||||
initializePlayers();
|
||||
|
||||
// Dynamisches Scoreboard erstellen
|
||||
createScoreboard();
|
||||
// Dynamische Buzzer-Buttons erstellen
|
||||
createBuzzerButtons();
|
||||
|
||||
console.log('Initialization complete');
|
||||
};
|
||||
|
||||
function createScoreboard() {
|
||||
console.log('Creating scoreboard for', players.length, 'players');
|
||||
const scoreboard = document.getElementById('scoreboard');
|
||||
if (!scoreboard) {
|
||||
console.error('Scoreboard element not found!');
|
||||
return;
|
||||
}
|
||||
scoreboard.innerHTML = '';
|
||||
|
||||
players.forEach(player => {
|
||||
@@ -560,10 +577,16 @@
|
||||
`;
|
||||
scoreboard.appendChild(card);
|
||||
});
|
||||
console.log('Scoreboard created');
|
||||
}
|
||||
|
||||
function createBuzzerButtons() {
|
||||
console.log('Creating buzzer buttons for', players.length, 'players');
|
||||
const grid = document.getElementById('buzzerGrid');
|
||||
if (!grid) {
|
||||
console.error('Buzzer grid element not found!');
|
||||
return;
|
||||
}
|
||||
grid.innerHTML = `
|
||||
<button class="player-buzzer start" id="startButton" onclick="startGame()">
|
||||
▶️<br>START
|
||||
@@ -578,6 +601,7 @@
|
||||
button.innerHTML = `🔴<br>${player.name}`;
|
||||
grid.appendChild(button);
|
||||
});
|
||||
console.log('Buzzer buttons created');
|
||||
}
|
||||
</script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
Reference in New Issue
Block a user