Spaces:
Running
Running
Add 1 files
Browse files- index.html +190 -97
index.html
CHANGED
|
@@ -3,19 +3,26 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Calculadora de Macronutrientes
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<style>
|
| 10 |
.gradient-bg {
|
| 11 |
-
background: linear-gradient(135deg, #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
.result-card {
|
| 14 |
transition: all 0.3s ease;
|
|
|
|
| 15 |
}
|
| 16 |
.result-card:hover {
|
| 17 |
transform: translateY(-5px);
|
| 18 |
-
box-shadow: 0 10px
|
| 19 |
}
|
| 20 |
.nutri-circle {
|
| 21 |
width: 100px;
|
|
@@ -26,194 +33,260 @@
|
|
| 26 |
justify-content: center;
|
| 27 |
font-weight: bold;
|
| 28 |
margin: 0 auto;
|
|
|
|
| 29 |
}
|
| 30 |
input[type="range"] {
|
| 31 |
-webkit-appearance: none;
|
| 32 |
-
height:
|
| 33 |
-
border-radius:
|
| 34 |
background: #e0e0e0;
|
| 35 |
outline: none;
|
| 36 |
}
|
| 37 |
input[type="range"]::-webkit-slider-thumb {
|
| 38 |
-webkit-appearance: none;
|
| 39 |
appearance: none;
|
| 40 |
-
width:
|
| 41 |
-
height:
|
| 42 |
border-radius: 50%;
|
| 43 |
-
background: #
|
| 44 |
cursor: pointer;
|
|
|
|
| 45 |
}
|
| 46 |
.tab-btn {
|
| 47 |
transition: all 0.3s ease;
|
|
|
|
| 48 |
}
|
| 49 |
.tab-btn.active {
|
| 50 |
-
background: linear-gradient(135deg, #
|
| 51 |
color: white;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
</style>
|
| 54 |
</head>
|
| 55 |
-
<body class="min-h-screen bg-
|
| 56 |
<div class="gradient-bg text-white py-12 px-4 shadow-lg">
|
| 57 |
<div class="max-w-4xl mx-auto text-center">
|
| 58 |
-
<h1 class="text-4xl font-bold mb-4">Calculadora de Macronutrientes
|
| 59 |
-
<p class="text-xl opacity-90">Calcula tus necesidades nutricionales personalizadas
|
| 60 |
</div>
|
| 61 |
</div>
|
| 62 |
|
| 63 |
<div class="max-w-4xl mx-auto px-4 py-8">
|
| 64 |
-
<div class="bg-white rounded-
|
| 65 |
-
<h2 class="text-2xl font-semibold text-gray-800 mb-6">
|
|
|
|
|
|
|
| 66 |
|
| 67 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 68 |
<div>
|
| 69 |
-
<label class="block text-gray-700 mb-2">
|
|
|
|
|
|
|
| 70 |
<div class="flex space-x-4">
|
| 71 |
-
<button id="maleBtn" class="gender-btn px-4 py-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
</div>
|
| 74 |
</div>
|
| 75 |
|
| 76 |
<div>
|
| 77 |
-
<label class="block text-gray-700 mb-2">
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
<option value="
|
|
|
|
|
|
|
| 82 |
</select>
|
| 83 |
</div>
|
| 84 |
|
| 85 |
<div>
|
| 86 |
-
<label class="block text-gray-700 mb-2">
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
</div>
|
| 89 |
|
| 90 |
<div>
|
| 91 |
-
<label class="block text-gray-700 mb-2
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
<option value="1.
|
| 96 |
-
<option value="1.
|
| 97 |
-
<option value="1.
|
|
|
|
|
|
|
| 98 |
</select>
|
| 99 |
</div>
|
| 100 |
|
| 101 |
<div>
|
| 102 |
-
<label class="block text-gray-700 mb-2">
|
| 103 |
-
|
|
|
|
|
|
|
| 104 |
</div>
|
| 105 |
|
| 106 |
<div>
|
| 107 |
-
<label class="block text-gray-700 mb-2">
|
| 108 |
-
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
|
| 112 |
<div class="mt-6">
|
| 113 |
<div class="flex mb-4">
|
| 114 |
-
<button id="manualTab" class="tab-btn px-4 py-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
</div>
|
| 117 |
|
| 118 |
<div id="manualBodyfatSection">
|
| 119 |
-
<label class="block text-gray-700 mb-2
|
|
|
|
|
|
|
| 120 |
<input type="range" id="bodyfat" class="w-full" min="5" max="50" value="20">
|
| 121 |
<div class="flex justify-between text-sm text-gray-600 mt-1">
|
| 122 |
-
<span>5
|
| 123 |
<span id="bodyfatValue">20%</span>
|
| 124 |
-
<span>50
|
| 125 |
</div>
|
| 126 |
</div>
|
| 127 |
|
| 128 |
<div id="calculateBodyfatSection" class="hidden">
|
| 129 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
|
| 130 |
<div>
|
| 131 |
-
<label class="block text-gray-700 mb-2">
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
</div>
|
| 134 |
<div>
|
| 135 |
-
<label class="block text-gray-700 mb-2">
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
</div>
|
| 138 |
<div id="hipSection">
|
| 139 |
-
<label class="block text-gray-700 mb-2">
|
| 140 |
-
|
|
|
|
|
|
|
| 141 |
</div>
|
| 142 |
</div>
|
| 143 |
-
<button id="calculateBodyfatBtn" class="w-full bg-
|
| 144 |
-
Calcular % Grasa
|
| 145 |
</button>
|
| 146 |
</div>
|
| 147 |
</div>
|
| 148 |
|
| 149 |
<div class="mt-8">
|
| 150 |
-
<button id="calculateBtn" class="w-full gradient-bg text-white py-
|
| 151 |
-
Calcular mis macronutrientes
|
| 152 |
</button>
|
| 153 |
</div>
|
| 154 |
</div>
|
| 155 |
|
| 156 |
-
<div id="results" class="hidden bg-white rounded-
|
| 157 |
-
<h2 class="text-2xl font-semibold text-gray-800 mb-6
|
|
|
|
|
|
|
| 158 |
|
| 159 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
| 160 |
-
<div class="result-card bg-blue-50 rounded-
|
| 161 |
-
<div class="nutri-circle bg-blue-100 text-blue-700 text-
|
| 162 |
-
<h3 class="text-xl font-semibold text-blue-800 mb-2">
|
|
|
|
|
|
|
| 163 |
<p class="text-gray-600">Recomendación basada en tus datos</p>
|
| 164 |
</div>
|
| 165 |
|
| 166 |
-
<div class="result-card bg-green-50 rounded-
|
| 167 |
-
<div class="nutri-circle bg-green-100 text-green-700 text-
|
| 168 |
-
<h3 class="text-xl font-semibold text-green-800 mb-2">
|
|
|
|
|
|
|
| 169 |
<p class="text-gray-600">Esencial para músculos y recuperación</p>
|
| 170 |
</div>
|
| 171 |
|
| 172 |
-
<div class="result-card bg-yellow-50 rounded-
|
| 173 |
-
<div class="nutri-circle bg-yellow-100 text-yellow-700 text-
|
| 174 |
-
<h3 class="text-xl font-semibold text-yellow-800 mb-2">
|
|
|
|
|
|
|
| 175 |
<p class="text-gray-600">Energía para tu día y entrenamientos</p>
|
| 176 |
</div>
|
| 177 |
</div>
|
| 178 |
|
| 179 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 180 |
-
<div class="result-card bg-purple-50 rounded-
|
| 181 |
-
<h3 class="text-xl font-semibold text-purple-800 mb-4
|
|
|
|
|
|
|
| 182 |
<div class="h-64 flex items-center justify-center">
|
| 183 |
<canvas id="macrosChart"></canvas>
|
| 184 |
</div>
|
| 185 |
</div>
|
| 186 |
|
| 187 |
-
<div class="result-card bg-red-50 rounded-
|
| 188 |
-
<h3 class="text-xl font-semibold text-red-800 mb-4">
|
|
|
|
|
|
|
| 189 |
<div class="space-y-4">
|
| 190 |
<div class="flex justify-between items-center">
|
| 191 |
-
<span class="text-gray-700">
|
|
|
|
|
|
|
| 192 |
<span class="font-semibold text-red-700" id="fatValue">0g</span>
|
| 193 |
</div>
|
| 194 |
-
<div class="w-full bg-gray-200 rounded-full h-
|
| 195 |
-
<div id="fatBar" class="bg-red-
|
| 196 |
</div>
|
| 197 |
|
| 198 |
<div class="flex justify-between items-center">
|
| 199 |
-
<span class="text-gray-700">
|
|
|
|
|
|
|
| 200 |
<span class="font-semibold text-blue-700" id="proteinValue">0g</span>
|
| 201 |
</div>
|
| 202 |
-
<div class="w-full bg-gray-200 rounded-full h-
|
| 203 |
-
<div id="proteinBar" class="bg-blue-
|
| 204 |
</div>
|
| 205 |
|
| 206 |
<div class="flex justify-between items-center">
|
| 207 |
-
<span class="text-gray-700">
|
|
|
|
|
|
|
| 208 |
<span class="font-semibold text-yellow-700" id="carbsValue">0g</span>
|
| 209 |
</div>
|
| 210 |
-
<div class="w-full bg-gray-200 rounded-full h-
|
| 211 |
-
<div id="carbsBar" class="bg-yellow-
|
| 212 |
</div>
|
| 213 |
|
| 214 |
<div class="pt-4 border-t border-gray-200">
|
| 215 |
<div class="flex justify-between items-center">
|
| 216 |
-
<span class="text-gray-700 font-medium">
|
|
|
|
|
|
|
| 217 |
<span class="font-semibold text-blue-700" id="waterValue">0L</span>
|
| 218 |
</div>
|
| 219 |
</div>
|
|
@@ -221,8 +294,10 @@
|
|
| 221 |
</div>
|
| 222 |
</div>
|
| 223 |
|
| 224 |
-
<div class="mt-8 bg-gray-50 rounded-
|
| 225 |
-
<h3 class="text-xl font-semibold text-gray-800 mb-4">
|
|
|
|
|
|
|
| 226 |
<div id="recommendations" class="space-y-3 text-gray-700">
|
| 227 |
<!-- Las recomendaciones se generarán aquí -->
|
| 228 |
</div>
|
|
@@ -244,14 +319,17 @@
|
|
| 244 |
document.getElementById('manualTab').addEventListener('click', () => switchBodyfatTab('manual'));
|
| 245 |
document.getElementById('calculateTab').addEventListener('click', () => switchBodyfatTab('calculate'));
|
| 246 |
document.getElementById('calculateBodyfatBtn').addEventListener('click', calculateBodyfatPercentage);
|
| 247 |
-
document.getElementById('gender').addEventListener('change', toggleHipInput);
|
| 248 |
|
| 249 |
// Funciones
|
| 250 |
function setGender(selectedGender) {
|
| 251 |
gender = selectedGender;
|
| 252 |
document.querySelectorAll('.gender-btn').forEach(btn => {
|
| 253 |
btn.classList.remove('gradient-bg', 'text-white');
|
| 254 |
-
btn.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
});
|
| 256 |
|
| 257 |
if (selectedGender === 'male') {
|
|
@@ -309,7 +387,7 @@
|
|
| 309 |
document.getElementById('bodyfatValue').textContent = `${Math.round(bodyfatPercentage)}%`;
|
| 310 |
|
| 311 |
// Mostrar notificación de éxito
|
| 312 |
-
alert(
|
| 313 |
|
| 314 |
// Cambiar a la pestaña manual para mostrar el resultado
|
| 315 |
switchBodyfatTab('manual');
|
|
@@ -326,7 +404,7 @@
|
|
| 326 |
|
| 327 |
// Validaciones básicas
|
| 328 |
if (age < 15 || age > 100 || weight < 40 || weight > 200 || height < 140 || height > 220) {
|
| 329 |
-
alert('Por favor ingresa valores válidos en todos los campos');
|
| 330 |
return;
|
| 331 |
}
|
| 332 |
|
|
@@ -422,42 +500,42 @@
|
|
| 422 |
let goalRecommendation = '';
|
| 423 |
switch(goal) {
|
| 424 |
case 'loss':
|
| 425 |
-
goalRecommendation = 'Para pérdida de peso
|
| 426 |
break;
|
| 427 |
case 'maintenance':
|
| 428 |
-
goalRecommendation = 'Para mantenimiento
|
| 429 |
break;
|
| 430 |
case 'gain':
|
| 431 |
-
goalRecommendation = 'Para aumento de peso
|
| 432 |
break;
|
| 433 |
}
|
| 434 |
|
| 435 |
addRecommendation(goalRecommendation);
|
| 436 |
|
| 437 |
// Recomendación de proteína
|
| 438 |
-
addRecommendation(`Consume aproximadamente ${protein}g de proteína diarios
|
| 439 |
|
| 440 |
// Recomendación de carbohidratos
|
| 441 |
if (goal === 'loss') {
|
| 442 |
-
addRecommendation(`Prioriza carbohidratos complejos (${carbs}g/día) como vegetales
|
| 443 |
} else {
|
| 444 |
-
addRecommendation(`Consume ${carbs}g de carbohidratos diarios
|
| 445 |
}
|
| 446 |
|
| 447 |
// Recomendación de grasas
|
| 448 |
-
addRecommendation(`Incluye ${fat}g de grasas saludables diarias de fuentes como aguacate, frutos secos
|
| 449 |
|
| 450 |
// Recomendación de agua
|
| 451 |
-
addRecommendation(`Bebe al menos ${water} litros de agua al día para mantener una hidratación óptima.`);
|
| 452 |
|
| 453 |
// Recomendación de comidas
|
| 454 |
-
addRecommendation('Distribuye tus macronutrientes en 3-5 comidas al día para mejor digestión y absorción.');
|
| 455 |
|
| 456 |
function addRecommendation(text) {
|
| 457 |
const div = document.createElement('div');
|
| 458 |
-
div.className = 'flex items-start';
|
| 459 |
div.innerHTML = `
|
| 460 |
-
<span class="text-
|
| 461 |
<span>${text}</span>
|
| 462 |
`;
|
| 463 |
recommendationsEl.appendChild(div);
|
|
@@ -475,7 +553,7 @@
|
|
| 475 |
macrosChart = new Chart(ctx, {
|
| 476 |
type: 'doughnut',
|
| 477 |
data: {
|
| 478 |
-
labels: ['Proteína', 'Carbohidratos', 'Grasas'],
|
| 479 |
datasets: [{
|
| 480 |
data: [protein, carbs, fat],
|
| 481 |
backgroundColor: [
|
|
@@ -483,7 +561,8 @@
|
|
| 483 |
'#f59e0b',
|
| 484 |
'#ef4444'
|
| 485 |
],
|
| 486 |
-
borderWidth: 0
|
|
|
|
| 487 |
}]
|
| 488 |
},
|
| 489 |
options: {
|
|
@@ -494,9 +573,12 @@
|
|
| 494 |
position: 'bottom',
|
| 495 |
labels: {
|
| 496 |
font: {
|
| 497 |
-
size: 14
|
|
|
|
| 498 |
},
|
| 499 |
-
padding: 20
|
|
|
|
|
|
|
| 500 |
}
|
| 501 |
},
|
| 502 |
tooltip: {
|
|
@@ -508,10 +590,21 @@
|
|
| 508 |
const percentage = Math.round((value / total) * 100);
|
| 509 |
return `${label}: ${value}g (${percentage}%)`;
|
| 510 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
}
|
| 512 |
}
|
| 513 |
},
|
| 514 |
-
cutout: '70%'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
}
|
| 516 |
});
|
| 517 |
}
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Calculadora de Macronutrientes 🍎</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<style>
|
| 10 |
.gradient-bg {
|
| 11 |
+
background: linear-gradient(135deg, #8E2DE2 0%, #4A00E0 100%);
|
| 12 |
+
}
|
| 13 |
+
.gradient-bg-secondary {
|
| 14 |
+
background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
|
| 15 |
+
}
|
| 16 |
+
.gradient-bg-green {
|
| 17 |
+
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
|
| 18 |
}
|
| 19 |
.result-card {
|
| 20 |
transition: all 0.3s ease;
|
| 21 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
| 22 |
}
|
| 23 |
.result-card:hover {
|
| 24 |
transform: translateY(-5px);
|
| 25 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 26 |
}
|
| 27 |
.nutri-circle {
|
| 28 |
width: 100px;
|
|
|
|
| 33 |
justify-content: center;
|
| 34 |
font-weight: bold;
|
| 35 |
margin: 0 auto;
|
| 36 |
+
box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
| 37 |
}
|
| 38 |
input[type="range"] {
|
| 39 |
-webkit-appearance: none;
|
| 40 |
+
height: 12px;
|
| 41 |
+
border-radius: 10px;
|
| 42 |
background: #e0e0e0;
|
| 43 |
outline: none;
|
| 44 |
}
|
| 45 |
input[type="range"]::-webkit-slider-thumb {
|
| 46 |
-webkit-appearance: none;
|
| 47 |
appearance: none;
|
| 48 |
+
width: 25px;
|
| 49 |
+
height: 25px;
|
| 50 |
border-radius: 50%;
|
| 51 |
+
background: #8E2DE2;
|
| 52 |
cursor: pointer;
|
| 53 |
+
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
| 54 |
}
|
| 55 |
.tab-btn {
|
| 56 |
transition: all 0.3s ease;
|
| 57 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 58 |
}
|
| 59 |
.tab-btn.active {
|
| 60 |
+
background: linear-gradient(135deg, #8E2DE2 0%, #4A00E0 100%);
|
| 61 |
color: white;
|
| 62 |
+
transform: translateY(-2px);
|
| 63 |
+
}
|
| 64 |
+
.emoji-input {
|
| 65 |
+
font-size: 1.2em;
|
| 66 |
+
margin-right: 5px;
|
| 67 |
+
}
|
| 68 |
+
.pulse-animation {
|
| 69 |
+
animation: pulse 2s infinite;
|
| 70 |
+
}
|
| 71 |
+
@keyframes pulse {
|
| 72 |
+
0% { transform: scale(1); }
|
| 73 |
+
50% { transform: scale(1.05); }
|
| 74 |
+
100% { transform: scale(1); }
|
| 75 |
}
|
| 76 |
</style>
|
| 77 |
</head>
|
| 78 |
+
<body class="min-h-screen bg-gradient-to-br from-blue-50 to-purple-50">
|
| 79 |
<div class="gradient-bg text-white py-12 px-4 shadow-lg">
|
| 80 |
<div class="max-w-4xl mx-auto text-center">
|
| 81 |
+
<h1 class="text-4xl font-bold mb-4">Calculadora de Macronutrientes 🍏</h1>
|
| 82 |
+
<p class="text-xl opacity-90">Calcula tus necesidades nutricionales personalizadas 📊</p>
|
| 83 |
</div>
|
| 84 |
</div>
|
| 85 |
|
| 86 |
<div class="max-w-4xl mx-auto px-4 py-8">
|
| 87 |
+
<div class="bg-white rounded-2xl shadow-xl p-6 mb-8 border-2 border-purple-100">
|
| 88 |
+
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
|
| 89 |
+
<span class="emoji-input">👤</span> Datos Personales
|
| 90 |
+
</h2>
|
| 91 |
|
| 92 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 93 |
<div>
|
| 94 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 95 |
+
<span class="emoji-input">🚻</span> Género
|
| 96 |
+
</label>
|
| 97 |
<div class="flex space-x-4">
|
| 98 |
+
<button id="maleBtn" class="gender-btn px-4 py-3 rounded-xl bg-blue-100 text-blue-700 font-medium hover:bg-blue-200 transition duration-300 flex items-center">
|
| 99 |
+
<span class="emoji-input">👨</span> Hombre
|
| 100 |
+
</button>
|
| 101 |
+
<button id="femaleBtn" class="gender-btn px-4 py-3 rounded-xl bg-pink-100 text-pink-700 font-medium hover:bg-pink-200 transition duration-300 flex items-center">
|
| 102 |
+
<span class="emoji-input">👩</span> Mujer
|
| 103 |
+
</button>
|
| 104 |
</div>
|
| 105 |
</div>
|
| 106 |
|
| 107 |
<div>
|
| 108 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 109 |
+
<span class="emoji-input">🎯</span> Objetivo
|
| 110 |
+
</label>
|
| 111 |
+
<select id="goal" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent">
|
| 112 |
+
<option value="loss">📉 Pérdida de peso</option>
|
| 113 |
+
<option value="maintenance" selected>⚖️ Mantenimiento</option>
|
| 114 |
+
<option value="gain">📈 Aumento de peso</option>
|
| 115 |
</select>
|
| 116 |
</div>
|
| 117 |
|
| 118 |
<div>
|
| 119 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 120 |
+
<span class="emoji-input">🎂</span> Edad (años)
|
| 121 |
+
</label>
|
| 122 |
+
<input type="number" id="age" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="15" max="100" value="30">
|
| 123 |
</div>
|
| 124 |
|
| 125 |
<div>
|
| 126 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 127 |
+
<span class="emoji-input">🏃</span> Nivel de actividad
|
| 128 |
+
</label>
|
| 129 |
+
<select id="activity" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent">
|
| 130 |
+
<option value="1.2">🛋️ Sedentario (poco o nada de ejercicio)</option>
|
| 131 |
+
<option value="1.375">🚶♂️ Ligero (ejercicio 1-3 días/semana)</option>
|
| 132 |
+
<option value="1.55" selected>🏋️♂️ Moderado (ejercicio 3-5 días/semana)</option>
|
| 133 |
+
<option value="1.725">🚴♀️ Activo (ejercicio 6-7 días/semana)</option>
|
| 134 |
+
<option value="1.9">🔥 Muy activo (ejercicio intenso diario)</option>
|
| 135 |
</select>
|
| 136 |
</div>
|
| 137 |
|
| 138 |
<div>
|
| 139 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 140 |
+
<span class="emoji-input">⚖️</span> Peso (kg)
|
| 141 |
+
</label>
|
| 142 |
+
<input type="number" id="weight" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="40" max="200" value="70">
|
| 143 |
</div>
|
| 144 |
|
| 145 |
<div>
|
| 146 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 147 |
+
<span class="emoji-input">📏</span> Altura (cm)
|
| 148 |
+
</label>
|
| 149 |
+
<input type="number" id="height" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="140" max="220" value="170">
|
| 150 |
</div>
|
| 151 |
</div>
|
| 152 |
|
| 153 |
<div class="mt-6">
|
| 154 |
<div class="flex mb-4">
|
| 155 |
+
<button id="manualTab" class="tab-btn px-4 py-3 rounded-l-xl border-2 border-gray-200 font-medium active flex items-center">
|
| 156 |
+
<span class="emoji-input">✋</span> Manual
|
| 157 |
+
</button>
|
| 158 |
+
<button id="calculateTab" class="tab-btn px-4 py-3 rounded-r-xl border-2 border-gray-200 font-medium flex items-center">
|
| 159 |
+
<span class="emoji-input">🧮</span> Calcular % Grasa
|
| 160 |
+
</button>
|
| 161 |
</div>
|
| 162 |
|
| 163 |
<div id="manualBodyfatSection">
|
| 164 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 165 |
+
<span class="emoji-input">💪</span> % Grasa corporal
|
| 166 |
+
</label>
|
| 167 |
<input type="range" id="bodyfat" class="w-full" min="5" max="50" value="20">
|
| 168 |
<div class="flex justify-between text-sm text-gray-600 mt-1">
|
| 169 |
+
<span>5% 🏃♂️</span>
|
| 170 |
<span id="bodyfatValue">20%</span>
|
| 171 |
+
<span>50% 🍔</span>
|
| 172 |
</div>
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<div id="calculateBodyfatSection" class="hidden">
|
| 176 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
|
| 177 |
<div>
|
| 178 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 179 |
+
<span class="emoji-input">👔</span> Cuello (cm)
|
| 180 |
+
</label>
|
| 181 |
+
<input type="number" id="neck" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="20" max="50" value="38">
|
| 182 |
</div>
|
| 183 |
<div>
|
| 184 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 185 |
+
<span class="emoji-input">👖</span> Cintura (cm)
|
| 186 |
+
</label>
|
| 187 |
+
<input type="number" id="waist" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="50" max="150" value="80">
|
| 188 |
</div>
|
| 189 |
<div id="hipSection">
|
| 190 |
+
<label class="block text-gray-700 mb-2 flex items-center">
|
| 191 |
+
<span class="emoji-input">👗</span> Cadera (cm)
|
| 192 |
+
</label>
|
| 193 |
+
<input type="number" id="hip" class="w-full px-4 py-3 border-2 border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent" min="60" max="150" value="95">
|
| 194 |
</div>
|
| 195 |
</div>
|
| 196 |
+
<button id="calculateBodyfatBtn" class="w-full gradient-bg-secondary text-white py-3 rounded-xl font-bold text-lg hover:opacity-90 transition duration-300 flex items-center justify-center pulse-animation">
|
| 197 |
+
<span class="emoji-input">🧠</span> Calcular % Grasa
|
| 198 |
</button>
|
| 199 |
</div>
|
| 200 |
</div>
|
| 201 |
|
| 202 |
<div class="mt-8">
|
| 203 |
+
<button id="calculateBtn" class="w-full gradient-bg text-white py-4 rounded-xl font-bold text-lg hover:opacity-90 transition duration-300 flex items-center justify-center pulse-animation">
|
| 204 |
+
<span class="emoji-input">✨</span> Calcular mis macronutrientes
|
| 205 |
</button>
|
| 206 |
</div>
|
| 207 |
</div>
|
| 208 |
|
| 209 |
+
<div id="results" class="hidden bg-white rounded-2xl shadow-xl p-6 mb-8 border-2 border-purple-100">
|
| 210 |
+
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
|
| 211 |
+
<span class="emoji-input">📊</span> Tus resultados nutricionales
|
| 212 |
+
</h2>
|
| 213 |
|
| 214 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
| 215 |
+
<div class="result-card bg-gradient-to-br from-blue-50 to-indigo-50 rounded-2xl p-6 text-center border-2 border-blue-100">
|
| 216 |
+
<div class="nutri-circle bg-gradient-to-br from-blue-100 to-blue-200 text-blue-700 text-3xl mb-4" id="caloriesCircle">0</div>
|
| 217 |
+
<h3 class="text-xl font-semibold text-blue-800 mb-2 flex items-center justify-center">
|
| 218 |
+
<span class="emoji-input">🔥</span> Calorías diarias
|
| 219 |
+
</h3>
|
| 220 |
<p class="text-gray-600">Recomendación basada en tus datos</p>
|
| 221 |
</div>
|
| 222 |
|
| 223 |
+
<div class="result-card bg-gradient-to-br from-green-50 to-teal-50 rounded-2xl p-6 text-center border-2 border-green-100">
|
| 224 |
+
<div class="nutri-circle bg-gradient-to-br from-green-100 to-green-200 text-green-700 text-3xl mb-4" id="proteinCircle">0g</div>
|
| 225 |
+
<h3 class="text-xl font-semibold text-green-800 mb-2 flex items-center justify-center">
|
| 226 |
+
<span class="emoji-input">🍗</span> Proteína
|
| 227 |
+
</h3>
|
| 228 |
<p class="text-gray-600">Esencial para músculos y recuperación</p>
|
| 229 |
</div>
|
| 230 |
|
| 231 |
+
<div class="result-card bg-gradient-to-br from-yellow-50 to-amber-50 rounded-2xl p-6 text-center border-2 border-yellow-100">
|
| 232 |
+
<div class="nutri-circle bg-gradient-to-br from-yellow-100 to-yellow-200 text-yellow-700 text-3xl mb-4" id="carbsCircle">0g</div>
|
| 233 |
+
<h3 class="text-xl font-semibold text-yellow-800 mb-2 flex items-center justify-center">
|
| 234 |
+
<span class="emoji-input">🍞</span> Carbohidratos
|
| 235 |
+
</h3>
|
| 236 |
<p class="text-gray-600">Energía para tu día y entrenamientos</p>
|
| 237 |
</div>
|
| 238 |
</div>
|
| 239 |
|
| 240 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 241 |
+
<div class="result-card bg-gradient-to-br from-purple-50 to-indigo-50 rounded-2xl p-6 border-2 border-purple-100">
|
| 242 |
+
<h3 class="text-xl font-semibold text-purple-800 mb-4 flex items-center">
|
| 243 |
+
<span class="emoji-input">📊</span> Distribución de macronutrientes
|
| 244 |
+
</h3>
|
| 245 |
<div class="h-64 flex items-center justify-center">
|
| 246 |
<canvas id="macrosChart"></canvas>
|
| 247 |
</div>
|
| 248 |
</div>
|
| 249 |
|
| 250 |
+
<div class="result-card bg-gradient-to-br from-red-50 to-pink-50 rounded-2xl p-6 border-2 border-red-100">
|
| 251 |
+
<h3 class="text-xl font-semibold text-red-800 mb-4 flex items-center">
|
| 252 |
+
<span class="emoji-input">🔍</span> Detalles nutricionales
|
| 253 |
+
</h3>
|
| 254 |
<div class="space-y-4">
|
| 255 |
<div class="flex justify-between items-center">
|
| 256 |
+
<span class="text-gray-700 flex items-center">
|
| 257 |
+
<span class="emoji-input">🥑</span> Grasas
|
| 258 |
+
</span>
|
| 259 |
<span class="font-semibold text-red-700" id="fatValue">0g</span>
|
| 260 |
</div>
|
| 261 |
+
<div class="w-full bg-gray-200 rounded-full h-3">
|
| 262 |
+
<div id="fatBar" class="bg-gradient-to-r from-red-400 to-red-600 h-3 rounded-full" style="width: 0%"></div>
|
| 263 |
</div>
|
| 264 |
|
| 265 |
<div class="flex justify-between items-center">
|
| 266 |
+
<span class="text-gray-700 flex items-center">
|
| 267 |
+
<span class="emoji-input">🍗</span> Proteína
|
| 268 |
+
</span>
|
| 269 |
<span class="font-semibold text-blue-700" id="proteinValue">0g</span>
|
| 270 |
</div>
|
| 271 |
+
<div class="w-full bg-gray-200 rounded-full h-3">
|
| 272 |
+
<div id="proteinBar" class="bg-gradient-to-r from-blue-400 to-blue-600 h-3 rounded-full" style="width: 0%"></div>
|
| 273 |
</div>
|
| 274 |
|
| 275 |
<div class="flex justify-between items-center">
|
| 276 |
+
<span class="text-gray-700 flex items-center">
|
| 277 |
+
<span class="emoji-input">🍞</span> Carbohidratos
|
| 278 |
+
</span>
|
| 279 |
<span class="font-semibold text-yellow-700" id="carbsValue">0g</span>
|
| 280 |
</div>
|
| 281 |
+
<div class="w-full bg-gray-200 rounded-full h-3">
|
| 282 |
+
<div id="carbsBar" class="bg-gradient-to-r from-yellow-400 to-yellow-600 h-3 rounded-full" style="width: 0%"></div>
|
| 283 |
</div>
|
| 284 |
|
| 285 |
<div class="pt-4 border-t border-gray-200">
|
| 286 |
<div class="flex justify-between items-center">
|
| 287 |
+
<span class="text-gray-700 font-medium flex items-center">
|
| 288 |
+
<span class="emoji-input">💧</span> Agua recomendada
|
| 289 |
+
</span>
|
| 290 |
<span class="font-semibold text-blue-700" id="waterValue">0L</span>
|
| 291 |
</div>
|
| 292 |
</div>
|
|
|
|
| 294 |
</div>
|
| 295 |
</div>
|
| 296 |
|
| 297 |
+
<div class="mt-8 bg-gradient-to-br from-gray-50 to-gray-100 rounded-2xl p-6 border-2 border-gray-200">
|
| 298 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
| 299 |
+
<span class="emoji-input">💡</span> Recomendaciones personalizadas
|
| 300 |
+
</h3>
|
| 301 |
<div id="recommendations" class="space-y-3 text-gray-700">
|
| 302 |
<!-- Las recomendaciones se generarán aquí -->
|
| 303 |
</div>
|
|
|
|
| 319 |
document.getElementById('manualTab').addEventListener('click', () => switchBodyfatTab('manual'));
|
| 320 |
document.getElementById('calculateTab').addEventListener('click', () => switchBodyfatTab('calculate'));
|
| 321 |
document.getElementById('calculateBodyfatBtn').addEventListener('click', calculateBodyfatPercentage);
|
|
|
|
| 322 |
|
| 323 |
// Funciones
|
| 324 |
function setGender(selectedGender) {
|
| 325 |
gender = selectedGender;
|
| 326 |
document.querySelectorAll('.gender-btn').forEach(btn => {
|
| 327 |
btn.classList.remove('gradient-bg', 'text-white');
|
| 328 |
+
if (btn.id === 'maleBtn') {
|
| 329 |
+
btn.classList.add('bg-blue-100', 'text-blue-700');
|
| 330 |
+
} else {
|
| 331 |
+
btn.classList.add('bg-pink-100', 'text-pink-700');
|
| 332 |
+
}
|
| 333 |
});
|
| 334 |
|
| 335 |
if (selectedGender === 'male') {
|
|
|
|
| 387 |
document.getElementById('bodyfatValue').textContent = `${Math.round(bodyfatPercentage)}%`;
|
| 388 |
|
| 389 |
// Mostrar notificación de éxito
|
| 390 |
+
alert(`🎉 Tu porcentaje de grasa corporal calculado es: ${Math.round(bodyfatPercentage)}%`);
|
| 391 |
|
| 392 |
// Cambiar a la pestaña manual para mostrar el resultado
|
| 393 |
switchBodyfatTab('manual');
|
|
|
|
| 404 |
|
| 405 |
// Validaciones básicas
|
| 406 |
if (age < 15 || age > 100 || weight < 40 || weight > 200 || height < 140 || height > 220) {
|
| 407 |
+
alert('⚠️ Por favor ingresa valores válidos en todos los campos');
|
| 408 |
return;
|
| 409 |
}
|
| 410 |
|
|
|
|
| 500 |
let goalRecommendation = '';
|
| 501 |
switch(goal) {
|
| 502 |
case 'loss':
|
| 503 |
+
goalRecommendation = 'Para pérdida de peso 🏃♂️, mantén un déficit calórico constante y prioriza proteínas para preservar masa muscular 💪.';
|
| 504 |
break;
|
| 505 |
case 'maintenance':
|
| 506 |
+
goalRecommendation = 'Para mantenimiento ⚖️, sigue una dieta balanceada y mantén tus niveles de actividad 🚶♀️.';
|
| 507 |
break;
|
| 508 |
case 'gain':
|
| 509 |
+
goalRecommendation = 'Para aumento de peso 📈, asegúrate de consumir suficientes calorías y proteínas para apoyar el crecimiento muscular 🏋️♂️.';
|
| 510 |
break;
|
| 511 |
}
|
| 512 |
|
| 513 |
addRecommendation(goalRecommendation);
|
| 514 |
|
| 515 |
// Recomendación de proteína
|
| 516 |
+
addRecommendation(`Consume aproximadamente ${protein}g de proteína diarios 🍗. Buenas fuentes incluyen carnes magras, pescado 🐟, huevos 🥚 y lácteos 🧀.`);
|
| 517 |
|
| 518 |
// Recomendación de carbohidratos
|
| 519 |
if (goal === 'loss') {
|
| 520 |
+
addRecommendation(`Prioriza carbohidratos complejos (${carbs}g/día) como vegetales 🥦, granos enteros 🌾 y legumbres para energía sostenida ⚡.`);
|
| 521 |
} else {
|
| 522 |
+
addRecommendation(`Consume ${carbs}g de carbohidratos diarios 🍞, priorizando fuentes complejas como arroz integral 🍚, quinoa y avena 🥣.`);
|
| 523 |
}
|
| 524 |
|
| 525 |
// Recomendación de grasas
|
| 526 |
+
addRecommendation(`Incluye ${fat}g de grasas saludables diarias 🥑 de fuentes como aguacate, frutos secos 🥜, aceite de oliva y pescados grasos 🐠.`);
|
| 527 |
|
| 528 |
// Recomendación de agua
|
| 529 |
+
addRecommendation(`Bebe al menos ${water} litros de agua al día 💧 para mantener una hidratación óptima.`);
|
| 530 |
|
| 531 |
// Recomendación de comidas
|
| 532 |
+
addRecommendation('Distribuye tus macronutrientes en 3-5 comidas al día 🍽️ para mejor digestión y absorción.');
|
| 533 |
|
| 534 |
function addRecommendation(text) {
|
| 535 |
const div = document.createElement('div');
|
| 536 |
+
div.className = 'flex items-start bg-white p-4 rounded-lg border border-gray-200';
|
| 537 |
div.innerHTML = `
|
| 538 |
+
<span class="text-purple-500 mr-3 mt-1"><i class="fas fa-check-circle"></i></span>
|
| 539 |
<span>${text}</span>
|
| 540 |
`;
|
| 541 |
recommendationsEl.appendChild(div);
|
|
|
|
| 553 |
macrosChart = new Chart(ctx, {
|
| 554 |
type: 'doughnut',
|
| 555 |
data: {
|
| 556 |
+
labels: ['Proteína 🍗', 'Carbohidratos 🍞', 'Grasas 🥑'],
|
| 557 |
datasets: [{
|
| 558 |
data: [protein, carbs, fat],
|
| 559 |
backgroundColor: [
|
|
|
|
| 561 |
'#f59e0b',
|
| 562 |
'#ef4444'
|
| 563 |
],
|
| 564 |
+
borderWidth: 0,
|
| 565 |
+
hoverOffset: 10
|
| 566 |
}]
|
| 567 |
},
|
| 568 |
options: {
|
|
|
|
| 573 |
position: 'bottom',
|
| 574 |
labels: {
|
| 575 |
font: {
|
| 576 |
+
size: 14,
|
| 577 |
+
family: 'sans-serif'
|
| 578 |
},
|
| 579 |
+
padding: 20,
|
| 580 |
+
usePointStyle: true,
|
| 581 |
+
pointStyle: 'circle'
|
| 582 |
}
|
| 583 |
},
|
| 584 |
tooltip: {
|
|
|
|
| 590 |
const percentage = Math.round((value / total) * 100);
|
| 591 |
return `${label}: ${value}g (${percentage}%)`;
|
| 592 |
}
|
| 593 |
+
},
|
| 594 |
+
bodyFont: {
|
| 595 |
+
size: 14
|
| 596 |
+
},
|
| 597 |
+
titleFont: {
|
| 598 |
+
size: 16,
|
| 599 |
+
weight: 'bold'
|
| 600 |
}
|
| 601 |
}
|
| 602 |
},
|
| 603 |
+
cutout: '70%',
|
| 604 |
+
animation: {
|
| 605 |
+
animateScale: true,
|
| 606 |
+
animateRotate: true
|
| 607 |
+
}
|
| 608 |
}
|
| 609 |
});
|
| 610 |
}
|