Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +61 -0
nutri_call.html
CHANGED
|
@@ -997,6 +997,9 @@ document.getElementById('calculate-btn').addEventListener('click', function() {
|
|
| 997 |
// Показываем статус расчёта
|
| 998 |
showCalculationStatus(call_data);
|
| 999 |
|
|
|
|
|
|
|
|
|
|
| 1000 |
// Обновляем поля NH4 и NO3
|
| 1001 |
updateNitrogenFields(call_data);
|
| 1002 |
|
|
@@ -1172,6 +1175,64 @@ function calculateOxidePercentages(data) {
|
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1175 |
|
| 1176 |
|
| 1177 |
function calculateEC(data, temperature, alpha = 0.019) {
|
|
|
|
| 997 |
// Показываем статус расчёта
|
| 998 |
showCalculationStatus(call_data);
|
| 999 |
|
| 1000 |
+
// Вызываем функцию для расчета катионов и анионов
|
| 1001 |
+
calculateCationsAndAnions(data);
|
| 1002 |
+
|
| 1003 |
// Обновляем поля NH4 и NO3
|
| 1004 |
updateNitrogenFields(call_data);
|
| 1005 |
|
|
|
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
+
|
| 1179 |
+
|
| 1180 |
+
|
| 1181 |
+
function calculateCationsAndAnions(data) {
|
| 1182 |
+
console.log("=== РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
| 1183 |
+
|
| 1184 |
+
// Извлекаем данные из ответа сервера
|
| 1185 |
+
const actualProfile = data.actual_profile;
|
| 1186 |
+
const elementContributions = data.element_contributions;
|
| 1187 |
+
|
| 1188 |
+
// Массы катионов
|
| 1189 |
+
const caMass = actualProfile["Ca"] || 0; // Ca²⁺
|
| 1190 |
+
const mgMass = actualProfile["Mg"] || 0; // Mg²⁺
|
| 1191 |
+
const kMass = actualProfile["K"] || 0; // K⁺
|
| 1192 |
+
const nh4Mass = actualProfile["N (NH4+)"] || 0; // NH₄⁺
|
| 1193 |
+
|
| 1194 |
+
// Массы анионов
|
| 1195 |
+
const no3Mass = actualProfile["N (NO3-)"] || 0; // NO₃⁻
|
| 1196 |
+
const sMass = actualProfile["S"] || 0; // SO₄²⁻
|
| 1197 |
+
const pMass = actualProfile["P"] || 0; // H₂PO₄⁻
|
| 1198 |
+
|
| 1199 |
+
// Общая масса катионов
|
| 1200 |
+
const totalCations = caMass + mgMass + kMass + nh4Mass;
|
| 1201 |
+
|
| 1202 |
+
// Общая масса анионов
|
| 1203 |
+
const totalAnions = no3Mass + sMass + pMass;
|
| 1204 |
+
|
| 1205 |
+
console.log(`Общая масса катионов: ${totalCations}`);
|
| 1206 |
+
console.log(`Общая масса анионов: ${totalAnions}`);
|
| 1207 |
+
|
| 1208 |
+
// Обновляем заголовок N1
|
| 1209 |
+
document.getElementById("n1-value").textContent = `Катионы:${totalCations.toFixed(2)}: Анионы:${totalAnions.toFixed(2)} PPM=${data.total_ppm}`;
|
| 1210 |
+
|
| 1211 |
+
// Обновляем шкалы индикаторов
|
| 1212 |
+
const cationIndicator = document.getElementById("cation-indicator");
|
| 1213 |
+
const anionIndicator = document.getElementById("anion-indicator");
|
| 1214 |
+
|
| 1215 |
+
// Рассчитываем ширину индикаторов (в процентах)
|
| 1216 |
+
const total = totalCations + totalAnions;
|
| 1217 |
+
const cationWidth = ((totalCations / total) * 100).toFixed(2);
|
| 1218 |
+
const anionWidth = ((totalAnions / total) * 100).toFixed(2);
|
| 1219 |
+
|
| 1220 |
+
// Устанавливаем ширину индикаторов
|
| 1221 |
+
cationIndicator.style.width = `${cationWidth}%`;
|
| 1222 |
+
anionIndicator.style.width = `${anionWidth}%`;
|
| 1223 |
+
|
| 1224 |
+
console.log(`Ширина индикаторов: Катионы=${cationWidth}%, Анионы=${anionWidth}%`);
|
| 1225 |
+
}
|
| 1226 |
+
|
| 1227 |
+
|
| 1228 |
+
|
| 1229 |
+
|
| 1230 |
+
|
| 1231 |
+
|
| 1232 |
+
|
| 1233 |
+
|
| 1234 |
+
|
| 1235 |
+
|
| 1236 |
|
| 1237 |
|
| 1238 |
function calculateEC(data, temperature, alpha = 0.019) {
|