modified: templates/quiz.html

This commit is contained in:
2025-10-31 20:05:58 +01:00
parent 2bee85a8fe
commit 266692a41d

View File

@@ -5,89 +5,208 @@
<!-- Spotify Web Playback SDK -->
<script src="https://sdk.scdn.co/spotify-player.js"></script>
<style>
/* Dark, modern theme for the quiz page */
:root{
--bg:#0f1113;
--card:#121416;
--muted:#9aa3a8;
--accent:#1DB954;
--accent-strong:#17c24a;
--danger:#f44336;
--success:#4CAF50;
--glass: rgba(255,255,255,0.03);
--radius:14px;
}
html,body{height:100%;}
body {
* {
margin: 0;
padding:24px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: linear-gradient(180deg, #070708 0%, #0b0c0e 100%);
color:#e6eef1;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0f1419 100%);
color: #e0e0e0;
min-height: 100vh;
padding: 20px;
display: flex;
align-items:flex-start;
justify-content:center;
flex-direction: column;
align-items: center;
}
.quiz-viewport{
.quiz-container {
max-width: 900px;
width: 100%;
max-width:980px;
background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
border-radius:18px;
padding:28px;
box-shadow: 0 6px 30px rgba(2,6,23,0.6);
backdrop-filter: blur(6px);
background: rgba(25, 30, 45, 0.95);
border-radius: 20px;
padding: 40px;
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.05);
}
.header-section {
text-align: center;
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.progress-info {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 20px;
padding: 15px;
background: rgba(29, 185, 84, 0.1);
border-radius: 15px;
border: 1px solid rgba(29, 185, 84, 0.3);
}
.progress-item {
text-align: center;
}
.progress-label {
font-size: 0.85em;
color: #999;
text-transform: uppercase;
letter-spacing: 1px;
}
.progress-value {
font-size: 1.5em;
font-weight: bold;
color: #1DB954;
margin-top: 5px;
}
.controls {
margin: 25px 0;
text-align: center;
}
.btn {
padding: 12px 24px;
margin: 5px;
background: linear-gradient(135deg, #1DB954 0%, #1ed760 100%);
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
font-weight: 600;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(29, 185, 84, 0.3);
text-decoration: none;
display: inline-block;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(29, 185, 84, 0.5);
}
.btn-secondary {
background: linear-gradient(135deg, #535353 0%, #6b6b6b 100%);
box-shadow: 0 4px 15px rgba(83, 83, 83, 0.3);
}
.btn-secondary:hover {
box-shadow: 0 6px 20px rgba(83, 83, 83, 0.5);
}
.btn-success {
background: linear-gradient(135deg, #4CAF50 0%, #66bb6a 100%);
box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}
.btn-danger {
background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}
.game-modes {
margin: 25px 0;
display: flex;
justify-content: center;
gap: 10px;
flex-wrap: wrap;
}
.search-results {
margin-top: 15px;
max-height: 250px;
overflow-y: auto;
background: rgba(15, 20, 35, 0.9);
border: 1px solid rgba(29, 185, 84, 0.3);
border-radius: 12px;
display: none;
}
.search-item {
padding: 12px 15px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
cursor: pointer;
transition: all 0.2s ease;
color: #e0e0e0;
}
.search-item:hover {
background: rgba(29, 185, 84, 0.2);
padding-left: 20px;
}
.result-container {
margin: 25px 0;
padding: 20px;
border-radius: 15px;
text-align: center;
display: none;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.correct {
background: rgba(76, 175, 80, 0.15);
border: 2px solid #4CAF50;
}
.incorrect {
background: rgba(244, 67, 54, 0.15);
border: 2px solid #f44336;
}
input[type="text"], input[type="number"], select {
padding: 14px 20px;
width: 100%;
max-width: 400px;
border: 2px solid rgba(29, 185, 84, 0.3);
background: rgba(15, 20, 35, 0.6);
color: #e0e0e0;
border-radius: 25px;
font-size: 16px;
transition: all 0.3s ease;
outline: none;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
border-color: #1DB954;
box-shadow: 0 0 15px rgba(29, 185, 84, 0.4);
}
h2 {
color: #ffffff;
text-align: center;
font-size: 2em;
margin-bottom: 15px;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.hint-container {
margin: 20px 0;
font-style: italic;
color: #999;
text-align: center;
padding: 10px;
background: rgba(255, 255, 255, 0.03);
border-radius: 10px;
}
.game-options {
text-align: center;
margin-bottom: 25px;
padding: 20px;
background: rgba(15, 20, 35, 0.5);
border-radius: 15px;
border: 1px solid rgba(255, 255, 255, 0.05);
}
.game-options label {
margin: 0 15px;
color: #b0b0b0;
font-weight: 500;
}
.game-options select {
max-width: 150px;
margin: 5px;
}
@media (max-width: 600px) {
.quiz-container {
padding: 20px;
}
/* header area */
.quiz-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.quiz-header .left{display:flex;align-items:center;gap:12px}
.back-link{background:transparent;border:1px solid rgba(255,255,255,0.06);color:var(--muted);padding:8px 12px;border-radius:10px;text-decoration:none}
.back-link:hover{border-color:rgba(255,255,255,0.12);color:#fff}
/* progress and score */
.meta{display:flex;gap:16px;align-items:center;color:var(--muted);font-size:0.95rem}
/* question */
h2#question-text{font-size:1.7rem;margin:6px 0 14px;color:#fff}
.game-modes{display:flex;gap:10px;justify-content:center;margin-bottom:18px;flex-wrap:wrap}
.btn{padding:10px 16px;border-radius:12px;border:none;cursor:pointer;font-weight:600}
.btn:not(.btn-danger){background:var(--glass);color:#dff3e6;border:1px solid rgba(255,255,255,0.04)}
.btn:hover{transform:translateY(-1px)}
.btn-success{background:linear-gradient(180deg,var(--accent),var(--accent-strong));color:#08120a}
.btn-secondary{background:transparent;color:var(--muted);border:1px solid rgba(255,255,255,0.04)}
.btn-danger{background:transparent;color:var(--danger);border:1px solid rgba(244,67,54,0.12)}
.game-options{display:flex;gap:12px;justify-content:center;margin-bottom:18px;flex-wrap:wrap}
select{background:transparent;color:var(--muted);border:1px solid rgba(255,255,255,0.04);padding:8px 10px;border-radius:10px}
.controls{text-align:center;margin:18px 0}
input[type="text"], input[type="number"] {
width:min(72%,520px);
padding:12px 14px;border-radius:12px;border:1px solid rgba(255,255,255,0.04);background:rgba(255,255,255,0.02);color:#e6eef1;font-size:1rem;outline:none
width: 100%;
}
.progress-info {
flex-direction: column;
}
.search-results{margin-top:8px;max-height:260px;overflow:auto;border-radius:10px;background:var(--card);border:1px solid rgba(255,255,255,0.03);display:none}
.search-item{padding:10px 12px;border-bottom:1px solid rgba(255,255,255,0.02);cursor:pointer;color:#dbe7e9}
.search-item:hover{background:rgba(255,255,255,0.02)}
.result-container{margin:18px auto;padding:16px;border-radius:12px;text-align:center;display:none;max-width:720px}
.result-container.correct{background:linear-gradient(180deg, rgba(6,58,6,0.6), rgba(6,58,6,0.45));border:1px solid rgba(76,175,80,0.18)}
.result-container.incorrect{background:linear-gradient(180deg, rgba(58,6,6,0.6), rgba(58,6,6,0.45));border:1px solid rgba(244,67,54,0.12)}
.result-container img{width:84px;border-radius:8px;margin-top:10px}
.result-container a{color:var(--accent);text-decoration:none;font-weight:600}
.hint-container{color:var(--muted);text-align:center;margin-top:16px}
/* responsive */
@media (max-width:700px){
.quiz-viewport{padding:16px}
input[type="text"]{width:92%}
.game-modes{gap:8px}
}
</style>
<script>
@@ -281,13 +400,15 @@
// Song-Infos ergänzen
resultContainer.innerHTML += `
<div style="margin-top:10px;">
<img src="{{ track.album.images[0].url }}" alt="Cover" style="width:80px;border-radius:8px;"><br>
<strong>${i18n.song}:</strong> {{ track.name }}<br>
<strong>${i18n.artist}:</strong> {{ track.artists[0].name }}<br>
<strong>${i18n.album}:</strong> {{ track.album.name }}<br>
<strong>${i18n.year}:</strong> {{ track.album.release_date[:4] }}<br>
<a href="{{ track.external_urls.spotify }}" target="_blank" style="color:#1DB954;">${i18n.open_on_spotify}</a>
<div style="margin-top:20px; padding:20px; background:rgba(15,20,35,0.8); border-radius:15px; border:1px solid rgba(29,185,84,0.3);">
<img src="{{ track.album.images[0].url }}" alt="Cover" style="width:120px; height:120px; border-radius:12px; margin-bottom:15px; box-shadow:0 4px 15px rgba(0,0,0,0.5);"><br>
<div style="text-align:left; display:inline-block; margin-top:10px;">
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.song || 'Song'}:</strong> <span style="color:#e0e0e0;">{{ track.name }}</span></p>
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.artist || 'Artist'}:</strong> <span style="color:#e0e0e0;">{{ track.artists[0].name }}</span></p>
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.album || 'Album'}:</strong> <span style="color:#e0e0e0;">{{ track.album.name }}</span></p>
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.year || 'Year'}:</strong> <span style="color:#e0e0e0;">{{ track.album.release_date[:4] }}</span></p>
<a href="{{ track.external_urls.spotify }}" target="_blank" style="display:inline-block; margin-top:10px; padding:8px 16px; background:linear-gradient(135deg, #1DB954 0%, #1ed760 100%); color:#fff; text-decoration:none; border-radius:20px; font-weight:600; transition:all 0.3s ease;">${i18n.open_on_spotify || 'Open on Spotify'}</a>
</div>
</div>
`;
@@ -317,17 +438,25 @@ window.onload = function() {
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div style="text-align:center; margin-bottom: 10px;">
<span id="progressInfo">{{ translations['songs_in_playlist'] }} {{ total_questions }}</span>
<span id="scoreInfo" style="margin-left:20px;">
{{ translations['score'] }}: {{ score }} / {{ answered if answered > 0 else 1 }}
({{ ((score / (answered if answered > 0 else 1)) * 100) | round(0) if answered > 0 else 0 }}{{ translations['percent'] }})
</span>
</div>
<div style="text-align:center; margin-bottom: 20px;">
<a href="/reset_quiz/{{ playlist_id }}" class="btn btn-danger" style="margin-top:10px;">{{ translations['end_quiz'] }}</a>
</div>
<div class="quiz-container">
<!-- Header Section -->
<div class="header-section">
<h2 id="question-text">{{ translations['question_artist'] }}</h2>
<div class="progress-info">
<div class="progress-item">
<div class="progress-label">{{ translations['songs_in_playlist'] if translations.get('songs_in_playlist') else 'Songs in Playlist' }}</div>
<div class="progress-value">{{ total_questions }}</div>
</div>
<div class="progress-item">
<div class="progress-label">{{ translations['score'] if translations.get('score') else 'Score' }}</div>
<div class="progress-value">{{ score }} / {{ answered if answered > 0 else 1 }}</div>
</div>
<div class="progress-item">
<div class="progress-label">{{ translations['accuracy'] if translations.get('accuracy') else 'Accuracy' }}</div>
<div class="progress-value">{{ ((score / (answered if answered > 0 else 1)) * 100) | round(0) if answered > 0 else 0 }}%</div>
</div>
</div>
</div>
<!-- Verstecktes Feld für device_id -->
<input type="hidden" id="device_id" value="">
@@ -341,25 +470,25 @@ window.onload = function() {
<!-- Optionen für das Spiel -->
<div class="game-options">
<label>{{ translations['play_duration'] }}:
<label>{{ translations['play_duration'] if translations.get('play_duration') else 'Play Duration' }}:
<select id="playDuration" onchange="setOption('playDuration', this.value)">
<option value="10">10s</option>
<option value="15">15s</option>
<option value="30">30s</option>
<option value="0" selected>{{ translations['unlimited'] }}</option>
<option value="0" selected>{{ translations['unlimited'] if translations.get('unlimited') else 'Unlimited' }}</option>
</select>
</label>
<label style="margin-left:20px;">{{ translations['start_position'] }}:
<label style="margin-left:20px;">{{ translations['start_position'] if translations.get('start_position') else 'Start Position' }}:
<select id="startPosition" onchange="setOption('startPosition', this.value)">
<option value="start" selected>{{ translations['start'] }}</option>
<option value="random">{{ translations['random'] }}</option>
<option value="start" selected>{{ translations['start'] if translations.get('start') else 'Start' }}</option>
<option value="random">{{ translations['random'] if translations.get('random') else 'Random' }}</option>
</select>
</label>
</div>
<!-- Player Controls -->
<div class="controls" style="text-align: center;">
<button id="playPauseBtn" class="btn" onclick="togglePlay()">{{ translations['pause'] }}</button>
<div class="controls">
<button id="playPauseBtn" class="btn" onclick="togglePlay()">{{ translations['pause'] if translations.get('pause') else '⏸ Pause' }}</button>
</div>
<!-- Antwort-Eingabe -->
@@ -380,12 +509,19 @@ window.onload = function() {
<!-- Hilfe-Text je nach Modus -->
<div class="hint-container">
{% if game_mode == 'artist' %}
<p>{{ translations['tip_artist'] }}</p>
<p>{{ translations['tip_artist'] if translations.get('tip_artist') else 'Tip: Start typing to search for artists' }}</p>
{% elif game_mode == 'title' %}
<p>{{ translations['tip_title'] }}</p>
<p>{{ translations['tip_title'] if translations.get('tip_title') else 'Tip: Start typing to search for song titles' }}</p>
{% elif game_mode == 'year' %}
<p>{{ translations['tip_year'] }}</p>
<p>{{ translations['tip_year'] if translations.get('tip_year') else 'Tip: Enter the release year' }}</p>
{% endif %}
</div>
<!-- Navigation -->
<div class="controls">
<a href="/reset_quiz/{{ playlist_id }}" class="btn btn-danger">{{ translations['end_quiz'] if translations.get('end_quiz') else '🏁 End Quiz' }}</a>
<a href="/playlists" class="btn btn-secondary">{{ translations['back_to_playlists'] if translations.get('back_to_playlists') else '⬅️ Back to Playlists' }}</a>
</div>
</div>
</body>
</html>