DmitrMakeev commited on
Commit
5a49b9e
·
verified ·
1 Parent(s): 95a95fd

Update calculate.html

Browse files
Files changed (1) hide show
  1. 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 = getValue("ca_content_ca") / 100;
90
- const caContentN = getValue("ca_content_n") / 100;
91
- const kh2po4ContentP = getValue("kh2po4_content_p") / 100;
92
- const kh2po4ContentK = getValue("kh2po4_content_k") / 100;
93
- const kno3ContentK = getValue("kno3_content_k") / 100;
94
- const kno3ContentN = getValue("kno3_content_n") / 100;
95
- const mgso4ContentMg = getValue("mgso4_content_mg") / 100;
96
- const mgso4ContentS = getValue("mgso4_content_s") / 100;
97
- const k2so4ContentK = getValue("k2so4_content_k") / 100;
98
- const k2so4ContentS = getValue("k2so4_content_s") / 100;
99
- const nh4no3ContentN = getValue("nh4no3_content_n") / 100;
100
 
101
  // Требуемые концентрации (мг/л)
102
- const ca = getValue("ca");
103
- const p = getValue("p");
104
- const k = getValue("k");
105
- const mg = getValue("mg");
106
- const s = getValue("s");
107
- const nitrogen = getValue("nitrogen");
108
- const nRatio = getValue("n_ratio") / 10;
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>