modified: app.py

modified:   templates/quiz.html
This commit is contained in:
2025-11-15 00:00:01 +01:00
parent 97d8444441
commit 98bb694004
2 changed files with 18 additions and 25 deletions

View File

@@ -297,11 +297,11 @@
function setCorrectAnswer() {
if (currentGameMode === 'artist') {
correctAnswer = "{{ track.artists[0].name }}";
correctAnswer = "{{ track.artists[0].name | clean }}";
document.getElementById('question-text').innerText = i18n.question_artist;
document.getElementById('answerInput').placeholder = i18n.input_artist;
} else if (currentGameMode === 'title') {
correctAnswer = "{{ track.name }}";
correctAnswer = "{{ track.name | clean }}";
document.getElementById('question-text').innerText = i18n.question_title;
document.getElementById('answerInput').placeholder = i18n.input_title;
} else if (currentGameMode === 'year') {
@@ -312,17 +312,6 @@
}
}
// Hilfsfunktion: Entfernt Sonderzeichen wie in Python clean_title
function cleanTitle(title) {
// Entferne Klammerzusätze
title = title.replace(/(\s*[\(\[][^)\]]*[\)\]])/g, '');
// Entferne Apostrophe und Anführungszeichen
title = title.replace(/['''`´ʼ""„""']/g, '');
// Entferne weitere Sonderzeichen (außer Buchstaben, Zahlen, Leerzeichen, - und &)
title = title.replace(/[^\w\s\-&]/g, '');
return title.trim();
}
function togglePlay() {
const deviceId = document.getElementById('device_id').value;
@@ -367,9 +356,8 @@
item.className = 'search-item';
item.innerHTML = `<strong>${result.name}</strong> - ${result.artist}`;
item.onclick = function() {
// Setze den bereinigten Wert (ohne Sonderzeichen) ins Input
const valueToSet = currentGameMode === 'artist' ? result.artist : result.name;
document.getElementById('answerInput').value = cleanTitle(valueToSet);
document.getElementById('answerInput').value =
currentGameMode === 'artist' ? result.artist : result.name;
resultsContainer.style.display = 'none';
};
resultsContainer.appendChild(item);
@@ -415,9 +403,9 @@
<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.song || 'Song'}:</strong> <span style="color:#e0e0e0;">{{ track.name | clean }}</span></p>
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.artist || 'Artist'}:</strong> <span style="color:#e0e0e0;">{{ track.artists[0].name | clean }}</span></p>
<p style="margin:8px 0;"><strong style="color:#1DB954;">${i18n.album || 'Album'}:</strong> <span style="color:#e0e0e0;">{{ track.album.name | clean }}</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>