Add 2 files
Browse files- index.html +107 -123
- prompts.txt +2 -1
index.html
CHANGED
|
@@ -159,11 +159,10 @@
|
|
| 159 |
</div>
|
| 160 |
|
| 161 |
<script>
|
| 162 |
-
// API Configuration
|
| 163 |
-
const
|
| 164 |
-
const
|
| 165 |
-
const
|
| 166 |
-
const NUTRITION_INFO_URL = 'https://api.spoonacular.com/recipes/{id}/nutritionWidget.json';
|
| 167 |
|
| 168 |
// Global variables
|
| 169 |
let currentMenu = [];
|
|
@@ -255,7 +254,7 @@
|
|
| 255 |
});
|
| 256 |
|
| 257 |
// Add ingredients to shopping list
|
| 258 |
-
addToShoppingList(recipe.
|
| 259 |
}
|
| 260 |
}
|
| 261 |
|
|
@@ -270,61 +269,59 @@
|
|
| 270 |
}
|
| 271 |
}
|
| 272 |
|
| 273 |
-
// Fetch healthy recipe from API
|
| 274 |
async function fetchHealthyRecipe(mealType) {
|
| 275 |
-
const
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
const maxCalories = mealType === 'breakfast' ? 400 : 600;
|
| 278 |
const minProtein = mealType === 'breakfast' ? 10 : 20;
|
| 279 |
|
| 280 |
const params = new URLSearchParams({
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
sort: 'healthiness',
|
| 291 |
-
type: mealType
|
| 292 |
});
|
| 293 |
|
| 294 |
try {
|
| 295 |
-
//
|
| 296 |
-
const
|
| 297 |
-
|
|
|
|
| 298 |
console.warn(`No recipes found for ${mealType}`);
|
| 299 |
return null;
|
| 300 |
}
|
| 301 |
|
| 302 |
-
const
|
| 303 |
-
|
| 304 |
-
// Then get detailed information
|
| 305 |
-
const infoResponse = await axios.get(
|
| 306 |
-
RECIPE_INFO_URL.replace('{id}', recipeId),
|
| 307 |
-
{ params: { apiKey: API_KEY } }
|
| 308 |
-
);
|
| 309 |
|
| 310 |
-
//
|
| 311 |
-
const nutritionResponse = await axios.get(
|
| 312 |
-
NUTRITION_INFO_URL.replace('{id}', recipeId),
|
| 313 |
-
{ params: { apiKey: API_KEY } }
|
| 314 |
-
);
|
| 315 |
-
|
| 316 |
-
// Combine all data
|
| 317 |
return {
|
| 318 |
-
id:
|
| 319 |
-
title:
|
| 320 |
-
image:
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
};
|
| 329 |
} catch (error) {
|
| 330 |
console.error('Error fetching recipe:', error);
|
|
@@ -335,9 +332,9 @@
|
|
| 335 |
// Add ingredients to shopping list
|
| 336 |
function addToShoppingList(ingredients) {
|
| 337 |
ingredients.forEach(ingredient => {
|
| 338 |
-
const name = ingredient.
|
| 339 |
-
const amount = ingredient.
|
| 340 |
-
const unit = ingredient.
|
| 341 |
|
| 342 |
if (shoppingList[name]) {
|
| 343 |
shoppingList[name].amount += amount;
|
|
@@ -345,12 +342,26 @@
|
|
| 345 |
shoppingList[name] = {
|
| 346 |
amount,
|
| 347 |
unit,
|
| 348 |
-
aisle: ingredient.
|
| 349 |
};
|
| 350 |
}
|
| 351 |
});
|
| 352 |
}
|
| 353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
// Render recipes
|
| 355 |
function renderRecipes(recipes) {
|
| 356 |
if (recipes.length === 0) {
|
|
@@ -366,12 +377,6 @@
|
|
| 366 |
recipeCard.dataset.day = recipe.day;
|
| 367 |
recipeCard.dataset.mealType = recipe.mealType;
|
| 368 |
|
| 369 |
-
// Nutrition badges
|
| 370 |
-
const calories = Math.round(recipe.nutrition.calories.replace(/[^\d.]/g, ''));
|
| 371 |
-
const protein = Math.round(recipe.nutrition.protein.replace(/[^\d.]/g, ''));
|
| 372 |
-
const carbs = Math.round(recipe.nutrition.carbs.replace(/[^\d.]/g, ''));
|
| 373 |
-
const fat = Math.round(recipe.nutrition.fat.replace(/[^\d.]/g, ''));
|
| 374 |
-
|
| 375 |
recipeCard.innerHTML = `
|
| 376 |
<div class="md:flex">
|
| 377 |
<div class="md:w-1/3">
|
|
@@ -387,33 +392,33 @@
|
|
| 387 |
<h3 class="text-xl font-bold text-gray-800 mb-2">${recipe.title}</h3>
|
| 388 |
</div>
|
| 389 |
<div class="flex items-center gap-1">
|
| 390 |
-
<span class="text-xs text-gray-500">${recipe.
|
| 391 |
-
<i class="fas fa-
|
| 392 |
</div>
|
| 393 |
</div>
|
| 394 |
|
| 395 |
<div class="flex flex-wrap gap-2 my-3">
|
| 396 |
<div class="nutrition-badge bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 397 |
-
<i class="fas fa-fire"></i> ${calories} kcal
|
| 398 |
</div>
|
| 399 |
<div class="nutrition-badge bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 400 |
-
<i class="fas fa-dumbbell"></i> ${protein}g proteína
|
| 401 |
</div>
|
| 402 |
<div class="nutrition-badge bg-yellow-100 text-yellow-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 403 |
-
<i class="fas fa-bread-slice"></i> ${carbs}g carbos
|
| 404 |
</div>
|
| 405 |
<div class="nutrition-badge bg-orange-100 text-orange-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 406 |
-
<i class="fas fa-oil-can"></i> ${fat}g grasas
|
| 407 |
</div>
|
| 408 |
</div>
|
| 409 |
|
| 410 |
<div class="mb-4">
|
| 411 |
<h4 class="font-medium text-gray-700 mb-2">Ingredientes (${recipe.servings} porciones):</h4>
|
| 412 |
<ul class="grid grid-cols-1 sm:grid-cols-2 gap-1 text-sm text-gray-600">
|
| 413 |
-
${recipe.
|
| 414 |
`<li class="flex items-start">
|
| 415 |
<i class="fas fa-check-circle text-green-400 mt-1 mr-2 text-xs"></i>
|
| 416 |
-
<span>${ing.
|
| 417 |
</li>`
|
| 418 |
).join('')}
|
| 419 |
</ul>
|
|
@@ -421,7 +426,9 @@
|
|
| 421 |
|
| 422 |
<div class="mb-4">
|
| 423 |
<h4 class="font-medium text-gray-700 mb-2">Instrucciones:</h4>
|
| 424 |
-
<div class="text-sm text-gray-600">
|
|
|
|
|
|
|
| 425 |
</div>
|
| 426 |
|
| 427 |
${recipe.sourceUrl ? `
|
|
@@ -440,20 +447,6 @@
|
|
| 440 |
});
|
| 441 |
}
|
| 442 |
|
| 443 |
-
// Format recipe instructions
|
| 444 |
-
function formatInstructions(instructions) {
|
| 445 |
-
if (!instructions) return 'No hay instrucciones disponibles.';
|
| 446 |
-
|
| 447 |
-
// Remove HTML tags
|
| 448 |
-
let text = instructions.replace(/<[^>]*>/g, '');
|
| 449 |
-
|
| 450 |
-
// Split into paragraphs
|
| 451 |
-
const paragraphs = text.split(/\r?\n/).filter(p => p.trim().length > 0);
|
| 452 |
-
|
| 453 |
-
// Format each paragraph
|
| 454 |
-
return paragraphs.map(p => `<p class="mb-2">${p}</p>`).join('');
|
| 455 |
-
}
|
| 456 |
-
|
| 457 |
// Filter recipes by type
|
| 458 |
function filterRecipes(type) {
|
| 459 |
const allRecipes = document.querySelectorAll('.recipe-card');
|
|
@@ -499,7 +492,7 @@
|
|
| 499 |
}
|
| 500 |
|
| 501 |
aisles[aisle].push({
|
| 502 |
-
name,
|
| 503 |
amount: data.amount,
|
| 504 |
unit: data.unit
|
| 505 |
});
|
|
@@ -535,6 +528,11 @@
|
|
| 535 |
shoppingModal.classList.remove('hidden');
|
| 536 |
}
|
| 537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
// Print shopping list
|
| 539 |
function printShoppingList() {
|
| 540 |
const printContent = shoppingListContent.innerHTML;
|
|
@@ -601,12 +599,7 @@
|
|
| 601 |
doc.setFontSize(10);
|
| 602 |
doc.setTextColor(0, 0, 0);
|
| 603 |
|
| 604 |
-
|
| 605 |
-
const protein = recipe.nutrition.protein.replace(/[^\d.]/g, '');
|
| 606 |
-
const carbs = recipe.nutrition.carbs.replace(/[^\d.]/g, '');
|
| 607 |
-
const fat = recipe.nutrition.fat.replace(/[^\d.]/g, '');
|
| 608 |
-
|
| 609 |
-
doc.text(`Nutrición por porción: ${calories} kcal | ${protein}g proteína | ${carbs}g carbohidratos | ${fat}g grasas`, 20, y);
|
| 610 |
y += 8;
|
| 611 |
|
| 612 |
// Ingredients
|
|
@@ -616,41 +609,38 @@
|
|
| 616 |
y += 6;
|
| 617 |
|
| 618 |
doc.setFontSize(10);
|
| 619 |
-
recipe.
|
| 620 |
if (y > 270) {
|
| 621 |
doc.addPage();
|
| 622 |
y = 20;
|
| 623 |
page++;
|
| 624 |
}
|
| 625 |
|
| 626 |
-
doc.text(`- ${ing.
|
| 627 |
y += 6;
|
| 628 |
});
|
| 629 |
|
| 630 |
y += 6;
|
| 631 |
|
| 632 |
// Instructions
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
y = 20;
|
| 647 |
-
page++;
|
| 648 |
-
}
|
| 649 |
-
|
| 650 |
-
doc.text(line, 25, y);
|
| 651 |
-
y += 6;
|
| 652 |
-
});
|
| 653 |
-
}
|
| 654 |
|
| 655 |
y += 10;
|
| 656 |
|
|
@@ -674,18 +664,12 @@
|
|
| 674 |
return;
|
| 675 |
}
|
| 676 |
|
| 677 |
-
let csv = 'Día,Tipo,Receta,Calorías,Proteína (g),Carbohidratos (g),Grasas (g),Ingredientes,
|
| 678 |
|
| 679 |
currentMenu.forEach(recipe => {
|
| 680 |
-
const
|
| 681 |
-
const protein = recipe.nutrition.protein.replace(/[^\d.]/g, '');
|
| 682 |
-
const carbs = recipe.nutrition.carbs.replace(/[^\d.]/g, '');
|
| 683 |
-
const fat = recipe.nutrition.fat.replace(/[^\d.]/g, '');
|
| 684 |
-
|
| 685 |
-
const ingredients = recipe.extendedIngredients.map(ing => ing.original).join(' | ');
|
| 686 |
-
const instructions = recipe.instructions ? recipe.instructions.replace(/<[^>]*>/g, '').replace(/"/g, '""').replace(/\n/g, ' ') : '';
|
| 687 |
|
| 688 |
-
csv += `"${recipe.day}","${recipe.mealType === 'breakfast' ? 'Desayuno' : 'Cena'}","${recipe.title}","${calories}","${protein}","${carbs}","${fat}","${ingredients}","${
|
| 689 |
});
|
| 690 |
|
| 691 |
// Create download link
|
|
@@ -735,7 +719,7 @@
|
|
| 735 |
}
|
| 736 |
|
| 737 |
aisles[aisle].push({
|
| 738 |
-
name,
|
| 739 |
amount: data.amount,
|
| 740 |
unit: data.unit
|
| 741 |
});
|
|
@@ -799,10 +783,10 @@
|
|
| 799 |
let totalFat = 0;
|
| 800 |
|
| 801 |
currentMenu.forEach(recipe => {
|
| 802 |
-
totalCalories +=
|
| 803 |
-
totalProtein +=
|
| 804 |
-
totalCarbs +=
|
| 805 |
-
totalFat +=
|
| 806 |
});
|
| 807 |
|
| 808 |
const avgCal = Math.round(totalCalories / currentMenu.length);
|
|
|
|
| 159 |
</div>
|
| 160 |
|
| 161 |
<script>
|
| 162 |
+
// API Configuration for Edamam
|
| 163 |
+
const APP_ID = '1b8ad4ca'; // Your Edamam app ID
|
| 164 |
+
const APP_KEY = 'd3b5e2a1c6e5b8a1f5e9c7a8b3d4e5f'; // Your Edamam API key
|
| 165 |
+
const API_URL = 'https://api.edamam.com/api/recipes/v2';
|
|
|
|
| 166 |
|
| 167 |
// Global variables
|
| 168 |
let currentMenu = [];
|
|
|
|
| 254 |
});
|
| 255 |
|
| 256 |
// Add ingredients to shopping list
|
| 257 |
+
addToShoppingList(recipe.ingredients);
|
| 258 |
}
|
| 259 |
}
|
| 260 |
|
|
|
|
| 269 |
}
|
| 270 |
}
|
| 271 |
|
| 272 |
+
// Fetch healthy recipe from Edamam API
|
| 273 |
async function fetchHealthyRecipe(mealType) {
|
| 274 |
+
const healthLabels = [
|
| 275 |
+
'low-sugar',
|
| 276 |
+
'low-fat-abs',
|
| 277 |
+
'sugar-conscious',
|
| 278 |
+
'low-potassium',
|
| 279 |
+
'kidney-friendly'
|
| 280 |
+
].join('&health=');
|
| 281 |
+
|
| 282 |
const maxCalories = mealType === 'breakfast' ? 400 : 600;
|
| 283 |
const minProtein = mealType === 'breakfast' ? 10 : 20;
|
| 284 |
|
| 285 |
const params = new URLSearchParams({
|
| 286 |
+
type: 'public',
|
| 287 |
+
app_id: APP_ID,
|
| 288 |
+
app_key: APP_KEY,
|
| 289 |
+
diet: 'balanced',
|
| 290 |
+
health: healthLabels,
|
| 291 |
+
calories: `0-${maxCalories}`,
|
| 292 |
+
nutrient: `PROCNT.min=${minProtein}`,
|
| 293 |
+
random: 'true',
|
| 294 |
+
field: ['uri', 'label', 'image', 'url', 'yield', 'ingredients', 'totalNutrients', 'totalDaily', 'digest'].join(',')
|
|
|
|
|
|
|
| 295 |
});
|
| 296 |
|
| 297 |
try {
|
| 298 |
+
// Search for recipes
|
| 299 |
+
const response = await axios.get(`${API_URL}?${params}`);
|
| 300 |
+
|
| 301 |
+
if (response.data.hits.length === 0) {
|
| 302 |
console.warn(`No recipes found for ${mealType}`);
|
| 303 |
return null;
|
| 304 |
}
|
| 305 |
|
| 306 |
+
const recipeData = response.data.hits[0].recipe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
+
// Format recipe data for our app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
return {
|
| 310 |
+
id: recipeData.uri.split('#')[1], // Extract ID from URI
|
| 311 |
+
title: recipeData.label,
|
| 312 |
+
image: recipeData.image,
|
| 313 |
+
servings: recipeData.yield,
|
| 314 |
+
sourceUrl: recipeData.url,
|
| 315 |
+
sourceName: 'Edamam',
|
| 316 |
+
ingredients: recipeData.ingredients,
|
| 317 |
+
instructions: 'Ver instrucciones en el enlace original',
|
| 318 |
+
nutrition: {
|
| 319 |
+
calories: Math.round(recipeData.calories / recipeData.yield),
|
| 320 |
+
protein: Math.round(recipeData.totalNutrients.PROCNT.quantity / recipeData.yield),
|
| 321 |
+
carbs: Math.round(recipeData.totalNutrients.CHOCDF.quantity / recipeData.yield),
|
| 322 |
+
fat: Math.round(recipeData.totalNutrients.FAT.quantity / recipeData.yield),
|
| 323 |
+
fiber: Math.round(recipeData.totalNutrients.FIBTG.quantity / recipeData.yield)
|
| 324 |
+
}
|
| 325 |
};
|
| 326 |
} catch (error) {
|
| 327 |
console.error('Error fetching recipe:', error);
|
|
|
|
| 332 |
// Add ingredients to shopping list
|
| 333 |
function addToShoppingList(ingredients) {
|
| 334 |
ingredients.forEach(ingredient => {
|
| 335 |
+
const name = ingredient.food.toLowerCase();
|
| 336 |
+
const amount = ingredient.quantity;
|
| 337 |
+
const unit = ingredient.measure || 'unidad';
|
| 338 |
|
| 339 |
if (shoppingList[name]) {
|
| 340 |
shoppingList[name].amount += amount;
|
|
|
|
| 342 |
shoppingList[name] = {
|
| 343 |
amount,
|
| 344 |
unit,
|
| 345 |
+
aisle: getIngredientAisle(ingredient.food)
|
| 346 |
};
|
| 347 |
}
|
| 348 |
});
|
| 349 |
}
|
| 350 |
|
| 351 |
+
// Simple function to categorize ingredients into aisles
|
| 352 |
+
function getIngredientAisle(ingredientName) {
|
| 353 |
+
const name = ingredientName.toLowerCase();
|
| 354 |
+
|
| 355 |
+
if (name.includes('leche') || name.includes('yogur') || name.includes('queso')) return 'Lácteos';
|
| 356 |
+
if (name.includes('pollo') || name.includes('carne') || name.includes('pescado') || name.includes('huevo')) return 'Carnicería/Pescadería';
|
| 357 |
+
if (name.includes('pan') || name.includes('arroz') || name.includes('pasta') || name.includes('harina')) return 'Panadería/Cereales';
|
| 358 |
+
if (name.includes('manzana') || name.includes('plátano') || name.includes('naranja') || name.includes('fruta')) return 'Frutas';
|
| 359 |
+
if (name.includes('zanahoria') || name.includes('cebolla') || name.includes('tomate') || name.includes('verdura')) return 'Verduras';
|
| 360 |
+
if (name.includes('aceite') || name.includes('vinagre') || name.includes('especia')) return 'Aceites/Especias';
|
| 361 |
+
|
| 362 |
+
return 'Otros';
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
// Render recipes
|
| 366 |
function renderRecipes(recipes) {
|
| 367 |
if (recipes.length === 0) {
|
|
|
|
| 377 |
recipeCard.dataset.day = recipe.day;
|
| 378 |
recipeCard.dataset.mealType = recipe.mealType;
|
| 379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
recipeCard.innerHTML = `
|
| 381 |
<div class="md:flex">
|
| 382 |
<div class="md:w-1/3">
|
|
|
|
| 392 |
<h3 class="text-xl font-bold text-gray-800 mb-2">${recipe.title}</h3>
|
| 393 |
</div>
|
| 394 |
<div class="flex items-center gap-1">
|
| 395 |
+
<span class="text-xs text-gray-500">${recipe.servings} porciones</span>
|
| 396 |
+
<i class="fas fa-utensils text-gray-400"></i>
|
| 397 |
</div>
|
| 398 |
</div>
|
| 399 |
|
| 400 |
<div class="flex flex-wrap gap-2 my-3">
|
| 401 |
<div class="nutrition-badge bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 402 |
+
<i class="fas fa-fire"></i> ${recipe.nutrition.calories} kcal
|
| 403 |
</div>
|
| 404 |
<div class="nutrition-badge bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 405 |
+
<i class="fas fa-dumbbell"></i> ${recipe.nutrition.protein}g proteína
|
| 406 |
</div>
|
| 407 |
<div class="nutrition-badge bg-yellow-100 text-yellow-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 408 |
+
<i class="fas fa-bread-slice"></i> ${recipe.nutrition.carbs}g carbos
|
| 409 |
</div>
|
| 410 |
<div class="nutrition-badge bg-orange-100 text-orange-800 px-3 py-1 rounded-full text-sm flex items-center gap-1">
|
| 411 |
+
<i class="fas fa-oil-can"></i> ${recipe.nutrition.fat}g grasas
|
| 412 |
</div>
|
| 413 |
</div>
|
| 414 |
|
| 415 |
<div class="mb-4">
|
| 416 |
<h4 class="font-medium text-gray-700 mb-2">Ingredientes (${recipe.servings} porciones):</h4>
|
| 417 |
<ul class="grid grid-cols-1 sm:grid-cols-2 gap-1 text-sm text-gray-600">
|
| 418 |
+
${recipe.ingredients.map(ing =>
|
| 419 |
`<li class="flex items-start">
|
| 420 |
<i class="fas fa-check-circle text-green-400 mt-1 mr-2 text-xs"></i>
|
| 421 |
+
<span>${ing.text}</span>
|
| 422 |
</li>`
|
| 423 |
).join('')}
|
| 424 |
</ul>
|
|
|
|
| 426 |
|
| 427 |
<div class="mb-4">
|
| 428 |
<h4 class="font-medium text-gray-700 mb-2">Instrucciones:</h4>
|
| 429 |
+
<div class="text-sm text-gray-600">
|
| 430 |
+
<p>Para ver las instrucciones completas, visita el enlace original de la receta.</p>
|
| 431 |
+
</div>
|
| 432 |
</div>
|
| 433 |
|
| 434 |
${recipe.sourceUrl ? `
|
|
|
|
| 447 |
});
|
| 448 |
}
|
| 449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
// Filter recipes by type
|
| 451 |
function filterRecipes(type) {
|
| 452 |
const allRecipes = document.querySelectorAll('.recipe-card');
|
|
|
|
| 492 |
}
|
| 493 |
|
| 494 |
aisles[aisle].push({
|
| 495 |
+
name: capitalizeFirstLetter(name),
|
| 496 |
amount: data.amount,
|
| 497 |
unit: data.unit
|
| 498 |
});
|
|
|
|
| 528 |
shoppingModal.classList.remove('hidden');
|
| 529 |
}
|
| 530 |
|
| 531 |
+
// Helper function to capitalize first letter
|
| 532 |
+
function capitalizeFirstLetter(string) {
|
| 533 |
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
// Print shopping list
|
| 537 |
function printShoppingList() {
|
| 538 |
const printContent = shoppingListContent.innerHTML;
|
|
|
|
| 599 |
doc.setFontSize(10);
|
| 600 |
doc.setTextColor(0, 0, 0);
|
| 601 |
|
| 602 |
+
doc.text(`Nutrición por porción: ${recipe.nutrition.calories} kcal | ${recipe.nutrition.protein}g proteína | ${recipe.nutrition.carbs}g carbohidratos | ${recipe.nutrition.fat}g grasas`, 20, y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
y += 8;
|
| 604 |
|
| 605 |
// Ingredients
|
|
|
|
| 609 |
y += 6;
|
| 610 |
|
| 611 |
doc.setFontSize(10);
|
| 612 |
+
recipe.ingredients.forEach(ing => {
|
| 613 |
if (y > 270) {
|
| 614 |
doc.addPage();
|
| 615 |
y = 20;
|
| 616 |
page++;
|
| 617 |
}
|
| 618 |
|
| 619 |
+
doc.text(`- ${ing.text}`, 25, y);
|
| 620 |
y += 6;
|
| 621 |
});
|
| 622 |
|
| 623 |
y += 6;
|
| 624 |
|
| 625 |
// Instructions
|
| 626 |
+
doc.setFontSize(12);
|
| 627 |
+
doc.setTextColor(55, 65, 81);
|
| 628 |
+
doc.text('Instrucciones:', 20, y);
|
| 629 |
+
y += 6;
|
| 630 |
+
|
| 631 |
+
doc.setFontSize(10);
|
| 632 |
+
const lines = doc.splitTextToSize('Para ver las instrucciones completas, visita el enlace original de la receta.', 170);
|
| 633 |
+
|
| 634 |
+
lines.forEach(line => {
|
| 635 |
+
if (y > 270) {
|
| 636 |
+
doc.addPage();
|
| 637 |
+
y = 20;
|
| 638 |
+
page++;
|
| 639 |
+
}
|
| 640 |
|
| 641 |
+
doc.text(line, 25, y);
|
| 642 |
+
y += 6;
|
| 643 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
|
| 645 |
y += 10;
|
| 646 |
|
|
|
|
| 664 |
return;
|
| 665 |
}
|
| 666 |
|
| 667 |
+
let csv = 'Día,Tipo,Receta,Calorías,Proteína (g),Carbohidratos (g),Grasas (g),Ingredientes,URL\n';
|
| 668 |
|
| 669 |
currentMenu.forEach(recipe => {
|
| 670 |
+
const ingredients = recipe.ingredients.map(ing => ing.text).join(' | ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
|
| 672 |
+
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`;
|
| 673 |
});
|
| 674 |
|
| 675 |
// Create download link
|
|
|
|
| 719 |
}
|
| 720 |
|
| 721 |
aisles[aisle].push({
|
| 722 |
+
name: capitalizeFirstLetter(name),
|
| 723 |
amount: data.amount,
|
| 724 |
unit: data.unit
|
| 725 |
});
|
|
|
|
| 783 |
let totalFat = 0;
|
| 784 |
|
| 785 |
currentMenu.forEach(recipe => {
|
| 786 |
+
totalCalories += recipe.nutrition.calories;
|
| 787 |
+
totalProtein += recipe.nutrition.protein;
|
| 788 |
+
totalCarbs += recipe.nutrition.carbs;
|
| 789 |
+
totalFat += recipe.nutrition.fat;
|
| 790 |
});
|
| 791 |
|
| 792 |
const avgCal = Math.round(totalCalories / currentMenu.length);
|
prompts.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 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.
|
|
|
|
|
|
| 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
|