${formatDate(entry.date)}
-
${Object.entries(entry.symptoms).map(([id, value]) => `
- ${SYMPTOMS.find(s=>s.id===id).name}: ${value}/10 `).join('')} ${entry.pem ? `
- Triggers: ${entry.pem} ` : ''} ${entry.notes ? `
- Notes: ${entry.notes} ` : ''}
$1
') .replace(/### (.*?)\n/g, '$1
') .replace(/- (.*?)\n/g, '- $1
- /g, '');
summaryContentContainer.innerHTML = `
Full Journal History
${historyHtml}${insightsHtml}`; }; // --- PDF GENERATION --- const handleDownloadPdf = () => { const content = document.getElementById('pdf-content'); if (!content) return; html2canvas(content, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const ratio = canvas.width / canvas.height; const imgWidth = pdfWidth - 20; let imgHeight = imgWidth / ratio; let heightLeft = imgHeight; let position = 10; pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); while (heightLeft > 0) { position = -heightLeft - 10; pdf.addPage(); pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - 20); } pdf.save('My-Long-COVID-Journal.pdf'); }) .catch(err => console.error("PDF Generation Error:", err)); }; // --- UTILITIES --- const formatDate = (dateString) => { const date = new Date(dateString + 'T00:00:00'); return date.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); }; // --- START THE APP --- initialize(); });
