Spaces:
Sleeping
Sleeping
Update calculate.html
Browse files- calculate.html +19 -24
calculate.html
CHANGED
@@ -79,33 +79,27 @@
|
|
79 |
});
|
80 |
|
81 |
function calculate() {
|
82 |
-
// Функция для безопасного получения числового значения
|
83 |
-
function getValue(id) {
|
84 |
-
const value = parseFloat(document.getElementById(id).value);
|
85 |
-
return isNaN(value) ? 0 : value;
|
86 |
-
}
|
87 |
-
|
88 |
// Состав удобрений (% → доли)
|
89 |
-
const caContentCa =
|
90 |
-
const caContentN =
|
91 |
-
const kh2po4ContentP =
|
92 |
-
const kh2po4ContentK =
|
93 |
-
const kno3ContentK =
|
94 |
-
const kno3ContentN =
|
95 |
-
const mgso4ContentMg =
|
96 |
-
const mgso4ContentS =
|
97 |
-
const k2so4ContentK =
|
98 |
-
const k2so4ContentS =
|
99 |
-
const nh4no3ContentN =
|
100 |
|
101 |
// Требуемые концентрации (мг/л)
|
102 |
-
const ca =
|
103 |
-
const p =
|
104 |
-
const k =
|
105 |
-
const mg =
|
106 |
-
const s =
|
107 |
-
const nitrogen =
|
108 |
-
const nRatio =
|
109 |
|
110 |
// Проверка ввода
|
111 |
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) {
|
@@ -166,6 +160,7 @@ function calculate() {
|
|
166 |
totalMg = (mgso4 * mgso4ContentMg).toFixed(2);
|
167 |
let totalS = (mgso4 * mgso4ContentS + k2so4 * k2so4ContentS).toFixed(2);
|
168 |
|
|
|
169 |
const result = `
|
170 |
<h3>Результат расчёта (г/1000 л):</h3>
|
171 |
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${totalMg}, S: ${sFromMgSO4.toFixed(2)})</p>
|
|
|
79 |
});
|
80 |
|
81 |
function calculate() {
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
// Состав удобрений (% → доли)
|
83 |
+
const caContentCa = parseFloat(document.getElementById("ca_content_ca").value) / 100;
|
84 |
+
const caContentN = parseFloat(document.getElementById("ca_content_n").value) / 100;
|
85 |
+
const kh2po4ContentP = parseFloat(document.getElementById("kh2po4_content_p").value) / 100;
|
86 |
+
const kh2po4ContentK = parseFloat(document.getElementById("kh2po4_content_k").value) / 100;
|
87 |
+
const kno3ContentK = parseFloat(document.getElementById("kno3_content_k").value) / 100;
|
88 |
+
const kno3ContentN = parseFloat(document.getElementById("kno3_content_n").value) / 100;
|
89 |
+
const mgso4ContentMg = parseFloat(document.getElementById("mgso4_content_mg").value) / 100;
|
90 |
+
const mgso4ContentS = parseFloat(document.getElementById("mgso4_content_s").value) / 100;
|
91 |
+
const k2so4ContentK = parseFloat(document.getElementById("k2so4_content_k").value) / 100;
|
92 |
+
const k2so4ContentS = parseFloat(document.getElementById("k2so4_content_s").value) / 100;
|
93 |
+
const nh4no3ContentN = parseFloat(document.getElementById("nh4no3_content_n").value) / 100;
|
94 |
|
95 |
// Требуемые концентрации (мг/л)
|
96 |
+
const ca = parseFloat(document.getElementById("ca").value) || 0;
|
97 |
+
const p = parseFloat(document.getElementById("p").value) || 0;
|
98 |
+
const k = parseFloat(document.getElementById("k").value) || 0;
|
99 |
+
const mg = parseFloat(document.getElementById("mg").value) || 0;
|
100 |
+
const s = parseFloat(document.getElementById("s").value) || 0;
|
101 |
+
const nitrogen = parseFloat(document.getElementById("nitrogen").value) || 0;
|
102 |
+
const nRatio = parseFloat(document.getElementById("n_ratio").value) / 10;
|
103 |
|
104 |
// Проверка ввода
|
105 |
if ([ca, p, k, mg, s, nitrogen].some(v => isNaN(v))) {
|
|
|
160 |
totalMg = (mgso4 * mgso4ContentMg).toFixed(2);
|
161 |
let totalS = (mgso4 * mgso4ContentS + k2so4 * k2so4ContentS).toFixed(2);
|
162 |
|
163 |
+
// Отображение результатов
|
164 |
const result = `
|
165 |
<h3>Результат расчёта (г/1000 л):</h3>
|
166 |
<p>MgSO₄·7H₂O: ${mgso4.toFixed(2)} (Mg: ${totalMg}, S: ${sFromMgSO4.toFixed(2)})</p>
|