DmitrMakeev commited on
Commit
4e56f05
·
verified ·
1 Parent(s): 81c9369

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +71 -0
nutri_call.html CHANGED
@@ -307,5 +307,76 @@
307
  <legend>Расчёт удобрений</legend>
308
  <button id="calculate-btn">Запуск</button>
309
  </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  </body>
311
  </html>
 
307
  <legend>Расчёт удобрений</legend>
308
  <button id="calculate-btn">Запуск</button>
309
  </fieldset>
310
+
311
+
312
+ <script>
313
+ // Константы содержания элементов в удобрениях (массовые доли)
314
+ const NUTRIENT_CONTENT_IN_FERTILIZERS = {
315
+ "CaN2O6": {"NO3": 0.11863, "Ca": 0.16972},
316
+ "KNO3": {"NO3": 0.136, "K": 0.382},
317
+ "K2SO4": {"K": 0.44874, "S": 0.18401},
318
+ "NH4NO3": {"NO3": 0.17499, "NH4": 0.17499},
319
+ "MgSO4": {"Mg": 0.09861, "S": 0.13010},
320
+ "KH2PO4": {"P": 0.218, "K": 0.275}
321
+ };
322
+
323
+ // Функция для пересчета процентов в константы
324
+ function calculateNutrientConstants() {
325
+ // Получаем все элементы удобрений
326
+ const fertilizers = {
327
+ "CaN2O6": {
328
+ NO3: parseFloat(document.getElementById('fert_ca_no3').value) || 0,
329
+ Ca: parseFloat(document.getElementById('fert_ca_ca').value) || 0
330
+ },
331
+ "KNO3": {
332
+ NO3: parseFloat(document.getElementById('fert_kno3_no3').value) || 0,
333
+ K: parseFloat(document.getElementById('fert_kno3_k').value) || 0
334
+ },
335
+ "NH4NO3": {
336
+ NH4: parseFloat(document.getElementById('fert_nh4no3_nh4').value) || 0,
337
+ NO3: parseFloat(document.getElementById('fert_nh4no3_no3').value) || 0
338
+ },
339
+ "MgSO4": {
340
+ Mg: parseFloat(document.getElementById('fert_mgso4_mg').value) || 0,
341
+ S: parseFloat(document.getElementById('fert_mgso4_s').value) || 0
342
+ },
343
+ "KH2PO4": {
344
+ P: parseFloat(document.getElementById('fert_kh2po4_p').value) || 0,
345
+ K: parseFloat(document.getElementById('fert_kh2po4_k').value) || 0
346
+ },
347
+ "K2SO4": {
348
+ K: parseFloat(document.getElementById('fert_k2so4_k').value) || 0,
349
+ S: parseFloat(document.getElementById('fert_k2so4_s').value) || 0
350
+ }
351
+ };
352
+
353
+ // Пересчитываем проценты в константы (делим на 100)
354
+ const calculatedConstants = {};
355
+
356
+ for (const [fert, nutrients] of Object.entries(fertilizers)) {
357
+ calculatedConstants[fert] = {};
358
+ for (const [nutrient, value] of Object.entries(nutrients)) {
359
+ calculatedConstants[fert][nutrient] = value / 100;
360
+ }
361
+ }
362
+
363
+ // Выводим результат в консоль
364
+ console.log("Calculated Nutrient Constants:", calculatedConstants);
365
+
366
+ // Можно также сравнить с эталонными значениями
367
+ console.log("Reference Constants:", NUTRIENT_CONTENT_IN_FERTILIZERS);
368
+
369
+ return calculatedConstants;
370
+ }
371
+
372
+ // Назначаем обработчик на кнопку "Запуск"
373
+ document.getElementById('calculate-btn').addEventListener('click', function() {
374
+ const result = calculateNutrientConstants();
375
+ // Здесь можно добавить отправку данных на сервер
376
+ // fetch('/api/calculate', { method: 'POST', body: JSON.stringify(result) })
377
+ });
378
+ </script>
379
+
380
+
381
  </body>
382
  </html>