-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
567 lines (496 loc) · 17.1 KB
/
Copy pathindex.html
File metadata and controls
567 lines (496 loc) · 17.1 KB
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>assets.DLES.gg</title>
<link rel="icon" href="favicon.ico" sizes="any" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Rampart+One&display=swap"
rel="stylesheet"
/>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Poppins", Arial, Helvetica, sans-serif;
background: #fff9ef;
color: #1a1a1a;
line-height: 1.6;
padding: 2rem 1rem;
}
.container {
max-width: 720px;
margin: 0 auto;
}
header {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 0.5rem 1rem;
margin-bottom: 2.5rem;
padding-bottom: 1.5rem;
border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}
h1 {
font-family: "Rampart One", cursive;
font-size: 2.5rem;
color: #d900ff;
letter-spacing: -0.02em;
line-height: 1.1;
white-space: nowrap;
}
header p {
flex-basis: 100%;
text-align: center;
color: rgba(0, 0, 0, 0.5);
font-size: 0.85rem;
font-weight: 400;
line-height: 1.4;
}
h2 {
font-size: 1.25rem;
font-weight: 700;
margin: 2.5rem 0 1rem;
color: #a600ac;
}
.word-list {
list-style: none;
display: grid;
gap: 0.75rem;
}
.word-list li {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.5rem 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.word-list li:last-child {
border-bottom: none;
}
.word-list .info {
flex: 1;
}
.word-list .info > a {
color: #a600ac;
text-decoration: none;
font-weight: 600;
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 0.9rem;
}
.word-list .info > a:hover {
text-decoration: underline;
}
.word-list .meta {
color: rgba(0, 0, 0, 0.5);
font-size: 0.85rem;
margin-top: 0.25rem;
}
.word-list .meta a {
color: #d900ff;
font-family: "Poppins", Arial, Helvetica, sans-serif;
font-size: 0.85rem;
font-weight: 500;
}
.word-list .meta span {
color: #a856f7;
font-weight: 600;
}
.btn-download {
display: inline-block;
background: #d900ff;
color: #fff;
font-weight: 600;
font-size: 0.8rem;
text-decoration: none;
padding: 0.4em 1em;
border-radius: 8px;
white-space: nowrap;
transition:
background 0.2s ease,
transform 0.2s ease;
}
.btn-download:hover {
background: #a600ac;
transform: scale(1.05);
text-decoration: none;
}
.btn-explore {
display: inline-block;
background: transparent;
color: #d900ff;
border: 2px solid #d900ff;
font-weight: 600;
font-size: 0.8rem;
text-decoration: none;
padding: calc(0.4em - 2px) calc(1em - 2px);
border-radius: 8px;
white-space: nowrap;
transition:
background 0.2s ease,
color 0.2s ease,
transform 0.2s ease;
}
.btn-explore:hover {
background: #d900ff;
color: #fff;
transform: scale(1.05);
text-decoration: none;
}
/* Plain links (no asset to explore/download) use the regular body font */
.word-list li.link-only .info > a {
font-family: "Poppins", Arial, Helvetica, sans-serif;
font-size: 1rem;
color: #d900ff;
}
.actions {
display: flex;
gap: 0.5rem;
align-items: center;
}
h3 {
font-size: 1.1rem;
font-weight: 600;
margin: 1.5rem 0 0.75rem;
color: #1a1a1a;
}
.resources {
list-style: none;
}
.resources li {
padding: 0.5rem 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.resources li:last-child {
border-bottom: none;
}
.resources a {
color: #d900ff;
text-decoration: none;
font-weight: 500;
}
.resources a:hover {
text-decoration: underline;
}
.resources .desc {
color: rgba(0, 0, 0, 0.5);
font-size: 0.85rem;
}
code {
background: rgba(168, 86, 247, 0.1);
color: #a600ac;
padding: 0.15em 0.4em;
border-radius: 4px;
font-size: 0.85em;
}
.note {
background: #fff;
border: 2px solid rgba(0, 0, 0, 0.08);
border-left: 4px solid #d900ff;
border-radius: 12px;
padding: 0.75rem 1rem;
margin: 1.25rem 0;
font-size: 0.9rem;
color: rgba(0, 0, 0, 0.5);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.note a {
color: #d900ff;
}
.note strong {
color: #1a1a1a;
}
.intro {
color: rgba(0, 0, 0, 0.6);
font-size: 0.95rem;
margin-bottom: 1rem;
}
.intro p {
margin-bottom: 0.75rem;
}
.intro p:last-child {
margin-bottom: 0;
}
a.highlight {
color: #d900ff;
text-decoration: none;
font-weight: 600;
}
a.highlight:hover {
text-decoration: underline;
}
footer {
margin-top: 3rem;
padding-top: 1.5rem;
border-top: 2px solid rgba(0, 0, 0, 0.1);
text-align: center;
font-size: 0.8rem;
}
footer a {
font-family: "Rampart One", cursive;
color: #d900ff;
text-decoration: none;
font-size: 1.1rem;
}
footer a:hover {
text-decoration: underline;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script
defer
src="https://datafa.st/js/script.js"
data-website-id="dfid_csHpeEcLThGggDSTTRmBm"
data-domain="dles.gg"
></script>
</head>
<body>
<div class="container">
<header>
<h1>assets.DLES.gg</h1>
<p>
Collection of free assets for daily game makers: words, dictionaries,
sounds and images.
</p>
</header>
<div
id="loading-placeholder"
class="intro"
style="text-align: center; padding: 3rem 0; opacity: 0.6"
>
<p>Loading assets collection...</p>
</div>
<footer>
Made with ❤️ for <a href="https://dles.gg">daily games</a> by
<a href="https://buymeacoffee.com/trizoza">trizoza</a>
</footer>
</div>
<script>
async function loadReadme() {
try {
const response = await fetch("README.md");
if (!response.ok) throw new Error("Failed to fetch README.md");
const markdown = await response.text();
// Convert markdown to HTML using marked.js
const rawHtml = marked.parse(markdown);
// Use DOMParser to parse the HTML string
const parser = new DOMParser();
const doc = parser.parseFromString(rawHtml, "text/html");
const sourceBody = doc.body;
const container = document.querySelector(".container");
const header = container.querySelector("header");
const footer = container.querySelector("footer");
const newNodes = [];
let currentSection = "";
let currentIntroDiv = null;
let hasSetSubtitle = false;
Array.from(sourceBody.children).forEach((child) => {
const tagName = child.tagName.toLowerCase();
// If it is H1, update the page title and header title
if (tagName === "h1") {
const siteTitle = header.querySelector("h1");
if (siteTitle) siteTitle.textContent = child.textContent;
document.title = child.textContent;
currentIntroDiv = null;
}
// If it is the first paragraph after H1, update the subtitle
else if (tagName === "p" && !hasSetSubtitle) {
const siteSubtitle = header.querySelector("p");
if (siteSubtitle) siteSubtitle.innerHTML = child.innerHTML;
hasSetSubtitle = true;
currentIntroDiv = null;
}
// Intro/General paragraphs (group consecutive <p> tags into a single <div class="intro">)
else if (tagName === "p") {
if (!currentIntroDiv) {
currentIntroDiv = document.createElement("div");
currentIntroDiv.className = "intro";
newNodes.push(currentIntroDiv);
}
const p = document.createElement("p");
p.innerHTML = child.innerHTML;
p.querySelectorAll("a").forEach((a) => {
a.classList.add("highlight");
});
currentIntroDiv.appendChild(p);
}
// Headings (H2, H3, etc.)
else if (/^h[2-6]$/.test(tagName)) {
currentIntroDiv = null;
currentSection = child.textContent.trim();
const heading = document.createElement(tagName);
heading.innerHTML = child.innerHTML;
// Slug from the heading text so it can be linked via #hash
// (e.g. assets.dles.gg/#words scrolls to the Words section)
heading.id = currentSection
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
newNodes.push(heading);
}
// Lists (UL)
else if (tagName === "ul") {
currentIntroDiv = null;
const ul = document.createElement("ul");
ul.className = "word-list";
Array.from(child.children).forEach((li) => {
const newLi = document.createElement("li");
const firstLink = li.querySelector("a");
const rawHref = firstLink
? firstLink.getAttribute("href")
: null;
// Normalise a leading "./" or "/" so we can test for asset paths
const relativePath = rawHref
? rawHref.replace(/^\.?\//, "")
: "";
const isAsset = /^assets\//i.test(relativePath);
if (firstLink && isAsset) {
// Asset resource: link + meta + Explore/Download buttons
const fileLink = firstLink.cloneNode(true);
const infoDiv = document.createElement("div");
infoDiv.className = "info";
infoDiv.appendChild(fileLink);
// Remove first link to extract metadata
firstLink.remove();
let metaHtml = li.innerHTML.trim();
metaHtml = metaHtml.replace(/^[\s\-\–\—\•]+/, ""); // remove leading dashes/bullets
const metaDiv = document.createElement("div");
metaDiv.className = "meta";
metaDiv.innerHTML = metaHtml;
// Map <strong> inside meta to <span> for styling
metaDiv.querySelectorAll("strong").forEach((strong) => {
const span = document.createElement("span");
span.innerHTML = strong.innerHTML;
strong.replaceWith(span);
});
infoDiv.appendChild(metaDiv);
newLi.appendChild(infoDiv);
// Actions container (Explore + Download buttons)
const actionsDiv = document.createElement("div");
actionsDiv.className = "actions";
// Explore button -> GitHub location of the asset
const exploreBtn = document.createElement("a");
exploreBtn.href = `https://github.com/trizoza/assets.dles.gg/blob/main/${relativePath}`;
exploreBtn.className = "btn-explore";
exploreBtn.textContent = "Explore";
actionsDiv.appendChild(exploreBtn);
// Download button -> downloads the raw asset file
const downloadBtn = document.createElement("a");
downloadBtn.href = rawHref;
downloadBtn.className = "btn-download";
downloadBtn.textContent = "Download";
actionsDiv.appendChild(downloadBtn);
newLi.appendChild(actionsDiv);
} else if (firstLink) {
// Plain link (not an asset): just the link + description, no buttons
newLi.classList.add("link-only");
const resourceLink = firstLink.cloneNode(true);
const infoDiv = document.createElement("div");
infoDiv.className = "info";
infoDiv.appendChild(resourceLink);
firstLink.remove();
let descHtml = li.innerHTML.trim();
descHtml = descHtml.replace(/^[\s\-\–\—\•]+/, ""); // remove leading dashes/bullets
const descDiv = document.createElement("div");
descDiv.className = "meta";
descDiv.innerHTML = descHtml;
infoDiv.appendChild(descDiv);
newLi.appendChild(infoDiv);
} else {
newLi.innerHTML = li.innerHTML;
}
ul.appendChild(newLi);
});
newNodes.push(ul);
}
// For other elements (e.g. blockquotes, horizontal rules, etc.)
else {
currentIntroDiv = null;
const clonedNode = child.cloneNode(true);
newNodes.push(clonedNode);
}
});
// Clear elements between header and footer (this removes the loading placeholder)
let sibling = header.nextElementSibling;
while (sibling && sibling !== footer) {
const next = sibling.nextElementSibling;
sibling.remove();
sibling = next;
}
// Insert all parsed nodes
newNodes.forEach((node) => {
container.insertBefore(node, footer);
});
// Re-bind interactions for dynamically loaded elements
initializeInteractions();
// Content loads after the browser's initial #hash jump, so scroll
// to the targeted section (e.g. #words) once it actually exists.
if (location.hash.length > 1) {
const target = document.getElementById(
decodeURIComponent(location.hash.slice(1)),
);
if (target) target.scrollIntoView();
}
} catch (err) {
console.error("Error rendering markdown:", err);
const placeholder = document.getElementById("loading-placeholder");
if (placeholder) {
placeholder.innerHTML =
'<p style="color: red;">Failed to load assets collection. Please try refreshing.</p>';
}
}
}
function initializeInteractions() {
document.querySelectorAll("a[href]").forEach(function (a) {
if (a.classList.contains("btn-download")) return;
if (a.hostname && a.hostname !== location.hostname) {
a.target = "_blank";
a.rel = "noopener noreferrer";
}
});
document.querySelectorAll(".btn-download").forEach(function (btn) {
btn.addEventListener("click", function (e) {
e.preventDefault();
var href = btn.getAttribute("href");
var filename = href.split("/").pop();
if (window.location.protocol === "file:") {
window.open(href, "_blank");
return;
}
fetch(href)
.then(function (res) {
return res.blob();
})
.then(function (blob) {
var blobUrl = URL.createObjectURL(blob);
var link = document.createElement("a");
link.href = blobUrl;
link.download = filename;
link.style.display = "none";
document.body.appendChild(link);
link.click();
setTimeout(function () {
link.remove();
URL.revokeObjectURL(blobUrl);
}, 100);
})
.catch(function () {
window.open(href, "_blank");
});
});
});
}
// Run load on DOMContentLoaded
document.addEventListener("DOMContentLoaded", loadReadme);
</script>
</body>
</html>