-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
352 lines (300 loc) · 12.8 KB
/
index.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Decoration Gallery</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<style>
/* Basic styling */
body {
font-family: 'Verdana', sans-serif;
background-color: #181818;
color: #e0e0e0;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
overflow-x: hidden;
}
h1 {
color: #00ccff;
font-size: 36px;
text-transform: uppercase;
letter-spacing: 2px;
margin: 20px 0;
}
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Ensures flexibility */
grid-auto-rows: auto; /* Adjusts the height based on content */
gap: 20px;
width: 100%;
padding: 10px;
box-sizing: border-box;
}
.grid-item {
background-color: #292929;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
overflow: hidden;
text-align: center;
transition: transform 0.3s, background-color 0.2s;
position: relative;
cursor: pointer;
}
.grid-item:hover {
transform: scale(1.05);
background-color: #333333;
}
.grid-item img {
width: 100%;
height: auto;
object-fit: contain;
border-radius: 12px 12px 0 0;
transition: opacity 0.3s;
}
.grid-item img.preview {
position: absolute;
top: 0;
left: 0;
opacity: 0;
transition: opacity 0.3s;
}
.grid-item:hover img.main {
opacity: 0;
}
.grid-item:hover img.preview {
opacity: 1;
}
.decoration-name {
font-size: 14px;
color: #e0e0e0;
margin-top: 8px;
}
.creator-link, .socials-link {
display: block;
font-size: 14px;
color: #00ccff;
text-decoration: none;
margin: 5px 0;
}
.creator-link:hover, .socials-link:hover {
text-decoration: underline;
}
.group-title {
font-size: 28px;
color: #00ccff;
letter-spacing: 1px;
margin-top: 40px;
border-bottom: 2px solid #00ccff;
padding-bottom: 10px;
text-align: center;
}
.error-message {
color: #ff4d4d;
font-size: 18px;
text-align: center;
margin-top: 20px;
}
@media (max-width: 1024px) {
.grid-container {
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
gap: 15px;
}
.grid-item {
margin: 0 auto;
}
.group-title {
font-size: 24px;
}
}
@media (max-width: 768px) {
body {
padding: 10px;
}
h1 {
font-size: 28px;
}
.grid-container {
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 10px;
}
.group-title {
font-size: 20px;
}
.grid-item img {
max-height: 150px;
}
.decoration-name {
font-size: 12px;
}
}
@media (max-width: 480px) {
h1 {
font-size: 24px;
text-align: center;
}
.group-title {
font-size: 18px;
}
.grid-container {
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
.grid-item img {
max-height: 120px;
}
.decoration-name {
font-size: 10px;
}
.creator-link, .socials-link {
font-size: 10px;
}
}
@media (max-width: 320px) {
h1 {
font-size: 20px;
}
.group-title {
font-size: 16px;
}
.grid-container {
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
}
}
</style>
</head>
<body>
<h1>Decoration Gallery</h1>
<div id="grid" class="grid"></div>
<script>
// Fetch logos and decorations from separate json files dynamically
function loadGroupLogos() {
return fetch('https://raw.githubusercontent.com/DiscoLook/discolook.github.io/refs/heads/main/group_logos.json?' + Date.now())
.then(response => response.json())
.catch(error => {
console.error('Error loading group_logos.json:', error);
return {}; // Return an empty object if logos cannot be loaded
});
}
// Add this function to handle replacing the group title with the logo
function setGroupLogo(groupName, groupTitleElement, logos) {
if (logos[groupName]) {
// Create an image element for the logo
const logoImage = document.createElement('img');
logoImage.src = logos[groupName];
logoImage.alt = `${groupName} Logo`;
logoImage.style.height = '60px'; // Adjusted logo height for mobile screens
// Replace the text content with the logo
groupTitleElement.innerHTML = '';
groupTitleElement.appendChild(logoImage);
} else {
// If no logo exists, keep the original text
groupTitleElement.textContent = groupName.charAt(0).toUpperCase() + groupName.slice(1);
}
}
function getFileExtension(url) {
return url.split('.').pop().split(/\#|\?/)[0];
}
function loadDecorations(logos) {
fetch('https://raw.githubusercontent.com/DiscoLook/discolook.github.io/refs/heads/main/decorations.json?' + Date.now())
.then(response => {
if (!response.ok) throw new Error('Failed to load decorations.json');
return response.json();
})
.then(data => {
const grid = document.getElementById('grid');
grid.innerHTML = ''; // Clear any existing content
Object.entries(data.groups)
.sort((a, b) => b[1].length - a[1].length) // Sort groups by number of items in descending order
.forEach(([groupName, groupItems]) => {
// Create and append group title
const groupTitle = document.createElement('h2');
groupTitle.className = 'group-title';
// Set group title with logo (replaces text with image)
setGroupLogo(groupName, groupTitle, logos);
grid.appendChild(groupTitle);
// Create grid container for each group
const gridContainer = document.createElement('div');
gridContainer.className = 'grid-container';
groupItems.forEach(decoration => {
const gridItem = document.createElement('div');
gridItem.className = 'grid-item';
// Main and preview images
const mainImg = document.createElement('img');
mainImg.src = decoration.url;
mainImg.alt = decoration.name;
mainImg.className = 'main';
mainImg.loading = 'lazy';
const previewImg = document.createElement('img');
previewImg.src = decoration.preview || '';
previewImg.alt = `${decoration.name} Preview`;
previewImg.className = 'preview';
previewImg.loading = 'lazy';
// Decoration name
const decorationName = document.createElement('div');
decorationName.textContent = decoration.name;
decorationName.className = 'decoration-name';
// Creator link
const creatorLink = document.createElement('a');
creatorLink.href = `https://discordapp.com/users/${decoration.id}`;
creatorLink.textContent = decoration.creator;
creatorLink.className = 'creator-link';
creatorLink.target = '_blank';
// Creator socials link if available
if (decoration.creatorDecor && decoration.socials) {
const socialsLink = document.createElement('a');
socialsLink.href = decoration.socials;
socialsLink.textContent = decoration.decorText || 'For Zoink';
socialsLink.className = 'socials-link';
socialsLink.target = '_blank';
gridItem.appendChild(socialsLink);
}
// Add download functionality on click
gridItem.addEventListener('click', (event) => {
if (!event.target.closest('.creator-link') && !event.target.closest('.socials-link')) {
// Generate unique hash for the image
const uniqueValue = `${Date.now()}-${Math.random()}`;
const uniqueHash = CryptoJS.MD5(uniqueValue).toString();
fetch(decoration.url)
.then(response => {
if (!response.ok) throw new Error('Failed to fetch image');
return response.blob();
})
.then(blob => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${decoration.name}-${uniqueHash}.${getFileExtension(decoration.url)}`;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error downloading image:', error));
}
});
// Append items to the grid item
gridItem.appendChild(mainImg);
gridItem.appendChild(previewImg);
gridItem.appendChild(decorationName);
gridItem.appendChild(creatorLink);
gridContainer.appendChild(gridItem);
});
grid.appendChild(gridContainer);
});
})
.catch(error => {
console.error('Error loading decorations:', error);
const errorMessage = document.createElement('div');
errorMessage.className = 'error-message';
errorMessage.textContent = 'Failed to load decorations.';
document.body.appendChild(errorMessage);
});
}
// Load logos and decorations
loadGroupLogos().then(logos => loadDecorations(logos));
</script>
</body>
</html>