-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.html
More file actions
694 lines (615 loc) · 35.6 KB
/
index.html
File metadata and controls
694 lines (615 loc) · 35.6 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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canadian Bioinformatics Workshops</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<!-- Load Tailwind Library (Pinned Version) -->
<script src="https://cdn.tailwindcss.com/3.4.5"></script>
<!-- Configure Tailwind with Safety Check -->
<script>
if (typeof tailwind !== 'undefined') {
tailwind.config = {
theme: {
extend: {
fontFamily: { sans: ['Manrope', 'sans-serif'], },
colors: {
// Original Brand Colors
'brand-purple': '#5A1F65',
'region-bc': '#3C9048',
'region-alberta': '#86264E',
'region-prairies': '#BD8528',
'region-ontario': '#BB682C',
'region-quebec': '#427FA4',
'region-atlantic': '#208A99',
'region-online': '#5A1F65',
// Lighter Regional Colors
'region-bc-light': '#8ed792',
'region-alberta-light': '#ca668a',
'region-prairies-light': '#f6bc6a',
'region-ontario-light': '#ffb37a',
'region-quebec-light': '#9bccf0',
'region-atlantic-light': '#84d3e1',
'region-online-light': '#cc7ed9',
}
}
}
}
} else {
console.warn("Tailwind CSS failed to load. Styles may be missing.");
}
</script>
<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=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
html, body { font-family: 'Manrope', 'sans-serif'; scroll-behavior: smooth; }
body { background-color: #f8fafc; }
.container { background-color: white; padding: 2rem; border-radius: 1rem; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); width: 100%; max-width: 80rem; border: 1px solid #e5e7eb; }
.dropdown-panel, .year-section, .card-interactive-wrapper { transition: all 0.3s ease-in-out; }
/* Permanent visual adjustments for cards with no materials (excluding image and colors) */
/* Note: Grayscale removed from color bar (.h-1.5) and region tags (.flex-wrap > span) */
.card.no-materials-card img { opacity: 1; }
.card.no-materials-card .h3-title { color: #6b7280; }
/* Grayscale image and show overlay on hover for 'Material Coming Soon' cards */
.card.group:hover .materials-overlay { opacity: 1; }
.card.group:hover img { filter: grayscale(100%); }
/* Materials Coming Soon overlay */
.materials-overlay {
background-color: rgba(0, 0, 0, 0.7);
opacity: 0;
transition: opacity 0.3s ease-in-out;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
text-align: center;
color: white;
font-weight: 700;
font-size: 1.25rem;
padding: 1rem;
}
.card.hidden, .year-section.hidden { opacity: 0; transform: scale(0.95); max-height: 0; overflow: hidden; margin: 0 !important; padding: 0 !important; border: none; pointer-events: none; }
.filter-button:hover .dropdown-arrow { transform: translateY(2px); }
a:focus, button:focus, input:focus, .card:focus-within {
outline: 2px solid #5A1F65;
outline-offset: 3px;
}
@media (max-width: 639px) {
.carousel-on-mobile {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
gap: 1rem;
padding: 0.5rem 1rem;
margin: 0 -1rem;
scrollbar-width: none;
-ms-overflow-style: none;
}
.carousel-on-mobile::-webkit-scrollbar { display: none; }
.carousel-on-mobile > .card {
flex: 0 0 80%;
max-width: 320px;
scroll-snap-align: start;
}
}
.truncate-2-lines {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
/* Status Display Styles */
.status-icon-text {
display: flex;
align-items: center;
font-size: 0.875rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: #1f2937;
}
.status-icon-text .icon-symbol {
font-size: 1.25rem;
margin-right: 0.5rem;
flex-shrink: 0;
display: inline-block;
vertical-align: middle;
line-height: 1;
}
.icon-green { color: #059669; }
.icon-orange { color: #EA580C; }
/* Accessibility helper */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
</style>
</head>
<body class="antialiased">
<div class="container mx-auto my-8 md:my-12">
<header class="text-center mb-12">
<a href="https://bioinformatics.ca" target="_blank" rel="noopener noreferrer">
<img src="img/CBW_logo.png" alt="Canadian Bioinformatics Workshops Logo - Link to Bioinformatics.ca homepage" class="mx-auto mb-6 h-40 w-auto">
</a>
<h1 class="text-4xl md:text-5xl font-extrabold text-gray-800 tracking-tight">Canadian Bioinformatics Workshops</h1>
</header>
<nav aria-label="Main Navigation" class="text-center mb-12 flex justify-center items-center gap-4 md:gap-6 flex-wrap py-4">
<a href="#current-workshops-section" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Upcoming Workshops</a>
<a href="#past-workshops-section" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Past Workshops</a>
<a href="https://bioinformatics.ca/hub/about/" target="_blank" rel="noopener noreferrer" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">About<img src="img/box-arrow-up-right.svg" alt="External link icon" class="ml-2 inline-block w-3 h-3"><span class="sr-only"> (opens in new tab)</span></a>
<a href="https://bioinformatics.ca/workshops/workshop-application-form/" target="_blank" rel="noopener noreferrer" class="inline-block bg-white text-brand-purple font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 shadow-lg border-2 border-brand-purple hover:bg-purple-50">Apply Now<img src="img/box-arrow-up-right.svg" alt="External link icon" class="ml-2 inline-block w-3 h-3"><span class="sr-only"> (opens in new tab)</span></a>
</nav>
<div id="filter-bar" role="region" aria-label="Workshop Filters" class="mb-12 flex justify-center items-center flex-wrap gap-4 p-4 bg-slate-100/70 rounded-xl">
<div class="relative w-full sm:w-auto">
<label for="text-search-input" class="sr-only">Search workshops by keyword</label>
<input type="search" id="text-search-input" placeholder="Search workshops..." class="w-full sm:w-48 px-4 py-2.5 border border-gray-300 rounded-lg shadow-sm focus:ring-brand-purple focus:border-brand-purple transition">
</div>
</div>
<main id="link-container" class="space-y-16">
<!-- Prototype warning will be injected here if needed -->
<div id="no-results-message" class="hidden" role="status" aria-live="polite">
<div class="text-center py-12 px-6 bg-slate-50 rounded-lg">
<h3 class="mt-2 text-xl font-semibold text-gray-900">No workshops found</h3>
</div>
</div>
</main>
</div>
<script>
document.addEventListener('DOMContentLoaded', async () => {
// === FALLBACK SYSTEM: Mock Data ===
// This data is used if 'workshops.json' cannot be found (e.g., in Canvas or local dev without a server)
const MOCK_DATA = [
{
"startDate": new Date(new Date().getFullYear(), new Date().getMonth() + 1, 10).toISOString().split('T')[0],
"endDate": new Date(new Date().getFullYear(), new Date().getMonth() + 1, 12).toISOString().split('T')[0],
"year": new Date().getFullYear(),
"title": "Prototype: Future Informatics",
"tags": ["Genomics", "Prototype"],
"regions": ["Ontario"],
"format": "In-Person",
"locations": ["Toronto, ON"],
"instructors": ["Dr. Jane Doe"],
"image": "https://images.unsplash.com/photo-1576086213369-97a306d36557?q=80&w=800",
"url": "#"
},
{
"startDate": "2023-05-15",
"endDate": "2023-05-17",
"year": 2023,
"title": "Prototype: Past Analytics",
"tags": ["R", "Statistics"],
"regions": ["BC"],
"format": "Hybrid",
"locations": ["Vancouver, BC"],
"instructors": ["Dr. John Smith"],
"image": "https://images.unsplash.com/photo-1551288049-bebda4e38f71?q=80&w=800",
"url": "#"
}
];
try {
const workshopColors = {
'BC': '#3C9048',
'Alberta': '#86264E',
'Prairies': '#BD8528',
'Ontario': '#BB682C',
'Quebec': '#427FA4',
'Atlantic': '#208A99',
'Online': '#5A1F65'
};
// === ROBUST DATA FETCHING ===
let linksData = [];
let isPrototypeMode = false;
try {
const response = await fetch('workshops.json');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
linksData = await response.json();
} catch (fetchError) {
console.warn("Failed to load workshops.json. Falling back to prototype data.", fetchError);
isPrototypeMode = true;
linksData = MOCK_DATA;
}
const regionOrder = ['BC', 'Alberta', 'Prairies', 'Ontario', 'Quebec', 'Atlantic', 'Online'];
const today = new Date();
today.setHours(0, 0, 0, 0);
const linkContainer = document.getElementById('link-container');
const noResultsMessage = document.getElementById('no-results-message');
const searchInput = document.getElementById('text-search-input');
const filterBar = document.getElementById('filter-bar');
// === PROTOTYPE BANNER ===
if (isPrototypeMode) {
const banner = document.createElement('div');
banner.className = "bg-amber-100 border-l-4 border-amber-500 text-amber-700 p-4 mb-8 rounded shadow-sm";
banner.innerHTML = `
<div class="flex items-center">
<div class="py-1"><svg class="fill-current h-6 w-6 text-amber-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z"/></svg></div>
<div>
<p class="font-bold">Prototype Mode Active</p>
<p class="text-sm">Could not load 'workshops.json'. Displaying mock data for testing purposes.</p>
</div>
</div>
`;
linkContainer.insertBefore(banner, linkContainer.firstChild);
}
const allFilters = {
year: { container: null, active: new Set(), label: "Year" },
regions: { container: null, active: new Set(), label: "Region" },
title: { container: null, active: new Set(), label: "Workshop" },
tags: { container: null, active: new Set(), label: "Topics" },
format: { container: null, active: new Set(), label: "Format" },
status: { container: null, active: new Set(), label: "Status" },
};
function formatDateRange(startDateStr, endDateStr) {
const start = new Date(startDateStr + 'T00:00:00');
const end = new Date(endDateStr + 'T00:00:00');
const startMonth = start.toLocaleString('en-US', { month: 'long' });
const startDay = start.getDate();
const year = start.getFullYear();
if (!endDateStr || startDateStr === endDateStr) return `${startMonth} ${startDay}, ${year}`;
const endMonth = end.toLocaleString('en-US', { month: 'long' });
const endDay = end.getDate();
if (startMonth === endMonth) return `${startMonth} ${startDay} - ${endMonth} ${endDay}, ${year}`;
return `${startMonth} ${startDay} - ${endMonth} ${endDay}, ${year}`;
}
function createCardElement(link) {
const workshopStartDate = new Date(link.startDate + 'T00:00:00');
const workshopEndDate = new Date(link.endDate + 'T00:00:00');
const isPastWorkshop = workshopEndDate < today;
const hasUrl = (link.url && link.url !== "");
const applyNoMaterialsStyling = !hasUrl;
const cardClassSuffix = applyNoMaterialsStyling ? ' no-materials-card' : '';
const card = document.createElement('article');
card.className = `card flex flex-col bg-white rounded-xl shadow-lg overflow-hidden ${cardClassSuffix}`;
card.setAttribute('role', 'group');
card.dataset.year = JSON.stringify([link.year]);
card.dataset.title = JSON.stringify([link.title]);
card.dataset.tags = JSON.stringify(link.tags);
card.dataset.regions = JSON.stringify(link.regions);
card.dataset.format = JSON.stringify([link.format]);
card.dataset.search = (
link.title + ' ' +
link.tags.join(' ') + ' ' +
(link.locations || []).join(' ') + ' ' +
(link.instructors || []).join(' ')
).toLowerCase();
let statusInfoHTML = '';
let statusTags = [];
if (workshopStartDate <= today && today <= workshopEndDate) {
statusInfoHTML = `
<div class="status-icon-text icon-green mb-2">
<span class="icon-symbol">●</span> <span>Happening Now</span>
</div>`;
statusTags = ["Happening Now"];
} else if (workshopStartDate > today) {
statusInfoHTML = `
<div class="status-icon-text icon-orange mb-2">
<span class="icon-symbol">⏱</span> <span>Upcoming</span>
</div>`;
statusTags = ["Upcoming"];
} else {
statusTags = ["Past"];
}
card.dataset.status = JSON.stringify(statusTags);
const sortedRegions = [...link.regions].sort((a,b) => regionOrder.indexOf(a) - regionOrder.indexOf(b));
const regionTagsHTML = sortedRegions.map(region => {
const borderClass = `border-region-${region.toLowerCase().replace(' ', '-')}`;
const lightBgClass = `bg-region-${region.toLowerCase().replace(' ', '-')}-light`;
return `<span class="flex items-center justify-center ${lightBgClass} text-gray-900 border-2 ${borderClass} rounded-full px-3 py-1 text-xs font-bold shadow-sm" title="Region: ${region}">${region}</span>`;
}).join('');
// Safely retrieve colors from our local 'workshopColors' object
const regionColors = sortedRegions.map(region => workshopColors[region] || '#333333');
let colorBarHTML = '<div class="h-1.5 bg-gray-300"><span class="sr-only">Workshop regions color bar</span></div>';
if (regionColors.length > 1) {
colorBarHTML = `<div class="h-1.5" style="background-image: linear-gradient(to right, ${regionColors.join(', ')})"><span class="sr-only">Workshop regions color bar</span></div>`;
} else if (regionColors.length === 1) {
colorBarHTML = `<div class="h-1.5" style="background-color: ${regionColors[0]}"><span class="sr-only">Workshop region: ${sortedRegions[0]}</span></div>`;
}
const locationsHTML = (link.locations || []).map(loc => `
<div class="flex items-center text-sm text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-gray-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
<span class="font-medium">${loc}</span>
</div>
`).join('');
const imageBaseClass = 'w-full h-48 object-cover';
const imageHoverEffectClass = 'transition-all duration-300';
let titleAriaLabelSuffix = '';
let overlayHTML = '';
if (applyNoMaterialsStyling) {
overlayHTML = `
<div class="absolute inset-0 flex items-center justify-content-center materials-overlay">
<span class="text-xl font-bold uppercase">Material Coming Soon</span>
<span class="sr-only"> for ${link.title} workshop</span>
</div>
`;
titleAriaLabelSuffix = ' - Material coming soon';
}
const commonCardVisuals = `
<div class="relative">
<img loading="lazy" class="${imageBaseClass} ${imageHoverEffectClass}" src="${link.image}" alt="Image for ${link.title} workshop${titleAriaLabelSuffix}" onerror="this.onerror=null;this.src='https://images.unsplash.com/photo-1584824486509-112e4181ff6b?q=80&w=800';">
${overlayHTML}
<div class="absolute top-3 right-3 z-10">
<div class="flex flex-wrap justify-end gap-2 max-w-[calc(100% - 6rem)]">
${regionTagsHTML}
</div>
</div>
</div>
<div class="p-5 flex flex-col flex-grow">
${statusInfoHTML} <div class="min-h-16">
<h3 class="text-lg font-bold text-gray-800 h3-title truncate-2-lines" ${titleAriaLabelSuffix ? `aria-label="${link.title}${titleAriaLabelSuffix}"` : ''}>
${link.title}
</h3>
</div>
<div class="space-y-2 mt-3">
<div class="flex items-center text-sm text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-gray-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
<span class="font-medium">${formatDateRange(link.startDate, link.endDate)}</span>
</div>
${locationsHTML}
</div>
</div>
`;
if (hasUrl) {
card.innerHTML = `
<a href="${link.url}" target="_blank" rel="noopener noreferrer"
class="card-interactive-wrapper flex flex-col flex-grow transform hover:-translate-y-1 transition-all duration-300 ease-in-out hover:shadow-xl">
${colorBarHTML}
${commonCardVisuals}
<span class="sr-only">View workshop materials for ${link.title} (opens in new tab)</span>
</a>
`;
} else {
card.classList.add('group');
card.innerHTML = `
${colorBarHTML}
<div class="flex flex-col flex-grow">
${commonCardVisuals}
</div>
`;
}
return card;
}
function generatePageContent() {
const currentAndUpcomingLinks = [];
const pastLinks = [];
for (const link of linksData) {
const workshopEndDate = new Date(link.endDate + 'T00:00:00');
const isPast = workshopEndDate < today;
if (!isPast) currentAndUpcomingLinks.push(link);
else pastLinks.push(link);
}
currentAndUpcomingLinks.sort((a, b) => new Date(a.startDate) - new Date(b.startDate));
pastLinks.sort((a, b) => new Date(b.startDate) - new Date(a.startDate));
if (currentAndUpcomingLinks.length > 0) {
const currentSection = document.createElement('section');
currentSection.className = 'year-section';
currentSection.id = 'current-workshops-section';
const currentTitle = document.createElement('h2');
currentTitle.className = 'text-3xl font-bold mb-8 text-gray-800 pl-3 border-l-4 border-green-500';
currentTitle.textContent = 'Happening Now & Upcoming';
const gridContainer = document.createElement('div');
gridContainer.className = 'carousel-on-mobile sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-8';
gridContainer.setAttribute('role', 'region');
gridContainer.setAttribute('aria-label', 'List of Upcoming and Happening Now Workshops');
currentAndUpcomingLinks.forEach(link => gridContainer.appendChild(createCardElement(link)));
currentSection.appendChild(currentTitle);
currentSection.appendChild(gridContainer);
linkContainer.insertBefore(currentSection, noResultsMessage);
}
const pastLinksByYear = pastLinks.reduce((acc, link) => { (acc[link.year] = acc[link.year] || []).push(link); return acc; }, {});
const sortedYears = Object.keys(pastLinksByYear).sort((a, b) => b - a);
let firstPastSectionAssigned = false;
sortedYears.forEach(year => {
const yearSection = document.createElement('section');
yearSection.className = 'year-section';
if (!firstPastSectionAssigned) { yearSection.id = 'past-workshops-section'; firstPastSectionAssigned = true; }
const yearTitle = document.createElement('h2');
yearTitle.className = 'text-3xl font-bold mb-8 text-gray-800 pl-3 border-l-4 border-brand-purple';
yearTitle.textContent = `${year}`;
const gridContainer = document.createElement('div');
gridContainer.className = 'carousel-on-mobile sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 sm:gap-8';
gridContainer.setAttribute('role', 'region');
gridContainer.setAttribute('aria-label', `List of Past Workshops from ${year}`);
pastLinksByYear[year].forEach(link => gridContainer.appendChild(createCardElement(link)));
yearSection.appendChild(yearTitle);
yearSection.appendChild(gridContainer);
linkContainer.insertBefore(yearSection, noResultsMessage);
});
}
function updateFilterCounts() {
for (const type in allFilters) {
if (allFilters[type] && allFilters[type].active instanceof Set) {
const count = allFilters[type].active.size;
const countEl = document.getElementById(`${type}-filter-count`);
if(countEl) {
countEl.textContent = count;
countEl.classList.toggle('hidden', count === 0);
const button = countEl.closest('.filter-button');
if (button) {
if (count > 0) {
button.setAttribute('aria-label', `${allFilters[type].label} filter active, ${count} selected`);
} else {
button.setAttribute('aria-label', `${allFilters[type].label} filter`);
}
}
}
} else {
console.error(`Error: Filter type '${type}' or its 'active' property is not a Set.`, allFilters[type]);
}
}
}
function applyFilters() {
const searchTerm = searchInput.value.toLowerCase().trim();
let totalVisibleCards = 0;
noResultsMessage.classList.add('hidden');
noResultsMessage.setAttribute('aria-live', 'off');
document.querySelectorAll('.card').forEach(card => {
const searchMatch = !searchTerm || card.dataset.search.includes(searchTerm);
let filtersMatch = true;
for (const type in allFilters) {
if (allFilters[type].active.size === 0) continue;
const cardValues = new Set(JSON.parse(card.dataset[type] || '[]').map(String));
if (![...allFilters[type].active].some(filterValue => cardValues.has(filterValue))) {
filtersMatch = false;
break;
}
}
if (searchMatch && filtersMatch) {
card.classList.remove('hidden');
totalVisibleCards++;
} else {
card.classList.add('hidden');
}
});
document.querySelectorAll('.year-section').forEach(section => {
const visibleCards = section.querySelectorAll('.card:not(.hidden)').length;
section.classList.toggle('hidden', visibleCards === 0);
});
if (totalVisibleCards === 0) {
noResultsMessage.classList.remove('hidden');
noResultsMessage.setAttribute('aria-live', 'polite');
} else {
noResultsMessage.setAttribute('aria-live', 'off');
}
updateFilterCounts();
}
function generateFilterOptions() {
const options = {
year: [...new Set(linksData.map(link => link.year))].sort((a, b) => b - a),
regions: regionOrder,
title: [...new Set(linksData.map(link => link.title))].sort(),
tags: [...new Set(linksData.flatMap(link => link.tags))].sort(),
format: [...new Set(linksData.map(link => link.format))].sort(),
status: ["Upcoming", "Happening Now", "Past"],
};
for (const type in allFilters) {
if (options[type] && options[type].length > 0) {
const dropdown = document.createElement('div');
dropdown.className = 'relative';
const dropdownButtonId = `filter-button-${type}`;
const dropdownPanelId = `filter-panel-${type}`;
const dropdownPanel = document.createElement('div');
dropdownPanel.className = 'dropdown-panel hidden absolute z-10 mt-2 w-56 bg-white rounded-md shadow-2xl border border-gray-200/80 origin-top-right right-0 max-h-60 overflow-y-auto';
dropdownPanel.setAttribute('role', 'listbox');
dropdownPanel.setAttribute('id', dropdownPanelId);
dropdownPanel.setAttribute('aria-labelledby', dropdownButtonId);
const checkboxContainer = document.createElement('div');
checkboxContainer.className = 'p-2 space-y-1';
options[type].forEach(value => {
const optionId = `filter-${type}-${String(value).replace(/\s+/g, '-')}`;
const label = document.createElement('label');
label.className = 'flex items-center space-x-3 p-2 hover:bg-slate-100 rounded-md cursor-pointer';
label.setAttribute('for', optionId);
label.innerHTML = `
<input type="checkbox" id="${optionId}" data-type="${type}" value="${value}"
class="h-4 w-4 rounded border-gray-300 text-brand-purple focus:ring-brand-purple/50">
<span class="text-sm text-gray-700 font-medium">${value}</span>
`;
checkboxContainer.appendChild(label);
});
dropdownPanel.appendChild(checkboxContainer);
dropdown.innerHTML = `
<button id="${dropdownButtonId}" class="filter-button bg-white hover:bg-gray-50 text-gray-700 font-semibold py-2.5 px-5 border border-gray-300 rounded-lg shadow-sm flex items-center transition-all duration-200"
aria-haspopup="listbox" aria-expanded="false" aria-controls="${dropdownPanelId}">
<span>${allFilters[type].label}</span>
<span id="${type}-filter-count" class="ml-2 bg-brand-purple text-white text-xs font-bold rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
<svg class="dropdown-arrow w-4 h-4 ml-2 text-gray-500 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path></svg>
</button>`;
dropdown.appendChild(dropdownPanel);
filterBar.appendChild(dropdown);
allFilters[type].container = checkboxContainer;
}
}
const resetButton = document.createElement('button');
resetButton.id = 'reset-filters-button';
resetButton.className = 'bg-gray-600 hover:bg-gray-700 text-white font-semibold py-2.5 px-5 rounded-lg shadow-sm flex items-center transition-all duration-200';
resetButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h5M20 20v-5h-5M4 9a9 9 0 0114.12-5.12M20 15a9 9 0 01-14.12 5.12" /></svg>Reset Filters`;
filterBar.appendChild(resetButton);
}
function setupInteraction() {
filterBar.addEventListener('click', e => {
const button = e.target.closest('.filter-button');
if (button) {
const panel = button.nextElementSibling;
const isExpanded = button.getAttribute('aria-expanded') === 'true';
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
if (!isExpanded) {
panel.classList.remove('hidden');
button.setAttribute('aria-expanded', 'true');
} else {
panel.classList.add('hidden');
button.setAttribute('aria-expanded', 'false');
}
return;
}
if (e.target.type === 'checkbox') {
const type = e.target.dataset.type;
const value = e.target.value;
if (e.target.checked) allFilters[type].active.add(value);
else allFilters[type].active.delete(value);
applyFilters();
return;
}
if(e.target.closest('#reset-filters-button')) {
searchInput.value = '';
document.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = false);
for (const type in allFilters) allFilters[type].active.clear();
applyFilters();
const liveRegion = document.createElement('div');
liveRegion.setAttribute('aria-live', 'polite');
liveRegion.classList.add('sr-only');
liveRegion.textContent = 'All filters reset.';
document.body.appendChild(liveRegion);
setTimeout(() => liveRegion.remove(), 1000);
}
});
document.addEventListener('click', e => {
if (!e.target.closest('.relative') && !e.target.closest('.dropdown-panel')) {
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
}
});
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
document.querySelectorAll('.dropdown-panel').forEach(p => {
p.classList.add('hidden');
p.previousElementSibling.setAttribute('aria-expanded', 'false');
});
}
});
searchInput.addEventListener('input', applyFilters);
}
generatePageContent();
generateFilterOptions();
setupInteraction();
updateFilterCounts();
} catch (error) {
console.error("Could not initialize the app:", error);
document.body.innerHTML = `<div class="text-center p-8"><h2 class="text-xl font-bold text-red-700">A critical error occurred.</h2><p class="mt-2 text-red-500">Could not load or render workshops. Please check the browser console for details.</p></div>`;
}
});
</script>
<footer class="mt-16 py-8 px-4 text-center text-lg text-gray-600 bg-slate-50 border-t border-gray-200">
<p>
<strong>Looking for a workshop not listed above?</strong> <br> Many CBW workshops are archived, but only the most recent are displayed here.
Email us at <a href="mailto:training@bioinformatics.ca" class="text-brand-purple hover:text-purple-700 font-semibold transition-colors duration-200">training@bioinformatics.ca</a> and we can help you find what you're looking for.
</p>
</footer>
</body>
</html>