modified: templates/quiz_multiplayer.html
This commit is contained in:
@@ -57,12 +57,6 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_body %}
|
{% 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');
|
|
||||||
</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;">
|
||||||
<div style="background:#191414;padding:30px 40px;border-radius:18px;box-shadow:0 8px 32px 0 rgba(0,0,0,0.37);min-width:320px;text-align:center;">
|
<div style="background:#191414;padding:30px 40px;border-radius:18px;box-shadow:0 8px 32px 0 rgba(0,0,0,0.37);min-width:320px;text-align:center;">
|
||||||
@@ -104,7 +98,6 @@ let currentGameMode = "{{ game_mode }}";
|
|||||||
let correctAnswer = "";
|
let correctAnswer = "";
|
||||||
const i18n = {{ translations|tojson }};
|
const i18n = {{ translations|tojson }};
|
||||||
|
|
||||||
// Spotify Web Playback SDK
|
|
||||||
window.onSpotifyWebPlaybackSDKReady = () => {
|
window.onSpotifyWebPlaybackSDKReady = () => {
|
||||||
const token = '{{ access_token }}';
|
const token = '{{ access_token }}';
|
||||||
const player = new Spotify.Player({
|
const player = new Spotify.Player({
|
||||||
@@ -236,6 +229,9 @@ function checkAnswer() {
|
|||||||
localStorage.setItem('quizify_multiplayer_current', next);
|
localStorage.setItem('quizify_multiplayer_current', next);
|
||||||
updateMultiplayerUI();
|
updateMultiplayerUI();
|
||||||
document.getElementById('nextQuestionBtn').style.display = 'inline-block';
|
document.getElementById('nextQuestionBtn').style.display = 'inline-block';
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error checking answer:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,25 +263,16 @@ 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)
|
// Starte Quiz nur, wenn KEIN Multiplayer-Popup offen ist
|
||||||
};
|
const mpPopup = document.getElementById('multiplayerPopup');
|
||||||
|
if (!mpPopup || mpPopup.style.display === 'none') {
|
||||||
|
quizifyReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function quizifyReady() {
|
function quizifyReady() {
|
||||||
// Hier alles, was nach dem Schließen des Popups passieren soll
|
// Hier alles, was nach dem Schließen des Popups passieren soll
|
||||||
if (window.spotifyPlayer && window.spotifyPlayer._options && window.spotifyPlayer._options.getOAuthToken) {
|
if (window.onSpotifyWebPlaybackSDKReady) {
|
||||||
const device_id = document.getElementById('device_id').value;
|
|
||||||
const playDuration = getPlayDuration();
|
|
||||||
const startPosition = getOption('startPosition', 'start');
|
|
||||||
let position_ms = 0;
|
|
||||||
if (startPosition === 'random') {
|
|
||||||
const duration = {{ track.duration_ms if track.duration_ms else 180000 }};
|
|
||||||
position_ms = Math.floor(Math.random() * (duration - 30000));
|
|
||||||
}
|
|
||||||
fetch(`/play_track?device_id=${device_id}&track_uri={{ track.uri }}&position_ms=${position_ms}`, { method: 'POST' });
|
|
||||||
if (playDuration > 0) {
|
|
||||||
window.quizifyTimeout = setTimeout(() => { window.spotifyPlayer.pause(); }, playDuration * 1000);
|
|
||||||
}
|
|
||||||
} else if (window.onSpotifyWebPlaybackSDKReady) {
|
|
||||||
window.onSpotifyWebPlaybackSDKReady();
|
window.onSpotifyWebPlaybackSDKReady();
|
||||||
}
|
}
|
||||||
setCorrectAnswer();
|
setCorrectAnswer();
|
||||||
@@ -314,6 +301,7 @@ function getPlayDuration() {
|
|||||||
return parseInt(sel.value);
|
return parseInt(sel.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Nochmal X Sekunden"-Button Funktion
|
||||||
function replayDuration() {
|
function replayDuration() {
|
||||||
const playDuration = getPlayDuration();
|
const playDuration = getPlayDuration();
|
||||||
if (window.spotifyPlayer) {
|
if (window.spotifyPlayer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user