Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- index.html +587 -689
index.html
CHANGED
|
@@ -1,703 +1,601 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
|
| 4 |
<head>
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
background: #2563eb10;
|
| 243 |
-
border-radius: 40px;
|
| 244 |
-
padding: 4px 12px;
|
| 245 |
-
font-size: 0.75rem;
|
| 246 |
-
font-weight: 600;
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
hr {
|
| 250 |
-
margin: 20px 0;
|
| 251 |
-
border-color: #e2e8f0;
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
.biome-tag {
|
| 255 |
-
background: #e2e8f0;
|
| 256 |
-
border-radius: 20px;
|
| 257 |
-
padding: 2px 8px;
|
| 258 |
-
font-size: 0.7rem;
|
| 259 |
-
display: inline-block;
|
| 260 |
-
margin-left: 8px;
|
| 261 |
-
}
|
| 262 |
-
|
| 263 |
-
.food-panel {
|
| 264 |
-
background: white;
|
| 265 |
-
border-radius: 24px;
|
| 266 |
-
margin: 16px 0 24px 0;
|
| 267 |
-
padding: 16px;
|
| 268 |
-
border: 1px solid #cbd5e1;
|
| 269 |
-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
|
| 270 |
-
transition: all 0.3s ease;
|
| 271 |
-
max-height: 500px;
|
| 272 |
-
overflow: hidden;
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
.food-panel.hidden {
|
| 276 |
-
display: none;
|
| 277 |
-
}
|
| 278 |
-
|
| 279 |
-
.food-search {
|
| 280 |
-
width: 100%;
|
| 281 |
-
margin-bottom: 12px;
|
| 282 |
-
}
|
| 283 |
-
|
| 284 |
-
.food-list {
|
| 285 |
-
max-height: 300px;
|
| 286 |
-
overflow-y: auto;
|
| 287 |
-
border: 1px solid #e2e8f0;
|
| 288 |
-
border-radius: 16px;
|
| 289 |
-
padding: 8px;
|
| 290 |
-
background: #fafcff;
|
| 291 |
-
}
|
| 292 |
-
|
| 293 |
-
.food-item {
|
| 294 |
-
display: flex;
|
| 295 |
-
align-items: center;
|
| 296 |
-
gap: 8px;
|
| 297 |
-
padding: 6px 8px;
|
| 298 |
-
border-bottom: 1px solid #eef2ff;
|
| 299 |
-
font-size: 0.85rem;
|
| 300 |
-
transition: background 0.2s;
|
| 301 |
-
}
|
| 302 |
-
|
| 303 |
-
.food-item:hover {
|
| 304 |
-
background: #f1f5f9;
|
| 305 |
-
}
|
| 306 |
-
|
| 307 |
-
.food-item input {
|
| 308 |
-
width: auto;
|
| 309 |
-
margin: 0;
|
| 310 |
-
transform: scale(1.1);
|
| 311 |
-
cursor: pointer;
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
.food-item .food-name {
|
| 315 |
-
flex: 1;
|
| 316 |
-
font-weight: 500;
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
.food-item .food-stats {
|
| 320 |
-
font-size: 0.7rem;
|
| 321 |
-
color: #64748b;
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
.global-check {
|
| 325 |
-
display: flex;
|
| 326 |
-
align-items: center;
|
| 327 |
-
gap: 12px;
|
| 328 |
-
margin-bottom: 12px;
|
| 329 |
-
padding: 8px;
|
| 330 |
-
background: #f1f5f9;
|
| 331 |
-
border-radius: 40px;
|
| 332 |
-
}
|
| 333 |
-
|
| 334 |
-
.global-check label {
|
| 335 |
-
margin: 0;
|
| 336 |
-
font-size: 0.85rem;
|
| 337 |
-
cursor: pointer;
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
.global-check input {
|
| 341 |
-
width: 18px;
|
| 342 |
-
height: 18px;
|
| 343 |
-
margin: 0;
|
| 344 |
-
}
|
| 345 |
-
|
| 346 |
-
.plan-counter {
|
| 347 |
-
background: #e2e8f0;
|
| 348 |
-
border-radius: 40px;
|
| 349 |
-
padding: 4px 12px;
|
| 350 |
-
font-size: 0.75rem;
|
| 351 |
-
font-weight: 600;
|
| 352 |
-
display: inline-block;
|
| 353 |
-
margin-top: 8px;
|
| 354 |
-
}
|
| 355 |
-
|
| 356 |
-
.perfect-badge {
|
| 357 |
-
background: #22c55e;
|
| 358 |
-
color: white;
|
| 359 |
-
padding: 4px 12px;
|
| 360 |
-
border-radius: 40px;
|
| 361 |
-
font-size: 0.75rem;
|
| 362 |
-
font-weight: bold;
|
| 363 |
-
}
|
| 364 |
-
|
| 365 |
-
.nutrition-summary {
|
| 366 |
-
display: grid;
|
| 367 |
-
grid-template-columns: repeat(4, 1fr);
|
| 368 |
-
gap: 8px;
|
| 369 |
-
margin-bottom: 12px;
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
.nutrition-box {
|
| 373 |
-
text-align: center;
|
| 374 |
-
padding: 8px;
|
| 375 |
-
border-radius: 12px;
|
| 376 |
-
font-size: 0.8rem;
|
| 377 |
-
font-weight: 600;
|
| 378 |
-
transition: transform 0.2s;
|
| 379 |
-
}
|
| 380 |
-
|
| 381 |
-
.nutrition-box:hover {
|
| 382 |
-
transform: scale(1.05);
|
| 383 |
-
}
|
| 384 |
-
|
| 385 |
-
.nutrition-box.carbs {
|
| 386 |
-
background: #fee2e2;
|
| 387 |
-
color: #991b1b;
|
| 388 |
-
}
|
| 389 |
-
|
| 390 |
-
.nutrition-box.protein {
|
| 391 |
-
background: #ffedd5;
|
| 392 |
-
color: #9a3412;
|
| 393 |
-
}
|
| 394 |
-
|
| 395 |
-
.nutrition-box.fat {
|
| 396 |
-
background: #fef9c3;
|
| 397 |
-
color: #854d0e;
|
| 398 |
-
}
|
| 399 |
-
|
| 400 |
-
.nutrition-box.vitamins {
|
| 401 |
-
background: #dcfce7;
|
| 402 |
-
color: #166534;
|
| 403 |
-
}
|
| 404 |
-
|
| 405 |
-
.calorie-progress {
|
| 406 |
-
margin-top: 12px;
|
| 407 |
-
background: #e2e8f0;
|
| 408 |
-
border-radius: 20px;
|
| 409 |
-
height: 24px;
|
| 410 |
-
overflow: hidden;
|
| 411 |
-
position: relative;
|
| 412 |
-
}
|
| 413 |
-
|
| 414 |
-
.calorie-progress-bar {
|
| 415 |
-
height: 100%;
|
| 416 |
-
background: linear-gradient(90deg, #22c55e, #16a34a);
|
| 417 |
-
border-radius: 20px;
|
| 418 |
-
transition: width 0.5s ease;
|
| 419 |
-
}
|
| 420 |
-
|
| 421 |
-
.calorie-progress-text {
|
| 422 |
-
position: absolute;
|
| 423 |
-
top: 50%;
|
| 424 |
-
left: 50%;
|
| 425 |
-
transform: translate(-50%, -50%);
|
| 426 |
-
font-size: 0.75rem;
|
| 427 |
-
font-weight: 600;
|
| 428 |
-
color: #1e293b;
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
-
.food-stats-header {
|
| 432 |
-
display: flex;
|
| 433 |
-
justify-content: space-between;
|
| 434 |
-
font-size: 0.7rem;
|
| 435 |
-
color: #64748b;
|
| 436 |
-
margin-bottom: 8px;
|
| 437 |
-
}
|
| 438 |
-
|
| 439 |
-
.food-item-details {
|
| 440 |
-
display: flex;
|
| 441 |
-
gap: 8px;
|
| 442 |
-
font-size: 0.65rem;
|
| 443 |
-
color: #64748b;
|
| 444 |
-
}
|
| 445 |
-
|
| 446 |
-
.food-item-details span {
|
| 447 |
-
display: flex;
|
| 448 |
-
align-items: center;
|
| 449 |
-
gap: 2px;
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
@media (max-width: 800px) {
|
| 453 |
-
.results-area {
|
| 454 |
-
grid-template-columns: 1fr;
|
| 455 |
-
}
|
| 456 |
-
|
| 457 |
-
.eco-container {
|
| 458 |
-
padding: 18px;
|
| 459 |
-
}
|
| 460 |
-
|
| 461 |
-
.nutrition-summary {
|
| 462 |
-
grid-template-columns: repeat(2, 1fr);
|
| 463 |
-
}
|
| 464 |
-
}
|
| 465 |
-
</style>
|
| 466 |
</head>
|
| 467 |
-
|
| 468 |
<body>
|
| 469 |
-
<div class="eco-container">
|
| 470 |
-
<div class="header-brand">
|
| 471 |
-
<h1>🌾 ECO: Perfect Balance Meal Planner <small>1:1:1:1 | Whole Servings Only | Max Calories</small></h1>
|
| 472 |
-
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">Built with anycoder ↗</a>
|
| 473 |
-
</div>
|
| 474 |
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
<
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
<
|
| 481 |
-
<
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
</div>
|
| 525 |
|
| 526 |
-
<
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
<div id="foodPanel" class="food-panel hidden">
|
| 533 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
| 534 |
-
<h3 style="margin:0;">🍽️ Active Food Database</h3>
|
| 535 |
-
<span style="font-size:0.7rem;">Check foods to include in meal plans</span>
|
| 536 |
-
</div>
|
| 537 |
-
<div class="food-search">
|
| 538 |
-
<input type="text" id="foodSearch" placeholder="🔍 Search food...">
|
| 539 |
-
</div>
|
| 540 |
-
<div class="global-check">
|
| 541 |
-
<input type="checkbox" id="toggleAllFoods" checked>
|
| 542 |
-
<label for="toggleAllFoods">✔️ Enable / Disable All Foods</label>
|
| 543 |
-
</div>
|
| 544 |
-
<div class="food-stats-header">
|
| 545 |
-
<span>Selected: <strong id="selectedCount">0</strong> foods</span>
|
| 546 |
-
<span>Total available: <strong id="totalCount">0</strong></span>
|
| 547 |
-
</div>
|
| 548 |
-
<div id="foodListContainer" class="food-list"></div>
|
| 549 |
-
</div>
|
| 550 |
-
|
| 551 |
-
<div class="results-area">
|
| 552 |
-
<div class="stat-card">
|
| 553 |
-
<h3>📊 NUTRIENT BALANCE STATUS</h3>
|
| 554 |
-
<div class="nutrition-summary" id="nutritionSummary">
|
| 555 |
-
<div class="nutrition-box carbs">Carbs: <span id="dispCarbs">0</span></div>
|
| 556 |
-
<div class="nutrition-box protein">Protein: <span id="dispProtein">0</span></div>
|
| 557 |
-
<div class="nutrition-box fat">Fat: <span id="dispFat">0</span></div>
|
| 558 |
-
<div class="nutrition-box vitamins">Vitamins: <span id="dispVitamins">0</span></div>
|
| 559 |
-
</div>
|
| 560 |
-
|
| 561 |
-
<div class="calorie-progress">
|
| 562 |
-
<div class="calorie-progress-bar" id="calorieBar" style="width: 0%"></div>
|
| 563 |
-
<div class="calorie-progress-text" id="calorieText">0 / 3000 cal</div>
|
| 564 |
-
</div>
|
| 565 |
-
|
| 566 |
-
<div id="algebraBox" class="math-note"></div>
|
| 567 |
-
<div class="meal-plan">
|
| 568 |
-
<h4>🍽️ MEAL PLAN <span id="planCounter" class="plan-counter">—</span></h4>
|
| 569 |
-
<div id="mealList">✨ Click "Optimal Plan" to generate perfectly balanced suggestions</div>
|
| 570 |
-
<div id="balanceQuality" style="margin-top: 12px;"></div>
|
| 571 |
-
<div id="calorieInfo" style="margin-top: 8px; font-size:0.85rem;"></div>
|
| 572 |
</div>
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
<h3>🥧 CURRENT NUTRIENTS</h3>
|
| 577 |
-
<canvas id="beforeChart" width="280" height="280" style="width:100%; max-width:280px; height:auto;"></canvas>
|
| 578 |
-
<div><span class="badge">🔴 Carbs</span> <span class="badge">🟠 Protein</span>
|
| 579 |
-
<span class="badge">🟡 Fat</span> <span class="badge">🟢 Vitamins</span>
|
| 580 |
-
</div>
|
| 581 |
</div>
|
| 582 |
-
<div class="
|
| 583 |
-
|
| 584 |
-
<canvas id="afterChart" width="280" height="280" style="width:100%; max-width:280px; height:auto;"></canvas>
|
| 585 |
-
<div><span class="perfect-badge">✓ PERFECT BALANCE TARGET</span></div>
|
| 586 |
</div>
|
| 587 |
-
</div>
|
| 588 |
</div>
|
| 589 |
-
|
| 590 |
|
| 591 |
-
|
| 592 |
-
// ====================
|
| 593 |
const RAW_FOODS = [
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
|
|
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 6 |
+
<title>Eco — 1:1:1:1 Exact Equality Meal Planner</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary: #2563eb;
|
| 10 |
+
--primary-dark: #1d4ed8;
|
| 11 |
+
--accent: #eab308;
|
| 12 |
+
--success: #22c55e;
|
| 13 |
+
--bg-gradient: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
|
| 14 |
+
--card-bg: #ffffff;
|
| 15 |
+
--text-main: #1e293b;
|
| 16 |
+
--text-sub: #475569;
|
| 17 |
+
--border-radius: 24px;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
* { box-sizing: border-box; transition: all 0.2s ease; }
|
| 21 |
+
|
| 22 |
+
body {
|
| 23 |
+
background: var(--bg-gradient);
|
| 24 |
+
font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
|
| 25 |
+
margin: 0;
|
| 26 |
+
padding: 24px 16px;
|
| 27 |
+
min-height: 100vh;
|
| 28 |
+
color: var(--text-main);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.container {
|
| 32 |
+
max-width: 1400px;
|
| 33 |
+
margin: 0 auto;
|
| 34 |
+
background: var(--card-bg);
|
| 35 |
+
border-radius: var(--border-radius);
|
| 36 |
+
box-shadow: 0 30px 50px -12px rgba(0, 0, 0, 0.4);
|
| 37 |
+
overflow: hidden;
|
| 38 |
+
display: flex;
|
| 39 |
+
flex-direction: column;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
header {
|
| 43 |
+
padding: 24px 32px;
|
| 44 |
+
border-bottom: 1px solid #e2e8f0;
|
| 45 |
+
background: #f8fafc;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
h1 { font-size: 1.8rem; margin: 0; color: var(--text-main); display: flex; align-items: center; gap: 12px; }
|
| 49 |
+
h1 small { font-size: 0.85rem; font-weight: normal; color: var(--text-sub); text-transform: uppercase; letter-spacing: 1px; }
|
| 50 |
+
|
| 51 |
+
.footer-link {
|
| 52 |
+
margin-left: auto;
|
| 53 |
+
font-size: 0.75rem;
|
| 54 |
+
color: var(--text-sub);
|
| 55 |
+
text-decoration: none;
|
| 56 |
+
font-weight: 600;
|
| 57 |
+
}
|
| 58 |
+
.footer-link:hover { color: var(--primary); text-decoration: underline; }
|
| 59 |
+
|
| 60 |
+
.main-content {
|
| 61 |
+
display: grid;
|
| 62 |
+
grid-template-columns: 380px 1fr;
|
| 63 |
+
gap: 0;
|
| 64 |
+
min-height: 600px;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/* Sidebar Inputs */
|
| 68 |
+
.sidebar {
|
| 69 |
+
background: #f1f5f9;
|
| 70 |
+
padding: 24px;
|
| 71 |
+
border-right: 1px solid #e2e8f0;
|
| 72 |
+
overflow-y: auto;
|
| 73 |
+
height: 100%;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.input-group { margin-bottom: 20px; }
|
| 77 |
+
.input-group h3 { font-size: 0.85rem; text-transform: uppercase; color: var(--text-sub); margin-bottom: 12px; letter-spacing: 0.5px; }
|
| 78 |
+
|
| 79 |
+
.control-row { margin-bottom: 16px; }
|
| 80 |
+
label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; color: var(--text-main); }
|
| 81 |
+
input[type="number"], select {
|
| 82 |
+
width: 100%;
|
| 83 |
+
padding: 10px 12px;
|
| 84 |
+
border: 1px solid #cbd5e1;
|
| 85 |
+
border-radius: 12px;
|
| 86 |
+
font-size: 0.9rem;
|
| 87 |
+
background: white;
|
| 88 |
+
outline: none;
|
| 89 |
+
}
|
| 90 |
+
input[type="number"]:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
|
| 91 |
+
|
| 92 |
+
.checkbox-wrapper { display: flex; align-items: center; gap: 10px; margin-top: 8px; cursor: pointer; }
|
| 93 |
+
.checkbox-wrapper input { width: auto; accent-color: var(--primary); transform: scale(1.2); }
|
| 94 |
+
.checkbox-wrapper span { font-size: 0.85rem; color: var(--text-sub); }
|
| 95 |
+
|
| 96 |
+
.btn-group { display: flex; flex-direction: column; gap: 12px; margin-top: 30px; border-top: 2px solid #e2e8f0; padding-top: 20px; }
|
| 97 |
+
button {
|
| 98 |
+
width: 100%;
|
| 99 |
+
padding: 14px;
|
| 100 |
+
border: none;
|
| 101 |
+
border-radius: 14px;
|
| 102 |
+
font-weight: 700;
|
| 103 |
+
font-size: 0.95rem;
|
| 104 |
+
cursor: pointer;
|
| 105 |
+
display: flex;
|
| 106 |
+
align-items: center;
|
| 107 |
+
justify-content: center;
|
| 108 |
+
gap: 8px;
|
| 109 |
+
transition: transform 0.1s, box-shadow 0.2s;
|
| 110 |
+
}
|
| 111 |
+
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
|
| 112 |
+
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
|
| 113 |
+
.btn-secondary { background: white; color: var(--text-main); border: 2px solid #cbd5e1; }
|
| 114 |
+
.btn-secondary:hover { background: #f1f5f9; border-color: var(--text-sub); }
|
| 115 |
+
.btn-success { background: var(--success); color: white; box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
|
| 116 |
+
.btn-success:hover { background: #16a34a; transform: translateY(-1px); }
|
| 117 |
+
|
| 118 |
+
/* Main Results Area */
|
| 119 |
+
.dashboard {
|
| 120 |
+
padding: 32px;
|
| 121 |
+
display: flex;
|
| 122 |
+
flex-direction: column;
|
| 123 |
+
gap: 24px;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.stats-bar {
|
| 127 |
+
display: grid;
|
| 128 |
+
grid-template-columns: repeat(4, 1fr);
|
| 129 |
+
gap: 16px;
|
| 130 |
+
background: #fff;
|
| 131 |
+
padding: 20px;
|
| 132 |
+
border-radius: 20px;
|
| 133 |
+
border: 1px solid #e2e8f0;
|
| 134 |
+
text-align: center;
|
| 135 |
+
}
|
| 136 |
+
.stat-box h4 { font-size: 0.75rem; text-transform: uppercase; color: var(--text-sub); margin: 0; }
|
| 137 |
+
.stat-box .val { font-size: 2rem; font-weight: 800; margin: 8px 0; }
|
| 138 |
+
.stat-carbs { color: #ef4444; border-bottom: 3px solid #ef4444; }
|
| 139 |
+
.stat-protein { color: #f97316; border-bottom: 3px solid #f97316; }
|
| 140 |
+
.stat-fat { color: #eab308; border-bottom: 3px solid #eab308; }
|
| 141 |
+
.stat-vitamins { color: #22c55e; border-bottom: 3px solid #22c55e; }
|
| 142 |
+
|
| 143 |
+
.chart-section {
|
| 144 |
+
display: grid;
|
| 145 |
+
grid-template-columns: 1fr 1fr;
|
| 146 |
+
gap: 24px;
|
| 147 |
+
align-items: center;
|
| 148 |
+
}
|
| 149 |
+
.chart-panel {
|
| 150 |
+
background: white;
|
| 151 |
+
padding: 20px;
|
| 152 |
+
border-radius: 24px;
|
| 153 |
+
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
|
| 154 |
+
text-align: center;
|
| 155 |
+
}
|
| 156 |
+
.chart-title { font-weight: 700; margin-bottom: 16px; color: var(--text-main); }
|
| 157 |
+
canvas { max-width: 100%; height: auto; }
|
| 158 |
+
|
| 159 |
+
.meal-planner {
|
| 160 |
+
background: #fefce8;
|
| 161 |
+
border: 2px solid #fde047;
|
| 162 |
+
border-radius: 24px;
|
| 163 |
+
padding: 24px;
|
| 164 |
+
position: relative;
|
| 165 |
+
}
|
| 166 |
+
.meal-planner::before {
|
| 167 |
+
content: "🎯 OPTIMAL 1:1:1:1 MEAL PLAN";
|
| 168 |
+
position: absolute;
|
| 169 |
+
top: -16px;
|
| 170 |
+
left: 20px;
|
| 171 |
+
background: #fde047;
|
| 172 |
+
padding: 0 12px;
|
| 173 |
+
font-weight: 800;
|
| 174 |
+
font-size: 0.8rem;
|
| 175 |
+
color: #854d0e;
|
| 176 |
+
border-radius: 12px;
|
| 177 |
+
}
|
| 178 |
+
.meal-list {
|
| 179 |
+
display: flex;
|
| 180 |
+
flex-direction: column;
|
| 181 |
+
gap: 12px;
|
| 182 |
+
max-height: 300px;
|
| 183 |
+
overflow-y: auto;
|
| 184 |
+
padding-right: 8px;
|
| 185 |
+
}
|
| 186 |
+
.meal-item {
|
| 187 |
+
background: white;
|
| 188 |
+
padding: 12px 16px;
|
| 189 |
+
border-radius: 16px;
|
| 190 |
+
display: flex;
|
| 191 |
+
justify-content: space-between;
|
| 192 |
+
align-items: center;
|
| 193 |
+
border-left: 4px solid var(--primary);
|
| 194 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 195 |
+
}
|
| 196 |
+
.meal-details { display: flex; flex-direction: column; gap: 4px; }
|
| 197 |
+
.meal-name { font-weight: 700; font-size: 1.1rem; color: var(--text-main); }
|
| 198 |
+
.meal-nutrients { font-size: 0.8rem; font-family: monospace; color: var(--text-sub); }
|
| 199 |
+
.meal-count { font-weight: 700; background: var(--primary); color: white; padding: 4px 10px; border-radius: 20px; font-size: 0.85rem; }
|
| 200 |
+
|
| 201 |
+
.math-note {
|
| 202 |
+
background: #eef2ff;
|
| 203 |
+
padding: 16px;
|
| 204 |
+
border-radius: 16px;
|
| 205 |
+
font-family: 'Courier New', monospace;
|
| 206 |
+
font-size: 0.9rem;
|
| 207 |
+
color: #3730a3;
|
| 208 |
+
margin-top: 10px;
|
| 209 |
+
border-left: 5px solid var(--primary);
|
| 210 |
+
}
|
| 211 |
+
.math-note strong { color: var(--primary-dark); }
|
| 212 |
+
|
| 213 |
+
/* Food Selector Panel */
|
| 214 |
+
.food-panel {
|
| 215 |
+
position: sticky;
|
| 216 |
+
bottom: 0;
|
| 217 |
+
left: 0;
|
| 218 |
+
width: 100%;
|
| 219 |
+
background: white;
|
| 220 |
+
border-top: 1px solid #cbd5e1;
|
| 221 |
+
padding: 16px;
|
| 222 |
+
display: none; /* Hidden by default */
|
| 223 |
+
animation: slideUp 0.3s ease;
|
| 224 |
+
}
|
| 225 |
+
.food-panel.active { display: block; }
|
| 226 |
+
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
|
| 227 |
+
|
| 228 |
+
.food-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
|
| 229 |
+
.food-search { display: flex; gap: 10px; margin-bottom: 12px; }
|
| 230 |
+
.food-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto; padding: 8px; background: #f8fafc; border-radius: 12px; }
|
| 231 |
+
.food-item { display: flex; align-items: center; gap: 8px; padding: 6px; background: white; border-radius: 8px; border: 1px solid #e2e8f0; font-size: 0.8rem; }
|
| 232 |
+
.food-item input { width: auto; margin: 0; }
|
| 233 |
+
|
| 234 |
+
@media (max-width: 900px) {
|
| 235 |
+
.main-content { grid-template-columns: 1fr; }
|
| 236 |
+
.sidebar { border-right: none; border-bottom: 1px solid #e2e8f0; }
|
| 237 |
+
.stats-bar { grid-template-columns: 1fr 1fr; }
|
| 238 |
+
.chart-section { grid-template-columns: 1fr; }
|
| 239 |
+
}
|
| 240 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
</head>
|
|
|
|
| 242 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
|
| 244 |
+
<div class="container">
|
| 245 |
+
<header>
|
| 246 |
+
<h1>
|
| 247 |
+
🌾 ECO Planner
|
| 248 |
+
<small>1:1:1:1 Exact Equality Engine</small>
|
| 249 |
+
</h1>
|
| 250 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="footer-link">Built with anycoder</a>
|
| 251 |
+
</header>
|
| 252 |
+
|
| 253 |
+
<div class="main-content">
|
| 254 |
+
<!-- Sidebar Controls -->
|
| 255 |
+
<aside class="sidebar">
|
| 256 |
+
<div class="input-group">
|
| 257 |
+
<h3>👤 Player Status</h3>
|
| 258 |
+
<div class="control-row">
|
| 259 |
+
<label>Current Calories</label>
|
| 260 |
+
<input type="number" id="curCalories" value="1200" min="0">
|
| 261 |
+
</div>
|
| 262 |
+
<div class="control-row">
|
| 263 |
+
<label>Max Calories Capacity</label>
|
| 264 |
+
<input type="number" id="maxCalories" value="3000" min="1000">
|
| 265 |
+
</div>
|
| 266 |
+
<div class="checkbox-wrapper">
|
| 267 |
+
<input type="checkbox" id="ignoreCalorieLimit">
|
| 268 |
+
<span>Ignore Calorie Limit (Unlimited Mode)</span>
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
+
|
| 272 |
+
<div class="input-group">
|
| 273 |
+
<h3>⚖️ Current Nutrients (Base)</h3>
|
| 274 |
+
<div class="control-row">
|
| 275 |
+
<label>🍞 Carbs (C)</label>
|
| 276 |
+
<input type="number" id="carbs" value="8" step="1">
|
| 277 |
+
</div>
|
| 278 |
+
<div class="control-row">
|
| 279 |
+
<label>🍗 Protein (P)</label>
|
| 280 |
+
<input type="number" id="protein" value="12" step="1">
|
| 281 |
+
</div>
|
| 282 |
+
<div class="control-row">
|
| 283 |
+
<label>🧈 Fat (F)</label>
|
| 284 |
+
<input type="number" id="fat" value="6" step="1">
|
| 285 |
+
</div>
|
| 286 |
+
<div class="control-row">
|
| 287 |
+
<label>🥕 Vitamins (V)</label>
|
| 288 |
+
<input type="number" id="vitamins" value="14" step="1">
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
|
| 292 |
+
<div class="input-group">
|
| 293 |
+
<h3>🍽️ Filters</h3>
|
| 294 |
+
|
| 295 |
+
<div class="control-row">
|
| 296 |
+
<label>Player Tier / Skill</label>
|
| 297 |
+
<select id="tier">
|
| 298 |
+
<option value="all">🌟 All Foods Available</option>
|
| 299 |
+
<option value="starter">🌱 Starter (Easy)</option>
|
| 300 |
+
<option value="campfire">🔥 Campfire Cook</option>
|
| 301 |
+
<option value="gatherer">🍄 Gatherer (Raw/Basic)</option>
|
| 302 |
+
<option value="baked">🍞 Baked Specialist</option>
|
| 303 |
+
<option value="cooked">🍲 Cooked Specialist</option>
|
| 304 |
+
<option value="advanced">🏆 Advanced Chef</option>
|
| 305 |
+
</select>
|
| 306 |
+
</div>
|
| 307 |
+
|
| 308 |
+
<div class="control-row">
|
| 309 |
+
<label>Preferred Biome</label>
|
| 310 |
+
<select id="biomeFilter">
|
| 311 |
+
<option value="all">🌍 Any Biome</option>
|
| 312 |
+
<option value="forest">🌲 Forest</option>
|
| 313 |
+
<option value="grassland">🌾 Grassland</option>
|
| 314 |
+
<option value="desert">🏜️ Desert</option>
|
| 315 |
+
<option value="rainforest">🌧️ Rainforest</option>
|
| 316 |
+
<option value="aquatic">💧 Aquatic</option>
|
| 317 |
+
</select>
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
<div class="checkbox-wrapper">
|
| 321 |
+
<input type="checkbox" id="disableTierFilter" checked>
|
| 322 |
+
<span>Disable Tier Filter</span>
|
| 323 |
+
</div>
|
| 324 |
+
<div class="checkbox-wrapper">
|
| 325 |
+
<input type="checkbox" id="disableBiomeFilter" checked>
|
| 326 |
+
<span>Disable Biome Filter</span>
|
| 327 |
+
</div>
|
| 328 |
+
</div>
|
| 329 |
+
|
| 330 |
+
<div class="btn-group">
|
| 331 |
+
<button id="toggleFoodPanelBtn" class="btn-secondary">📋 Edit Food Database</button>
|
| 332 |
+
<button id="randomizeBtn" class="btn-secondary">🎲 Random Balanced Plan</button>
|
| 333 |
+
<button id="calculateBtn" class="btn-primary">⚖️ CALCULATE PERFECT BALANCE</button>
|
| 334 |
+
</div>
|
| 335 |
+
</aside>
|
| 336 |
+
|
| 337 |
+
<!-- Main Dashboard -->
|
| 338 |
+
<main class="dashboard">
|
| 339 |
+
|
| 340 |
+
<!-- Current Stats Header -->
|
| 341 |
+
<div class="stats-bar">
|
| 342 |
+
<div class="stat-box stat-carbs">
|
| 343 |
+
<h4>Current Carbs</h4>
|
| 344 |
+
<div class="val" id="dispCurC">8</div>
|
| 345 |
+
</div>
|
| 346 |
+
<div class="stat-box stat-protein">
|
| 347 |
+
<h4>Current Protein</h4>
|
| 348 |
+
<div class="val" id="dispCurP">12</div>
|
| 349 |
+
</div>
|
| 350 |
+
<div class="stat-box stat-fat">
|
| 351 |
+
<h4>Current Fat</h4>
|
| 352 |
+
<div class="val" id="dispCurF">6</div>
|
| 353 |
+
</div>
|
| 354 |
+
<div class="stat-box stat-vitamins">
|
| 355 |
+
<h4>Current Vitamins</h4>
|
| 356 |
+
<div class="val" id="dispCurV">14</div>
|
| 357 |
+
</div>
|
| 358 |
+
</div>
|
| 359 |
+
|
| 360 |
+
<!-- Charts Section -->
|
| 361 |
+
<div class="chart-section">
|
| 362 |
+
<div class="chart-panel">
|
| 363 |
+
<div class="chart-title">Current Nutrient Status</div>
|
| 364 |
+
<canvas id="beforeChart" width="300" height="300"></canvas>
|
| 365 |
+
</div>
|
| 366 |
+
<div class="chart-panel">
|
| 367 |
+
<div class="chart-title">Target: 1:1:1:1 Equality</div>
|
| 368 |
+
<canvas id="afterChart" width="300" height="300"></canvas>
|
| 369 |
+
</div>
|
| 370 |
+
</div>
|
| 371 |
+
|
| 372 |
+
<!-- Meal Plan Output -->
|
| 373 |
+
<div class="meal-planner">
|
| 374 |
+
<h3 style="margin-top:0; font-size:1.2rem;">Generated Meal Plan</h3>
|
| 375 |
+
<div id="mealListContainer" class="meal-list">
|
| 376 |
+
<div style="text-align:center; padding: 40px 0; color: #94a3b8;">
|
| 377 |
+
Click "Calculate Perfect Balance" to generate a meal plan that equalizes all nutrients exactly.
|
| 378 |
+
</div>
|
| 379 |
+
</div>
|
| 380 |
+
|
| 381 |
+
<div id="mathNote" class="math-note">
|
| 382 |
+
<strong>🧮 ALGORITHM STATUS:</strong> <br>
|
| 383 |
+
Waiting for calculation...
|
| 384 |
+
</div>
|
| 385 |
+
|
| 386 |
+
<div style="display:flex; justify-content:space-between; margin-top:10px; font-size:0.9rem; color:var(--text-sub);">
|
| 387 |
+
<span id="calorieSummary">Calorie Budget: 1200 / 3000</span>
|
| 388 |
+
<span id="planCounter" style="font-weight:bold; color:var(--primary);">Plan 1 of 1</span>
|
| 389 |
+
</div>
|
| 390 |
+
</div>
|
| 391 |
+
|
| 392 |
+
</main>
|
| 393 |
</div>
|
| 394 |
|
| 395 |
+
<!-- Food Selector Panel -->
|
| 396 |
+
<div id="foodPanel" class="food-panel">
|
| 397 |
+
<div class="food-header">
|
| 398 |
+
<h3>🍽️ Active Food Database</h3>
|
| 399 |
+
<button onclick="document.getElementById('foodPanel').classList.remove('active')" style="padding: 4px 12px; font-size: 0.8rem;">Close</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
</div>
|
| 401 |
+
<div class="food-search">
|
| 402 |
+
<input type="text" id="foodSearch" placeholder="Search food by name..." style="flex:1;">
|
| 403 |
+
<button id="selectAllBtn" style="padding: 8px 16px; font-size: 0.8rem; background: #cbd5e1;">Select All</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
</div>
|
| 405 |
+
<div id="foodListContainer" class="food-list">
|
| 406 |
+
<!-- Food items injected here -->
|
|
|
|
|
|
|
| 407 |
</div>
|
|
|
|
| 408 |
</div>
|
| 409 |
+
</div>
|
| 410 |
|
| 411 |
+
<script>
|
| 412 |
+
// ==================== DATA & CONSTANTS ====================
|
| 413 |
const RAW_FOODS = [
|
| 414 |
+
{ name: "Heart Of Palm", carbs:4, protein:2, fat:0, vitamins:2, cal:100, tier:"gatherer", biomes:["rainforest","forest"] },
|
| 415 |
+
{ name: "Bolete Mushrooms", carbs:2, protein:4, fat:1, vitamins:1, cal:200, tier:"gatherer", biomes:["forest"] },
|
| 416 |
+
{ name: "Leavened Dough", carbs:6, protein:18, fat:13, vitamins:5, cal:10, tier:"advanced", biomes:["any"] },
|
| 417 |
+
{ name: "Charred Taro", carbs:10, protein:1, fat:0, vitamins:1, cal:350, tier:"campfire", biomes:["rainforest","forest"] },
|
| 418 |
+
{ name: "Taro Root", carbs:6, protein:1, fat:0, vitamins:1, cal:250, tier:"gatherer", biomes:["rainforest","forest"] },
|
| 419 |
+
{ name: "Baked Agave", carbs:14, protein:2, fat:4, vitamins:8, cal:700, tier:"baked", biomes:["desert"] },
|
| 420 |
+
{ name: "Huckleberries", carbs:2, protein:0, fat:0, vitamins:6, cal:150, tier:"gatherer", biomes:["forest"] },
|
| 421 |
+
{ name: "Pupusas", carbs:6, protein:11, fat:9, vitamins:14, cal:900, tier:"advanced", biomes:["any"] },
|
| 422 |
+
{ name: "Vegetable Medley", carbs:8, protein:4, fat:7, vitamins:17, cal:900, tier:"cooked", biomes:["any"] },
|
| 423 |
+
{ name: "Huckleberry Fritter", carbs:16, protein:0, fat:20, vitamins:8, cal:900, tier:"baked", biomes:["forest"] },
|
| 424 |
+
{ name: "Baked Heart Of Palm", carbs:12, protein:6, fat:4, vitamins:6, cal:700, tier:"baked", biomes:["rainforest"] },
|
| 425 |
+
{ name: "Camas Bulb Bake", carbs:12, protein:7, fat:5, vitamins:4, cal:700, tier:"baked", biomes:["grassland"] },
|
| 426 |
+
{ name: "Pineapple", carbs:6, protein:0, fat:0, vitamins:2, cal:200, tier:"gatherer", biomes:["rainforest"] },
|
| 427 |
+
{ name: "Basic Salad", carbs:18, protein:6, fat:4, vitamins:10, cal:800, tier:"starter", biomes:["any"] },
|
| 428 |
+
{ name: "Scrap Meat", carbs:0, protein:5, fat:5, vitamins:0, cal:50, tier:"starter", biomes:["any"] },
|
| 429 |
+
{ name: "Charred Sausage", carbs:0, protein:10, fat:14, vitamins:0, cal:700, tier:"campfire", biomes:["any"] },
|
| 430 |
+
{ name: "Clam Chowder", carbs:16, protein:15, fat:3, vitamins:11, cal:800, tier:"cooked", biomes:["aquatic"] },
|
| 431 |
+
{ name: "Wild Stew", carbs:10, protein:2, fat:6, vitamins:12, cal:1100, tier:"cooked", biomes:["forest"] },
|
| 432 |
+
{ name: "Fried Vegetables", carbs:11, protein:3, fat:8, vitamins:2, cal:560, tier:"cooked", biomes:["any"] },
|
| 433 |
+
{ name: "Tasty Tropical Pizza", carbs:21, protein:6, fat:12, vitamins:11, cal:1200, tier:"advanced", biomes:["rainforest"] },
|
| 434 |
+
{ name: "Meat Pie", carbs:18, protein:4, fat:20, vitamins:2, cal:1300, tier:"baked", biomes:["any"] },
|
| 435 |
+
{ name: "Fireweed Shoots", carbs:3, protein:1, fat:0, vitamins:4, cal:150, tier:"gatherer", biomes:["grassland"] },
|
| 436 |
+
{ name: "Crimson Salad", carbs:13, protein:7, fat:8, vitamins:28, cal:1200, tier:"advanced", biomes:["any"] },
|
| 437 |
+
{ name: "Baked Tomato", carbs:16, protein:1, fat:5, vitamins:6, cal:700, tier:"baked", biomes:["grassland"] },
|
| 438 |
+
{ name: "Corn Fritters", carbs:13, protein:4, fat:22, vitamins:8, cal:500, tier:"cooked", biomes:["grassland"] },
|
| 439 |
+
{ name: "Baked Meat", carbs:0, protein:17, fat:13, vitamins:0, cal:700, tier:"baked", biomes:["any"] },
|
| 440 |
+
{ name: "Bison Chow Fun", carbs:16, protein:13, fat:20, vitamins:8, cal:1450, tier:"advanced", biomes:["grassland"] },
|
| 441 |
+
{ name: "Pineapple Friend Rice", carbs:20, protein:9, fat:12, vitamins:12, cal:720, tier:"cooked", biomes:["rainforest"] },
|
| 442 |
+
{ name: "Baked Roast", carbs:4, protein:16, fat:10, vitamins:4, cal:1000, tier:"baked", biomes:["any"] },
|
| 443 |
+
{ name: "Camas Bread", carbs:13, protein:5, fat:11, vitamins:7, cal:800, tier:"baked", biomes:["grassland"] },
|
| 444 |
+
{ name: "Elk Taco", carbs:15, protein:8, fat:22, vitamins:6, cal:700, tier:"cooked", biomes:["forest"] },
|
| 445 |
+
{ name: "Flaxseed Oil", carbs:0, protein:0, fat:15, vitamins:0, cal:120, tier:"starter", biomes:["grassland"] },
|
| 446 |
+
{ name: "Sugar", carbs:15, protein:0, fat:0, vitamins:0, cal:50, tier:"starter", biomes:["any"] },
|
| 447 |
+
{ name: "Papaya", carbs:2, protein:1, fat:0, vitamins:5, cal:200, tier:"gatherer", biomes:["rainforest"] },
|
| 448 |
+
{ name: "Infused Oil", carbs:0, protein:0, fat:12, vitamins:3, cal:120, tier:"advanced", biomes:["any"] },
|
| 449 |
+
{ name: "Wilted Fiddleheads", carbs:4, protein:1, fat:0, vitamins:7, cal:350, tier:"gatherer", biomes:["forest"] },
|
| 450 |
+
{ name: "Wild Mix", carbs:15, protein:6, fat:4, vitamins:21, cal:800, tier:"cooked", biomes:["any"] },
|
| 451 |
+
{ name: "Elk Wellington", carbs:10, protein:26, fat:22, vitamins:4, cal:1450, tier:"advanced", biomes:["forest"] },
|
| 452 |
+
{ name: "Wheat", carbs:6, protein:2, fat:0, vitamins:0, cal:150, tier:"gatherer", biomes:["grassland"] },
|
| 453 |
+
{ name: "Bear S U P R E M E", carbs:6, protein:22, fat:23, vitamins:9, cal:1250, tier:"advanced", biomes:["forest"] },
|
| 454 |
+
{ name: "Vegetable Stock", carbs:11, protein:1, fat:2, vitamins:11, cal:700, tier:"cooked", biomes:["any"] },
|
| 455 |
+
{ name: "Vegetable Soup", carbs:12, protein:4, fat:7, vitamins:19, cal:1200, tier:"cooked", biomes:["any"] },
|
| 456 |
+
{ name: "Autumn Stew", carbs:13, protein:8, fat:5, vitamins:12, cal:1200, tier:"cooked", biomes:["forest"] },
|
| 457 |
+
{ name: "Bean Paste", carbs:3, protein:5, fat:7, vitamins:0, cal:40, tier:"starter", biomes:["any"] },
|
| 458 |
+
{ name: "Bearclaw", carbs:14, protein:4, fat:21, vitamins:7, cal:850, tier:"baked", biomes:["forest"] },
|
| 459 |
+
{ name: "Pirozhok", carbs:14, protein:19, fat:10, vitamins:4, cal:850, tier:"advanced", biomes:["any"] },
|
| 460 |
+
{ name: "Bread", carbs:23, protein:6, fat:4, vitamins:2, cal:750, tier:"baked", biomes:["any"] },
|
| 461 |
+
{ name: "Seared Meat", carbs:4, protein:19, fat:17, vitamins:7, cal:600, tier:"cooked", biomes:["any"] },
|
| 462 |
+
{ name: "Prickly Pear Fruit", carbs:2, protein:1, fat:1, vitamins:4, cal:190, tier:"gatherer", biomes:["desert"] },
|
| 463 |
+
{ name: "Phad Thai", carbs:9, protein:11, fat:19, vitamins:5, cal:1200, tier:"advanced", biomes:["any"] },
|
| 464 |
+
{ name: "Camas Bulb", carbs:1, protein:2, fat:5, vitamins:0, cal:150, tier:"gatherer", biomes:["grassland"] },
|
| 465 |
+
{ name: "Topped Porridge", carbs:10, protein:4, fat:0, vitamins:10, cal:700, tier:"cooked", biomes:["any"] },
|
| 466 |
+
{ name: "Dried Meat", carbs:1, protein:14, fat:4, vitamins:0, cal:550, tier:"campfire", biomes:["any"] },
|
| 467 |
+
{ name: "Tomato", carbs:5, protein:1, fat:0, vitamins:2, cal:240, tier:"gatherer", biomes:["grassland"] },
|
| 468 |
+
{ name: "Campfire Stew", carbs:5, protein:10, fat:9, vitamins:4, cal:1200, tier:"campfire", biomes:["any"] },
|
| 469 |
+
{ name: "Taro Fries", carbs:10, protein:2, fat:20, vitamins:0, cal:600, tier:"cooked", biomes:["rainforest"] },
|
| 470 |
+
{ name: "Tallow", carbs:0, protein:0, fat:8, vitamins:0, cal:200, tier:"starter", biomes:["any"] },
|
| 471 |
+
{ name: "Sweet Salad", carbs:18, protein:9, fat:7, vitamins:22, cal:1200, tier:"advanced", biomes:["any"] },
|
| 472 |
+
{ name: "Raw Fish", carbs:0, protein:7, fat:3, vitamins:0, cal:200, tier:"gatherer", biomes:["aquatic"] },
|
| 473 |
+
{ name: "Sweet Deer Jerky", carbs:4, protein:22, fat:6, vitamins:3, cal:600, tier:"campfire", biomes:["forest"] },
|
| 474 |
+
{ name: "Beet Greens", carbs:3, protein:1, fat:0, vitamins:4, cal:100, tier:"gatherer", biomes:["grassland"] },
|
| 475 |
+
{ name: "Sun Cheese", carbs:2, protein:4, fat:12, vitamins:0, cal:250, tier:"advanced", biomes:["any"] },
|
| 476 |
+
{ name: "Worldly Donut", carbs:15, protein:2, fat:17, vitamins:2, cal:750, tier:"baked", biomes:["any"] },
|
| 477 |
+
{ name: "Stuffed Turkey", carbs:17, protein:24, fat:16, vitamins:7, cal:1600, tier:"advanced", biomes:["forest"] },
|
| 478 |
+
{ name: "Spiky Roll", carbs:20, protein:17, fat:7, vitamins:2, cal:1300, tier:"advanced", biomes:["desert"] },
|
| 479 |
+
{ name: "Baked Corn", carbs:12, protein:3, fat:2, vitamins:11, cal:700, tier:"baked", biomes:["grassland"] },
|
| 480 |
+
{ name: "Jungle Campfire Salad", carbs:11, protein:4, fat:3, vitamins:10, cal:900, tier:"campfire", biomes:["rainforest"] },
|
| 481 |
+
{ name: "Simmered Meat", carbs:6, protein:18, fat:13, vitamins:5, cal:900, tier:"cooked", biomes:["any"] },
|
| 482 |
+
{ name: "Beet Campfire Salad", carbs:8, protein:4, fat:3, vitamins:13, cal:900, tier:"campfire", biomes:["grassland"] },
|
| 483 |
+
{ name: "Sensuous Sea Pizza", carbs:28, protein:11, fat:7, vitamins:4, cal:1200, tier:"advanced", biomes:["aquatic"] },
|
| 484 |
+
{ name: "Seeded Camas Roll", carbs:20, protein:2, fat:13, vitamins:16, cal:1400, tier:"baked", biomes:["grassland"] },
|
| 485 |
+
{ name: "Beet", carbs:2, protein:0, fat:2, vitamins:4, cal:230, tier:"gatherer", biomes:["grassland"] },
|
| 486 |
+
{ name: "Meaty Stew", carbs:6, protein:13, fat:10, vitamins:1, cal:1100, tier:"cooked", biomes:["any"] },
|
| 487 |
+
{ name: "Roast Pumpkin", carbs:23, protein:2, fat:2, vitamins:7, cal:1400, tier:"baked", biomes:["grassland"] },
|
| 488 |
+
{ name: "Fried Hare Haunches", carbs:6, protein:15, fat:27, vitamins:4, cal:750, tier:"cooked", biomes:["forest"] },
|
| 489 |
+
{ name: "Tortilla", carbs:20, protein:10, fat:0, vitamins:0, cal:350, tier:"baked", biomes:["any"] },
|
| 490 |
+
{ name: "Dried Fish", carbs:1, protein:16, fat:2, vitamins:0, cal:450, tier:"campfire", biomes:["aquatic"] },
|
| 491 |
+
{ name: "Charred Beans", carbs:1, protein:8, fat:3, vitamins:0, cal:350, tier:"campfire", biomes:["any"] },
|
| 492 |
+
{ name: "Kelpy Crab Roll", carbs:22, protein:13, fat:11, vitamins:5, cal:1350, tier:"advanced", biomes:["aquatic"] },
|
| 493 |
+
{ name: "Rice", carbs:7, protein:1, fat:0, vitamins:0, cal:150, tier:"gatherer", biomes:["any"] },
|
| 494 |
+
{ name: "Charred Beet", carbs:3, protein:0, fat:3, vitamins:6, cal:350, tier:"campfire", biomes:["grassland"] },
|
| 495 |
+
{ name: "Pumpkin", carbs:5, protein:1, fat:0, vitamins:2, cal:340, tier:"gatherer", biomes:["grassland"] },
|
| 496 |
+
{ name: "Milk", carbs:3, protein:10, fat:7, vitamins:0, cal:120, tier:"gatherer", biomes:["any"] },
|
| 497 |
+
{ name: "Fish N Chips", carbs:20, protein:10, fat:20, vitamins:0, cal:1000, tier:"cooked", biomes:["aquatic"] },
|
| 498 |
+
{ name: "Raw Meat", carbs:0, protein:4, fat:8, vitamins:0, cal:250, tier:"gatherer", biomes:["any"] },
|
| 499 |
+
{ name: "Agouti Enchiladas", carbs:20, protein:8, fat:27, vitamins:3, cal:800, tier:"advanced", biomes:["rainforest"] },
|
| 500 |
+
{ name: "Baked Taro", carbs:8, protein:6, fat:2, vitamins:12, cal:700, tier:"baked", biomes:["rainforest"] },
|
| 501 |
+
{ name: "Campfire Roast", carbs:0, protein:16, fat:12, vitamins:0, cal:1000, tier:"campfire", biomes:["any"] },
|
| 502 |
+
{ name: "Boiled Sausage", carbs:0, protein:27, fat:22, vitamins:0, cal:600, tier:"cooked", biomes:["any"] },
|
| 503 |
+
{ name: "Mochi", carbs:25, protein:0, fat:0, vitamins:5, cal:750, tier:"baked", biomes:["any"] },
|
| 504 |
+
{ name: "Root Campfire Stew", carbs:8, protein:5, fat:12, vitamins:5, cal:1100, tier:"campfire", biomes:["any"] },
|
| 505 |
+
{ name: "Macarons", carbs:20, protein:7, fat:14, vitamins:16, cal:1000, tier:"advanced", biomes:["any"] },
|
| 506 |
+
{ name: "Fruit Salad", carbs:12, protein:4, fat:3, vitamins:19, cal:900, tier:"starter", biomes:["any"] },
|
| 507 |
+
{ name: "Flatbread", carbs:17, protein:8, fat:3, vitamins:2, cal:500, tier:"baked", biomes:["any"] },
|
| 508 |
+
{ name: "Charred Fish", carbs:0, protein:11, fat:4, vitamins:0, cal:400, tier:"campfire", biomes:["aquatic"] },
|
| 509 |
+
{ name: "Poke Bowl", carbs:21, protein:10, fat:11, vitamins:7, cal:1100, tier:"advanced", biomes:["aquatic"] },
|
| 510 |
+
{ name: "Crispy Bacon", carbs:0, protein:18, fat:26, vitamins:0, cal:800, tier:"cooked", biomes:["any"] },
|
| 511 |
+
{ name: "Corn", carbs:4, protein:1, fat:0, vitamins:3, cal:230, tier:"gatherer", biomes:["grassland"] },
|
| 512 |
+
{ name: "Millionaires Salad", carbs:18, protein:6, fat:6, vitamins:26, cal:1000, tier:"advanced", biomes:["any"] },
|
| 513 |
+
{ name: "Banh Xeo", carbs:26, protein:17, fat:10, vitamins:4, cal:1550, tier:"advanced", biomes:["any"] },
|
| 514 |
+
{ name: "Charred Pineapple", carbs:8, protein:1, fat:0, vitamins:3, cal:350, tier:"campfire", biomes:["rainforest"] },
|
| 515 |
+
{ name: "Charred Mushrooms", carbs:3, protein:6, fat:2, vitamins:1, cal:350, tier:"campfire", biomes:["forest"] },
|
| 516 |
+
{ name: "Fern Campfire Salad", carbs:9, protein:5, fat:1, vitamins:13, cal:900, tier:"campfire", biomes:["forest"] },
|
| 517 |
+
{ name: "Boiled Grains", carbs:9, protein:2, fat:0, vitamins:1, cal:350, tier:"starter", biomes:["any"] },
|
| 518 |
+
{ name: "Baked Beet", carbs:10, protein:1, fat:2, vitamins:15, cal:700, tier:"baked", biomes:["grassland"] },
|
| 519 |
+
{ name: "Rice Noodles", carbs:10, protein:0, fat:0, vitamins:0, cal:200, tier:"starter", biomes:["any"] },
|
| 520 |
+
{ name: "Huckleberry Pie", carbs:13, protein:5, fat:10, vitamins:16, cal:1300, tier:"baked", biomes:["forest"] },
|
| 521 |
+
{ name: "Fruit Muffin", carbs:10, protein:5, fat:4, vitamins:16, cal:800, tier:"baked", biomes:["any"] }
|
| 522 |
+
];
|
| 523 |
+
|
| 524 |
+
// State
|
| 525 |
+
let enabledFoods = new Set(RAW_FOODS.map(f => f.name));
|
| 526 |
+
let currentPlanPool = [];
|
| 527 |
+
let currentPlanIndex = 0;
|
| 528 |
+
|
| 529 |
+
// ==================== UTILITIES ====================
|
| 530 |
+
|
| 531 |
+
function getFilter() {
|
| 532 |
+
const tier = document.getElementById('tier').value;
|
| 533 |
+
const disableTier = document.getElementById('disableTierFilter').checked;
|
| 534 |
+
const biome = document.getElementById('biomeFilter').value;
|
| 535 |
+
const disableBiome = document.getElementById('disableBiomeFilter').checked;
|
| 536 |
+
|
| 537 |
+
return (food) => {
|
| 538 |
+
if (!enabledFoods.has(food.name)) return false;
|
| 539 |
+
if (!disableTier && tier !== 'all' && food.tier !== tier) return false;
|
| 540 |
+
if (!disableBiome && biome !== 'all' && !food.biomes.includes(biome) && !food.biomes.includes('any')) return false;
|
| 541 |
+
return true;
|
| 542 |
+
};
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
function drawPieChart(canvasId, c, p, f, v) {
|
| 546 |
+
const canvas = document.getElementById(canvasId);
|
| 547 |
+
if (!canvas) return;
|
| 548 |
+
const ctx = canvas.getContext('2d');
|
| 549 |
+
const w = canvas.width;
|
| 550 |
+
const h = canvas.height;
|
| 551 |
+
ctx.clearRect(0, 0, w, h);
|
| 552 |
+
|
| 553 |
+
const total = c + p + f + v;
|
| 554 |
+
if (total === 0) {
|
| 555 |
+
ctx.fillStyle = '#cbd5e1';
|
| 556 |
+
ctx.beginPath();
|
| 557 |
+
ctx.arc(w/2, h/2, 100, 0, Math.PI*2);
|
| 558 |
+
ctx.fill();
|
| 559 |
+
ctx.fillStyle = '#64748b';
|
| 560 |
+
ctx.font = '20px Arial';
|
| 561 |
+
ctx.textAlign = 'center';
|
| 562 |
+
ctx.fillText("No Data", w/2, h/2 + 7);
|
| 563 |
+
return;
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
const vals = [c, p, f, v];
|
| 567 |
+
const colors = ["#ef4444", "#f97316", "#eab308", "#22c55e"];
|
| 568 |
+
let startAngle = -Math.PI / 2;
|
| 569 |
+
const cx = w/2, cy = h/2, r = 110;
|
| 570 |
+
|
| 571 |
+
vals.forEach((val, i) => {
|
| 572 |
+
if (val <= 0) return;
|
| 573 |
+
const sliceAngle = (val / total) * 2 * Math.PI;
|
| 574 |
+
ctx.beginPath();
|
| 575 |
+
ctx.moveTo(cx, cy);
|
| 576 |
+
ctx.arc(cx, cy, r, startAngle, startAngle + sliceAngle);
|
| 577 |
+
ctx.closePath();
|
| 578 |
+
ctx.fillStyle = colors[i];
|
| 579 |
+
ctx.fill();
|
| 580 |
+
startAngle += sliceAngle;
|
| 581 |
+
});
|
| 582 |
+
|
| 583 |
+
// Inner circle for donut effect
|
| 584 |
+
ctx.beginPath();
|
| 585 |
+
ctx.arc(cx, cy, r * 0.55, 0, 2 * Math.PI);
|
| 586 |
+
ctx.fillStyle = "#ffffff";
|
| 587 |
+
ctx.fill();
|
| 588 |
+
|
| 589 |
+
// Text in center
|
| 590 |
+
ctx.fillStyle = "#334155";
|
| 591 |
+
ctx.font = "bold 24px Segoe UI";
|
| 592 |
+
ctx.textAlign = "center";
|
| 593 |
+
ctx.textBaseline = "middle";
|
| 594 |
+
ctx.fillText(total.toFixed(1), cx, cy);
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
// ==================== CORE ALGORITHM (The Balance Logic) ====================
|
| 598 |
+
|
| 599 |
+
function calculatePerfectBalance() {
|
| 600 |
+
// 1. Get Inputs
|
| 601 |
+
const c = parseFloat(document.getElementById('carbs').value) || 0;
|