modified: app.py
modified: templates/quiz.html
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user