`;
document.getElementById('summary-profile').innerHTML = profileHtml;
// Symptoms Table
const symptomsHtml = `
`;
document.getElementById('summary-symptoms').innerHTML = symptomsHtml;
// AI Insights
const insightsHtml = insights
.replace(/### (.*?)\n/g, '
') .replace(/\n- /g, '
- ') .replace(/\*\*(.*?)\*\*/g, '$1'); document.getElementById('summary-insights').innerHTML = `
My Symptoms
| Symptom | Severity |
|---|---|
| ${SYMPTOMS.find(s => s.id === id).name} | ${val.severity || 'Not rated'} |
| No symptoms with severity were selected. | |
$1
') .replace(/\n\n/g, '') .replace(/\n- /g, '
- ') .replace(/\*\*(.*?)\*\*/g, '$1'); document.getElementById('summary-insights').innerHTML = `
${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 canvasHeight = canvas.height;
const canvasWidth = canvas.width;
const ratio = canvasWidth / canvasHeight;
const imgWidth = pdfWidth - 20;
const imgHeight = imgWidth / ratio;
let heightLeft = imgHeight;
let position = 10;
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - 20);
while (heightLeft > 0) {
position = -heightLeft - 10;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - 20);
}
pdf.save('My-Pet-Allergy-Plan.pdf');
})
.catch(err => console.error("PDF Generation Error:", err));
};
// --- START THE APP ---
initialize();
});
