diff --git a/static/js/script.js b/static/js/script.js index 6d8eaff..b7041f2 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -1,5 +1,6 @@ // Theme Management function initializeTheme() { + // Beim ersten Start Light-Modus, sonst gespeicherten Modus verwenden const savedTheme = localStorage.getItem('theme') || 'light'; document.body.setAttribute('data-bs-theme', savedTheme); updateThemeButton(savedTheme); @@ -111,46 +112,44 @@ document.addEventListener('DOMContentLoaded', function() { // Behandle Pfeiltasten if (event.key === 'ArrowLeft') { event.preventDefault(); - keyStrokeCount++; - if (!startTime) { - startTime = new Date(); - } if (currentCharIndex > 0) { + keyStrokeCount++; + if (!startTime) { + startTime = new Date(); + } currentCharIndex--; updateTextDisplay(); + updateStatistics(); } - updateStatistics(); return; } if (event.key === 'ArrowRight') { event.preventDefault(); - keyStrokeCount++; - if (!startTime) { - startTime = new Date(); - } if (currentCharIndex < userInput.length) { + keyStrokeCount++; + if (!startTime) { + startTime = new Date(); + } currentCharIndex++; updateTextDisplay(); + updateStatistics(); } - updateStatistics(); return; } // Behandle Backspace if (event.key === 'Backspace') { event.preventDefault(); - keyStrokeCount++; - if (!startTime) { - startTime = new Date(); - } if (userInput.length > 0 && currentCharIndex > 0) { + keyStrokeCount++; + if (!startTime) { + startTime = new Date(); + } userInput = userInput.slice(0, currentCharIndex - 1) + userInput.slice(currentCharIndex); currentCharIndex--; updateTextDisplay(); updateStatistics(); - } else { - updateStatistics(); } return; } @@ -500,8 +499,8 @@ document.addEventListener('DOMContentLoaded', function() { function initializeProgressStatsToggle() { const performanceBtn = document.getElementById('performance-btn'); - // Lade gespeicherten Zustand aus localStorage - const progressStatsVisible = localStorage.getItem('progressStatsVisible') !== 'false'; + // Beim ersten Start abgeschaltet, sonst gespeicherten Zustand verwenden + const progressStatsVisible = localStorage.getItem('progressStatsVisible') === 'true'; // Setze initialen Zustand setProgressStatsVisibility(progressStatsVisible);