Fiber Intake Optimization Tool

Fiber Intake Optimization Tool

1. Profile
2. Food Log
3. Report

Your Profile

Provide your age and gender to determine your recommended daily fiber intake based on US Dietary Guidelines.

Log Your Daily Food Intake

Your Food List:

Your added foods will appear here.

Your report will be generated here.

${Math.round(percentage)}% of your daily goal

Summary:

${getReportMessage(totalFiber, userProfile.recommendation)}
`; downloadPdfBtn.style.display = 'inline-block'; } function getReportMessage(total, goal) { if (total >= goal) return "Congratulations! You've met your daily fiber goal. Keep up the great work for optimal digestive health."; if (total > goal * 0.7) return "You're very close! Add one more high-fiber snack like a pear or a small handful of almonds to reach your goal."; if (total > goal * 0.4) return "Good start! To improve, try swapping white bread for whole wheat, and add a side of beans or lentils to your next meal."; return "There's room for improvement. Focus on adding more fruits, vegetables, and whole grains to every meal to boost your fiber intake."; } function updateUI() { tabs.forEach((tab, index) => tab.classList.toggle('active', index === currentTab)); tabContents.forEach((content, index) => content.classList.toggle('active', index === currentTab)); prevBtn.disabled = currentTab === 0; nextBtn.disabled = currentTab === tabs.length - 1; } function generatePdf() { const { jsPDF } = jspdf; const doc = new jsPDF(); const pageW = doc.internal.pageSize.getWidth(); const totalFiber = loggedFoods.reduce((sum, food) => sum + food.fiber, 0); // Header doc.setFillColor(34, 197, 94); // Green doc.rect(0, 0, pageW, 25, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor(255, 255, 255); doc.text('Fiber Intake Optimization Report', pageW / 2, 15, { align: 'center' }); // Profile & Goal doc.autoTable({ startY: 30, theme: 'striped', body: [ ['Age', userProfile.age], ['Gender', userProfile.gender], ['Recommended Daily Fiber', `${userProfile.recommendation}g`], ['Your Total Intake', `${totalFiber.toFixed(1)}g`], ], }); // Food Log doc.autoTable({ startY: doc.lastAutoTable.finalY + 10, theme: 'grid', headStyles: { fillColor: [34, 197, 94] }, head: [['Food Item', 'Fiber (g)']], body: loggedFoods.map(f => [f.name, f.fiber.toFixed(1)]), footStyles: { fillColor: [240, 253, 244], textColor: [21, 128, 61], fontStyle: 'bold' }, foot: [['Total', totalFiber.toFixed(1)]] }); // Summary doc.autoTable({ startY: doc.lastAutoTable.finalY + 10, theme: 'plain', head: [['Summary & Recommendations']], body: [[ getReportMessage(totalFiber, userProfile.recommendation) + "\n\nDisclaimer: This tool is for informational purposes and is not a substitute for professional medical or dietary advice." ]] }); // Footer const pageH = doc.internal.pageSize.getHeight(); doc.setLineWidth(0.5); doc.setDrawColor(34, 197, 94); doc.line(15, pageH - 15, pageW - 15, pageH - 15); doc.setFontSize(8); doc.setTextColor(128, 128, 128); doc.text('Personalized Nutrition Report', pageW / 2, pageH - 10, { align: 'center' }); doc.save('Fiber_Intake_Report.pdf'); } updateUI(); });
Scroll to Top