diff --git a/static/js/script.js b/static/js/script.js index fc8d3b1..4a39e01 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -12,8 +12,7 @@ document.addEventListener('DOMContentLoaded', function() { const totalElement = document.getElementById('total'); const wpmElement = document.getElementById('wpm'); - // Aktuelle Textdaten - let currentText = window.initialText; + // Aktuelle Textdaten (verwende nur lines, entferne currentText) let lines = window.lines; let currentLineIndex = window.currentLineIndex; let startTime = null; @@ -66,7 +65,8 @@ document.addEventListener('DOMContentLoaded', function() { function updateTimer() { if (startTime) { const userValue = userInput.value; - updateStatistics(userValue, currentText); + const currentLine = lines[currentLineIndex]; + updateStatistics(userValue, currentLine); } } @@ -95,8 +95,8 @@ document.addEventListener('DOMContentLoaded', function() { if (data.error) { alert('Fehler: ' + data.error); } else { - currentText = data.text; - lines = currentText.split('\n'); + // Verwende nur lines, entferne currentText + lines = data.text.split('\n'); currentLineIndex = 0; updateLineDisplay(); document.getElementById('lesson-title').textContent = data.title; @@ -126,8 +126,8 @@ document.addEventListener('DOMContentLoaded', function() { }) .then(response => response.json()) .then(data => { - currentText = data.text; - lines = currentText.split('\n'); + // Verwende nur lines, entferne currentText + lines = data.text.split('\n'); currentLineIndex = 0; updateLineDisplay(); // Aktualisiere den Lektionstitel