modified: app.py

modified:   templates/quiz.html
This commit is contained in:
2025-11-14 23:56:46 +01:00
parent 5c02266370
commit 97d8444441
2 changed files with 18 additions and 3 deletions

View File

@@ -312,6 +312,17 @@
}
}
// 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;
@@ -356,8 +367,9 @@
item.className = 'search-item';
item.innerHTML = `<strong>${result.name}</strong> - ${result.artist}`;
item.onclick = function() {
document.getElementById('answerInput').value =
currentGameMode === 'artist' ? result.artist : result.name;
// Setze den bereinigten Wert (ohne Sonderzeichen) ins Input
const valueToSet = currentGameMode === 'artist' ? result.artist : result.name;
document.getElementById('answerInput').value = cleanTitle(valueToSet);
resultsContainer.style.display = 'none';
};
resultsContainer.appendChild(item);