diff --git a/static/js/script.js b/static/js/script.js index 7900c4b..5ee56c7 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -119,31 +119,28 @@ document.addEventListener('DOMContentLoaded', function() { // Verwende den ursprünglichen Text für die Anzeige const originalText = currentText; - // Erstelle eine Kopie des Textes für die Anzeige, um Tabulatoren korrekt zu behandeln - let displayText = originalText; - - for (let i = 0; i < displayText.length; i++) { + for (let i = 0; i < originalText.length; i++) { if (i < userInput.length) { - if (userInput[i] === displayText[i]) { + if (userInput[i] === originalText[i]) { // Für korrekt getippte Leerzeichen und Tabulatoren: sichtbar machen - if (displayText[i] === ' ') { + if (originalText[i] === ' ') { highlightedText += '·'; - } else if (displayText[i] === '\t') { + } else if (originalText[i] === '\t') { highlightedText += ''; } else { - highlightedText += `${displayText[i]}`; + highlightedText += `${originalText[i]}`; } } else { - highlightedText += `${displayText[i]}`; + highlightedText += `${originalText[i]}`; } } else { // Für nicht eingegebene Zeichen: Einrückungen anzeigen - if (displayText[i] === ' ') { + if (originalText[i] === ' ') { highlightedText += '·'; - } else if (displayText[i] === '\t') { + } else if (originalText[i] === '\t') { highlightedText += ''; } else { - highlightedText += displayText[i]; + highlightedText += originalText[i]; } } }