recetas / index.html
note7's picture
Add 2 files
5ba2bdd verified
Raw History Blame Contribute Delete
47.1 kB
<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Menú Saludable para Mayores de 50</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> /* Reset y estilos base */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f5f5f5; color: #333; line-height: 1.6; } .container { width: 95%; max-width: 1200px; margin: 0 auto; padding: 20px 0; } /* Header */ .header { text-align: center; margin-bottom: 30px; } .header h1 { font-size: 2.5rem; color: #1a365d; margin-bottom: 10px; } .header h2 { font-size: 1.3rem; color: #4a5568; margin-bottom: 20px; } .header-line { width: 100%; height: 2px; background: linear-gradient(to right, #4299e1, #38b2ac); margin-top: 20px; border-radius: 2px; } /* Controles */ .controls { background-color: white; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); padding: 20px; margin-bottom: 30px; } .controls-container { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; } .filter-group { display: flex; flex-direction: column; } .filter-label { font-weight: 500; color: #4a5568; margin-bottom: 10px; } .filter-buttons { display: flex; gap: 10px; } .button { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer; font-weight: 500; transition: all 0.3s ease; } .button:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .button-all { background-color: #4299e1; color: white; } .button-all:hover { background-color: #3182ce; } .button-breakfast { background-color: #48bb78; color: white; } .button-breakfast:hover { background-color: #38a169; } .button-dinner { background-color: #9f7aea; color: white; } .button-dinner:hover { background-color: #805ad5; } .button-lunch { background-color: #ed8936; color: white; } .button-lunch:hover { background-color: #dd6b20; } .button-generate { background-color: #ed8936; color: white; } .button-generate:hover { background-color: #dd6b20; } .button-shopping { background-color: #667eea; color: white; } .button-shopping:hover { background-color: #5a67d8; } .button-pdf { background-color: #f56565; color: white; } .button-pdf:hover { background-color: #e53e3e; } .button-csv { background-color: #38a169; color: white; } .button-csv:hover { background-color: #2f855a; } /* Loading */ .loading { display: none; flex-direction: column; align-items: center; justify-content: center; padding: 30px; } .loading-spinner { border: 5px solid #f3f3f3; border-top: 5px solid #4299e1; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 20px auto; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .loading-text { color: #4a5568; margin-top: 15px; } /* Contenido principal */ .main-content { display: flex; flex-direction: column; } @media (min-width: 992px) { .main-content { flex-direction: row; } } /* Calendario */ .calendar { background-color: white; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); padding: 20px; margin-bottom: 20px; } @media (min-width: 992px) { .calendar { width: 30%; margin-right: 20px; position: sticky; top: 20px; align-self: flex-start; } } .calendar-title { font-size: 1.3rem; font-weight: 600; color: #2d3748; margin-bottom: 20px; } .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 15px; } .calendar-day-header { text-align: center; font-size: 0.8rem; font-weight: 500; color: #718096; } .calendar-day { text-align: center; padding: 8px; border-radius: 8px; border: 1px solid #e2e8f0; cursor: pointer; transition: all 0.3s ease; } .calendar-day:hover { background-color: #ebf8ff; } .calendar-day.selected { background-color: #4299e1; color: white; border-color: #4299e1; } /* Resumen nutricional */ .nutrition-summary { margin-top: 25px; } .nutrition-title { font-weight: 500; color: #4a5568; margin-bottom: 15px; } .nutrition-card { background-color: #ebf8ff; border-radius: 8px; padding: 15px; } .nutrition-item { display: flex; justify-content: space-between; margin-bottom: 10px; } .nutrition-label { color: #4a5568; } .nutrition-value { font-weight: 500; } /* Recetas */ .recipes-container { flex: 1; } .no-recipes { text-align: center; padding: 40px 20px; } .no-recipes-icon { font-size: 3rem; color: #e2e8f0; margin-bottom: 20px; } .no-recipes-title { font-size: 1.3rem; color: #718096; margin-bottom: 10px; } .no-recipes-text { color: #a0aec0; } .recipes-list { display: flex; flex-direction: column; gap: 20px; } .recipe-card { background-color: white; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); overflow: hidden; transition: all 0.3s ease; } .recipe-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1); } .recipe-content { display: flex; flex-direction: column; } @media (min-width: 768px) { .recipe-content { flex-direction: row; } } .recipe-image { width: 100%; height: 200px; object-fit: cover; } @media (min-width: 768px) { .recipe-image { width: 40%; height: auto; } } .recipe-details { padding: 20px; flex: 1; } .recipe-header { display: flex; flex-direction: column; margin-bottom: 20px; } @media (min-width: 768px) { .recipe-header { flex-direction: row; justify-content: space-between; align-items: flex-start; } } .recipe-tag { font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; margin-bottom: 10px; display: inline-block; } .recipe-title { font-size: 1.3rem; font-weight: 700; color: #2d3748; margin-bottom: 8px; } .recipe-servings { display: flex; align-items: center; gap: 5px; color: #718096; font-size: 0.9rem; margin-top: 10px; } @media (min-width: 768px) { .recipe-servings { margin-top: 0; } } .nutrition-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; } .nutrition-badge { padding: 6px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; display: flex; align-items: center; gap: 5px; } .ingredients-section { margin-bottom: 20px; } .ingredients-title { font-weight: 500; color: #4a5568; margin-bottom: 10px; } .ingredients-list { display: grid; grid-template-columns: 1fr; gap: 8px; font-size: 0.9rem; color: #4a5568; } @media (min-width: 480px) { .ingredients-list { grid-template-columns: repeat(2, 1fr); } } .ingredient-item { display: flex; align-items: flex-start; } .instructions-section { margin-bottom: 15px; } .instructions-title { font-weight: 500; color: #4a5568; margin-bottom: 10px; } .instructions-text { font-size: 0.9rem; color: #4a5568; white-space: pre-line; } .recipe-source { margin-top: 20px; font-size: 0.9rem; } .source-label { color: #718096; } .source-link { color: #4299e1; text-decoration: none; } .source-link:hover { color: #3182ce; text-decoration: underline; } /* Modal */ .modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: none; align-items: center; justify-content: center; z-index: 1000; } .modal-content { background-color: white; border-radius: 10px; width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto; padding: 20px; } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; } .modal-title { font-size: 1.3rem; font-weight: 600; color: #2d3748; } .close-modal { color: #718096; font-size: 1.5rem; cursor: pointer; background: none; border: none; } .shopping-empty { text-align: center; padding: 40px 20px; } .shopping-empty-icon { font-size: 3rem; color: #e2e8f0; margin-bottom: 20px; } .shopping-empty-text { color: #718096; } .aisle-section { margin-bottom: 25px; } .aisle-title { font-size: 1.1rem; font-weight: 500; color: #2d3748; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; } .shopping-list { display: flex; flex-direction: column; gap: 12px; } .shopping-item { display: flex; justify-content: space-between; align-items: center; background-color: #f8fafc; padding: 12px 16px; border-radius: 8px; } .item-name { font-weight: 500; } .item-quantity { color: #718096; } .modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; } /* Animaciones */ .fade-in { animation: fadeIn 0.5s ease-in; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } /* Clases de utilidad */ .hidden { display: none !important; } </style> </head> <body> <div class="container"> <!-- Header --> <header class="header"> <h1>Menú Saludable</h1> <h2>Plan de 30 días para mayores de 50 años</h2> <div class="header-line"></div> </header> <!-- Controls --> <div class="controls"> <div class="controls-container"> <div class="filter-group"> <span class="filter-label">Filtrar por:</span> <div class="filter-buttons"> <button id="filter-all" class="button button-all"> <i class="fas fa-list"></i> Todas </button> <button id="filter-breakfast" class="button button-breakfast"> <i class="fas fa-coffee"></i> Desayunos </button> <button id="filter-lunch" class="button button-lunch"> <i class="fas fa-utensils"></i> Comidas </button> <button id="filter-dinner" class="button button-dinner"> <i class="fas fa-moon"></i> Cenas </button> </div> </div> <div class="filter-buttons"> <button id="generate-menu" class="button button-generate"> <i class="fas fa-sync-alt"></i> Nuevo Menú </button> <button id="shopping-list" class="button button-shopping"> <i class="fas fa-shopping-basket"></i> Lista de Compra </button> </div> <div class="filter-buttons"> <button id="export-pdf" class="button button-pdf"> <i class="fas fa-file-pdf"></i> PDF </button> <button id="export-csv" class="button button-csv"> <i class="fas fa-file-csv"></i> CSV </button> </div> </div> </div> <!-- Loading State --> <div id="loading" class="loading hidden"> <div class="loading-spinner"></div> <p class="loading-text">Generando menú saludable...</p> </div> <!-- Main Content --> <div class="main-content"> <!-- Calendar View --> <div id="calendar-view" class="calendar"> <h3 class="calendar-title">Calendario del Menú</h3> <div class="calendar-grid"> <div class="calendar-day-header">L</div> <div class="calendar-day-header">M</div> <div class="calendar-day-header">X</div> <div class="calendar-day-header">J</div> <div class="calendar-day-header">V</div> <div class="calendar-day-header">S</div> <div class="calendar-day-header">D</div> </div> <div id="calendar-days" class="calendar-grid"> <!-- Calendar days will be populated here --> </div> <div class="nutrition-summary"> <h4 class="nutrition-title">Resumen Nutricional</h4> <div class="nutrition-card"> <div class="nutrition-item"> <span class="nutrition-label">Calorías promedio:</span> <span id="avg-calories" class="nutrition-value">-</span> </div> <div class="nutrition-item"> <span class="nutrition-label">Proteínas promedio:</span> <span id="avg-protein" class="nutrition-value">-</span> </div> <div class="nutrition-item"> <span class="nutrition-label">Balance nutricional:</span> <span id="nutrition-score" class="nutrition-value">-</span> </div> </div> </div> </div> <!-- Recipes List --> <div id="recipes-container" class="recipes-container"> <div id="no-recipes" class="no-recipes"> <i class="fas fa-utensils no-recipes-icon"></i> <h3 class="no-recipes-title">No hay recetas cargadas</h3> <p class="no-recipes-text">Haz clic en "Generar Menú" para comenzar</p> </div> <div id="recipes-list" class="recipes-list"> <!-- Recipe cards will be populated here --> </div> </div> </div> <!-- Shopping List Modal --> <div id="shopping-modal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h3 class="modal-title">Lista de la Compra</h3> <button id="close-shopping-modal" class="close-modal"> <i class="fas fa-times"></i> </button> </div> <div id="shopping-list-content"> <div class="shopping-empty"> <i class="fas fa-shopping-basket shopping-empty-icon"></i> <p class="shopping-empty-text">Genera un menú primero para ver la lista de compra</p> </div> </div> <div class="modal-footer"> <button id="print-shopping-list" class="button button-generate"> <i class="fas fa-print"></i> Imprimir </button> <button id="export-shopping-pdf" class="button button-pdf"> <i class="fas fa-file-pdf"></i> PDF </button> </div> </div> </div> </div> <script> // API Configuration for TheMealDB const API_URL = 'https://www.themealdb.com/api/json/v1/1/'; // Global variables let currentMenu = []; let shoppingList = {}; let selectedDay = null; // DOM Elements const recipesContainer = document.getElementById('recipes-container'); const recipesList = document.getElementById('recipes-list'); const noRecipes = document.getElementById('no-recipes'); const loading = document.getElementById('loading'); const generateMenuBtn = document.getElementById('generate-menu'); const shoppingListBtn = document.getElementById('shopping-list'); const exportPdfBtn = document.getElementById('export-pdf'); const exportCsvBtn = document.getElementById('export-csv'); const shoppingModal = document.getElementById('shopping-modal'); const closeShoppingModal = document.getElementById('close-shopping-modal'); const shoppingListContent = document.getElementById('shopping-list-content'); const printShoppingListBtn = document.getElementById('print-shopping-list'); const exportShoppingPdfBtn = document.getElementById('export-shopping-pdf'); const calendarDays = document.getElementById('calendar-days'); const filterAllBtn = document.getElementById('filter-all'); const filterBreakfastBtn = document.getElementById('filter-breakfast'); const filterLunchBtn = document.getElementById('filter-lunch'); const filterDinnerBtn = document.getElementById('filter-dinner'); const avgCalories = document.getElementById('avg-calories'); const avgProtein = document.getElementById('avg-protein'); const nutritionScore = document.getElementById('nutrition-score'); // Event Listeners generateMenuBtn.addEventListener('click', generateMonthlyMenu); shoppingListBtn.addEventListener('click', showShoppingList); exportPdfBtn.addEventListener('click', exportToPdf); exportCsvBtn.addEventListener('click', exportToCsv); closeShoppingModal.addEventListener('click', () => shoppingModal.style.display = 'none'); printShoppingListBtn.addEventListener('click', printShoppingList); exportShoppingPdfBtn.addEventListener('click', exportShoppingListToPdf); filterAllBtn.addEventListener('click', () => filterRecipes('all')); filterBreakfastBtn.addEventListener('click', () => filterRecipes('breakfast')); filterLunchBtn.addEventListener('click', () => filterRecipes('lunch')); filterDinnerBtn.addEventListener('click', () => filterRecipes('dinner')); // Initialize calendar function initializeCalendar() { calendarDays.innerHTML = ''; // Create 30 days (1 month) for (let i = 1; i <= 30; i++) { const dayElement = document.createElement('div'); dayElement.className = 'calendar-day'; dayElement.textContent = i; dayElement.dataset.day = i; dayElement.addEventListener('click', () => { // Remove highlight from all days document.querySelectorAll('.calendar-day').forEach(el => { el.classList.remove('selected'); }); // Highlight selected day dayElement.classList.add('selected'); selectedDay = i; // Filter recipes for this day filterRecipesByDay(i); }); calendarDays.appendChild(dayElement); } } // Generate monthly menu async function generateMonthlyMenu() { loading.style.display = 'flex'; noRecipes.classList.add('hidden'); recipesList.innerHTML = ''; try { currentMenu = []; shoppingList = {}; // Generate 30 days (10 breakfasts, 10 lunches and 10 dinners) for (let day = 1; day <= 30; day++) { let mealType; if (day <= 10) { mealType = 'breakfast'; } else if (day <= 20) { mealType = 'lunch'; } else { mealType = 'dinner'; } const recipe = await fetchHealthyRecipe(mealType); if (recipe) { currentMenu.push({ ...recipe, day, mealType }); // Add ingredients to shopping list addToShoppingList(recipe.ingredients); } } renderRecipes(currentMenu); updateNutritionSummary(); initializeCalendar(); } catch (error) { console.error('Error generating menu:', error); alert('Error al generar el menú. Por favor intenta nuevamente.'); } finally { loading.style.display = 'none'; } } // Fetch healthy recipe from TheMealDB API async function fetchHealthyRecipe(mealType) { try { let endpoint; // TheMealDB doesn't have meal types, so we'll use categories if (mealType === 'breakfast') { // For breakfast, we'll use "Breakfast" category or similar endpoint = 'filter.php?c=Breakfast'; } else if (mealType === 'lunch') { // For lunch, we'll use "Vegetarian" or "Chicken" categories endpoint = 'filter.php?c=Vegetarian'; } else { // For dinner, we'll use "Seafood" or "Pasta" categories endpoint = 'filter.php?c=Seafood'; } // First fetch a list of meals const listResponse = await fetch(`${API_URL}${endpoint}`); const listData = await listResponse.json(); if (!listData.meals || listData.meals.length === 0) { console.warn(`No recipes found for ${mealType}`); return null; } // Select a random meal from the list const randomIndex = Math.floor(Math.random() * listData.meals.length); const mealId = listData.meals[randomIndex].idMeal; // Then fetch the full details of that meal const detailResponse = await fetch(`${API_URL}lookup.php?i=${mealId}`); const detailData = await detailResponse.json(); if (!detailData.meals || detailData.meals.length === 0) { return null; } const meal = detailData.meals[0]; // Extract ingredients and measures const ingredients = []; for (let i = 1; i <= 20; i++) { const ingredient = meal[`strIngredient${i}`]; const measure = meal[`strMeasure${i}`]; if (ingredient && ingredient.trim() !== '') { ingredients.push({ food: ingredient, measure: measure || '', text: `${measure || ''} ${ingredient}`.trim() }); } } // Estimate nutrition (TheMealDB doesn't provide nutrition info) // We'll use some averages based on meal type let calories, protein; if (mealType === 'breakfast') { calories = 300 + Math.floor(Math.random() * 200); // 300-500 kcal protein = 10 + Math.floor(Math.random() * 10); // 10-20g } else if (mealType === 'lunch') { calories = 500 + Math.floor(Math.random() * 300); // 500-800 kcal protein = 20 + Math.floor(Math.random() * 15); // 20-35g } else { calories = 400 + Math.floor(Math.random() * 300); // 400-700 kcal protein = 15 + Math.floor(Math.random() * 15); // 15-30g } return { id: meal.idMeal, title: meal.strMeal, image: meal.strMealThumb || 'https://via.placeholder.com/400x300?text=Imagen+no+disponible', servings: 2, // Default to 2 servings sourceUrl: meal.strSource || meal.strYoutube || '#', sourceName: meal.strArea || 'TheMealDB', ingredients: ingredients, instructions: meal.strInstructions || 'Ver instrucciones en el enlace original', nutrition: { calories: calories, protein: protein, carbs: Math.round(calories * 0.4 / 4), // 40% carbs fat: Math.round(calories * 0.3 / 9), // 30% fat fiber: 5 + Math.floor(Math.random() * 10) // 5-15g fiber } }; } catch (error) { console.error('Error fetching recipe:', error); return null; } } // Add ingredients to shopping list function addToShoppingList(ingredients) { ingredients.forEach(ingredient => { const name = ingredient.food.toLowerCase(); const amount = 1; // Default to 1 unit since we don't have precise measures const unit = ingredient.measure || 'unidad'; if (shoppingList[name]) { shoppingList[name].amount += amount; } else { shoppingList[name] = { amount, unit, aisle: getIngredientAisle(ingredient.food) }; } }); } // Simple function to categorize ingredients into aisles function getIngredientAisle(ingredientName) { const name = ingredientName.toLowerCase(); if (name.includes('leche') || name.includes('yogur') || name.includes('queso')) return 'Lácteos'; if (name.includes('pollo') || name.includes('carne') || name.includes('pescado') || name.includes('huevo')) return 'Carnicería/Pescadería'; if (name.includes('pan') || name.includes('arroz') || name.includes('pasta') || name.includes('harina')) return 'Panadería/Cereales'; if (name.includes('manzana') || name.includes('plátano') || name.includes('naranja') || name.includes('fruta')) return 'Frutas'; if (name.includes('zanahoria') || name.includes('cebolla') || name.includes('tomate') || name.includes('verdura')) return 'Verduras'; if (name.includes('aceite') || name.includes('vinagre') || name.includes('especia')) return 'Aceites/Especias'; return 'Otros'; } // Render recipes function renderRecipes(recipes) { if (recipes.length === 0) { noRecipes.classList.remove('hidden'); return; } recipesList.innerHTML = ''; recipes.forEach(recipe => { const recipeCard = document.createElement('div'); recipeCard.className = 'recipe-card fade-in'; recipeCard.dataset.day = recipe.day; recipeCard.dataset.mealType = recipe.mealType; // Determine tag color based on meal type let tagClass, mealName; if (recipe.mealType === 'breakfast') { tagClass = 'bg-green-100 text-green-800'; mealName = 'Desayuno'; } else if (recipe.mealType === 'lunch') { tagClass = 'bg-orange-100 text-orange-800'; mealName = 'Comida'; } else { tagClass = 'bg-purple-100 text-purple-800'; mealName = 'Cena'; } recipeCard.innerHTML = ` <div class="recipe-content"> <img class="recipe-image" src="${recipe.image}" alt="${recipe.title}" onerror="this.src='https://via.placeholder.com/400x300?text=Imagen+no+disponible'"> <div class="recipe-details"> <div class="recipe-header"> <div> <span class="recipe-tag ${tagClass}">${mealName} - Día ${recipe.day}</span> <h3 class="recipe-title">${recipe.title}</h3> </div> <div class="recipe-servings"> <span>${recipe.servings} porciones</span> <i class="fas fa-utensils"></i> </div> </div> <div class="nutrition-badges"> <div class="nutrition-badge ${recipe.mealType === 'breakfast' ? 'bg-red-100 text-red-800' : 'bg-red-200 text-red-900'}"> <i class="fas fa-fire"></i> ${recipe.nutrition.calories} kcal </div> <div class="nutrition-badge bg-blue-100 text-blue-800"> <i class="fas fa-dumbbell"></i> ${recipe.nutrition.protein}g proteína </div> <div class="nutrition-badge bg-yellow-100 text-yellow-800"> <i class="fas fa-bread-slice"></i> ${recipe.nutrition.carbs}g carbos </div> <div class="nutrition-badge bg-pink-100 text-pink-800"> <i class="fas fa-oil-can"></i> ${recipe.nutrition.fat}g grasas </div> </div> <div class="ingredients-section"> <h4 class="ingredients-title">Ingredientes (${recipe.servings} porciones):</h4> <ul class="ingredients-list"> ${recipe.ingredients.map(ing => `<li class="ingredient-item"> <i class="fas fa-check-circle"></i> <span>${ing.text || `${ing.quantity || 1} ${ing.measure || 'unidad'} ${ing.food}`}</span> </li>` ).join('')} </ul> </div> <div class="instructions-section"> <h4 class="instructions-title">Instrucciones:</h4> <p class="instructions-text">${recipe.instructions || 'Para ver las instrucciones completas, visita el enlace original de la receta.'}</p> </div> ${recipe.sourceUrl ? ` <div class="recipe-source"> <span class="source-label">Fuente: </span> <a href="${recipe.sourceUrl}" target="_blank" class="source-link"> ${recipe.sourceName || 'Ver receta original'} </a> </div> ` : ''} </div> </div> `; recipesList.appendChild(recipeCard); }); } // Filter recipes by type function filterRecipes(type) { const allRecipes = document.querySelectorAll('.recipe-card'); allRecipes.forEach(recipe => { recipe.style.display = 'none'; if (type === 'all' || (type === 'breakfast' && recipe.dataset.mealType === 'breakfast') || (type === 'lunch' && recipe.dataset.mealType === 'lunch') || (type === 'dinner' && recipe.dataset.mealType === 'dinner')) { recipe.style.display = 'block'; } }); } // Filter recipes by day function filterRecipesByDay(day) { const allRecipes = document.querySelectorAll('.recipe-card'); allRecipes.forEach(recipe => { recipe.style.display = recipe.dataset.day == day ? 'block' : 'none'; }); } // Show shopping list modal function showShoppingList() { if (Object.keys(shoppingList).length === 0) { shoppingListContent.innerHTML = ` <div class="shopping-empty"> <i class="fas fa-shopping-basket shopping-empty-icon"></i> <p class="shopping-empty-text">Genera un menú primero para ver la lista de compra</p> </div> `; } else { // Group by aisle const aisles = {}; Object.entries(shoppingList).forEach(([name, data]) => { const aisle = data.aisle || 'Otros'; if (!aisles[aisle]) { aisles[aisle] = []; } aisles[aisle].push({ name: capitalizeFirstLetter(name), amount: data.amount, unit: data.unit }); }); // Sort aisles alphabetically const sortedAisles = Object.keys(aisles).sort(); // Generate HTML let html = ''; sortedAisles.forEach(aisle => { html += ` <div class="aisle-section"> <h4 class="aisle-title"> <i class="fas fa-store-alt"></i>${aisle} </h4> <ul class="shopping-list"> ${aisles[aisle].map(item => ` <li class="shopping-item"> <span class="item-name">${item.name}</span> <span class="item-quantity">${Math.round(item.amount * 10) / 10} ${item.unit}</span> </li> `).join('')} </ul> </div> `; }); shoppingListContent.innerHTML = html; } shoppingModal.style.display = 'flex'; } // Helper function to capitalize first letter function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } // Print shopping list function printShoppingList() { const printContent = shoppingListContent.innerHTML; const originalContent = document.body.innerHTML; document.body.innerHTML = ` <div style="padding: 40px; font-family: sans-serif;"> <h1 style="font-size: 1.8rem; font-weight: bold; text-align: center; margin-bottom: 30px; color: #333;"> Lista de la Compra </h1> ${printContent} <div style="margin-top: 40px; text-align: center; font-size: 0.9rem; color: #666;"> Generado por Menú Saludable para Mayores de 50 </div> </div> `; window.print(); document.body.innerHTML = originalContent; renderRecipes(currentMenu); } // Export to PDF function exportToPdf() { if (currentMenu.length === 0) { alert('No hay menú para exportar. Genera un menú primero.'); return; } alert('La exportación a PDF requiere la biblioteca jsPDF. Esta función está deshabilitada en esta versión.'); } // Export to CSV function exportToCsv() { if (currentMenu.length === 0) { alert('No hay menú para exportar. Genera un menú primero.'); return; } let csv = 'Día,Tipo,Receta,Calorías,Proteína (g),Carbohidratos (g),Grasas (g),Ingredientes,URL\n'; currentMenu.forEach(recipe => { const mealType = recipe.mealType === 'breakfast' ? 'Desayuno' : recipe.mealType === 'lunch' ? 'Comida' : 'Cena'; const ingredients = recipe.ingredients.map(ing => ing.text || `${ing.quantity || 1} ${ing.measure || 'unidad'} ${ing.food}`).join(' | '); csv += `"${recipe.day}","${mealType}","${recipe.title}","${recipe.nutrition.calories}","${recipe.nutrition.protein}","${recipe.nutrition.carbs}","${recipe.nutrition.fat}","${ingredients}","${recipe.sourceUrl || ''}"\n`; }); // Create download link const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.setAttribute('href', url); link.setAttribute('download', 'menu-saludable-30-dias.csv'); link.style.visibility = 'hidden'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } // Export shopping list to PDF function exportShoppingListToPdf() { if (Object.keys(shoppingList).length === 0) { alert('No hay lista de compra para exportar. Genera un menú primero.'); return; } alert('La exportación a PDF requiere la biblioteca jsPDF. Esta función está deshabilitada en esta versión.'); } // Update nutrition summary function updateNutritionSummary() { if (currentMenu.length === 0) { avgCalories.textContent = '-'; avgProtein.textContent = '-'; nutritionScore.textContent = '-'; return; } let totalCalories = 0; let totalProtein = 0; let totalCarbs = 0; let totalFat = 0; currentMenu.forEach(recipe => { totalCalories += recipe.nutrition.calories; totalProtein += recipe.nutrition.protein; totalCarbs += recipe.nutrition.carbs; totalFat += recipe.nutrition.fat; }); const avgCal = Math.round(totalCalories / currentMenu.length); const avgProt = Math.round(totalProtein / currentMenu.length); avgCalories.textContent = `${avgCal} kcal`; avgProtein.textContent = `${avgProt} g`; // Simple nutrition score const proteinPercentage = (totalProtein * 4) / totalCalories * 100; const carbsPercentage = (totalCarbs * 4) / totalCalories * 100; const fatPercentage = (totalFat * 9) / totalCalories * 100; let score = 'Buena'; if (proteinPercentage < 15 || proteinPercentage > 35) score = 'Regular'; if (carbsPercentage < 45 || carbsPercentage > 65) score = 'Regular'; if (fatPercentage < 20 || fatPercentage > 35) score = 'Regular'; if ((proteinPercentage < 10 || proteinPercentage > 40) || (carbsPercentage < 40 || carbsPercentage > 70) || (fatPercentage < 15 || fatPercentage > 40)) { score = 'Mejorable'; } nutritionScore.textContent = score; } // Initialize initializeCalendar(); </script> <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=note7/recetas" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Menú Saludable para Mayores de 50</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Reset y estilos base */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
color: #333;
line-height: 1.6;
}
.container {
width: 95%;
max-width: 1200px;
margin: 0 auto;
padding: 20px 0;
}
/* Header */
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
font-size: 2.5rem;
color: #1a365d;
margin-bottom: 10px;
}
.header h2 {
font-size: 1.3rem;
color: #4a5568;
margin-bottom: 20px;
}
.header-line {
width: 100%;
height: 2px;
background: linear-gradient(to right, #4299e1, #38b2ac);
margin-top: 20px;
border-radius: 2px;
}
/* Controles */
.controls {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
margin-bottom: 30px;
}
.controls-container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: 20px;
}
.filter-group {
display: flex;
flex-direction: column;
}
.filter-label {
font-weight: 500;
color: #4a5568;
margin-bottom: 10px;
}
.filter-buttons {
display: flex;
gap: 10px;
}
.button {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
border-radius: 8px;
border: none;
cursor: pointer;
font-weight: 500;
transition: all 0.3s ease;
}