Personalized Supplement Stack Planner

Personalized Supplement Stack Planner

Build a supplement plan tailored to your unique health goals.

Select Your Health Goals (Choose all that apply)

Your Personalized Supplement Stack

Important Disclaimer:

This tool provides general information and is not a substitute for professional medical advice. Consult with a healthcare provider before starting any new supplement regimen, especially if you have existing health conditions or are taking medication.

${data.reason}

Supports: ${goalTags}
`; stackOutput.appendChild(card); } resultsContainer.style.display = 'block'; }; const generatePdf = () => { if (Object.keys(finalStack).length === 0) { alert('Please generate a plan first.'); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF('p', 'mm', 'a4'); const pageW = pdf.internal.pageSize.getWidth(); const margin = 15; let y = 0; // --- PDF Styling --- const primaryColor = '#6d28d9'; const secondaryColor = '#8b5cf6'; const textColor = '#3730a3'; const lightTextColor = '#5b21b6'; const borderColor = '#ddd6fe'; // --- Header --- pdf.setFillColor(primaryColor); pdf.rect(0, 0, pageW, 30, 'F'); pdf.setFontSize(22); pdf.setFont('helvetica', 'bold'); pdf.setTextColor('#FFFFFF'); pdf.text('Personalized Supplement Plan', pageW / 2, 18, { align: 'center' }); y = 40; // --- Goals Section --- const selectedGoalNames = Array.from(document.querySelectorAll('input[name="health-goal"]:checked')) .map(cb => goals.find(g => g.id === cb.value).name); pdf.setFontSize(14); pdf.setFont('helvetica', 'bold'); pdf.setTextColor(textColor); pdf.text('Your Selected Health Goals', margin, y); y += 8; pdf.setFontSize(10); pdf.setFont('helvetica', 'normal'); pdf.setTextColor(lightTextColor); pdf.text(selectedGoalNames.join(', '), margin, y); y += 10; pdf.setDrawColor(borderColor); pdf.line(margin, y, pageW - margin, y); y += 12; // --- Supplement Sections --- for (const supplementName in finalStack) { const data = finalStack[supplementName]; if (y > 250) { pdf.addPage(); y = 20; } pdf.setFontSize(12); pdf.setFont('helvetica', 'bold'); pdf.setTextColor(textColor); pdf.text(supplementName, margin, y); pdf.setFont('helvetica', 'normal'); pdf.setTextColor(secondaryColor); pdf.text(data.dosage, pageW - margin, y, { align: 'right' }); y += 6; pdf.setFontSize(9); pdf.setTextColor(lightTextColor); const reasonLines = pdf.splitTextToSize(`Reason: ${data.reason}`, pageW - margin * 2); pdf.text(reasonLines, margin, y); y += reasonLines.length * 4 + 2; const goalsLines = pdf.splitTextToSize(`Supports: ${data.matchedGoals.join(', ')}`, pageW - margin * 2); pdf.text(goalsLines, margin, y); y += goalsLines.length * 4 + 4; } // --- Disclaimer --- if (y > 240) { pdf.addPage(); y = 20; } pdf.setFillColor('#fefce8'); pdf.roundedRect(margin, y, pageW - margin * 2, 25, 3, 3, 'F'); pdf.setFontSize(10); pdf.setFont('helvetica', 'bold'); pdf.setTextColor('#b45309'); pdf.text('Disclaimer:', margin + 5, y + 7); pdf.setFontSize(9); pdf.setFont('helvetica', 'normal'); const disclaimerText = 'This tool provides general information and is not a substitute for professional medical advice. Consult with a healthcare provider before starting any new supplement regimen.'; const disclaimerLines = pdf.splitTextToSize(disclaimerText, pageW - margin * 2 - 10); pdf.text(disclaimerLines, margin + 5, y + 13); pdf.save('Supplement-Stack-Plan.pdf'); }; // --- EVENT LISTENERS --- generatePlanBtn.addEventListener('click', generatePlan); downloadPdfBtn.addEventListener('click', generatePdf); // --- INITIALIZATION --- renderGoals(); });
Scroll to Top