Personalized Anti-Inflammatory Diet Planner
Build a custom meal plan to support your wellness goals.
Your Dietary Needs
Select Your Favorite Anti-Inflammatory Foods
Choose at least 5-10 items you enjoy. The more you select, the more varied your plan will be.
Building your personalized plan...
My Anti-Inflammatory Diet Plan
A required library could not be loaded. Please check your internet connection and try again.
'; return; } const { jsPDF } = jspdf; // --- DATA & STATE --- const FOOD_CATEGORIES = { "Leafy Greens": ["Spinach", "Kale", "Swiss Chard", "Arugula"], "Berries & Fruits": ["Blueberries", "Strawberries", "Cherries", "Oranges", "Apples", "Grapes"], "Vegetables": ["Broccoli", "Cauliflower", "Bell Peppers", "Mushrooms", "Tomatoes", "Beets"], "Healthy Fats": ["Avocado", "Olive Oil", "Chia Seeds", "Flax Seeds"], "Nuts & Seeds": ["Almonds", "Walnuts", "Sunflower Seeds", "Pumpkin Seeds"], "Fatty Fish": ["Salmon", "Sardines", "Mackerel", "Herring"], "Lean Proteins": ["Chicken Breast", "Turkey", "Lentils", "Chickpeas", "Tofu"], "Spices & Herbs": ["Turmeric", "Ginger", "Garlic", "Cinnamon", "Rosemary"], "Beverages": ["Green Tea", "Water"] }; let userState = { profile: { preference: 'Omnivore (includes everything)', restrictions: '', }, selectedFoods: [], }; // --- ELEMENT SELECTORS --- const tabs = document.querySelectorAll('.tab-btn'); const tabContents = document.querySelectorAll('.tab-content'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const foodSelectionContainer = document.getElementById('food-selection-container'); // Profile const dietPreferenceSelect = document.getElementById('diet-preference'); const restrictionsInput = document.getElementById('restrictions'); // Plan const getPlanBtn = document.getElementById('getPlanBtn'); const planLoader = document.getElementById('plan-loader'); const planOutput = document.getElementById('plan-output'); const planContentContainer = document.getElementById('plan-content-container'); const downloadPdfBtn = document.getElementById('downloadPdfBtn'); // --- INITIALIZATION --- const initialize = () => { renderFoodSelection(); updateNavButtons(); attachEventListeners(); }; // --- RENDER FUNCTIONS --- const renderFoodSelection = () => { foodSelectionContainer.innerHTML = Object.entries(FOOD_CATEGORIES).map(([category, foods]) => `${category}
${foods.map(food => `
${food}
`).join('')}
$1
') .replace(/### (.*?)\n/g, '$1
') .replace(/- (.*?)\n/g, '- $1
- /g, ''); // Merge consecutive lists
planContentContainer.innerHTML = html;
};
// --- 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 canvasWidth = canvas.width;
const canvasHeight = canvas.height;
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 -= (pdfHeight - 20);
while (heightLeft > 0) {
position = -heightLeft - 10;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= (pdfHeight - 20);
}
pdf.save('My-Anti-Inflammatory-Plan.pdf');
})
.catch(err => console.error("PDF Generation Error:", err));
};
// --- START THE APP ---
initialize();
});
