modified: templates/quiz_multiplayer.html
This commit is contained in:
@@ -314,12 +314,13 @@
|
|||||||
if (data.correct) {
|
if (data.correct) {
|
||||||
resultContainer.className = 'result-container correct';
|
resultContainer.className = 'result-container correct';
|
||||||
resultContainer.innerHTML = `<h3>${i18n.correct}</h3>`;
|
resultContainer.innerHTML = `<h3>${i18n.correct}</h3>`;
|
||||||
scores[current] = (scores[current] || 0) + 1;
|
// Punkte werden jetzt NICHT hier gezählt!
|
||||||
localStorage.setItem('quizify_multiplayer_scores', JSON.stringify(scores));
|
resultContainer.dataset.wasCorrect = "1";
|
||||||
} else {
|
} else {
|
||||||
resultContainer.className = 'result-container incorrect';
|
resultContainer.className = 'result-container incorrect';
|
||||||
resultContainer.innerHTML = `<h3>${i18n.wrong}</h3>
|
resultContainer.innerHTML = `<h3>${i18n.wrong}</h3>
|
||||||
<p>${i18n.right_answer} <strong>${data.correct_answer}</strong></p>`;
|
<p>${i18n.right_answer} <strong>${data.correct_answer}</strong></p>`;
|
||||||
|
resultContainer.dataset.wasCorrect = "0";
|
||||||
}
|
}
|
||||||
resultContainer.innerHTML += `
|
resultContainer.innerHTML += `
|
||||||
<div style="margin-top:10px;">
|
<div style="margin-top:10px;">
|
||||||
@@ -331,13 +332,27 @@
|
|||||||
<a href="{{ track.external_urls.spotify }}" target="_blank" style="color:#1DB954;">${i18n.open_on_spotify}</a>
|
<a href="{{ track.external_urls.spotify }}" target="_blank" style="color:#1DB954;">${i18n.open_on_spotify}</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
document.getElementById('nextQuestionBtn').style.display = 'inline-block';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('nextQuestionBtn').addEventListener('click', function(e) {
|
||||||
|
// Punkte und Spielerwechsel erst jetzt!
|
||||||
|
const names = JSON.parse(localStorage.getItem('quizify_multiplayer_names') || "[]");
|
||||||
|
const scores = JSON.parse(localStorage.getItem('quizify_multiplayer_scores') || "[]");
|
||||||
|
let current = parseInt(localStorage.getItem('quizify_multiplayer_current') || "0");
|
||||||
|
const resultContainer = document.getElementById('resultContainer');
|
||||||
|
if (resultContainer.dataset.wasCorrect === "1") {
|
||||||
|
scores[current] = (scores[current] || 0) + 1;
|
||||||
|
localStorage.setItem('quizify_multiplayer_scores', JSON.stringify(scores));
|
||||||
|
}
|
||||||
// Nächster Spieler
|
// Nächster Spieler
|
||||||
let next = (current + 1) % names.length;
|
let next = (current + 1) % names.length;
|
||||||
localStorage.setItem('quizify_multiplayer_current', next);
|
localStorage.setItem('quizify_multiplayer_current', next);
|
||||||
updateMultiplayerUI();
|
updateMultiplayerUI();
|
||||||
document.getElementById('nextQuestionBtn').style.display = 'inline-block';
|
// Button funktioniert wie gehabt (Seitenwechsel)
|
||||||
|
// Kein preventDefault!
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function switchGameMode(mode) {
|
function switchGameMode(mode) {
|
||||||
// Multiplayer-Daten NICHT löschen, damit Namen erhalten bleiben!
|
// Multiplayer-Daten NICHT löschen, damit Namen erhalten bleiben!
|
||||||
|
|||||||
Reference in New Issue
Block a user