DmitrMakeev commited on
Commit
80c5add
·
verified ·
1 Parent(s): b2a0718

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +39 -46
nutri_call.html CHANGED
@@ -337,57 +337,50 @@ const NUTRIENT_CONTENT_IN_FERTILIZERS = {
337
 
338
  // Функция для пересчета процентов в константы
339
  document.getElementById('calculate-btn').addEventListener('click', function() {
340
- // 1. Собираем константы удобрений
341
- const fertilizerConstants = {
342
- "CaN2O6": {
343
- NO3: parseFloat(document.getElementById('fert_ca_no3').value) / 100 || 0,
344
- Ca: parseFloat(document.getElementById('fert_ca_ca').value) / 100 || 0
345
- },
346
- "KNO3": {
347
- NO3: parseFloat(document.getElementById('fert_kno3_no3').value) / 100 || 0,
348
- K: parseFloat(document.getElementById('fert_kno3_k').value) / 100 || 0
349
- },
350
- "NH4NO3": {
351
- NH4: parseFloat(document.getElementById('fert_nh4no3_nh4').value) / 100 || 0,
352
- NO3: parseFloat(document.getElementById('fert_nh4no3_no3').value) / 100 || 0
353
- },
354
- "MgSO4": {
355
- Mg: parseFloat(document.getElementById('fert_mgso4_mg').value) / 100 || 0,
356
- S: parseFloat(document.getElementById('fert_mgso4_s').value) / 100 || 0
357
- },
358
- "KH2PO4": {
359
- P: parseFloat(document.getElementById('fert_kh2po4_p').value) / 100 || 0,
360
- K: parseFloat(document.getElementById('fert_kh2po4_k').value) / 100 || 0
 
 
 
 
 
 
361
  },
362
- "K2SO4": {
363
- K: parseFloat(document.getElementById('fert_k2so4_k').value) / 100 || 0,
364
- S: parseFloat(document.getElementById('fert_k2so4_s').value) / 100 || 0
 
 
 
 
 
 
 
365
  }
366
  };
367
 
368
- // 2. Собираем настройки профиля и литры
369
- const profileSettings = {
370
- N: parseFloat(document.getElementById('profile_p').value) || 0,
371
- P: parseFloat(document.getElementById('profile_k').value) || 0,
372
- K: parseFloat(document.getElementById('profile_ca').value) || 0,
373
- Ca: parseFloat(document.getElementById('profile_mg').value) || 0,
374
- Mg: parseFloat(document.getElementById('profile_s').value) || 0,
375
- S: parseFloat(document.getElementById('profile_cl').value) || 0,
376
- NH4: parseFloat(document.getElementById('profile_nh4').value) || 0,
377
- NO3: parseFloat(document.getElementById('profile_no3').value) || 0,
378
- liters: parseInt(document.getElementById('liters-input').value) || 1
379
- };
380
-
381
- // 3. Формируем итоговый объект с двумя разделами
382
- const calculationData = {
383
- fertilizerConstants: fertilizerConstants,
384
- profileSettings: profileSettings
385
- };
386
-
387
- // 4. Выводим в консоль для проверки
388
- console.log("Calculation Data:", calculationData);
389
 
390
- // 2. Отправляем данные на сервер
391
  fetch('/calculation', {
392
  method: 'POST',
393
  headers: {
 
337
 
338
  // Функция для пересчета процентов в константы
339
  document.getElementById('calculate-btn').addEventListener('click', function() {
340
+ // 1. Собираем данные с формы
341
+ const calculationData = {
342
+ fertilizerConstants: {
343
+ "CaN2O6": {
344
+ "NO3": parseFloat(document.getElementById('fert_ca_no3').value) / 100,
345
+ "Ca": parseFloat(document.getElementById('fert_ca_ca').value) / 100
346
+ },
347
+ "KNO3": {
348
+ "NO3": parseFloat(document.getElementById('fert_kno3_no3').value) / 100,
349
+ "K": parseFloat(document.getElementById('fert_kno3_k').value) / 100
350
+ },
351
+ "NH4NO3": {
352
+ "NH4": parseFloat(document.getElementById('fert_nh4no3_nh4').value) / 100,
353
+ "NO3": parseFloat(document.getElementById('fert_nh4no3_no3').value) / 100
354
+ },
355
+ "MgSO4": {
356
+ "Mg": parseFloat(document.getElementById('fert_mgso4_mg').value) / 100,
357
+ "S": parseFloat(document.getElementById('fert_mgso4_s').value) / 100
358
+ },
359
+ "KH2PO4": {
360
+ "P": parseFloat(document.getElementById('fert_kh2po4_p').value) / 100,
361
+ "K": parseFloat(document.getElementById('fert_kh2po4_k').value) / 100
362
+ },
363
+ "K2SO4": {
364
+ "K": parseFloat(document.getElementById('fert_k2so4_k').value) / 100,
365
+ "S": parseFloat(document.getElementById('fert_k2so4_s').value) / 100
366
+ }
367
  },
368
+ profileSettings: {
369
+ "N": parseFloat(document.getElementById('profile_p').value),
370
+ "P": parseFloat(document.getElementById('profile_k').value),
371
+ "K": parseFloat(document.getElementById('profile_ca').value),
372
+ "Ca": parseFloat(document.getElementById('profile_mg').value),
373
+ "Mg": parseFloat(document.getElementById('profile_s').value),
374
+ "S": parseFloat(document.getElementById('profile_cl').value),
375
+ "NH4": parseFloat(document.getElementById('profile_nh4').value),
376
+ "NO3": parseFloat(document.getElementById('profile_no3').value),
377
+ "liters": parseInt(document.getElementById('liters-input').value) || 1
378
  }
379
  };
380
 
381
+ console.log("Отправляемые данные:", calculationData);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
 
383
+ // 2. Отправляем данные на сервер
384
  fetch('/calculation', {
385
  method: 'POST',
386
  headers: {