-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_accordian.html
762 lines (627 loc) · 25.5 KB
/
index_accordian.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
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
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ApproVideo - DIY Solutions Portal</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link href="style.css" rel="stylesheet">
</head>
<body class="theme-transition">
<!-- Navigation -->
<nav class="theme-transition shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex items-center justify-between h-16">
<!-- Logo -->
<a href="index.html" class="flex items-center space-x-3">
<svg class="h-8 w-8 text-green-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<path d="M12 8v8m-4-4h8"/>
</svg>
<span class="text-xl font-bold bg-gradient-to-r from-green-500 to-blue-500 bg-clip-text text-transparent">
ApproVideo
</span>
</a>
<!-- Navigation Items -->
<div class="flex items-center space-x-4">
<a href="index.html" class="text-white-300 hover:text-green-500 px-3 py-2">Home</a>
<!-- Theme Toggle -->
<button id="darkModeToggle" class="p-2 rounded-lg hover:bg-gray-700/50 text-gray-300">
<i class="fas fa-sun text-yellow-500 dark:hidden">About Approvideo</i>
<i class="fas fa-sun text-yellow-500 dark:hidden">Support Approvideo</i>
<i class="fas fa-moon text-blue-400 hidden dark:inline"></i>
</button>
<!-- Profile -->
<div class="relative">
<button id="profileButton" class="p-2 rounded-lg hover:bg-gray-700/50">
<i class="fas fa-user text-gray-300"></i>
</button>
<div id="profileDropdown" class="profile-dropdown absolute right-0 mt-2 w-48 rounded-lg shadow-lg bg-white dark:bg-gray-800">
<div class="py-1">
<a href="#" class="block px-4 py-2 text-sm hover:bg-green-100 dark:hover:bg-gray-700">Profile</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700">Settings</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700">Sign out</a>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
<!-- Hero Slider -->
<div class="hero-slider">
<div class="slide active">
<img src="https://images.unsplash.com/photo-1505236858219-8359eb29e329?auto=format&fit=crop" alt="Clean water solutions">
<div class="slide-content">
<h2 class="text-2xl font-bold mb-2">Clean Water Solutions</h2>
<p class="text-lg opacity-90">Discover sustainable technologies</p>
<div class="button-group">
<a href="/skills" class="cta-button cta-primary">
<i class="fas fa-graduation-cap"></i>
Drinking Water
</a>
<a href="/sanitation" class="cta-button cta-secondary">
<i class="fas fa-shield-alt"></i>
Sanitation
</a>
</div>
</div>
</div>
<div class="slide">
<img src="https://images.unsplash.com/photo-1531206715517-5c0ba140b2b8?auto=format&fit=crop" alt="Community impact">
<div class="slide-content">
<h2 class="text-2xl font-bold mb-2">Community Impact</h2>
<p class="text-lg opacity-90">Building together</p>
</div>
</div>
<div class="slide">
<img src="https://images.unsplash.com/photo-1501854140801-50d01698950b?auto=format&fit=crop" alt="Natural solutions">
<div class="slide-content">
<h2 class="text-2xl font-bold mb-2">Natural Solutions</h2>
<p class="text-lg opacity-90">Working with nature</p>
<div class="button-group">
<a href="/skills" class="cta-button cta-primary">
<i class="fas fa-graduation-cap"></i>
Drinking water
</a>
<a href="/sanitation" class="cta-button cta-secondary">
<i class="fas fa-shield-alt"></i>
Hygiene
</a>
</div>
</div>
</div>
<div class="slider-nav">
<button class="nav-dot active"></button>
<button class="nav-dot"></button>
<button class="nav-dot"></button>
</div>
</div>
<div class="container mx-auto p-4">
<!-- Category Navigation -->
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-8">
<button class="category-icon active flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="diy">
<i class="fas fa-home text-2xl mb-2 text-blue-500"></i>
<span class="text-sm text-gray-600">DIY</span>
</button>
<button class="category-icon flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="water">
<i class="fas fa-tint text-2xl mb-2 text-cyan-500"></i>
<span class="text-sm text-gray-600">Water</span>
</button>
<button class="category-icon flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="waste">
<i class="fas fa-recycle text-2xl mb-2 text-green-500"></i>
<span class="text-sm text-gray-600">Waste</span>
</button>
<button class="category-icon flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="energy">
<i class="fas fa-solar-panel text-2xl mb-2 text-yellow-500"></i>
<span class="text-sm text-gray-600">Energy</span>
</button>
<button class="category-icon flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="food">
<i class="fas fa-seedling text-2xl mb-2 text-emerald-500"></i>
<span class="text-sm text-gray-600">Agriculture</span>
</button>
<button class="category-icon flex flex-col items-center p-4 bg-white rounded-xl shadow-sm hover:shadow-md" data-category="health">
<i class="fas fa-heart text-2xl mb-2 text-red-500"></i>
<span class="text-sm text-gray-600">Health</span>
</button>
</div>
<!-- Search and Sort Controls -->
<div class="flex flex-col md:flex-row gap-4 mb-8">
<div class="flex-1">
<input
type="text"
id="searchInput"
placeholder="Search solutions..."
class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-200"
>
</div>
<div class="flex-shrink-0">
<select
id="sortSelect"
class="w-full md:w-auto px-4 py-3 bg-white border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-200"
>
<option value="newest">Newest First</option>
<option value="popular">Most Popular</option>
<option value="az">A-Z</option>
</select>
</div>
</div>
<!-- Loading Skeleton -->
<div id="skeletonLoader" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Skeleton cards will be injected here -->
</div>
<!-- Video Grid -->
<div id="videoGrid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 hidden">
<!-- Videos will be dynamically inserted here -->
</div>
<!-- Infinite Scroll Trigger -->
<div id="infiniteScrollTrigger" class="h-20"></div>
</div>
<script>
// Theme Toggle
const darkModeToggle = document.getElementById('darkModeToggle');
const html = document.documentElement;
function updateTheme(isDark) {
html.classList.toggle('dark', isDark);
localStorage.setItem('darkMode', isDark);
}
// Check saved preference
if (localStorage.getItem('darkMode') === 'true' ||
(!localStorage.getItem('darkMode') &&
window.matchMedia('(prefers-color-scheme: dark)').matches)) {
updateTheme(true);
}
darkModeToggle.addEventListener('click', () => {
updateTheme(!html.classList.contains('dark'));
});
// Profile Dropdown
const profileButton = document.getElementById('profileButton');
const profileDropdown = document.getElementById('profileDropdown');
profileButton.addEventListener('click', (e) => {
e.stopPropagation();
profileDropdown.classList.toggle('dropdown-active');
});
document.addEventListener('click', () => {
profileDropdown.classList.remove('dropdown-active');
});
// Slider Functionality
document.addEventListener('DOMContentLoaded', () => {
const slides = document.querySelectorAll('.slide');
const dots = document.querySelectorAll('.nav-dot');
let currentSlide = 0;
let interval;
function showSlide(n) {
slides[currentSlide].classList.remove('active');
dots[currentSlide].classList.remove('active');
currentSlide = (n + slides.length) % slides.length;
slides[currentSlide].classList.add('active');
dots[currentSlide].classList.add('active');
}
function startAutoSlide() {
interval = setInterval(() => showSlide(currentSlide + 1), 5000);
}
dots.forEach((dot, index) => {
dot.addEventListener('click', () => {
clearInterval(interval);
showSlide(index);
startAutoSlide();
});
});
startAutoSlide();
const slider = document.querySelector('.hero-slider');
slider.addEventListener('mouseenter', () => clearInterval(interval));
slider.addEventListener('mouseleave', startAutoSlide);
});
</script>
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm';
import safeHtml from './safeHtmlUtils.js';
class PublicVideoPortal {
constructor() {
// Initialize properties
this.supabase = createClient(
'https://vlvbodwrtblttvwnxkjx.supabase.co',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZsdmJvZHdydGJsdHR2d254a2p4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODY3NDk2NzIsImV4cCI6MjAwMjMyNTY3Mn0.TRT1HeX85vP1zDxnU7qBz5GqNPgYZUj-BOdek4qmtEg'
);
this.safeHtml = safeHtml;
this.currentPage = 0;
this.isLoading = false;
this.hasMore = true;
this.BATCH_SIZE = 12;
this.selectedCategory = null;
this.searchQuery = '';
// Initialize slider counter
this.sliderCounter = 0;
// Start initialization
this.init();
}
async init() {
this.setupEventListeners();
this.showSkeletonLoader();
await this.loadVideos();
}
setupEventListeners() {
// Search input
const searchInput = document.getElementById('searchInput');
if (searchInput) {
searchInput.addEventListener('input', (e) => {
this.searchQuery = e.target.value;
this.resetAndReload();
});
}
const categoryButtons = document.querySelectorAll('.category-icon');
categoryButtons.forEach(button => {
button.addEventListener('click', () => this.handleCategoryClick(button));
});
// Sort select
const sortSelect = document.getElementById('sortSelect');
if (sortSelect) {
sortSelect.addEventListener('change', (e) => {
this.handleSort(e.target.value);
});
}
// Category buttons with proper selection and data passing
document.querySelectorAll('.category-icon').forEach(button => {
button.addEventListener('click', () => {
this.handleCategoryClick(button);
});
});
// Infinite scroll
this.setupInfiniteScroll();
}
resetAndReload() {
this.currentPage = 0;
this.hasMore = true;
this.loadVideos();
}
setupInfiniteScroll() {
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting && !this.isLoading && this.hasMore) {
this.loadVideos();
}
},
{ threshold: 0.1 }
);
const trigger = document.getElementById('infiniteScrollTrigger');
if (trigger) {
observer.observe(trigger);
}
}
showSkeletonLoader() {
const loader = document.getElementById('skeletonLoader');
if (!loader) return;
const skeletons = Array(6).fill().map(() => this.createSkeletonCard()).join('');
loader.innerHTML = skeletons;
loader.classList.remove('hidden');
const videoGrid = document.getElementById('videoGrid');
if (videoGrid) {
videoGrid.classList.add('hidden');
}
}
createSkeletonCard() {
return `
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<div class="w-full h-48 shimmer"></div>
<div class="p-4">
<div class="h-6 w-3/4 shimmer rounded mb-2"></div>
<div class="h-4 w-full shimmer rounded mb-4"></div>
<div class="flex gap-2 mb-4">
<div class="h-6 w-20 shimmer rounded-full"></div>
<div class="h-6 w-20 shimmer rounded-full"></div>
</div>
</div>
</div>
`;
}
handleCategoryClick(button) {
// Get the category from the data attribute
const newCategory = button.dataset.category;
console.log('Clicking category:', newCategory);
// Get search input
const searchInput = document.getElementById('searchInput');
// Remove active class from all buttons
document.querySelectorAll('.category-icon').forEach(btn => {
btn.classList.remove('active','bg-gray-100');
btn.classList.add('bg-white');
});
// Toggle category selection
if (this.selectedCategory === newCategory) {
// If clicking the same category, deselect it
this.selectedCategory = null;
if (searchInput) {
searchInput.value = '';
this.searchQuery = '';
}
console.log('Deselected category, now null');
} else {
// Select the new category
this.selectedCategory = newCategory;
button.classList.add('active');
// Add visual feedback
button.classList.remove('bg-white');
button.classList.add('bg-gray-100');
// Update search input
if (searchInput) {
searchInput.value = newCategory;
this.searchQuery = newCategory;
}
console.log('Selected new category:', this.selectedCategory);
}
const videoGrid = document.getElementById('videoGrid');
if (videoGrid) {
videoGrid.innerHTML = '';
}
// Reset and reload videos
this.resetAndReload();
}
async loadPanels(videoId) {
try {
const { data: panels, error } = await this.supabase
.from('panels')
.select('*')
.eq('video_id', videoId);
if (error) throw error;
const panelsContainer = document.getElementById(`panels-container-${videoId}`);
if (panelsContainer) {
// Check if panels exist before rendering
if (panels && panels.length > 0) {
panelsContainer.innerHTML = this.renderPanels(panels);
this.initializeSliders();
} else {
// If no panels, hide the accordion item
const accordionItem = document.getElementById(`panels-heading-${videoId}`).parentElement;
accordionItem.style.display = 'none';
}
}
} catch (error) {
console.error('Error loading panels:', error);
// Handle the error (e.g., display an error message)
}
}
// Update loadVideos to search across both title and category
async loadVideos() {
if (this.isLoading || !this.hasMore) return;
this.isLoading = true;
try {
// Start building the query
let query = this.supabase
.from('Video')
.select('*, panels(*)');
// Apply search filter if present - now searches both title and category
if (this.searchQuery) {
query = query.or(`title.ilike.%${this.searchQuery}%,category.ilike.%${this.searchQuery}%`);
}
// Complete the query with range and order
query = query
.range(this.currentPage * this.BATCH_SIZE, (this.currentPage + 1) * this.BATCH_SIZE - 1)
.order('createdAt', { ascending: false });
// Execute the query
const { data: videos, error } = await query;
if (error) throw error;
console.log('Loaded videos:', videos);
if (videos.length < this.BATCH_SIZE) {
this.hasMore = false;
}
this.renderVideos(videos);
this.currentPage++;
} catch (error) {
console.error('Error loading videos:', error);
this.showError('Failed to load videos');
} finally {
this.isLoading = false;
document.getElementById('skeletonLoader').classList.add('hidden');
document.getElementById('videoGrid').classList.remove('hidden');
}
}
renderVideos(videos) {
const videoGrid = document.getElementById('videoGrid');
if (!videoGrid) return;
const videoHTML = videos.map(video => this.createVideoCard(video)).join('');
if (this.currentPage === 0) {
videoGrid.innerHTML = videoHTML;
} else {
videoGrid.insertAdjacentHTML('beforeend', videoHTML);
}
// Initialize sliders after rendering videos
this.initializeSliders();
this.initializeAccordions();
}
resetAndReload() {
this.currentPage = 0;
this.hasMore = true;
const videoGrid = document.getElementById('videoGrid');
if (videoGrid) {
videoGrid.innerHTML = ''; // Clear existing videos
}
this.showSkeletonLoader();
this.loadVideos();
}
createVideoCard(video) {
const safeVideo = this.safeHtml.escapeObject(video);
return `
<div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-xl transition-shadow duration-300">
<div class="relative aspect-video" id="video-container-${safeVideo.id}">
<img
src="https://img.youtube.com/vi/$${safeVideo.youtubeId}/maxresdefault.jpg"
alt="${safeVideo.title}"
class="w-full h-full object-cover"
onerror="this.src='https://img.youtube.com/vi/$${safeVideo.youtubeId}/0.jpg'"
>
<button class="play-button absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2" data-video-id="${safeVideo.youtubeId}">
<i class="fas fa-play text-white text-4xl"></i>
</button>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold mb-2 line-clamp-2">${safeVideo.title}</h3>
<p class="text-gray-600 text-sm mb-3 line-clamp-2">${safeVideo.description}</p>
<div class="flex items-center gap-2 mb-3">
<i class="fas ${this.getCategoryIcon(safeVideo.category)} text-gray-500"></i>
<span class="text-sm text-gray-600">${safeVideo.category || 'General'}</span>
</div>
<div class="accordion" id="accordion-${safeVideo.id}">
<div class="accordion-item">
<h2 class="accordion-header" id="panels-heading-${safeVideo.id}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panels-${safeVideo.id}" aria-expanded="false" aria-controls="panels-${safeVideo.id}">
Panels
</button>
</h2>
<div id="panels-${safeVideo.id}" class="accordion-collapse collapse" aria-labelledby="panels-heading-${safeVideo.id}" data-bs-parent="#accordion-${safeVideo.id}">
<div class="accordion-body">
<div id="panels-container-${safeVideo.id}"></div>
</div>
</div>
</div>
</div>
<div class="flex flex-wrap gap-2 mt-3">
${this.renderTags(safeVideo.tags)}
</div>
</div>
</div>
`;
}
renderPanels(panels) {
if (!panels || !panels.length) return '';
// Initially show skeleton loader
let panelHTML = `
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
${Array(panels.length).fill(this.createPanelSkeleton()).join('')}
</div>
`;
// Replace skeleton with actual panels when they load (simulated delay)
setTimeout(() => {
panelHTML = `
<div class="mt-4">
<div class="relative w-[380px] h-[200px] overflow-hidden">
<div class="slides flex transition-transform duration-500">
${panels.map(panel => `
<div class="slide w-full flex-shrink-0 P-3">
<div class="bg-gray-50 p-3 rounded-lg">
<h4 class="font-medium text-grey-700 text-sm mb-1">${this.safeHtml.escape(panel.title)}</h4>
<p class="text-sm text-gray-600">${this.safeHtml.escape(panel.content)}</p>
</div>
</div>
`).join('')}
</div>
<button class="prev absolute top-1/2 left-0 transform -translate-y-1/2 bg-white bg-opacity-75 p-2 rounded-full">◀</button>
<button class="next absolute top-1/2 right-0 transform -translate-y-1/2 bg-white bg-opacity-75 p-2 rounded-full">▶</button>
</div>
</div>
`;
const panelsContainer = document.getElementById(`panels-container-${panels[0].video_id}`);
if (panelsContainer) {
panelsContainer.innerHTML = panelHTML;
this.initializeSliders();
}
}, 500);
return panelHTML;
}
createPanelSkeleton() {
return `
<div class="bg-gray-200 rounded-lg animate-pulse h-24"></div>
`;
}
initializeAccordions() {
const accordionButtons = document.querySelectorAll('.accordion-button');
accordionButtons.forEach(button => {
button.addEventListener('click', () => {
const accordionItem = button.closest('.accordion-item');
const accordionContent = accordionItem.querySelector('.accordion-collapse');
// Toggle the content visibility
accordionContent.classList.toggle('hidden');
// Update button state
button.classList.toggle('collapsed');
button.setAttribute('aria-expanded', button.classList.contains('collapsed') ? 'false' : 'true');
// Optional: Rotate the arrow icon (if you have one)
const icon = button.querySelector('.arrow-icon'); // Replace '.arrow-icon' with your icon's selector
if (icon) {
icon.classList.toggle('rotate-180');
}
});
});
}
initializeSliders() {
const sliders = document.querySelectorAll('.slides');
sliders.forEach(slidesContainer => {
const slider = slidesContainer.parentElement;
const slides = slidesContainer.querySelectorAll('.slide');
const prevButton = slider.querySelector('.prev');
const nextButton = slider.querySelector('.next');
let currentIndex = 0;
function updateSlider() {
slidesContainer.style.transform = 'translateX(' + (-currentIndex * 100) + '%)';
}
prevButton.addEventListener('click', () => {
if (currentIndex > 0) {
currentIndex--;
updateSlider();
}
});
nextButton.addEventListener('click', () => {
if (currentIndex < slides.length - 1) {
currentIndex++;
updateSlider();
}
});
});
}
renderTags(tags) {
if (!tags) return '';
const processedTags = Array.isArray(tags)
? tags
: tags.toString().replace(/[{}]/g, '').split(',');
return processedTags.map(tag => `
<span class="px-2 py-1 bg-blue-50 text-blue-600 rounded-full text-xs">
${this.safeHtml.escape(tag.trim())}
</span>
`).join('');
}
getCategoryIcon(category) {
const icons = {
'diy': 'fa-home',
'water': 'fa-tint',
'waste': 'fa-recycle',
'energy': 'fa-solar-panel',
'agriculture': 'fa-seedling',
'health': 'fa-heart'
};
return icons[category?.toLowerCase()] || 'fa-tag';
}
resetAndReload() {
this.currentPage = 0;
this.hasMore = true;
this.showSkeletonLoader();
this.loadVideos();
}
showError(message) {
const videoGrid = document.getElementById('videoGrid');
if (!videoGrid) return;
videoGrid.innerHTML = `
<div class="col-span-full text-center py-8">
<div class="text-red-600 mb-2">${this.safeHtml.escape(message)}</div>
<button
onclick="location.reload()"
class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors"
>
Try Again
</button>
</div>
`;
}
}
// Initialize when DOM is ready
document.addEventListener('DOMContentLoaded', () => {
new PublicVideoPortal();
});
</script>
<footer>
<p>
<span>
<a href="https://github.com/biomassives/video-library-manager-vanilla">Approvideo source code</a>
</span>
<p>
</footer>
</body>
</html>