const noteContentElement = document.getElementById('noteContent'); const saveIcon = document.getElementById('saveIcon'); let currentNoteIndex = 0; window.onload = function () { const savedNote = localStorage.getItem('note'); if (savedNote) { noteContentElement.value = savedNote; } }; function myFunction() { var element = document.body; element.classList.toggle("dark-mode"); } function autosaveNote() { const noteContent = noteContentElement.value; localStorage.setItem('note', noteContent); saveIcon.style.display = 'inline'; setTimeout(function () { saveIcon.style.display = 'none'; }, 1000); } function saveNote() { const noteContent = noteContentElement.value; const timestamp = new Date().toISOString(); const versionHistory = JSON.parse(localStorage.getItem('versionHistory')) || []; versionHistory.push({ timestamp, content: noteContent }); localStorage.setItem('versionHistory', JSON.stringify(versionHistory)); localStorage.setItem('note', noteContent); saveIcon.style.display = 'inline'; setTimeout(function () { saveIcon.style.display = 'none'; }, 1000); alert('Note saved successfully!'); } function exportNote() { const noteContent = noteContentElement.value; const blob = new Blob([noteContent], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'note.txt'; a.click(); URL.revokeObjectURL(url); } function showVersionHistory() { const versionHistory = JSON.parse(localStorage.getItem('versionHistory')) || []; let historyHtml = '