-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgallery.html
108 lines (93 loc) · 3.07 KB
/
gallery.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Martian Potato - Image Gallery</title>
<style>
body {
margin: 0;
padding: 20px;
background-color: #1a1a1a;
color: #fff;
font-family: Arial, sans-serif;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
padding: 20px;
}
.gallery-item {
position: relative;
overflow: hidden;
border-radius: 8px;
background: #2a2a2a;
transition: transform 0.3s ease;
}
.gallery-item:hover {
transform: scale(1.02);
}
.gallery-item img {
width: 100%;
height: 200px;
object-fit: cover;
display: block;
}
.gallery-item .caption {
padding: 10px;
text-align: center;
font-size: 14px;
}
h1 {
text-align: center;
margin-bottom: 30px;
color: #fff;
}
.back-button {
display: inline-block;
padding: 10px 20px;
background-color: #4a4a4a;
color: white;
text-decoration: none;
border-radius: 5px;
margin-bottom: 20px;
transition: background-color 0.3s ease;
}
.back-button:hover {
background-color: #666;
}
</style>
</head>
<body>
<a href="/" class="back-button">← Back to Game</a>
<h1>Martian Potato Image Gallery</h1>
<div class="gallery" id="imageGallery"></div>
<script>
async function loadImages() {
const gallery = document.getElementById('imageGallery');
try {
const response = await fetch('/api/images');
const images = await response.json();
images.forEach(image => {
const item = document.createElement('div');
item.className = 'gallery-item';
const img = document.createElement('img');
img.src = `/images/${image}`;
img.alt = image.split('.')[0];
const caption = document.createElement('div');
caption.className = 'caption';
caption.textContent = image.split('.')[0].replace(/-/g, ' ');
item.appendChild(img);
item.appendChild(caption);
gallery.appendChild(item);
});
} catch (error) {
console.error('Error loading images:', error);
gallery.innerHTML = '<p>Error loading images. Please try again later.</p>';
}
}
window.addEventListener('load', loadImages);
</script>
</body>
</html>