summaryrefslogtreecommitdiff
path: root/index.html
blob: 73afdc884b8a2dc04914f489f8e43f882b932d57 (plain)
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
<!DOCTYPE html>
<html>
	<head>
		<title> waterpi </title>
		<meta http-equiv="refresh" content="60">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<style>
.responsive {
	width: 100%;
	max-width: 800;
	height: auto;
}
.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;
}

.thumbnails {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.thumbnails img {
    width: calc(20% - 8px);
    height: auto;
    cursor: pointer;
    transition: opacity 0.3s;
}

.thumbnails img:hover {
    opacity: 0.7;
}

		</style>
	</head>

	<body>
    <div class="gallery">
    <div class="main-image">
        <img id="featured" src="" alt="Hauptbild">
    </div>
    <div class="thumbnails" id="thumbnail-container">
    </div>
</div>
	</body>
</html>

<script>
let imageTimesList = [];

function roundToEvenMinute(date) {
    const minutes = date.getMinutes();
    date.setMinutes(minutes - (minutes % 2));
    return date;
}

function formatTimeString(date) {
    return date.getHours().toString().padStart(2, '0') + '_' + 
           date.getMinutes().toString().padStart(2, '0');
}

function updateGallery() {
    const now = roundToEvenMinute(new Date());
    imageTimesList = [];
    
    // Generiere Liste von 6 Zeitstempeln (1 Hauptbild + 5 Thumbnails)
    for(let i = 0; i < 6; i++) {
        const timeString = formatTimeString(new Date(now - i * 60 * 60 * 1000));
        imageTimesList.push(timeString);
    }
    
    renderGallery();
}

function renderGallery() {
    // Hauptbild aktualisieren
    document.getElementById('featured').src = `${imageTimesList[0]}.jpg`;
    
    // Thumbnails aktualisieren
    const thumbnailContainer = document.getElementById('thumbnail-container');
    thumbnailContainer.innerHTML = '';
    
    // Erstelle die 5 Thumbnails
    for(let i = 1; i < imageTimesList.length; i++) {
        const thumbnail = document.createElement('img');
        thumbnail.src = `${imageTimesList[i]}.jpg`;
        thumbnail.alt = `Thumbnail ${i}`;
        thumbnail.onclick = () => rotateImages(i);
        thumbnailContainer.appendChild(thumbnail);
    }
}

function rotateImages(clickedIndex) {
    // Bringe das geklickte Bild nach vorne und rotiere die anderen
    const clickedTime = imageTimesList[clickedIndex];
    imageTimesList.splice(clickedIndex, 1); // Entferne das geklickte Element
    imageTimesList.unshift(clickedTime);    // Füge es vorne ein
    
    renderGallery();
}

// Initial gallery setup
updateGallery();

// Aktualisiere die Galerie alle 2 Minuten
setInterval(updateGallery, 120000);


</script>