Add 2 files
Browse files- index.html +44 -47
- prompts.txt +2 -1
index.html
CHANGED
|
@@ -755,10 +755,9 @@
|
|
| 755 |
</div>
|
| 756 |
|
| 757 |
<script>
|
| 758 |
-
// API Configuration for
|
| 759 |
-
const
|
| 760 |
-
const
|
| 761 |
-
const API_URL = 'https://api.edamam.com/api/recipes/v2';
|
| 762 |
|
| 763 |
// Global variables
|
| 764 |
let currentMenu = [];
|
|
@@ -866,59 +865,57 @@
|
|
| 866 |
}
|
| 867 |
}
|
| 868 |
|
| 869 |
-
// Fetch healthy recipe from
|
| 870 |
async function fetchHealthyRecipe(mealType) {
|
| 871 |
-
const healthLabels = [
|
| 872 |
-
'low-sugar',
|
| 873 |
-
'low-fat-abs',
|
| 874 |
-
'sugar-conscious',
|
| 875 |
-
'low-potassium',
|
| 876 |
-
'kidney-friendly'
|
| 877 |
-
].join('&health=');
|
| 878 |
-
|
| 879 |
const maxCalories = mealType === 'breakfast' ? 400 : 600;
|
| 880 |
const minProtein = mealType === 'breakfast' ? 10 : 20;
|
| 881 |
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
|
|
|
|
|
|
| 892 |
});
|
| 893 |
|
| 894 |
try {
|
| 895 |
// Search for recipes
|
| 896 |
-
const
|
| 897 |
-
const
|
| 898 |
|
| 899 |
-
if (
|
| 900 |
console.warn(`No recipes found for ${mealType}`);
|
| 901 |
return null;
|
| 902 |
}
|
| 903 |
|
| 904 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 905 |
|
| 906 |
// Format recipe data for our app
|
| 907 |
return {
|
| 908 |
-
id: recipeData.
|
| 909 |
-
title: recipeData.
|
| 910 |
-
image: recipeData.image,
|
| 911 |
-
servings: recipeData.
|
| 912 |
-
sourceUrl: recipeData.
|
| 913 |
-
sourceName: '
|
| 914 |
-
ingredients: recipeData.
|
| 915 |
-
instructions: 'Ver instrucciones en el enlace original',
|
| 916 |
nutrition: {
|
| 917 |
-
calories: Math.round(recipeData.
|
| 918 |
-
protein: Math.round(recipeData.
|
| 919 |
-
carbs: Math.round(recipeData.
|
| 920 |
-
fat: Math.round(recipeData.
|
| 921 |
-
fiber: Math.round(recipeData.
|
| 922 |
}
|
| 923 |
};
|
| 924 |
} catch (error) {
|
|
@@ -930,9 +927,9 @@
|
|
| 930 |
// Add ingredients to shopping list
|
| 931 |
function addToShoppingList(ingredients) {
|
| 932 |
ingredients.forEach(ingredient => {
|
| 933 |
-
const name = ingredient.
|
| 934 |
-
const amount = ingredient.
|
| 935 |
-
const unit = ingredient.
|
| 936 |
|
| 937 |
if (shoppingList[name]) {
|
| 938 |
shoppingList[name].amount += amount;
|
|
@@ -940,7 +937,7 @@
|
|
| 940 |
shoppingList[name] = {
|
| 941 |
amount,
|
| 942 |
unit,
|
| 943 |
-
aisle: getIngredientAisle(ingredient.
|
| 944 |
};
|
| 945 |
}
|
| 946 |
});
|
|
@@ -1013,7 +1010,7 @@
|
|
| 1013 |
${recipe.ingredients.map(ing =>
|
| 1014 |
`<li class="ingredient-item">
|
| 1015 |
<i class="fas fa-check-circle ingredient-icon"></i>
|
| 1016 |
-
<span>${ing.
|
| 1017 |
</li>`
|
| 1018 |
).join('')}
|
| 1019 |
</ul>
|
|
@@ -1021,7 +1018,7 @@
|
|
| 1021 |
|
| 1022 |
<div class="instructions-section">
|
| 1023 |
<h4 class="instructions-title">Instrucciones:</h4>
|
| 1024 |
-
<p class="instructions-text">Para ver las instrucciones completas, visita el enlace original de la receta.</p>
|
| 1025 |
</div>
|
| 1026 |
|
| 1027 |
${recipe.sourceUrl ? `
|
|
@@ -1168,7 +1165,7 @@
|
|
| 1168 |
let csv = 'Día,Tipo,Receta,Calorías,Proteína (g),Carbohidratos (g),Grasas (g),Ingredientes,URL\n';
|
| 1169 |
|
| 1170 |
currentMenu.forEach(recipe => {
|
| 1171 |
-
const ingredients = recipe.ingredients.map(ing => ing.
|
| 1172 |
|
| 1173 |
csv += `"${recipe.day}","${recipe.mealType === 'breakfast' ? 'Desayuno' : 'Cena'}","${recipe.title}","${recipe.nutrition.calories}","${recipe.nutrition.protein}","${recipe.nutrition.carbs}","${recipe.nutrition.fat}","${ingredients}","${recipe.sourceUrl || ''}"\n`;
|
| 1174 |
});
|
|
|
|
| 755 |
</div>
|
| 756 |
|
| 757 |
<script>
|
| 758 |
+
// API Configuration for Spoonacular
|
| 759 |
+
const API_KEY = 'YOUR_SPOONACULAR_API_KEY'; // Reemplaza con tu API key de Spoonacular
|
| 760 |
+
const API_URL = 'https://api.spoonacular.com/recipes';
|
|
|
|
| 761 |
|
| 762 |
// Global variables
|
| 763 |
let currentMenu = [];
|
|
|
|
| 865 |
}
|
| 866 |
}
|
| 867 |
|
| 868 |
+
// Fetch healthy recipe from Spoonacular API
|
| 869 |
async function fetchHealthyRecipe(mealType) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 870 |
const maxCalories = mealType === 'breakfast' ? 400 : 600;
|
| 871 |
const minProtein = mealType === 'breakfast' ? 10 : 20;
|
| 872 |
|
| 873 |
+
// First search for recipes that match our criteria
|
| 874 |
+
const searchParams = new URLSearchParams({
|
| 875 |
+
apiKey: API_KEY,
|
| 876 |
+
type: mealType,
|
| 877 |
+
maxCalories: maxCalories,
|
| 878 |
+
minProtein: minProtein,
|
| 879 |
+
diet: 'vegetarian,gluten free', // Puedes ajustar según necesidades
|
| 880 |
+
intolerances: 'dairy,egg', // Puedes ajustar según necesidades
|
| 881 |
+
number: 1,
|
| 882 |
+
sort: 'random',
|
| 883 |
+
addRecipeInformation: true,
|
| 884 |
+
addRecipeNutrition: true
|
| 885 |
});
|
| 886 |
|
| 887 |
try {
|
| 888 |
// Search for recipes
|
| 889 |
+
const searchResponse = await fetch(`${API_URL}/complexSearch?${searchParams}`);
|
| 890 |
+
const searchData = await searchResponse.json();
|
| 891 |
|
| 892 |
+
if (searchData.results.length === 0) {
|
| 893 |
console.warn(`No recipes found for ${mealType}`);
|
| 894 |
return null;
|
| 895 |
}
|
| 896 |
|
| 897 |
+
const recipeId = searchData.results[0].id;
|
| 898 |
+
|
| 899 |
+
// Get detailed information about the recipe
|
| 900 |
+
const recipeResponse = await fetch(`${API_URL}/${recipeId}/information?apiKey=${API_KEY}&includeNutrition=true`);
|
| 901 |
+
const recipeData = await recipeResponse.json();
|
| 902 |
|
| 903 |
// Format recipe data for our app
|
| 904 |
return {
|
| 905 |
+
id: recipeData.id,
|
| 906 |
+
title: recipeData.title,
|
| 907 |
+
image: recipeData.image || 'https://spoonacular.com/recipeImages/' + recipeData.id + '-556x370.jpg',
|
| 908 |
+
servings: recipeData.servings || 2,
|
| 909 |
+
sourceUrl: recipeData.sourceUrl || recipeData.spoonacularSourceUrl,
|
| 910 |
+
sourceName: recipeData.sourceName || 'Spoonacular',
|
| 911 |
+
ingredients: recipeData.extendedIngredients || [],
|
| 912 |
+
instructions: recipeData.instructions || 'Ver instrucciones en el enlace original',
|
| 913 |
nutrition: {
|
| 914 |
+
calories: Math.round(recipeData.nutrition.nutrients.find(n => n.name === 'Calories').amount),
|
| 915 |
+
protein: Math.round(recipeData.nutrition.nutrients.find(n => n.name === 'Protein').amount),
|
| 916 |
+
carbs: Math.round(recipeData.nutrition.nutrients.find(n => n.name === 'Carbohydrates').amount),
|
| 917 |
+
fat: Math.round(recipeData.nutrition.nutrients.find(n => n.name === 'Fat').amount),
|
| 918 |
+
fiber: Math.round(recipeData.nutrition.nutrients.find(n => n.name === 'Fiber').amount)
|
| 919 |
}
|
| 920 |
};
|
| 921 |
} catch (error) {
|
|
|
|
| 927 |
// Add ingredients to shopping list
|
| 928 |
function addToShoppingList(ingredients) {
|
| 929 |
ingredients.forEach(ingredient => {
|
| 930 |
+
const name = ingredient.name.toLowerCase();
|
| 931 |
+
const amount = ingredient.amount;
|
| 932 |
+
const unit = ingredient.unit || 'unidad';
|
| 933 |
|
| 934 |
if (shoppingList[name]) {
|
| 935 |
shoppingList[name].amount += amount;
|
|
|
|
| 937 |
shoppingList[name] = {
|
| 938 |
amount,
|
| 939 |
unit,
|
| 940 |
+
aisle: getIngredientAisle(ingredient.name)
|
| 941 |
};
|
| 942 |
}
|
| 943 |
});
|
|
|
|
| 1010 |
${recipe.ingredients.map(ing =>
|
| 1011 |
`<li class="ingredient-item">
|
| 1012 |
<i class="fas fa-check-circle ingredient-icon"></i>
|
| 1013 |
+
<span>${ing.original || `${ing.amount} ${ing.unit} ${ing.name}`}</span>
|
| 1014 |
</li>`
|
| 1015 |
).join('')}
|
| 1016 |
</ul>
|
|
|
|
| 1018 |
|
| 1019 |
<div class="instructions-section">
|
| 1020 |
<h4 class="instructions-title">Instrucciones:</h4>
|
| 1021 |
+
<p class="instructions-text">${recipe.instructions || 'Para ver las instrucciones completas, visita el enlace original de la receta.'}</p>
|
| 1022 |
</div>
|
| 1023 |
|
| 1024 |
${recipe.sourceUrl ? `
|
|
|
|
| 1165 |
let csv = 'Día,Tipo,Receta,Calorías,Proteína (g),Carbohidratos (g),Grasas (g),Ingredientes,URL\n';
|
| 1166 |
|
| 1167 |
currentMenu.forEach(recipe => {
|
| 1168 |
+
const ingredients = recipe.ingredients.map(ing => ing.original || `${ing.amount} ${ing.unit} ${ing.name}`).join(' | ');
|
| 1169 |
|
| 1170 |
csv += `"${recipe.day}","${recipe.mealType === 'breakfast' ? 'Desayuno' : 'Cena'}","${recipe.title}","${recipe.nutrition.calories}","${recipe.nutrition.protein}","${recipe.nutrition.carbs}","${recipe.nutrition.fat}","${ingredients}","${recipe.sourceUrl || ''}"\n`;
|
| 1171 |
});
|
prompts.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
Una aplicacion html y javascript en local sin node y con flexbox, que pida recetas bajas en calorias para 30 dias (comida y cena) para personas de mas de 50 años, el menu tiene que ser equilibrado, además tiene que alimentarse de un api de recetas de internet. la aplicacion mostrará la receta, los ingredientes y si es posible de donde las ha sacado, cada comida indicará las calorias en una tabla. Además generará la lista de la compra y tendra un boton para exportarlo a pdf otro para csv y otro mas para generar un nuevo menu mensual. Si usas una api que sea gratuita.
|
| 2 |
puedes adaptarlo para usar el api de edamam.com y con mi api key edamam 1b8ad4ca
|
| 3 |
puedes hacerlo con flexbox y arreglar el siguiente error:
|
| 4 |
-
NO USES tailwind USA FLEXBOX
|
|
|
|
|
|
| 1 |
Una aplicacion html y javascript en local sin node y con flexbox, que pida recetas bajas en calorias para 30 dias (comida y cena) para personas de mas de 50 años, el menu tiene que ser equilibrado, además tiene que alimentarse de un api de recetas de internet. la aplicacion mostrará la receta, los ingredientes y si es posible de donde las ha sacado, cada comida indicará las calorias en una tabla. Además generará la lista de la compra y tendra un boton para exportarlo a pdf otro para csv y otro mas para generar un nuevo menu mensual. Si usas una api que sea gratuita.
|
| 2 |
puedes adaptarlo para usar el api de edamam.com y con mi api key edamam 1b8ad4ca
|
| 3 |
puedes hacerlo con flexbox y arreglar el siguiente error:
|
| 4 |
+
NO USES tailwind USA FLEXBOX
|
| 5 |
+
puedes adaptarla para usar spoonacular api?
|