Online Meeting Notes Archiver Online Meeting Notes Archiver Your User ID: Connecting... Archive Submit Notes My Meeting Notes Loading your archived notes... Submit New Meeting Notes Meeting Title Meeting Date Attendees (comma-separated) Notes & Action Items Archive Notes Meeting notes have been successfully archived! Date: ${note.meetingDate} Attendees: ${attendeesList} Notes & Action Items: ${note.notes} `; return div; } // --- EVENT LISTENERS --- // Tab navigation if (tabsContainer) { tabsContainer.addEventListener('click', (event) => { if (event.target.matches('.tab-btn')) { const tabIndex = parseInt(event.target.dataset.tabIndex); document.querySelectorAll('.tab-btn').forEach((btn, i) => { btn.classList.toggle('active', i === tabIndex); btn.classList.toggle('inactive', i !== tabIndex); }); tabContents.forEach((content, i) => { content.classList.toggle('active', i === tabIndex); }); } }); } // Notes submission form if (submitNotesForm) { submitNotesForm.addEventListener('submit', async (e) => { e.preventDefault(); if (!currentUserId) { alert("Not authenticated. Please wait or refresh."); return; } const submitBtn = document.getElementById('submit-notes-btn'); submitBtn.disabled = true; submitBtn.textContent = 'Archiving...'; const noteData = { title: document.getElementById('meeting-title').value, meetingDate: document.getElementById('meeting-date').value, attendees: document.getElementById('meeting-attendees').value, notes: document.getElementById('meeting-notes').value, archivedAt: serverTimestamp(), }; try { // **SECURITY**: Add to the user's private collection. await addDoc(collection(db, `artifacts/${appId}/users/${currentUserId}/notes`), noteData); const successMsg = document.getElementById('submit-success-message'); if (successMsg) { successMsg.classList.remove('hidden'); setTimeout(() => successMsg.classList.add('hidden'), 4000); } submitNotesForm.reset(); // Switch back to the archive view tabsContainer.querySelector('[data-tab-index="0"]').click(); } catch (error) { console.error("Error archiving notes:", error); alert("Failed to archive notes. Please try again."); } finally { submitBtn.disabled = false; submitBtn.textContent = 'Archive Notes'; } }); } // Search input searchInput.addEventListener('input', renderNotes); // Accordion functionality using event delegation notesContainer.addEventListener('click', (event) => { const header = event.target.closest('.accordion-header'); if (header) { const content = header.nextElementSibling; const icon = header.querySelector('svg'); if (content.style.maxHeight) { content.style.maxHeight = null; content.style.padding = "0 1.5rem"; icon.style.transform = 'rotate(0deg)'; } else { content.style.maxHeight = content.scrollHeight + "px"; content.style.padding = "1rem 1.5rem"; icon.style.transform = 'rotate(180deg)'; } } }); // --- INITIALIZATION --- initializeAuth(); });