Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +131 -0
nutri_call.html
CHANGED
@@ -926,6 +926,15 @@ legend {
|
|
926 |
<button id="calculate-btn">Рассчитать</button>
|
927 |
</div>
|
928 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
</fieldset>
|
930 |
|
931 |
|
@@ -1493,6 +1502,128 @@ function showCalculationStatus(response) {
|
|
1493 |
</script>
|
1494 |
|
1495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1496 |
|
1497 |
</body>
|
1498 |
</html>
|
|
|
926 |
<button id="calculate-btn">Рассчитать</button>
|
927 |
</div>
|
928 |
</div>
|
929 |
+
|
930 |
+
|
931 |
+
<!-- Выпадающий список -->
|
932 |
+
<label for="profile-selector">Выберите профиль:</label>
|
933 |
+
<select id="profile-selector">
|
934 |
+
</select>
|
935 |
+
|
936 |
+
<!-- Кнопка для сохранения нового профиля -->
|
937 |
+
<button id="save-profile">Сохранить текущий профиль</button>
|
938 |
</fieldset>
|
939 |
|
940 |
|
|
|
1502 |
</script>
|
1503 |
|
1504 |
|
1505 |
+
|
1506 |
+
|
1507 |
+
|
1508 |
+
|
1509 |
+
|
1510 |
+
|
1511 |
+
|
1512 |
+
<script>
|
1513 |
+
// Предустановленные профили (JSON)
|
1514 |
+
const predefinedProfiles = {
|
1515 |
+
"profiles": [
|
1516 |
+
{
|
1517 |
+
"name": "Профиль 1",
|
1518 |
+
"values": {
|
1519 |
+
"profile_p": 31,
|
1520 |
+
"profile_k": 210,
|
1521 |
+
"profile_mg": 24,
|
1522 |
+
"profile_ca": 82,
|
1523 |
+
"profile_s": 57.5,
|
1524 |
+
"profile_no3": 8.25,
|
1525 |
+
"profile_n": 125,
|
1526 |
+
"liters": 100
|
1527 |
+
}
|
1528 |
+
}
|
1529 |
+
]
|
1530 |
+
};
|
1531 |
+
|
1532 |
+
// Загрузка всех профилей (предустановленные + пользовательские)
|
1533 |
+
function loadAllProfiles() {
|
1534 |
+
const userProfiles = JSON.parse(localStorage.getItem("userProfiles")) || [];
|
1535 |
+
return [...predefinedProfiles.profiles, ...userProfiles];
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
// Создание выпадающего списка
|
1539 |
+
function populateProfileSelector() {
|
1540 |
+
const profiles = loadAllProfiles();
|
1541 |
+
const selector = document.getElementById("profile-selector");
|
1542 |
+
|
1543 |
+
// Очищаем предыдущие опции
|
1544 |
+
selector.innerHTML = "";
|
1545 |
+
|
1546 |
+
// Добавляем предустановленные профили
|
1547 |
+
const predefinedGroup = document.createElement("optgroup");
|
1548 |
+
predefinedGroup.label = "Предустановленные профили";
|
1549 |
+
predefinedProfiles.profiles.forEach(profile => {
|
1550 |
+
const option = document.createElement("option");
|
1551 |
+
option.value = profile.name;
|
1552 |
+
option.textContent = profile.name;
|
1553 |
+
predefinedGroup.appendChild(option);
|
1554 |
+
});
|
1555 |
+
selector.appendChild(predefinedGroup);
|
1556 |
+
|
1557 |
+
// Добавляем пользовательские профили
|
1558 |
+
const userProfiles = JSON.parse(localStorage.getItem("userProfiles")) || [];
|
1559 |
+
if (userProfiles.length > 0) {
|
1560 |
+
const userGroup = document.createElement("optgroup");
|
1561 |
+
userGroup.label = "Пользовательские профили";
|
1562 |
+
userProfiles.forEach(profile => {
|
1563 |
+
const option = document.createElement("option");
|
1564 |
+
option.value = profile.name;
|
1565 |
+
option.textContent = profile.name;
|
1566 |
+
userGroup.appendChild(option);
|
1567 |
+
});
|
1568 |
+
selector.appendChild(userGroup);
|
1569 |
+
}
|
1570 |
+
}
|
1571 |
+
|
1572 |
+
// Заполнение полей при выборе профиля
|
1573 |
+
document.getElementById("profile-selector").addEventListener("change", function () {
|
1574 |
+
const selectedProfileName = this.value;
|
1575 |
+
const allProfiles = loadAllProfiles();
|
1576 |
+
const selectedProfile = allProfiles.find(profile => profile.name === selectedProfileName);
|
1577 |
+
|
1578 |
+
if (selectedProfile) {
|
1579 |
+
document.getElementById("profile_p").value = selectedProfile.values.profile_p;
|
1580 |
+
document.getElementById("profile_k").value = selectedProfile.values.profile_k;
|
1581 |
+
document.getElementById("profile_mg").value = selectedProfile.values.profile_mg;
|
1582 |
+
document.getElementById("profile_ca").value = selectedProfile.values.profile_ca;
|
1583 |
+
document.getElementById("profile_s").value = selectedProfile.values.profile_s;
|
1584 |
+
document.getElementById("profile_no3").value = selectedProfile.values.profile_no3;
|
1585 |
+
document.getElementById("profile_n").value = selectedProfile.values.profile_n;
|
1586 |
+
document.getElementById("liters-input").value = selectedProfile.values.liters;
|
1587 |
+
}
|
1588 |
+
});
|
1589 |
+
|
1590 |
+
// Сохранение нового профиля
|
1591 |
+
document.getElementById("save-profile").addEventListener("click", function () {
|
1592 |
+
const profileName = prompt("Введите название профиля:");
|
1593 |
+
if (!profileName) return;
|
1594 |
+
|
1595 |
+
const newProfile = {
|
1596 |
+
name: profileName,
|
1597 |
+
values: {
|
1598 |
+
profile_p: parseFloat(document.getElementById("profile_p").value),
|
1599 |
+
profile_k: parseFloat(document.getElementById("profile_k").value),
|
1600 |
+
profile_mg: parseFloat(document.getElementById("profile_mg").value),
|
1601 |
+
profile_ca: parseFloat(document.getElementById("profile_ca").value),
|
1602 |
+
profile_s: parseFloat(document.getElementById("profile_s").value),
|
1603 |
+
profile_no3: parseFloat(document.getElementById("profile_no3").value),
|
1604 |
+
profile_n: parseFloat(document.getElementById("profile_n").value),
|
1605 |
+
liters: parseFloat(document.getElementById("liters-input").value)
|
1606 |
+
}
|
1607 |
+
};
|
1608 |
+
|
1609 |
+
let userProfiles = JSON.parse(localStorage.getItem("userProfiles")) || [];
|
1610 |
+
userProfiles.push(newProfile);
|
1611 |
+
localStorage.setItem("userProfiles", JSON.stringify(userProfiles));
|
1612 |
+
|
1613 |
+
// Обновляем выпадающий список
|
1614 |
+
populateProfileSelector();
|
1615 |
+
});
|
1616 |
+
|
1617 |
+
// Инициализация выпадающего списка при загрузке страницы
|
1618 |
+
populateProfileSelector();
|
1619 |
+
</script>
|
1620 |
+
|
1621 |
+
|
1622 |
+
|
1623 |
+
|
1624 |
+
|
1625 |
+
|
1626 |
+
|
1627 |
|
1628 |
</body>
|
1629 |
</html>
|