Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +10 -10
nutri_call.html
CHANGED
@@ -823,9 +823,10 @@ function data_out(response) {
|
|
823 |
|
824 |
|
825 |
|
826 |
-
|
|
|
827 |
function updateNPK(data) {
|
828 |
-
console.log("===
|
829 |
|
830 |
// Извлекаем значения из actual_profile
|
831 |
const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
|
@@ -836,21 +837,20 @@ function updateNPK(data) {
|
|
836 |
if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
|
837 |
console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
|
838 |
|
839 |
-
//
|
840 |
-
document.getElementById("npk-n-value").textContent = nValue.toFixed(3); // Округляем до 3 знаков
|
841 |
-
document.getElementById("npk-p-value").textContent = pValue.toFixed(3); // Округляем до 3 знаков
|
842 |
-
document.getElementById("npk-k-value").textContent = kValue.toFixed(3); // Округляем до 3 знаков
|
843 |
-
|
844 |
-
// Рассчитываем соотношение NPK в процентах
|
845 |
const minValue = Math.min(nValue, pValue, kValue);
|
|
|
|
|
846 |
const nRatio = Math.round(nValue / minValue);
|
847 |
const pRatio = Math.round(pValue / minValue);
|
848 |
const kRatio = Math.round(kValue / minValue);
|
849 |
|
850 |
console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
|
851 |
|
852 |
-
// Обновляем
|
853 |
-
document.getElementById("npk-
|
|
|
|
|
854 |
} else {
|
855 |
console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
|
856 |
}
|
|
|
823 |
|
824 |
|
825 |
|
826 |
+
|
827 |
+
// Функция для расчета соотношения NPK
|
828 |
function updateNPK(data) {
|
829 |
+
console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK ===");
|
830 |
|
831 |
// Извлекаем значения из actual_profile
|
832 |
const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
|
|
|
837 |
if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
|
838 |
console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
|
839 |
|
840 |
+
// Находим минимальное значение
|
|
|
|
|
|
|
|
|
|
|
841 |
const minValue = Math.min(nValue, pValue, kValue);
|
842 |
+
|
843 |
+
// Рассчитываем соотношение
|
844 |
const nRatio = Math.round(nValue / minValue);
|
845 |
const pRatio = Math.round(pValue / minValue);
|
846 |
const kRatio = Math.round(kValue / minValue);
|
847 |
|
848 |
console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
|
849 |
|
850 |
+
// Обновляем поля на странице
|
851 |
+
document.getElementById("npk-n-value").textContent = nRatio;
|
852 |
+
document.getElementById("npk-p-value").textContent = pRatio;
|
853 |
+
document.getElementById("npk-k-value").textContent = kRatio;
|
854 |
} else {
|
855 |
console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
|
856 |
}
|