modified: templates/quiz_multiplayer.html
This commit is contained in:
@@ -57,10 +57,44 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block extra_body %}
|
{% block extra_body %}
|
||||||
<script>
|
<script>
|
||||||
// Multiplayer-Daten beim Laden löschen, damit Popup immer erscheint
|
// Prüfe beim Laden, ob Namen gesetzt sind, und zeige das Popup ggf. an
|
||||||
localStorage.removeItem('quizify_multiplayer_names');
|
function showMultiplayerPopupIfNeeded() {
|
||||||
localStorage.removeItem('quizify_multiplayer_scores');
|
const names = JSON.parse(localStorage.getItem('quizify_multiplayer_names') || "[]");
|
||||||
localStorage.removeItem('quizify_multiplayer_current');
|
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>
|
</script>
|
||||||
{% if local_multiplayer %}
|
{% 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;">
|
<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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</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 %}
|
{% endif %}
|
||||||
<script>
|
<script>
|
||||||
let allTracks = {{ all_tracks|tojson }};
|
let allTracks = {{ all_tracks|tojson }};
|
||||||
@@ -266,11 +280,11 @@ window.onload = function() {
|
|||||||
}
|
}
|
||||||
document.getElementById('startPosition').value = getOption('startPosition', 'start');
|
document.getElementById('startPosition').value = getOption('startPosition', 'start');
|
||||||
updateMultiplayerUI();
|
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() {
|
function quizifyReady() {
|
||||||
// Hier alles, was nach dem Schließen des Popups passieren soll
|
|
||||||
if (window.spotifyPlayer && window.spotifyPlayer._options && window.spotifyPlayer._options.getOAuthToken) {
|
if (window.spotifyPlayer && window.spotifyPlayer._options && window.spotifyPlayer._options.getOAuthToken) {
|
||||||
const device_id = document.getElementById('device_id').value;
|
const device_id = document.getElementById('device_id').value;
|
||||||
const playDuration = getPlayDuration();
|
const playDuration = getPlayDuration();
|
||||||
|
|||||||
Reference in New Issue
Block a user