Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +12 -1
nutri_call.html
CHANGED
@@ -821,7 +821,7 @@ function data_out(response) {
|
|
821 |
|
822 |
|
823 |
|
824 |
-
// Функция для обновления значений NPK
|
825 |
function updateNPK(data) {
|
826 |
console.log("=== ОБНОВЛЕНИЕ ЗНАЧЕНИЙ NPK ===");
|
827 |
|
@@ -838,6 +838,17 @@ function updateNPK(data) {
|
|
838 |
document.getElementById("npk-n-value").textContent = nValue.toFixed(3); // Округляем до 3 знаков
|
839 |
document.getElementById("npk-p-value").textContent = pValue.toFixed(3); // Округляем до 3 знаков
|
840 |
document.getElementById("npk-k-value").textContent = kValue.toFixed(3); // Округляем до 3 знаков
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
841 |
} else {
|
842 |
console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
|
843 |
}
|
|
|
821 |
|
822 |
|
823 |
|
824 |
+
// Функция для обновления значений NPK и расчета соотношения в процентах
|
825 |
function updateNPK(data) {
|
826 |
console.log("=== ОБНОВЛЕНИЕ ЗНАЧЕНИЙ NPK ===");
|
827 |
|
|
|
838 |
document.getElementById("npk-n-value").textContent = nValue.toFixed(3); // Округляем до 3 знаков
|
839 |
document.getElementById("npk-p-value").textContent = pValue.toFixed(3); // Округляем до 3 знаков
|
840 |
document.getElementById("npk-k-value").textContent = kValue.toFixed(3); // Округляем до 3 знаков
|
841 |
+
|
842 |
+
// Рассчитываем соотношение NPK в процентах
|
843 |
+
const minValue = Math.min(nValue, pValue, kValue);
|
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 |
+
// Обновляем поле с соотношением NPK
|
851 |
+
document.getElementById("npk-ratio").textContent = `${nRatio}:${pRatio}:${kRatio}`;
|
852 |
} else {
|
853 |
console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
|
854 |
}
|