Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +22 -27
nutri_call.html
CHANGED
@@ -1208,8 +1208,8 @@ function calculateOxidePercentages(data) {
|
|
1208 |
|
1209 |
function calculateCationsAndAnions(data) {
|
1210 |
console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
1211 |
-
|
1212 |
-
// Молярные массы и валентности
|
1213 |
const ION_DATA = {
|
1214 |
// Катионы
|
1215 |
'Ca': { mass: 40.08, charge: 2 },
|
@@ -1222,27 +1222,27 @@ function calculateCationsAndAnions(data) {
|
|
1222 |
'H2PO4': { mass: 96.99, charge: 1 }
|
1223 |
};
|
1224 |
|
1225 |
-
//
|
1226 |
const profile = data.actual_profile;
|
1227 |
-
|
1228 |
-
//
|
1229 |
const ions = {
|
1230 |
// Катионы
|
1231 |
-
'Ca': (profile['Ca'] || 0) *
|
1232 |
-
'Mg': (profile['Mg'] || 0) *
|
1233 |
-
'K': (profile['K'] || 0) *
|
1234 |
-
'NH4': (profile['N (NH4+)'] || 0) *
|
1235 |
// Анионы
|
1236 |
-
'NO3': (profile['N (NO3-)'] || 0) *
|
1237 |
-
'SO4': (profile['S'] || 0) *
|
1238 |
-
'H2PO4': (profile['P'] || 0) *
|
1239 |
};
|
1240 |
|
1241 |
-
//
|
1242 |
const totalCations = ions['Ca'] + ions['Mg'] + ions['K'] + ions['NH4'];
|
1243 |
const totalAnions = ions['NO3'] + ions['SO4'] + ions['H2PO4'];
|
1244 |
-
|
1245 |
-
//
|
1246 |
const total = totalCations + totalAnions;
|
1247 |
const cationPercent = (totalCations / total * 100).toFixed(1);
|
1248 |
const anionPercent = (totalAnions / total * 100).toFixed(1);
|
@@ -1251,23 +1251,18 @@ function calculateCationsAndAnions(data) {
|
|
1251 |
console.log(`Анионы: ${totalAnions.toFixed(2)} mEq/L (${anionPercent}%)`);
|
1252 |
console.log(`Дисбаланс: ${(totalCations - totalAnions).toFixed(2)} mEq/L`);
|
1253 |
|
1254 |
-
//
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
const cationBar = document.getElementById("cation-indicator");
|
1262 |
-
const anionBar = document.getElementById("anion-indicator");
|
1263 |
-
if (cationBar) cationBar.style.width = `${cationPercent}%`;
|
1264 |
-
if (anionBar) anionBar.style.width = `${anionPercent}%`;
|
1265 |
}
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
-
|
1271 |
|
1272 |
|
1273 |
|
|
|
1208 |
|
1209 |
function calculateCationsAndAnions(data) {
|
1210 |
console.log("=== ТОЧНЫЙ РАСЧЕТ КАТИОНОВ И АНИОНОВ ===");
|
1211 |
+
|
1212 |
+
// Молярные массы и валентности элементов
|
1213 |
const ION_DATA = {
|
1214 |
// Катионы
|
1215 |
'Ca': { mass: 40.08, charge: 2 },
|
|
|
1222 |
'H2PO4': { mass: 96.99, charge: 1 }
|
1223 |
};
|
1224 |
|
1225 |
+
// Получаем данные профиля
|
1226 |
const profile = data.actual_profile;
|
1227 |
+
|
1228 |
+
// Рассчитываем миллиэквиваленты (meq/L) для каждого иона
|
1229 |
const ions = {
|
1230 |
// Катионы
|
1231 |
+
'Ca': (profile['Ca'] || 0) * 2 / 40.08,
|
1232 |
+
'Mg': (profile['Mg'] || 0) * 2 / 24.305,
|
1233 |
+
'K': (profile['K'] || 0) * 1 / 39.098,
|
1234 |
+
'NH4': (profile['N (NH4+)'] || 0) * 1 / 18.038,
|
1235 |
// Анионы
|
1236 |
+
'NO3': (profile['N (NO3-)'] || 0) * 1 / 62.004,
|
1237 |
+
'SO4': (profile['S'] || 0) * 2 / 96.06,
|
1238 |
+
'H2PO4': (profile['P'] || 0) * 1 / 96.99
|
1239 |
};
|
1240 |
|
1241 |
+
// Суммируем катионы и анионы
|
1242 |
const totalCations = ions['Ca'] + ions['Mg'] + ions['K'] + ions['NH4'];
|
1243 |
const totalAnions = ions['NO3'] + ions['SO4'] + ions['H2PO4'];
|
1244 |
+
|
1245 |
+
// Рассчитываем процентное соотношение
|
1246 |
const total = totalCations + totalAnions;
|
1247 |
const cationPercent = (totalCations / total * 100).toFixed(1);
|
1248 |
const anionPercent = (totalAnions / total * 100).toFixed(1);
|
|
|
1251 |
console.log(`Анионы: ${totalAnions.toFixed(2)} mEq/L (${anionPercent}%)`);
|
1252 |
console.log(`Дисбаланс: ${(totalCations - totalAnions).toFixed(2)} mEq/L`);
|
1253 |
|
1254 |
+
// Обновляем UI
|
1255 |
+
document.getElementById("n1-value").textContent =
|
1256 |
+
`Катионы: ${totalCations.toFixed(2)} mEq/L | Анионы: ${totalAnions.toFixed(2)} mEq/L`;
|
1257 |
+
|
1258 |
+
// Обновляем индикаторы
|
1259 |
+
document.getElementById("cation-indicator").style.width = `${cationPercent}%`;
|
1260 |
+
document.getElementById("anion-indicator").style.width = `${anionPercent}%`;
|
|
|
|
|
|
|
|
|
1261 |
}
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
|
|
1266 |
|
1267 |
|
1268 |
|