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
|
<!DOCTYPE html>
<html>
<head>
<title> waterpi </title>
<meta http-equiv="refresh" content="60">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.gallery {
max-width: 800px;
margin: 0 auto;
text-align: center;
}
.main-image {
margin-bottom: 20px;
}
.main-image img {
width: 100%;
height: auto;
display: block;
margin: 0 auto;
object-fit: contain;
}
.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, .now-button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
</style>
</head>
<body>
<div class="gallery">
<div class="main-image">
<img id="featured" src="" alt="Hauptbild" onerror="this.src='error.png'">
</div>
<div class="controls">
<button onclick="jumpDays(-7)" class="nav-button"><img src="fbck.png"></button>
<button onclick="jumpDays(-1)" class="nav-button"><img src="bck.png"></button>
<button onclick="jumpToCurrent()" class="now-button"><img src="stop.png"></button>
<button onclick="jumpDays(1)" class="nav-button"><img src="fwd.png"></button>
<button onclick="jumpDays(7)" class="nav-button"><img src="ffwd.png"></button>
</div>
</div>
<a href="index.html">go to current day</a>
</body>
</html>
<script>
let currentDate = new Date();
function formatDateString(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}_12_00`;
}
function updateGallery() {
// Setze die Uhrzeit auf 12:00
currentDate.setHours(12, 0, 0, 0);
updateImage();
updateButtons();
}
function jumpDays(days) {
const newDate = new Date(currentDate);
newDate.setDate(newDate.getDate() + days);
const today = new Date();
today.setHours(12, 0, 0, 0);
// Prüfe ob das neue Datum nicht in der Zukunft liegt
if (newDate <= today) {
currentDate = newDate;
updateImage();
updateButtons();
}
}
function jumpToCurrent() {
const today = new Date();
today.setHours(12, 0, 0, 0);
currentDate = today;
updateImage();
updateButtons();
}
function updateImage() {
const dateString = formatDateString(currentDate);
const img = document.getElementById('featured');
img.src = `waterpi_12h_images/${dateString}.jpg`;
}
function updateButtons() {
const today = new Date();
today.setHours(12, 0, 0, 0);
const buttons = document.querySelectorAll('.nav-button');
// Deaktiviere Vorwärts-Buttons wenn aktueller Tag erreicht
buttons[2].disabled = currentDate.getTime() + 24 * 60 * 60 * 1000 > today.getTime();
buttons[3].disabled = currentDate.getTime() + 7 * 24 * 60 * 60 * 1000 > today.getTime();
// Deaktiviere den Heute-Button wenn bereits der aktuelle Tag angezeigt wird
document.querySelector('.now-button').disabled =
currentDate.getTime() === today.getTime();
}
// Initial gallery setup
updateGallery();
// Aktualisiere die Galerie jede Sekunde
//setInterval(updateGallery, 1000);
</script>
|