DmitrMakeev commited on
Commit
5bb687b
·
verified ·
1 Parent(s): 98e2e64

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +49 -79
nutri_call.html CHANGED
@@ -1,75 +1,53 @@
1
  <!DOCTYPE html>
2
  <html lang="ru">
3
  <head>
4
- <!-- Стили -->
5
- <link href="https://cdn.jsdelivr.net/npm/@pnotify/core@5/dist/PNotify.css" rel="stylesheet">
6
- <link href="https://cdn.jsdelivr.net/npm/@pnotify/bootstrap4@5/dist/PNotifyBootstrap4.css" rel="stylesheet">
7
- <link href="https://cdn.jsdelivr.net/npm/@pnotify/mobile@5/dist/PNotifyMobile.css" rel="stylesheet">
 
 
8
 
9
  <!-- Скрипты -->
10
- <script src="https://cdn.jsdelivr.net/npm/@pnotify/core@5/dist/iife/PNotify.js"></script>
11
- <script src="https://cdn.jsdelivr.net/npm/@pnotify/mobile@5/dist/iife/PNotifyMobile.js"></script>
12
- <script src="https://cdn.jsdelivr.net/npm/@pnotify/bootstrap4@5/dist/iife/PNotifyBootstrap4.js"></script>
13
-
14
- <script>
15
- // Инициализация PNotify
16
- function initPNotify() {
17
- PNotify.defaultModules.set(PNotifyMobile);
18
- PNotify.defaultModules.set(PNotifyBootstrap4);
19
- PNotify.defaults.styling = 'bootstrap4';
20
- PNotify.defaults.icons = 'fontawesome5';
21
- window.PNotifyReady = true;
22
-
23
- // Проверка инициализации
24
- console.log('PNotify initialized successfully');
25
- }
26
-
27
- // Запускаем инициализацию при полной загрузке страницы
28
- window.addEventListener('DOMContentLoaded', initPNotify);
29
-
30
- // Функция для показа уведомлений
31
- function showCalculationStatus(response) {
32
- if (!window.PNotifyReady) {
33
- console.error('PNotify not loaded yet');
34
- return;
35
- }
36
-
37
- const options = {
38
- width: '350px',
39
- delay: 4000,
40
- modules: {
41
- Mobile: {
42
- swipeDismiss: true
43
- }
 
44
  }
45
  };
46
-
47
- if (Object.keys(response.deficits || {}).length === 0) {
48
- new PNotify({
49
- ...options,
50
- title: 'Успешный расчёт',
51
- text: 'Все элементы сбалансированы',
52
- type: 'success',
53
- icon: 'fas fa-check-circle'
54
- });
55
- } else {
56
- new PNotify({
57
- ...options,
58
- title: 'Обнаружены дефициты',
59
- text: Object.entries(response.deficits)
60
- .map(([el, val]) => `<b>${el}:</b> ${val.toFixed(2)} ppm`)
61
- .join('<br>'),
62
- type: 'error',
63
- delay: 7000,
64
- icon: 'fas fa-exclamation-triangle'
65
- });
66
- }
67
- }
68
  </script>
69
 
70
- <!-- Font Awesome для иконок -->
71
- <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
72
-
73
 
74
 
75
 
@@ -765,24 +743,16 @@ function data_out(response) {
765
 
766
 
767
 
 
 
768
  <script>
769
- document.getElementById('testNotify').addEventListener('click', async () => {
770
- try {
771
- await showCalculationStatus({ deficits: {} });
772
- setTimeout(async () => {
773
- await showCalculationStatus({
774
- deficits: { Ca: -5.2, Mg: -1.1 },
775
- total_ppm: 480.0
776
- });
777
- }, 2000);
778
- } catch (error) {
779
- console.error('Ошибка показа уведомлений:', error);
780
- alert('Включите интернет для загрузки уведомлений');
781
- }
782
- });
783
  </script>
784
-
785
- <button id="testNotify">Проверить уведомления</button>
786
 
787
  </body>
788
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="ru">
3
  <head>
4
+ <!-- Основные стили -->
5
+ <link href="https://cdn.jsdelivr.net/npm/@pnotify/core@5.2.0/dist/PNotify.css" rel="stylesheet">
6
+ <!-- Мобильная поддержка -->
7
+ <link href="https://cdn.jsdelivr.net/npm/@pnotify/mobile@5.2.0/dist/PNotifyMobile.css" rel="stylesheet">
8
+ <!-- Тема -->
9
+ <link href="https://cdn.jsdelivr.net/npm/@pnotify/core@5.2.0/dist/BrightTheme.css" rel="stylesheet">
10
 
11
  <!-- Скрипты -->
12
+ <script type="module">
13
+ import { alert, defaultModules } from 'https://cdn.jsdelivr.net/npm/@pnotify/core@5.2.0/dist/PNotify.js';
14
+ import * as PNotifyMobile from 'https://cdn.jsdelivr.net/npm/@pnotify/mobile@5.2.0/dist/PNotifyMobile.js';
15
+
16
+ // Инициализация мобильного модуля
17
+ defaultModules.set(PNotifyMobile, {});
18
+
19
+ // Теперь функция showCalculationStatus будет доступна глобально
20
+ window.showCalculationStatus = function(response) {
21
+ if (Object.keys(response.deficits || {}).length === 0) {
22
+ alert({
23
+ title: 'Успешный расчёт',
24
+ text: 'Все элементы сбалансированы!',
25
+ type: 'success',
26
+ delay: 3000,
27
+ modules: {
28
+ Mobile: {
29
+ swipeDismiss: true
30
+ }
31
+ }
32
+ });
33
+ } else {
34
+ alert({
35
+ title: 'Обнаружены отклонения',
36
+ text: 'Дефициты: ' + Object.entries(response.deficits)
37
+ .map(([el, val]) => `${el}: ${val.toFixed(2)}ppm`)
38
+ .join(', '),
39
+ type: 'error',
40
+ delay: 5000,
41
+ modules: {
42
+ Mobile: {
43
+ swipeDismiss: true
44
+ }
45
+ }
46
+ });
47
  }
48
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  </script>
50
 
 
 
 
51
 
52
 
53
 
 
743
 
744
 
745
 
746
+ <button id="testNotify">Тест уведомлений</button>
747
+
748
  <script>
749
+ document.getElementById('testNotify').addEventListener('click', () => {
750
+ showCalculationStatus({ deficits: {} }); // Тест успеха
751
+ setTimeout(() => {
752
+ showCalculationStatus({ deficits: { Ca: -5.2, Mg: -1.1 } }); // Тест ошибки
753
+ }, 3500);
754
+ });
 
 
 
 
 
 
 
 
755
  </script>
 
 
756
 
757
  </body>
758
  </html>