Spaces:
Running
Running
Update nutri_call.html
Browse files- nutri_call.html +61 -2
nutri_call.html
CHANGED
@@ -1,6 +1,13 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="ru">
|
3 |
<head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<title>Калькулятор удобрений</title>
|
6 |
<style>
|
@@ -595,8 +602,13 @@ document.getElementById('calculate-btn').addEventListener('click', function() {
|
|
595 |
.then(data => {
|
596 |
call_data = data;
|
597 |
console.log("=== УСПЕШНЫЙ ОТВЕТ ОТ СЕРВЕРА ===", call_data);
|
598 |
-
|
599 |
-
|
|
|
|
|
|
|
|
|
|
|
600 |
// Проверяем, применилась ли точность округления
|
601 |
console.log("Проверка округления в ответе:");
|
602 |
if (data.fertilizers) {
|
@@ -657,6 +669,53 @@ function data_out(response) {
|
|
657 |
console.log("Данные успешно обновлены");
|
658 |
}
|
659 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
660 |
|
661 |
</script>
|
662 |
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="ru">
|
3 |
<head>
|
4 |
+
|
5 |
+
|
6 |
+
<link href="https://cdn.jsdelivr.net/npm/pnotify@3.2.1/dist/pnotify.css" rel="stylesheet">
|
7 |
+
<script src="https://cdn.jsdelivr.net/npm/pnotify@3.2.1/dist/pnotify.js"></script>
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
<meta charset="UTF-8">
|
12 |
<title>Калькулятор удобрений</title>
|
13 |
<style>
|
|
|
602 |
.then(data => {
|
603 |
call_data = data;
|
604 |
console.log("=== УСПЕШНЫЙ ОТВЕТ ОТ СЕРВЕРА ===", call_data);
|
605 |
+
|
606 |
+
// Выводим данные в форму
|
607 |
+
data_out(call_data);
|
608 |
+
|
609 |
+
// Показываем статус расчёта
|
610 |
+
showCalculationStatus(call_data); // <-- Вот эта строка запуска
|
611 |
+
|
612 |
// Проверяем, применилась ли точность округления
|
613 |
console.log("Проверка округления в ответе:");
|
614 |
if (data.fertilizers) {
|
|
|
669 |
console.log("Данные успешно обновлены");
|
670 |
}
|
671 |
|
672 |
+
|
673 |
+
|
674 |
+
|
675 |
+
|
676 |
+
|
677 |
+
|
678 |
+
function showCalculationStatus(response) {
|
679 |
+
// Инициализация PNotify с настройками
|
680 |
+
PNotify.defaults.styling = 'bootstrap4';
|
681 |
+
PNotify.defaults.icons = 'fontawesome5';
|
682 |
+
PNotify.defaults.delay = 5000;
|
683 |
+
PNotify.defaults.width = '300px';
|
684 |
+
|
685 |
+
if (Object.keys(response.deficits || {}).length === 0) {
|
686 |
+
new PNotify({
|
687 |
+
title: 'Расчёт успешен!',
|
688 |
+
text: 'Все элементы сбалансированы',
|
689 |
+
type: 'success',
|
690 |
+
addclass: 'custom-success',
|
691 |
+
icon: 'fa fa-check-circle',
|
692 |
+
cornerclass: 'ui-pnotify-sharp',
|
693 |
+
stack: {"dir1": "down", "dir2": "left", "push": "top"}
|
694 |
+
});
|
695 |
+
} else {
|
696 |
+
const deficitText = Object.entries(response.deficits)
|
697 |
+
.map(([el, val]) => `${el}: ${val.toFixed(2)} ppm`)
|
698 |
+
.join('<br>');
|
699 |
+
|
700 |
+
new PNotify({
|
701 |
+
title: 'Обнаружены дефициты',
|
702 |
+
text: deficitText,
|
703 |
+
type: 'error',
|
704 |
+
addclass: 'custom-error',
|
705 |
+
icon: 'fa fa-exclamation-triangle',
|
706 |
+
cornerclass: 'ui-pnotify-sharp',
|
707 |
+
stack: {"dir1": "down", "dir2": "left", "push": "top"}
|
708 |
+
});
|
709 |
+
}
|
710 |
+
}
|
711 |
+
|
712 |
+
|
713 |
+
|
714 |
+
|
715 |
+
|
716 |
+
|
717 |
+
|
718 |
+
|
719 |
|
720 |
</script>
|
721 |
|