Study Notes Categorizer

Study Notes Categorizer

1. Paste Your Notes

2. Organized Notes

Your organized notes will appear here.

An error occurred. Please try again.

`; } finally { loadingSpinner.classList.add('hidden'); } }; /** * Renders the categorized notes in the output area. * @param {Array} categorizedData - The structured data from the API. */ const displayCategorizedNotes = (categorizedData) => { categorizedOutput.innerHTML = ''; // Clear previous content if (!categorizedData || categorizedData.length === 0) { categorizedOutput.appendChild(outputPlaceholder); outputPlaceholder.classList.remove('hidden'); outputPlaceholder.querySelector('p').innerText = "Could not categorize the notes. Please try different text."; return; } const fragment = document.createDocumentFragment(); categorizedData.forEach(subject => { const subjectContainer = document.createElement('div'); subjectContainer.className = 'p-4 border border-gray-200 rounded-lg bg-gray-50 mb-4'; const subjectTitle = document.createElement('h3'); subjectTitle.className = 'text-xl font-bold text-blue-700 mb-3'; subjectTitle.textContent = subject.subject; subjectContainer.appendChild(subjectTitle); subject.topics.forEach(topic => { const topicContainer = document.createElement('div'); topicContainer.className = 'ml-4 mb-3'; const topicTitle = document.createElement('h4'); topicTitle.className = 'text-lg font-semibold text-gray-800'; topicTitle.textContent = topic.topic_name; topicContainer.appendChild(topicTitle); const notesList = document.createElement('ul'); notesList.className = 'list-disc list-inside text-gray-700 ml-4 mt-1 space-y-1'; topic.notes.forEach(note => { const noteItem = document.createElement('li'); noteItem.textContent = note; notesList.appendChild(noteItem); }); topicContainer.appendChild(notesList); subjectContainer.appendChild(topicContainer); }); fragment.appendChild(subjectContainer); }); categorizedOutput.appendChild(fragment); }; // --- Event Listener --- if (categorizeBtn) { categorizeBtn.addEventListener('click', handleCategorizeNotes); } });
Scroll to Top