Changed around line 1
+ const editor = document.getElementById('editor');
+ const wordCount = document.getElementById('word-count');
+ const charCount = document.getElementById('char-count');
+ const lineCount = document.getElementById('line-count');
+ const paragraphCount = document.getElementById('paragraph-count');
+ const readingTime = document.getElementById('reading-time');
+ const themeToggle = document.getElementById('theme-toggle');
+ const clearBtn = document.getElementById('clear-btn');
+
+ // Load saved text
+ editor.value = localStorage.getItem('scribeText') || '';
+
+ // Update stats
+ function updateStats() {
+ const text = editor.value;
+
+ // Word count
+ const words = text.match(/\b\w+\b/g) || [];
+ wordCount.textContent = words.length;
+
+ // Character count
+ charCount.textContent = text.length;
+
+ // Line count
+ lineCount.textContent = text.split('\n').length;
+
+ // Paragraph count
+ paragraphCount.textContent = text.split('\n\n').filter(p => p.trim()).length;
+
+ // Reading time (200 words per minute)
+ const minutes = Math.ceil(words.length / 200);
+ readingTime.textContent = `${minutes} min`;
+
+ // Save text
+ localStorage.setItem('scribeText', text);
+ }
+
+ // Theme toggle
+ function toggleTheme() {
+ const isDark = document.body.getAttribute('data-theme') === 'dark';
+ document.body.setAttribute('data-theme', isDark ? 'light' : 'dark');
+ localStorage.setItem('scribeTheme', isDark ? 'light' : 'dark');
+ }
+
+ // Clear text
+ function clearText() {
+ editor.value = '';
+ updateStats();
+ }
+
+ // Event listeners
+ editor.addEventListener('input', updateStats);
+ themeToggle.addEventListener('click', toggleTheme);
+ clearBtn.addEventListener('click', clearText);
+
+ // Initialize theme
+ const savedTheme = localStorage.getItem('scribeTheme') || 'light';
+ document.body.setAttribute('data-theme', savedTheme);
+
+ // Initial stats update
+ updateStats();