Online Research Paper & Study Notes Collector

Online Research Paper & Study Notes Collector

Your Collected Notes

${escapeHTML(note.quotes).replace(/\n/g, '
')}

` : ''}
`; }); html += `
`; elements.pdfContent.innerHTML = html; elements.pdfContent.classList.remove('hidden'); try { const canvas = await html2canvas(elements.pdfContent, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'pt', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft > 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; } pdf.save('research-notes.pdf'); } catch (error) { console.error("PDF Generation Error:", error); } finally { elements.pdfContent.classList.add('hidden'); } }; const escapeHTML = (str) => str.replace(/[&<>'"]/g, tag => ({'&': '&','<': '<','>': '>',"'": ''','"': '"'}[tag])); // --- EVENT LISTENERS --- elements.tabButtons.dashboard.addEventListener('click', () => switchTab('dashboard')); elements.tabButtons.input.addEventListener('click', () => { resetForm(); switchTab('input'); }); elements.prevBtn.addEventListener('click', () => { const i = TABS.indexOf(activeTab); if (i > 0) switchTab(TABS[i - 1]); }); elements.nextBtn.addEventListener('click', () => { const i = TABS.indexOf(activeTab); if (i < TABS.length - 1) switchTab(TABS[i + 1]); }); elements.noteForm.addEventListener('submit', handleSaveNote); elements.cancelEditBtn.addEventListener('click', () => { resetForm(); switchTab('dashboard'); }); elements.topicFilter.addEventListener('change', renderNotes); elements.downloadPdfBtn.addEventListener('click', downloadPDF); elements.notesGrid.addEventListener('click', (e) => { if (e.target.classList.contains('edit-btn')) handleEditNote(e.target.dataset.id); if (e.target.classList.contains('delete-btn')) handleDeleteNote(e.target.dataset.id); }); // --- INITIALIZATION --- loadNotes(); updateTopicFilter(); renderNotes(); switchTab('dashboard'); });
Scroll to Top