Online Automated Daily Summary Generator
Your Automated Summary
Your summary will appear here after you generate it from the 'Input & Configuration' tab.
Generating your summary...
Provide Your Content
• $1
'); elements.pdfContent.innerHTML = `${formattedSummary}
`;
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 imgProps = pdf.getImageProperties(imgData);
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
const safeTitle = title.replace(/[^a-z0-9]/gi, '_').toLowerCase();
pdf.save(`${safeTitle}_summary.pdf`);
} catch (error) {
console.error("PDF Generation Error:", error);
} finally {
elements.pdfContent.classList.add('hidden');
}
};
// --- EVENT LISTENERS ---
elements.tabButtons.dashboard.addEventListener('click', () => switchTab('dashboard'));
elements.tabButtons.input.addEventListener('click', () => 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.inputForm.addEventListener('submit', handleGenerateSummary);
elements.downloadPdfBtn.addEventListener('click', downloadPDF);
// --- INITIALIZATION ---
switchTab('dashboard');
});
