Symptom: ${entry.symptom}
Foods: ${entry.foods}
Other Triggers: ${entry.triggers}
`; fullLogContainer.appendChild(entryEl); }); downloadPdfBtn.style.display = 'inline-block'; } function clearLog() { if (confirm('Are you sure you want to delete all log entries? This cannot be undone.')) { logData = []; localStorage.removeItem('refluxLog'); renderLog(); } } function generatePdf() { if (logData.length === 0) return; const { jsPDF } = jspdf; const doc = new jsPDF(); const pageW = doc.internal.pageSize.getWidth(); // Header doc.setFillColor(219, 39, 119); // Fuchsia doc.rect(0, 0, pageW, 25, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor(255, 255, 255); doc.text('Acid Reflux & Heartburn Log', pageW / 2, 15, { align: 'center' }); // Table const tableData = logData.map(entry => { const date = new Date(entry.datetime); return [ `${date.toLocaleDateString('en-US', {month:'short', day:'numeric'})}\n${date.toLocaleTimeString('en-US', {hour:'2-digit', minute:'2-digit'})}`, entry.foods, `${entry.symptom} (${entry.severity}/10)`, entry.triggers ]; }); doc.autoTable({ startY: 30, theme: 'grid', headStyles: { fillColor: [219, 39, 119] }, head: [['Date & Time', 'Foods & Drinks', 'Symptoms (Severity)', 'Other Triggers']], body: tableData, columnStyles: { 0: { cellWidth: 30 }, 1: { cellWidth: 'auto' }, 2: { cellWidth: 40 }, 3: { cellWidth: 40 } } }); // Disclaimer doc.autoTable({ startY: doc.lastAutoTable.finalY + 10, theme: 'plain', body: [[ "Disclaimer: This log is a personal tracking tool and not a substitute for professional medical advice. Share this log with your doctor to help them understand your symptoms." ]] }); // Footer const pageH = doc.internal.pageSize.getHeight(); doc.setLineWidth(0.5); doc.setDrawColor(219, 39, 119); doc.line(15, pageH - 15, pageW - 15, pageH - 15); doc.setFontSize(8); doc.setTextColor(128, 128, 128); doc.text('Personal Health Log', pageW / 2, pageH - 10, { align: 'center' }); doc.save('Acid_Reflux_Log.pdf'); } // Initial Render changeTab(0); renderLog(); });