Study Notes Organizer

Welcome to your Study Organizer

Select a topic from the sidebar to view notes, or add a new subject to get started.

${card.answer}

`; cardEl.onclick = () => cardEl.classList.toggle('is-flipped'); flashcardContainer.appendChild(cardEl); }); }; // --- MODAL CONTROLS --- app.showAddSubjectModal = () => document.getElementById('addSubjectModal').classList.remove('hidden'); app.showAddTopicModal = (subjectId) => { activeSubjectId = subjectId; document.getElementById('addTopicModal').classList.remove('hidden'); }; app.showAddFlashcardModal = () => document.getElementById('addFlashcardModal').classList.remove('hidden'); app.hideModal = (modalId) => document.getElementById(modalId).classList.add('hidden'); // --- CORE LOGIC --- app.addSubject = () => { const input = document.getElementById('subjectNameInput'); if (!input.value.trim()) return; data.subjects.push({ id: 's' + Date.now(), name: input.value, topics: [] }); saveData(); renderSidebar(); input.value = ''; app.hideModal('addSubjectModal'); }; app.addTopic = () => { const input = document.getElementById('topicNameInput'); if (!input.value.trim()) return; const subject = data.subjects.find(s => s.id === activeSubjectId); subject.topics.push({ id: 't' + Date.now(), name: input.value, notes: '', status: 'Not Started', flashcards: [] }); saveData(); renderSidebar(); input.value = ''; app.hideModal('addTopicModal'); }; app.saveFlashcard = () => { const question = document.getElementById('flashcardQuestionInput').value; const answer = document.getElementById('flashcardAnswerInput').value; if (!question.trim() || !answer.trim()) return; const subject = data.subjects.find(s => s.id === activeSubjectId); const topic = subject.topics.find(t => t.id === activeTopicId); topic.flashcards.push({ id: 'f' + Date.now(), question, answer }); saveData(); renderFlashcards(); document.getElementById('addFlashcardModal').querySelector('textarea').value = ''; document.getElementById('addFlashcardModal').querySelectorAll('textarea')[1].value = ''; app.hideModal('addFlashcardModal'); }; app.selectTopic = (subjectId, topicId) => { activeSubjectId = subjectId; activeTopicId = topicId; renderTopicView(); if (window.innerWidth < 768) { sidebar.classList.add('sidebar-hidden'); } }; app.changeTab = (tabName) => { const tabs = ['notes', 'flashcards']; tabs.forEach(tab => { document.getElementById(`tabContent-${tab}`).classList.add('hidden'); document.getElementById(`tab-${tab}`).classList.remove('text-blue-600', 'border-blue-600'); document.getElementById(`tab-${tab}`).classList.add('text-gray-500', 'border-transparent'); }); document.getElementById(`tabContent-${tabName}`).classList.remove('hidden'); document.getElementById(`tab-${tabName}`).classList.add('text-blue-600', 'border-blue-600'); }; // --- EVENT HANDLERS --- noteContent.addEventListener('input', () => { const subject = data.subjects.find(s => s.id === activeSubjectId); const topic = subject.topics.find(t => t.id === activeTopicId); topic.notes = noteContent.value; saveData(); }); topicStatus.addEventListener('change', () => { const subject = data.subjects.find(s => s.id === activeSubjectId); const topic = subject.topics.find(t => t.id === activeTopicId); topic.status = topicStatus.value; saveData(); }); mobileMenuButton.addEventListener('click', () => { sidebar.classList.toggle('sidebar-hidden'); }); // --- PDF DOWNLOAD --- app.downloadTopicPDF = () => { const subject = data.subjects.find(s => s.id === activeSubjectId); const topic = subject.topics.find(t => t.id === activeTopicId); const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(22); doc.text(topic.name, 105, 20, null, null, 'center'); doc.setFontSize(12); doc.text(`Subject: ${subject.name} | Status: ${topic.status}`, 105, 28, null, null, 'center'); doc.setFontSize(16); doc.text("Notes", 15, 45); doc.setFontSize(11); const notesText = doc.splitTextToSize(topic.notes, 180); doc.text(notesText, 15, 55); if (topic.flashcards.length > 0) { doc.addPage(); doc.setFontSize(16); doc.text("Flashcards", 105, 20, null, null, 'center'); doc.autoTable({ startY: 25, head: [['Question', 'Answer']], body: topic.flashcards.map(f => [f.question, f.answer]), theme: 'grid' }); } doc.save(`${topic.name.replace(/ /g, '_')}.pdf`); }; // --- INITIALIZATION --- loadData(); renderSidebar(); renderTopicView(); });
Scroll to Top