1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
<!DOCTYPE html>
<html>
<head>
<title> waterpi </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#featured {
max-width: 100%; /* Ensures the image doesn't exceed its container */
height: auto; /* Maintains aspect ratio */
}
.gallery {
max-width: 800px;
margin: auto;
text-align: center;
}
.img-magnifier-container {
max-width: 800px;
position:relative;
}
.main-image img {
width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
.img-magnifier-glass {
position: absolute;
border: 3px solid #000;
border-radius: 50%;
cursor: none;
/*Set the size of the magnifier glass:*/
/* width: 200px;
height: 200px;*/
}
.controls {
display: flex;
justify-content: center;
gap: 20px;
align-items: center;
}
.nav-button {
padding: 10px 20px;
font-size: 24px;
cursor: pointer;
border: none;
background-color: #f0f0f0;
border-radius: 5px;
transition: background-color 0.3s;
}
.now-button {
padding: 12px 24px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
border: none;
background-color: #4CAF50;
color: white;
border-radius: 5px;
transition: background-color 0.3s;
}
.now-button:hover {
background-color: #45a049;
}
.nav-button:hover {
background-color: #e0e0e0;
}
.nav-button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
</style>
<script>
function magnify(imgID, zoom) {
var img, glass, w, h, bw;
img = document.getElementById(imgID);
/*create magnifier glass:*/
glass = document.createElement("DIV");
glass.setAttribute("class", "img-magnifier-glass");
//set width and height
const displayWidth = window.innerWidth;
const displayHeight = window.innerHeight;
// Calculate 10% of the smaller dimension
const magnifierSize = Math.floor(Math.min(displayWidth, displayHeight) * 0.25);
// Update the magnifier's size dynamically
glass.style.width=`${magnifierSize}px`;
glass.style.height=`${magnifierSize}px`;
/*insert magnifier glass:*/
img.parentElement.insertBefore(glass, img);
/*set background properties for the magnifier glass:*/
glass.style.backgroundImage = "url('" + img.src + "')";
glass.style.backgroundRepeat = "no-repeat";
glass.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px";
bw = 3;
w = glass.offsetWidth / 2;
h = glass.offsetHeight / 2;
/*execute a function when someone moves the magnifier glass over the image:*/
glass.addEventListener("mousemove", moveMagnifier);
img.addEventListener("mousemove", moveMagnifier);
/*and also for touch screens:*/
glass.addEventListener("touchmove", moveMagnifier);
img.addEventListener("touchmove", moveMagnifier);
function moveMagnifier(e) {
var pos, x, y;
/*prevent any other actions that may occur when moving over the image*/
e.preventDefault();
/*get the cursor's x and y positions:*/
pos = getCursorPos(e);
x = pos.x;
y = pos.y;
/*prevent the magnifier glass from being positioned outside the image:*/
if (x > img.width - (w / zoom)) {x = img.width - (w / zoom);}
if (x < w / zoom) {x = w / zoom;}
if (y > img.height - (h / zoom)) {y = img.height - (h / zoom);}
if (y < h / zoom) {y = h / zoom;}
/*set the position of the magnifier glass:*/
glass.style.left = (x - w) + "px";
glass.style.top = (y - h) + "px";
/*display what the magnifier glass "sees":*/
glass.style.backgroundPosition = "-" + ((x * zoom) - w + bw) + "px -" + ((y * zoom) - h + bw) + "px";
}
function getCursorPos(e) {
var a, x = 0, y = 0;
e = e || window.event;
/*get the x and y positions of the image:*/
a = img.getBoundingClientRect();
/*calculate the cursor's x and y coordinates, relative to the image:*/
x = e.pageX - a.left;
y = e.pageY - a.top;
/*consider any page scrolling:*/
x = x - window.pageXOffset;
y = y - window.pageYOffset;
return {x : x, y : y};
}
}
function resetMagnifier() {
// Remove existing magnifier glass
const existingGlass = document.querySelector('.img-magnifier-glass');
if (existingGlass) {
existingGlass.remove();
}
}
</script>
</head>
<body>
<div class="gallery">
<div class="img-magnifier-container">
<img id="featured" src="12_00.jpg" alt="image of a hopefully healty coffee plant" onerror="this.src='error.png'">
</div>
<div class="controls">
<button onclick="jumpTime(-60)" class="nav-button"><img src="fbck.png"></button>
<button onclick="jumpTime(-15)" class="nav-button"><img src="bck.png"></button>
<button onclick="jumpToCurrent()" class="now-button"><img src="stop.png"></button>
<button onclick="jumpTime(15)" class="nav-button"><img src="fwd.png"></button>
<button onclick="jumpTime(60)" class="nav-button"><img src="ffwd.png"></button>
</div>
</div>
<a href="history.html">go to 12:00 images</a>
</body>
</html>
<script>
let currentDateTime = new Date();
function roundToQuarterHour(date) {
const minutes = date.getMinutes();
const roundedMinutes = Math.floor(minutes / 15) * 15;
const newDate = new Date(date);
newDate.setMinutes(roundedMinutes);
newDate.setSeconds(0);
newDate.setMilliseconds(0);
return newDate;
}
function formatTimeString(date) {
return date.getHours().toString().padStart(2, '0') + '_' +
date.getMinutes().toString().padStart(2, '0');
}
function updateGallery() {
currentDateTime = roundToQuarterHour(new Date());
updateImage();
updateButtons();
}
function jumpTime(minutes) {
const newTime = new Date(currentDateTime.getTime() + minutes * 60000);
const now = new Date();
if (newTime <= now) {
currentDateTime = newTime;
updateImage();
updateButtons();
}
}
function jumpToCurrent() {
currentDateTime = roundToQuarterHour(new Date());
updateImage();
updateButtons();
}
function updateImage() {
const timeString = formatTimeString(currentDateTime);
document.getElementById('featured').src = `${timeString}.jpg`;
// Wait for the new image to load before reinitializing
const featuredImage = document.getElementById('featured');
featuredImage.onload = function() {
resetMagnifier();
magnify("featured", 3);
};
}
function updateButtons() {
const now = roundToQuarterHour(new Date());
const buttons = document.querySelectorAll('.nav-button');
// Deaktiviere Vorwärts-Buttons wenn aktuelle Zeit erreicht
buttons[2].disabled = currentDateTime.getTime() + 15 * 60000 > now.getTime();
buttons[3].disabled = currentDateTime.getTime() + 60 * 60000 > now.getTime();
// Deaktiviere den Aktuell-Button wenn bereits das aktuelle Bild angezeigt wird
document.querySelector('.now-button').disabled =
currentDateTime.getTime() === now.getTime();
}
document.addEventListener('keydown', function(event) {
switch(event.key) {
case 'ArrowUp':
jumpTime(60); // Vorwärts um 1 Stunde
break;
case 'ArrowDown':
jumpTime(-60); // Rückwärts um 1 Stunde
break;
case 'ArrowRight':
jumpTime(15); // Vorwärts um 15 Minuten
break;
case 'ArrowLeft':
jumpTime(-15); // Rückwärts um 15 Minuten
break;
}
});
// Initial gallery setup
updateGallery();
/* Initiate Magnify Function
with the id of the image, and the strength of the magnifier glass:*/
const featuredImage = document.getElementById('featured');
featuredImage.onload = function() {
magnify("featured", 3);
};
// Aktualisiere die Galerie alle 15 Minuten
setInterval(updateGallery, 900000);
</script>
|