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