-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
658 lines (573 loc) · 27.1 KB
/
Copy pathindex.html
File metadata and controls
658 lines (573 loc) · 27.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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RL Workshop Collection</title>
<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=Lexend:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d0f14;
--bg2: #13161d;
--bg3: #1a1e28;
--card: #181c25;
--card-hover: #1e2330;
--border: rgba(255,255,255,0.07);
--border-hover: rgba(99,179,255,0.35);
--text: #e8eaf0;
--text2: #8a90a0;
--text3: #555c70;
--accent: #4fa3e8;
--accent2: #7ec8f5;
--accent-glow: rgba(79,163,232,0.15);
--tag-bg: rgba(79,163,232,0.1);
--tag-text: #7ec8f5;
--font: 'Lexend', sans-serif;
--radius: 10px;
--radius-lg: 14px;
}
html { scroll-behavior: smooth; }
body {
font-family: var(--font);
background: var(--bg);
color: var(--text);
min-height: 100vh;
font-size: 15px;
line-height: 1.6;
}
/* ── Header ── */
header {
border-bottom: 1px solid var(--border);
background: rgba(13,15,20,0.95);
backdrop-filter: blur(12px);
position: sticky;
top: 0;
z-index: 100;
padding: 0 2rem;
display: flex;
align-items: center;
justify-content: space-between;
height: 60px;
}
.logo {
font-size: 17px;
font-weight: 600;
color: var(--text);
text-decoration: none;
display: flex;
align-items: center;
gap: 10px;
}
.logo-icon {
width: 28px; height: 28px;
border-radius: 6px;
display: flex; align-items: center; justify-content: center;
overflow: hidden;
}
.logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.logo span { color: var(--accent); }
nav { display: flex; gap: 1.5rem; align-items: center; }
nav a { color: var(--text2); text-decoration: none; font-size: 14px; font-weight: 400; transition: color 0.15s; }
nav a:hover { color: var(--text); }
.btn-contribute {
background: var(--accent); color: #fff; border: none;
padding: 7px 16px; border-radius: 7px;
font-family: var(--font); font-size: 13px; font-weight: 500;
cursor: pointer; text-decoration: none;
transition: background 0.15s;
}
.btn-contribute:hover { background: var(--accent2); color: #0d0f14; }
/* ── Hero ── */
.hero { padding: 5rem 2rem 3.5rem; max-width: 900px; margin: 0 auto; }
.hero-badge {
display: inline-flex; align-items: center; gap: 6px;
background: var(--tag-bg); color: var(--tag-text);
font-size: 12px; font-weight: 500; padding: 4px 12px;
border-radius: 20px; border: 1px solid rgba(79,163,232,0.2);
margin-bottom: 1.5rem; letter-spacing: 0.02em;
}
.hero h1 {
font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700;
line-height: 1.15; margin-bottom: 1rem; letter-spacing: -0.02em;
}
.hero h1 span { color: var(--accent); }
.hero p { font-size: 17px; color: var(--text2); font-weight: 300; max-width: 560px; margin-bottom: 2rem; }
.hero-stats { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 26px; font-weight: 600; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text3); font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; }
/* ── Controls ── */
.controls {
max-width: 1200px; margin: 0 auto; padding: 0 2rem 2rem;
display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
#search {
width: 100%; background: var(--bg3); border: 1px solid var(--border);
border-radius: var(--radius); color: var(--text); font-family: var(--font);
font-size: 14px; padding: 10px 14px 10px 40px; outline: none; transition: border-color 0.15s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text3); }
/* ── Category filter buttons (multi-select) ── */
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-btn {
background: var(--bg3); border: 1px solid var(--border);
color: var(--text2); font-family: var(--font); font-size: 13px; font-weight: 400;
padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: all 0.15s;
user-select: none;
}
.filter-btn:hover { border-color: rgba(255,255,255,0.15); color: var(--text); }
.filter-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }
/* ── Author multi-select dropdown ── */
.author-dropdown-wrap { position: relative; }
.author-dropdown-btn {
background: var(--bg3); border: 1px solid var(--border);
color: var(--text2); font-family: var(--font); font-size: 13px; font-weight: 400;
padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: all 0.15s;
display: flex; align-items: center; gap: 6px; white-space: nowrap; user-select: none;
}
.author-dropdown-btn:hover { border-color: rgba(255,255,255,0.15); color: var(--text); }
.author-dropdown-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }
.author-dropdown-btn svg.chevron { transition: transform 0.15s; flex-shrink: 0; }
.author-dropdown-btn.open svg.chevron { transform: rotate(180deg); }
.author-badge {
background: var(--accent); color: #fff;
font-size: 11px; font-weight: 600;
padding: 1px 6px; border-radius: 10px;
line-height: 1.6;
}
.author-dropdown-menu {
display: none; position: absolute; top: calc(100% + 6px); left: 0;
background: var(--bg2); border: 1px solid var(--border);
border-radius: var(--radius); min-width: 200px; max-height: 280px;
overflow-y: auto; z-index: 200;
box-shadow: 0 8px 32px rgba(0,0,0,0.4); padding: 4px;
}
.author-dropdown-menu.open { display: block; }
.author-dropdown-menu::-webkit-scrollbar { width: 4px; }
.author-dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.author-dropdown-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.author-option {
display: flex; align-items: center; gap: 9px;
width: 100%; text-align: left; background: none; border: none;
color: var(--text2); font-family: var(--font); font-size: 13px; font-weight: 400;
padding: 8px 10px; border-radius: 6px; cursor: pointer;
transition: background 0.1s, color 0.1s; white-space: nowrap;
}
.author-option:hover { background: var(--bg3); color: var(--text); }
/* custom checkbox */
.author-check {
width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0;
border: 1px solid var(--text3);
background: transparent;
display: flex; align-items: center; justify-content: center;
transition: border-color 0.12s, background 0.12s;
}
.author-option.selected .author-check {
background: var(--accent); border-color: var(--accent);
}
.author-check svg { display: none; }
.author-option.selected .author-check svg { display: block; }
.author-divider {
height: 1px; background: var(--border); margin: 4px 0;
}
/* ── Grid ── */
.grid-section { max-width: 1200px; margin: 0 auto; padding: 0 2rem 4rem; }
.grid-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.grid-header h2 { font-size: 15px; font-weight: 500; color: var(--text2); }
#map-count { font-size: 13px; color: var(--text3); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
/* ── Map Card — no pointer cursor on the card itself ── */
.map-card {
background: var(--card); border: 1px solid var(--border);
border-radius: var(--radius-lg); overflow: hidden;
transition: border-color 0.2s, transform 0.2s, background 0.2s;
cursor: default; /* ← plain arrow, not pointer */
display: flex; flex-direction: column;
}
.map-card:hover { border-color: var(--border-hover); background: var(--card-hover); transform: translateY(-2px); }
.map-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--bg3); display: block; }
.map-thumb-placeholder {
width: 100%; aspect-ratio: 16/9; background: var(--bg3);
display: flex; align-items: center; justify-content: center;
color: var(--text3); font-size: 13px;
}
.map-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.map-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
background: var(--tag-bg); color: var(--tag-text);
font-size: 11px; font-weight: 500; padding: 2px 9px;
border-radius: 20px; letter-spacing: 0.02em;
}
.tag.training { background: rgba(62,207,142,0.1); color: #6de0a8; }
.tag.parkour { background: rgba(232,143,79,0.1); color: #f0a86a; }
.tag.fun { background: rgba(192,79,232,0.1); color: #d07ef5; }
.tag.dribble { background: rgba(79,163,232,0.1); color: #7ec8f5; }
.tag.other { background: rgba(255,255,255,0.05); color: var(--text2); }
.map-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.map-author { font-size: 12px; color: var(--text3); margin-bottom: 8px; font-weight: 400; }
.map-desc {
font-size: 13px; color: var(--text2); font-weight: 300; flex: 1;
display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
overflow: hidden; line-height: 1.5; margin-bottom: 14px;
}
.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btn-download {
display: inline-flex; align-items: center; gap: 6px;
background: var(--accent); color: #fff; border: none;
padding: 8px 16px; border-radius: 7px;
font-family: var(--font); font-size: 13px; font-weight: 500;
cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.btn-download:hover { background: var(--accent2); color: #0d0f14; }
/* right side of footer: format badge + optional steam icon */
.map-meta { display: flex; align-items: center; gap: 8px; }
.file-format { font-size: 11px; color: var(--text3); font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; }
.btn-steam {
display: inline-flex; align-items: center; justify-content: center;
width: 28px; height: 28px; border-radius: 6px;
background: rgba(255,255,255,0.05); border: 1px solid var(--border);
color: var(--text3); text-decoration: none;
transition: background 0.15s, border-color 0.15s, color 0.15s;
cursor: pointer; flex-shrink: 0;
}
.btn-steam:hover { background: rgba(103,193,245,0.15); border-color: #67c1f5; color: #67c1f5; }
/* ── Empty ── */
.empty { text-align: center; padding: 5rem 2rem; color: var(--text3); display: none; }
.empty h3 { font-size: 17px; color: var(--text2); margin-bottom: 0.5rem; }
/* ── Contribute ── */
.contribute { max-width: 1200px; margin: 0 auto 4rem; padding: 0 2rem; }
.contribute-inner {
background: linear-gradient(135deg, rgba(79,163,232,0.08), rgba(79,163,232,0.03));
border: 1px solid rgba(79,163,232,0.2); border-radius: var(--radius-lg);
padding: 2rem 2.5rem; display: flex; align-items: center;
justify-content: space-between; gap: 2rem; flex-wrap: wrap;
}
.contribute-text h3 { font-size: 18px; font-weight: 600; margin-bottom: 0.4rem; }
.contribute-text p { font-size: 14px; color: var(--text2); font-weight: 300; }
/* ── Footer ── */
footer { border-top: 1px solid var(--border); padding: 2rem; text-align: center; color: var(--text3); font-size: 13px; }
footer a { color: var(--text2); text-decoration: none; }
footer a:hover { color: var(--accent); }
</style>
</head>
<body>
<header>
<a href="/" class="logo">
<div class="logo-icon"><img src="favicon.png" alt="RL Icon"></div>
RL Map <span>Archive</span>
</a>
<nav>
<a href="https://github.com/xplodingeggo/RLWorkshopCollection" target="_blank" rel="noopener">GitHub</a>
<a href="https://github.com/xplodingeggo/RLWorkshopCollection#-adding-a-map" class="btn-contribute">+ Submit Map</a>
</nav>
</header>
<section class="hero">
<div class="hero-badge">Archived Workshop maps</div>
<h1>Rocket League<br><span>Workshop Archive</span></h1>
<p>My archive of Rocket League custom Workshop maps.</p>
<div class="hero-stats">
<div class="stat">
<span class="stat-num" id="total-maps">0</span>
<span class="stat-label">Maps</span>
</div>
</div>
</section>
<div class="controls">
<div class="search-wrap">
<svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>
</svg>
<input type="text" id="search" placeholder="Search maps, authors…" autocomplete="off" />
</div>
<!-- Category multi-select buttons -->
<div class="filter-group" id="cat-group">
<button class="filter-btn active" data-cat="all">All</button>
<button class="filter-btn" data-cat="training">Training</button>
<button class="filter-btn" data-cat="dribble">Dribble</button>
<button class="filter-btn" data-cat="parkour">Parkour</button>
<button class="filter-btn" data-cat="fun">Fun</button>
<button class="filter-btn" data-cat="other">Other</button>
</div>
<!-- Author multi-select dropdown -->
<div class="author-dropdown-wrap" id="author-wrap">
<button class="author-dropdown-btn" id="author-btn" aria-haspopup="listbox" aria-expanded="false">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>
</svg>
<span id="author-label">Author</span>
<span id="author-badge" class="author-badge" style="display:none"></span>
<svg class="chevron" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
<polyline points="6 9 12 15 18 9"/>
</svg>
</button>
<div class="author-dropdown-menu" id="author-menu" role="listbox"></div>
</div>
</div>
<section class="grid-section" id="maps">
<div class="grid-header">
<h2>Workshop Maps</h2>
<span id="map-count"></span>
</div>
<div class="grid" id="grid"></div>
<div class="empty" id="empty">
<h3>No maps found</h3>
<p>Try a different search or filter.</p>
</div>
</section>
<section class="contribute" id="contribute">
<div class="contribute-inner">
<div class="contribute-text">
<h3>Have Workshop maps?</h3>
<p>Help grow the archive. Submit your local <code>.upk</code> or <code>.udk</code> files and we'll add them for everyone (github pull request).</p>
</div>
<a href="https://github.com/xplodingeggo/RLWorkshopCollection" target="_blank" rel="noopener" class="btn-download">Submit via GitHub →</a>
</div>
</section>
<footer>
<p>RL Workshop Collection — Not affiliated with Psyonix or Epic Games. · <a href="https://github.com/xplodingeggo/RLWorkshopCollection">GitHub</a></p>
</footer>
<script>
// ── Category helpers ─────────────────────────────────────
const CAT_HINTS = {
'aim':'training','training':'training','warm':'training',
'dribble':'dribble','forbidden':'dribble',
'parkour':'parkour','jump':'parkour','rings':'parkour','speed':'parkour','orbital':'parkour','trail':'parkour',
'bounce':'fun','creative':'fun','bumblebee':'fun','wii':'fun','yoshi':'fun','rooftop':'fun','hornet':'fun','tennis':'fun',
};
function guessCategory(title) {
const t = title.toLowerCase();
for (const [k, v] of Object.entries(CAT_HINTS)) { if (t.includes(k)) return v; }
return 'other';
}
function normaliseCategories(raw, title) {
if (!raw) return [guessCategory(title)];
const list = Array.isArray(raw) ? raw : [raw];
return list.map(c => c.trim().toLowerCase()).filter(Boolean);
}
// ── State ────────────────────────────────────────────────
let allCards = [];
let activeCats = new Set(); // empty = "All"
let activeAuthors = new Set(); // empty = "All"
// ── Card factory ─────────────────────────────────────────
function makeCard(map) {
const title = map.Title || map.title || 'Unknown Map';
const cats = normaliseCategories(map.category, title);
const author = map.Author || map.author || '';
const desc = map.Description || map.description || '';
const preview = map.PreviewUrl || map.previewUrl || '';
const downloadUrl = map.downloadUrl || '';
const steamUrl = map.steamUrl || '';
const format = map.format || 'upk';
const card = document.createElement('div');
card.className = 'map-card';
card.dataset.cats = JSON.stringify(cats);
card.dataset.title = title.toLowerCase();
card.dataset.author = author.toLowerCase();
const tagsHtml = cats.map(c => `<span class="tag ${c}">${c}</span>`).join('');
const steamHtml = steamUrl
? `<a class="btn-steam" href="${steamUrl}" target="_blank" rel="noopener" title="View on Steam Workshop">
<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M11.979 0C5.678 0 .511 4.86.022 11.037l6.432 2.658c.545-.371 1.203-.59 1.912-.59.063 0 .125.004.187.008l2.861-4.142V8.91c0-2.495 2.028-4.524 4.524-4.524 2.494 0 4.524 2.029 4.524 4.524s-2.03 4.524-4.524 4.524h-.105l-4.076 2.911c0 .052.004.105.004.159 0 1.875-1.515 3.396-3.39 3.396-1.635 0-3.016-1.173-3.331-2.727L.436 15.27C1.862 20.307 6.486 24 11.979 24c6.627 0 11.999-5.373 11.999-12S18.605 0 11.979 0zM7.54 18.21l-1.473-.61c.262.543.714.999 1.314 1.25 1.297.539 2.793-.076 3.332-1.375.263-.63.264-1.319.005-1.949s-.75-1.121-1.377-1.383c-.624-.26-1.29-.249-1.878-.03l1.523.63c.956.4 1.409 1.497 1.009 2.455-.397.957-1.494 1.409-2.455 1.012H7.54zm11.415-9.303c0-1.662-1.353-3.015-3.015-3.015-1.665 0-3.015 1.353-3.015 3.015 0 1.665 1.35 3.015 3.015 3.015 1.663 0 3.015-1.35 3.015-3.015zm-5.273-.005c0-1.252 1.013-2.266 2.265-2.266 1.249 0 2.266 1.014 2.266 2.266 0 1.251-1.017 2.265-2.266 2.265-1.252 0-2.265-1.014-2.265-2.265z"/>
</svg>
</a>`
: '';
card.innerHTML = `
${preview
? `<img class="map-thumb" src="${preview}" alt="${title}" loading="lazy" onerror="this.outerHTML='<div class=map-thumb-placeholder>No preview</div>'">`
: `<div class="map-thumb-placeholder">No preview</div>`}
<div class="map-body">
<div class="map-tags">${tagsHtml}</div>
<div class="map-title">${title}</div>
${author ? `<div class="map-author">by ${author}</div>` : ''}
${desc ? `<div class="map-desc">${desc}</div>` : ''}
<div class="map-footer">
<a class="btn-download" href="${downloadUrl}" download>
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>
</svg>
Download
</a>
<div class="map-meta">
${steamHtml}
<span class="file-format">.${format}</span>
</div>
</div>
</div>
`;
return card;
}
// ── Category multi-select ────────────────────────────────
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', () => {
const cat = btn.dataset.cat;
if (cat === 'all') {
// "All" clears all specific selections
activeCats.clear();
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
} else {
// Toggle the clicked category
if (activeCats.has(cat)) {
activeCats.delete(cat);
} else {
activeCats.add(cat);
}
// If nothing selected, revert to "All"
if (activeCats.size === 0) {
document.querySelector('.filter-btn[data-cat="all"]').classList.add('active');
document.querySelectorAll('.filter-btn:not([data-cat="all"])').forEach(b => b.classList.remove('active'));
} else {
document.querySelector('.filter-btn[data-cat="all"]').classList.remove('active');
btn.classList.toggle('active', activeCats.has(cat));
}
}
applyFilters();
});
});
// ── Author multi-select dropdown ─────────────────────────
function buildAuthorDropdown(maps) {
const authors = Array.from(
new Set(maps.map(m => (m.Author || m.author || '').trim()).filter(Boolean))
).sort((a, b) => a.localeCompare(b));
const menu = document.getElementById('author-menu');
menu.innerHTML = '';
// "All Authors" clear option
const allOpt = makeAuthorOption('__all__', 'All Authors');
allOpt.classList.add('selected');
menu.appendChild(allOpt);
const div = document.createElement('div');
div.className = 'author-divider';
menu.appendChild(div);
authors.forEach(author => menu.appendChild(makeAuthorOption(author, author)));
}
function makeAuthorOption(value, label) {
const btn = document.createElement('button');
btn.className = 'author-option';
btn.dataset.author = value;
btn.setAttribute('role', 'option');
btn.innerHTML = `
<span class="author-check">
<svg width="9" height="9" viewBox="0 0 9 9" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="1,5 3.5,7.5 8,2"/>
</svg>
</span>
${label}
`;
btn.addEventListener('click', (e) => {
e.stopPropagation();
toggleAuthor(value);
});
return btn;
}
function toggleAuthor(value) {
const allOpt = document.querySelector('.author-option[data-author="__all__"]');
if (value === '__all__') {
activeAuthors.clear();
document.querySelectorAll('.author-option').forEach(o => o.classList.remove('selected'));
allOpt.classList.add('selected');
} else {
if (activeAuthors.has(value)) {
activeAuthors.delete(value);
} else {
activeAuthors.add(value);
}
if (activeAuthors.size === 0) {
allOpt.classList.add('selected');
} else {
allOpt.classList.remove('selected');
}
// Sync checkboxes
document.querySelectorAll('.author-option:not([data-author="__all__"])').forEach(o => {
o.classList.toggle('selected', activeAuthors.has(o.dataset.author));
});
}
updateAuthorBtn();
applyFilters();
}
function updateAuthorBtn() {
const btn = document.getElementById('author-btn');
const label = document.getElementById('author-label');
const badge = document.getElementById('author-badge');
const count = activeAuthors.size;
if (count === 0) {
label.textContent = 'Author';
badge.style.display = 'none';
btn.classList.remove('active');
} else if (count === 1) {
label.textContent = [...activeAuthors][0];
badge.style.display = 'none';
btn.classList.add('active');
} else {
label.textContent = 'Authors';
badge.textContent = count;
badge.style.display = '';
btn.classList.add('active');
}
}
// Toggle dropdown open/close
document.getElementById('author-btn').addEventListener('click', (e) => {
e.stopPropagation();
const btn = document.getElementById('author-btn');
const menu = document.getElementById('author-menu');
const isOpen = menu.classList.contains('open');
btn.classList.toggle('open', !isOpen);
btn.setAttribute('aria-expanded', String(!isOpen));
menu.classList.toggle('open', !isOpen);
});
document.addEventListener('click', (e) => {
if (!document.getElementById('author-wrap').contains(e.target)) {
const btn = document.getElementById('author-btn');
const menu = document.getElementById('author-menu');
btn.classList.remove('open');
btn.setAttribute('aria-expanded', 'false');
menu.classList.remove('open');
}
});
// ── Filter engine ────────────────────────────────────────
function applyFilters() {
const query = document.getElementById('search').value.toLowerCase().trim();
let visible = 0;
allCards.forEach(card => {
const cardCats = JSON.parse(card.dataset.cats);
// Category: pass if no cats selected OR card has at least one matching cat
const catMatch = activeCats.size === 0 || cardCats.some(c => activeCats.has(c));
// Author: pass if no authors selected OR card author is in the set
const authorMatch = activeAuthors.size === 0 || activeAuthors.has(card.dataset.author)
|| [...activeAuthors].some(a => a.toLowerCase() === card.dataset.author);
// Text search
const textMatch = !query || card.dataset.title.includes(query) || card.dataset.author.includes(query);
const show = catMatch && authorMatch && textMatch;
card.style.display = show ? '' : 'none';
if (show) visible++;
});
document.getElementById('map-count').textContent = visible + ' map' + (visible !== 1 ? 's' : '');
document.getElementById('empty').style.display = visible === 0 ? 'block' : 'none';
}
document.getElementById('search').addEventListener('input', applyFilters);
// ── Boot ─────────────────────────────────────────────────
function renderMaps(maps) {
const grid = document.getElementById('grid');
grid.innerHTML = '';
allCards = maps.map(makeCard);
allCards.forEach(c => grid.appendChild(c));
document.getElementById('total-maps').textContent = maps.length;
buildAuthorDropdown(maps);
applyFilters();
}
fetch('maps.json')
.then(r => r.json())
.then(renderMaps)
.catch(() => {
document.getElementById('empty').style.display = 'block';
document.getElementById('empty').innerHTML = '<h3>No maps loaded</h3><p>Add map entries to <code>maps.json</code> to get started.</p>';
});
</script>
</body>
</html>