Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +19 -29
nutri_call.html
CHANGED
@@ -328,30 +328,29 @@
|
|
328 |
document.getElementById('calculate-btn').addEventListener('click', function() {
|
329 |
const getValue = (id) => parseFloat(document.getElementById(id)?.value) || 0;
|
330 |
|
331 |
-
// Формируем запрос в правильном формате
|
332 |
const requestData = {
|
333 |
fertilizerConstants: {
|
334 |
-
"
|
335 |
-
"
|
336 |
"Ca": getValue('fert_ca_ca') / 100
|
337 |
},
|
338 |
-
"
|
339 |
-
"
|
340 |
"K": getValue('fert_kno3_k') / 100
|
341 |
},
|
342 |
-
"
|
343 |
-
"
|
344 |
-
"
|
345 |
},
|
346 |
-
"
|
347 |
"Mg": getValue('fert_mgso4_mg') / 100,
|
348 |
"S": getValue('fert_mgso4_s') / 100
|
349 |
},
|
350 |
-
"
|
351 |
"P": getValue('fert_kh2po4_p') / 100,
|
352 |
"K": getValue('fert_kh2po4_k') / 100
|
353 |
},
|
354 |
-
"
|
355 |
"K": getValue('fert_k2so4_k') / 100,
|
356 |
"S": getValue('fert_k2so4_s') / 100
|
357 |
}
|
@@ -362,14 +361,12 @@ document.getElementById('calculate-btn').addEventListener('click', function() {
|
|
362 |
'Mg': getValue('profile_mg'),
|
363 |
'Ca': getValue('profile_ca'),
|
364 |
'S': getValue('profile_s'),
|
365 |
-
'
|
366 |
-
'
|
367 |
'liters': parseInt(document.getElementById('liters-input')?.value) || 1
|
368 |
}
|
369 |
};
|
370 |
|
371 |
-
console.log("Отправка данных:", JSON.stringify(requestData, null, 2));
|
372 |
-
|
373 |
fetch('/calculation', {
|
374 |
method: 'POST',
|
375 |
headers: { 'Content-Type': 'application/json' },
|
@@ -377,17 +374,13 @@ document.getElementById('calculate-btn').addEventListener('click', function() {
|
|
377 |
})
|
378 |
.then(response => response.json())
|
379 |
.then(data => {
|
380 |
-
console.log("Ответ сервера:", data);
|
381 |
-
if (data.error) throw new Error(data.error);
|
382 |
-
|
383 |
-
// Заполняем результаты
|
384 |
const fertilizers = {
|
385 |
-
"
|
386 |
-
"
|
387 |
-
"
|
388 |
-
"
|
389 |
-
"
|
390 |
-
"
|
391 |
};
|
392 |
|
393 |
Object.values(fertilizers).forEach(id => {
|
@@ -401,10 +394,7 @@ document.getElementById('calculate-btn').addEventListener('click', function() {
|
|
401 |
}
|
402 |
});
|
403 |
})
|
404 |
-
.catch(error =>
|
405 |
-
console.error("Ошибка:", error);
|
406 |
-
alert(`Ошибка: ${error.message}`);
|
407 |
-
});
|
408 |
});
|
409 |
</script>
|
410 |
|
|
|
328 |
document.getElementById('calculate-btn').addEventListener('click', function() {
|
329 |
const getValue = (id) => parseFloat(document.getElementById(id)?.value) || 0;
|
330 |
|
|
|
331 |
const requestData = {
|
332 |
fertilizerConstants: {
|
333 |
+
"CaN2O6": {
|
334 |
+
"NO3": getValue('fert_ca_no3') / 100,
|
335 |
"Ca": getValue('fert_ca_ca') / 100
|
336 |
},
|
337 |
+
"KNO3": {
|
338 |
+
"NO3": getValue('fert_kno3_no3') / 100,
|
339 |
"K": getValue('fert_kno3_k') / 100
|
340 |
},
|
341 |
+
"NH4NO3": {
|
342 |
+
"NO3": getValue('fert_nh4no3_no3') / 100,
|
343 |
+
"NH4": getValue('fert_nh4no3_nh4') / 100
|
344 |
},
|
345 |
+
"MgSO4": {
|
346 |
"Mg": getValue('fert_mgso4_mg') / 100,
|
347 |
"S": getValue('fert_mgso4_s') / 100
|
348 |
},
|
349 |
+
"KH2PO4": {
|
350 |
"P": getValue('fert_kh2po4_p') / 100,
|
351 |
"K": getValue('fert_kh2po4_k') / 100
|
352 |
},
|
353 |
+
"K2SO4": {
|
354 |
"K": getValue('fert_k2so4_k') / 100,
|
355 |
"S": getValue('fert_k2so4_s') / 100
|
356 |
}
|
|
|
361 |
'Mg': getValue('profile_mg'),
|
362 |
'Ca': getValue('profile_ca'),
|
363 |
'S': getValue('profile_s'),
|
364 |
+
'NO3': getValue('profile_no3'),
|
365 |
+
'NH4': getValue('profile_nh4'),
|
366 |
'liters': parseInt(document.getElementById('liters-input')?.value) || 1
|
367 |
}
|
368 |
};
|
369 |
|
|
|
|
|
370 |
fetch('/calculation', {
|
371 |
method: 'POST',
|
372 |
headers: { 'Content-Type': 'application/json' },
|
|
|
374 |
})
|
375 |
.then(response => response.json())
|
376 |
.then(data => {
|
|
|
|
|
|
|
|
|
377 |
const fertilizers = {
|
378 |
+
"CaN2O6": "calcium_nitrate",
|
379 |
+
"KNO3": "potassium_nitrate",
|
380 |
+
"NH4NO3": "ammonium_nitrate",
|
381 |
+
"MgSO4": "magnesium_sulfate",
|
382 |
+
"KH2PO4": "monopotassium_phosphate",
|
383 |
+
"K2SO4": "potassium_sulfate"
|
384 |
};
|
385 |
|
386 |
Object.values(fertilizers).forEach(id => {
|
|
|
394 |
}
|
395 |
});
|
396 |
})
|
397 |
+
.catch(error => alert("Ошибка: " + error));
|
|
|
|
|
|
|
398 |
});
|
399 |
</script>
|
400 |
|