modified: templates/quiz_multiplayer.html
This commit is contained in:
@@ -57,10 +57,44 @@
|
||||
{% endblock %}
|
||||
{% block extra_body %}
|
||||
<script>
|
||||
// Multiplayer-Daten beim Laden löschen, damit Popup immer erscheint
|
||||
localStorage.removeItem('quizify_multiplayer_names');
|
||||
localStorage.removeItem('quizify_multiplayer_scores');
|
||||
localStorage.removeItem('quizify_multiplayer_current');
|
||||
// Prüfe beim Laden, ob Namen gesetzt sind, und zeige das Popup ggf. an
|
||||
function showMultiplayerPopupIfNeeded() {
|
||||
const names = JSON.parse(localStorage.getItem('quizify_multiplayer_names') || "[]");
|
||||
if (!names || names.length < 2) {
|
||||
// Popup anzeigen
|
||||
if (document.getElementById('multiplayerPopup')) {
|
||||
document.getElementById('multiplayerPopup').style.display = 'flex';
|
||||
}
|
||||
} else {
|
||||
// Popup ausblenden, falls schon Spieler gesetzt
|
||||
if (document.getElementById('multiplayerPopup')) {
|
||||
document.getElementById('multiplayerPopup').style.display = 'none';
|
||||
}
|
||||
updateMultiplayerUI();
|
||||
quizifyReady();
|
||||
}
|
||||
}
|
||||
|
||||
function startMultiplayer(e) {
|
||||
e.preventDefault();
|
||||
const names = [];
|
||||
for(let i=1;i<=4;i++) {
|
||||
const val = document.getElementById('player'+i).value.trim();
|
||||
if(val) names.push(val);
|
||||
}
|
||||
if(names.length < 2) {
|
||||
alert("Bitte mindestens 2 Namen eingeben!");
|
||||
return;
|
||||
}
|
||||
localStorage.setItem('quizify_multiplayer_names', JSON.stringify(names));
|
||||
localStorage.setItem('quizify_multiplayer_scores', JSON.stringify(Array(names.length).fill(0)));
|
||||
localStorage.setItem('quizify_multiplayer_current', 0);
|
||||
if (document.getElementById('multiplayerPopup')) {
|
||||
document.getElementById('multiplayerPopup').style.display = 'none';
|
||||
}
|
||||
updateMultiplayerUI();
|
||||
quizifyReady();
|
||||
}
|
||||
</script>
|
||||
{% if local_multiplayer %}
|
||||
<div id="multiplayerPopup" style="position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0,0,0,0.7);display:flex;align-items:center;justify-content:center;z-index:2000;">
|
||||
@@ -76,26 +110,6 @@ localStorage.removeItem('quizify_multiplayer_current');
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function startMultiplayer(e) {
|
||||
e.preventDefault();
|
||||
const names = [];
|
||||
for(let i=1;i<=4;i++) {
|
||||
const val = document.getElementById('player'+i).value.trim();
|
||||
if(val) names.push(val);
|
||||
}
|
||||
if(names.length < 2) {
|
||||
alert("Bitte mindestens 2 Namen eingeben!");
|
||||
return;
|
||||
}
|
||||
localStorage.setItem('quizify_multiplayer_names', JSON.stringify(names));
|
||||
localStorage.setItem('quizify_multiplayer_scores', JSON.stringify(Array(names.length).fill(0)));
|
||||
localStorage.setItem('quizify_multiplayer_current', 0);
|
||||
document.getElementById('multiplayerPopup').style.display = 'none';
|
||||
updateMultiplayerUI();
|
||||
quizifyReady();
|
||||
}
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
let allTracks = {{ all_tracks|tojson }};
|
||||
@@ -266,11 +280,11 @@ window.onload = function() {
|
||||
}
|
||||
document.getElementById('startPosition').value = getOption('startPosition', 'start');
|
||||
updateMultiplayerUI();
|
||||
// Kein Popup-Handling nötig, da es immer sichtbar ist (außer nach Start)
|
||||
showMultiplayerPopupIfNeeded();
|
||||
};
|
||||
|
||||
// Musikstart und Quiz erst nach Namensbestätigung!
|
||||
function quizifyReady() {
|
||||
// Hier alles, was nach dem Schließen des Popups passieren soll
|
||||
if (window.spotifyPlayer && window.spotifyPlayer._options && window.spotifyPlayer._options.getOAuthToken) {
|
||||
const device_id = document.getElementById('device_id').value;
|
||||
const playDuration = getPlayDuration();
|
||||
|
||||
Reference in New Issue
Block a user