DmitrMakeev commited on
Commit
c06d8c1
·
verified ·
1 Parent(s): 0477840

Update online.html

Browse files
Files changed (1) hide show
  1. online.html +128 -40
online.html CHANGED
@@ -34,36 +34,82 @@
34
  <style>
35
  /* Стили для блока с картинкой растения */
36
  .plant-image-container {
37
- text-align: center; /* Центрируем содержимое */
38
- margin: 20px auto; /* Отступы сверху/снизу и автоматические по бокам для центрирования */
39
- max-width: 80%; /* Максимальная ширина блока */
40
  padding: 15px;
41
- background-color: #f8f9fa; /* Светло-серый фон */
42
- border-radius: 15px; /* Закругленные углы */
43
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Тень для "поднятия" блока */
 
44
  }
45
 
46
- /* Стили для самой картинки */
47
  #plantImage {
48
- max-width: 80%; /* Уменьшаем размер картинки */
49
  height: auto;
50
- border: 3px solid #dee2e6; /* Серая рамка */
51
- border-radius: 10px; /* Закругленные углы у картинки */
52
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Легкая тень */
53
- display: block; /* Чтобы margin: auto работал */
54
- margin: 0 auto 15px; /* Центрирование и отступ снизу */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  /* Заголовок над картинкой */
58
  .plant-image-container h1 {
59
  margin-bottom: 15px;
60
- color: #343a40; /* Темно-серый цвет текста */
61
  font-size: 2.5rem;
62
  }
63
  </style>
64
 
65
 
66
-
67
 
68
 
69
 
@@ -298,9 +344,11 @@ document.addEventListener("DOMContentLoaded", function () {
298
  <br>
299
 
300
 
 
301
  <div class="plant-image-container">
302
  <h1>Текущее состояние растения</h1>
303
  <img id="plantImage" src="/last_image" alt="Изображение растения">
 
304
  </div>
305
 
306
  <br>
@@ -1012,31 +1060,71 @@ function updateAlW(value) {
1012
  setInterval(fetchValues, 10000);
1013
  };
1014
  </script>
1015
- <script>
1016
- function updateImage() {
1017
- // Добавляем timestamp для предотвращения кеширования
1018
- const timestamp = new Date().getTime();
1019
- const imgElement = document.getElementById("plantImage");
1020
-
1021
- // Показываем индикатор загрузки
1022
- imgElement.style.opacity = "0.9";
1023
-
1024
- // Обновляем источник изображения
1025
- imgElement.src = "/last_image?t=" + timestamp;
1026
-
1027
- // Возвращаем нормальную прозрачность после загрузки
1028
- imgElement.onload = function() {
1029
- imgElement.style.opacity = "1";
1030
- }
1031
- }
1032
- // Первичная загрузка при открытии страницы
1033
- document.addEventListener('DOMContentLoaded', function() {
1034
- updateImage();
1035
-
1036
- // Автоматическое обновление каждые 10 секунд
1037
- setInterval(updateImage, 10000);
1038
- });
1039
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
 
1041
  </body>
1042
  </html>
 
34
  <style>
35
  /* Стили для блока с картинкой растения */
36
  .plant-image-container {
37
+ text-align: center;
38
+ margin: 20px auto;
39
+ max-width: 80%;
40
  padding: 15px;
41
+ background-color: #f8f9fa;
42
+ border-radius: 15px;
43
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
44
+ cursor: pointer; /* Добавляем курсор-указатель */
45
  }
46
 
47
+ /* Стили для обычного размера картинки */
48
  #plantImage {
49
+ max-width: 60%;
50
  height: auto;
51
+ border: 3px solid #dee2e6;
52
+ border-radius: 10px;
53
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
54
+ display: block;
55
+ margin: 0 auto 15px;
56
+ transition: transform 0.3s ease; /* Анимация при наведении */
57
+ }
58
+
59
+ /* Увеличение при наведении */
60
+ #plantImage:hover {
61
+ transform: scale(1.03);
62
+ }
63
+
64
+ /* Стили для полноэкранного режима */
65
+ #plantImage.fullscreen {
66
+ position: fixed;
67
+ top: 0;
68
+ left: 0;
69
+ right: 0;
70
+ bottom: 0;
71
+ max-width: 100%;
72
+ max-height: 100%;
73
+ width: auto;
74
+ height: auto;
75
+ margin: auto;
76
+ z-index: 1000;
77
+ background-color: rgba(0, 0, 0, 0.9);
78
+ border: none;
79
+ border-radius: 0;
80
+ cursor: grab;
81
+ object-fit: contain;
82
+ padding: 20px;
83
+ box-sizing: border-box;
84
+ }
85
+
86
+ /* Кнопка закрытия */
87
+ .close-fullscreen {
88
+ position: fixed;
89
+ top: 20px;
90
+ right: 20px;
91
+ color: white;
92
+ font-size: 30px;
93
+ z-index: 1001;
94
+ cursor: pointer;
95
+ display: none;
96
+ background: rgba(0, 0, 0, 0.5);
97
+ width: 40px;
98
+ height: 40px;
99
+ text-align: center;
100
+ line-height: 40px;
101
+ border-radius: 50%;
102
  }
103
 
104
  /* Заголовок над картинкой */
105
  .plant-image-container h1 {
106
  margin-bottom: 15px;
107
+ color: #343a40;
108
  font-size: 2.5rem;
109
  }
110
  </style>
111
 
112
 
 
113
 
114
 
115
 
 
344
  <br>
345
 
346
 
347
+ <!-- HTML-блок с картинкой -->
348
  <div class="plant-image-container">
349
  <h1>Текущее состояние растения</h1>
350
  <img id="plantImage" src="/last_image" alt="Изображение растения">
351
+ <div class="close-fullscreen" id="closeFullscreen">×</div>
352
  </div>
353
 
354
  <br>
 
1060
  setInterval(fetchValues, 10000);
1061
  };
1062
  </script>
1063
+ <script>
1064
+ // Обработчик клика по картинке
1065
+ document.getElementById('plantImage').addEventListener('click', function() {
1066
+ this.classList.toggle('fullscreen');
1067
+ document.getElementById('closeFullscreen').style.display =
1068
+ this.classList.contains('fullscreen') ? 'block' : 'none';
1069
+
1070
+ // Блокируем скролл страницы при открытом изображении
1071
+ document.body.style.overflow =
1072
+ this.classList.contains('fullscreen') ? 'hidden' : '';
1073
+ });
1074
+
1075
+ // Обработчик закрытия по кнопке
1076
+ document.getElementById('closeFullscreen').addEventListener('click', function() {
1077
+ const img = document.getElementById('plantImage');
1078
+ img.classList.remove('fullscreen');
1079
+ this.style.display = 'none';
1080
+ document.body.style.overflow = '';
1081
+ });
1082
+
1083
+ // Функция для перетаскивания изображения
1084
+ let isDragging = false;
1085
+ let startY, startScrollTop;
1086
+
1087
+ document.getElementById('plantImage').addEventListener('mousedown', function(e) {
1088
+ if (!this.classList.contains('fullscreen')) return;
1089
+
1090
+ isDragging = true;
1091
+ startY = e.clientY;
1092
+ startScrollTop = window.scrollY;
1093
+ this.style.cursor = 'grabbing';
1094
+ e.preventDefault(); // Предотвращаем выделение текста
1095
+ });
1096
+
1097
+ document.addEventListener('mousemove', function(e) {
1098
+ const img = document.getElementById('plantImage');
1099
+ if (!isDragging || !img.classList.contains('fullscreen')) return;
1100
+
1101
+ window.scrollTo(0, startScrollTop - (e.clientY - startY));
1102
+ });
1103
+
1104
+ document.addEventListener('mouseup', function() {
1105
+ isDragging = false;
1106
+ const img = document.getElementById('plantImage');
1107
+ if (img.classList.contains('fullscreen')) {
1108
+ img.style.cursor = 'grab';
1109
+ }
1110
+ });
1111
+
1112
+ // Обновление изображения (ваш существующий код)
1113
+ function updateImage() {
1114
+ const timestamp = new Date().getTime();
1115
+ const imgElement = document.getElementById("plantImage");
1116
+ imgElement.style.opacity = "0.9";
1117
+ imgElement.src = "/last_image?t=" + timestamp;
1118
+ imgElement.onload = function() {
1119
+ imgElement.style.opacity = "1";
1120
+ }
1121
+ }
1122
+
1123
+ document.addEventListener('DOMContentLoaded', function() {
1124
+ updateImage();
1125
+ setInterval(updateImage, 10000);
1126
+ });
1127
+ </script>
1128
 
1129
  </body>
1130
  </html>