-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal.html
678 lines (612 loc) · 23.2 KB
/
portal.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eco Ops Learning Portal</title>
<script src="https://cdn.jsdelivr.net/npm/localforage/dist/localforage.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100 text-gray-800">
<header class="bg-green-600 text-white py-4">
<div class="container mx-auto flex justify-between items-center">
<h1 class="text-2xl font-bold">Approvideo DIY Learning Portal</h1>
<nav>
<a href="#" class="text-white mx-2">Home</a>
<a href="#modules" class="text-white mx-2">Learn</a>
<a href="#contribute" class="text-white mx-2">Contribute</a>
<a href="#dashboard" class="text-white mx-2">Dashboard</a>
</nav>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto mt-6">
<!-- Welcome Section -->
<section class="bg-white p-6 rounded shadow-md">
<h2 class="text-xl font-bold">Welcome to Eco Ops</h2>
<p>Your gateway to making a difference in biodiversity and climate action. Explore, contribute, and earn rewards for your actions!</p>
</section>
<!-- Learning Modules -->
<section id="modules" class="mt-8">
<h2 class="text-2xl font-bold">Learning Modules</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mt-4">
<div class="bg-white p-4 rounded shadow-md">
<h3 class="text-lg font-bold">Biodiversity Credits</h3>
<p>Learn how to earn and trade biodiversity credits.</p>
</div>
<div class="bg-white p-4 rounded shadow-md">
<h3 class="text-lg font-bold">Climate Actions</h3>
<p>Discover how to offset emissions through verified projects.</p>
</div>
<div class="bg-white p-4 rounded shadow-md">
<h3 class="text-lg font-bold">Sustainable Development</h3>
<p>Explore initiatives aligned with UN SDGs.</p>
</div>
</div>
</section>
</main>
<Style>
.hero {
background-image: url('path-to-background-image.jpg');
background-size: cover;
background-position: center;
}
.video-grid {
min-height: 200px;
}
</style>
<div class="hero bg-green-600 text-white p-8">
<h1 class="text-4xl font-bold">Welcome to Eco Ops Learning Portal</h1>
<p class="mt-4">Learn, contribute, and earn rewards for making a difference!</p>
<input type="text" id="searchBar" class="mt-4 w-full p-2 rounded" placeholder="Search videos...">
</div>
<div class="video-grid container mx-auto p-4 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
<!-- Videos will be dynamically injected here -->
</div>
<button id="loadMoreBtn" class="mt-4 mx-auto block bg-blue-500 text-white p-2 rounded">Load More</button>
<script>
const topicData = {
"Water Security": {
icon: "fa-tint",
subtopics: [
{ name: "Water Purification", category: "Water Purification", icon: "fa-filter" },
{ name: "Desalination", category: "Desalination", icon: "fa-faucet-drip" },
{ name: "Efficient Distribution", category: "Efficient Distribution", icon: "fa-truck-container" }
]
},
"Energy Solutions": {
icon: "fa-bolt",
subtopics: [
{ name: "DIY Solar", category: "DIY Solar", icon: "fa-solar-panel" },
{ name: "Biogas Generation", category: "Biogas", icon: "fa-biohazard" },
{ name: "Microgrids", category: "Microgrids", icon: "fa-plug-circle-bolt" }
]
},
"Food Production": {
icon: "fa-apple-whole",
subtopics: [
{ name: "Urban Gardening", category: "Urban Gardening", icon: "fa-seedling" },
{ name: "Hydroponics", category: "Hydroponics", icon: "fa-water" },
{ name: "Sustainable Agriculture", category: "Sustainable Agriculture", icon: "fa-tractor" }
]
},
"Shelter": {
icon: "fa-house-chimney",
subtopics: [
{ name: "Low-cost Construction", category: "Low-cost Construction", icon: "fa-house-crack" },
{ name: "Local Materials", category: "Local Materials", icon: "fa-tree" }
]
},
"Healthcare": {
icon: "fa-kit-medical",
subtopics: [
{ name: "Emergency Medical Training", category: "Emergency Medical Training", icon: "fa-first-aid" },
{ name: "Telemedicine", category: "Telemedicine", icon: "fa-video" },
{ name: "Self-Sufficient Healthcare", category: "Self-Sufficient Healthcare", icon: "fa-user-doctor" }
]
}
};
const videoData = {
"Water Purification": [
{
title: "Rick Astley - Never Gonna Give You Up (Official Music Video)",
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
tags: ["rickroll", "classic", "music", "meme"],
category: "Water Purification",
subcategory: "Water Security"
},
{
title: "Ultimate Water Purification System!",
url: "https://www.youtube.com/watch?v=oAKG-kbKeIo",
tags: ["water", "purification", "diy", "survival"],
category: "Water Purification",
subcategory: "Water Security"
},
{
title: "Crazy Frog - Axel F",
url: "https://www.youtube.com/watch?v=SomeDesalinationVideo", // Replace with actual ID
tags: ["crazy", "frog", "music", "meme", "animation"],
category: "Water Purification",
subcategory: "Water Security"
},
{
title: "DIY Water Filter for Emergencies",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["water", "filter", "diy", "emergency", "survival"],
category: "Water Purification",
subcategory: "Water Security"
}
],
"Desalination": [
{
title: "Funny Cats and Dogs",
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
tags: ["funny", "animals", "cats", "dogs", "meme"],
category: "Desalination",
subcategory: "Water Security"
},
{
title: "Desalination Explained",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["water", "desalination", "science", "technology"],
category: "Desalination",
subcategory: "Water Security"
},
{
title: "He-Man Sings \"What's Up\"",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["he-man", "what's up", "music", "meme", "funny"],
category: "Desalination",
subcategory: "Water Security"
},
{
title: "Home Desalination Techniques",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["water", "desalination", "diy", "home"],
category: "Desalination",
subcategory: "Water Security"
}
],
"Efficient Distribution": [
{
title: "Charlie Bit My Finger - Again !",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["funny", "kids", "classic", "meme"],
category: "Efficient Distribution",
subcategory: "Water Security"
},
{
title: "Water Distribution in Developing Countries",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["water", "distribution", "infrastructure", "development"],
category: "Efficient Distribution",
subcategory: "Water Security"
},
{
title: "Chocolate Rain Song",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["chocolate", "rain", "song", "music", "meme"],
category: "Efficient Distribution",
subcategory: "Water Security"
},
{
title: "Efficient Irrigation Methods",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["water", "distribution", "irrigation", "agriculture"],
category: "Efficient Distribution",
subcategory: "Water Security"
}
],
"DIY Solar": [
{
title: "Nyan Cat [original]",
url: "https://www.youtube.com/watch?v=QH2-TGUlwu4",
tags: ["meme", "music", "animation", "cat"],
category: "DIY Solar",
subcategory: "Energy Solutions"
},
{
title: "How to Build a Simple Solar Panel",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["solar", "diy", "energy", "tutorial"],
category: "DIY Solar",
subcategory: "Energy Solutions"
},
{
title: "Badger Badger Badger Mushroom Mushroom",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["badger", "mushroom", "animation", "meme", "music"],
category: "DIY Solar",
subcategory: "Energy Solutions"
},
{
title: "Solar Panel Installation Guide",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["solar", "diy", "installation", "guide"],
category: "DIY Solar",
subcategory: "Energy Solutions"
}
],
"Biogas Generation": [
{
title: "Keyboard Cat",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["meme", "funny", "cat", "keyboard"],
category: "Biogas Generation",
subcategory: "Energy Solutions"
},
{
title: "Building a Biogas Digester",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["biogas", "diy", "energy", "renewable"],
category: "Biogas Generation",
subcategory: "Energy Solutions"
},
{
title: "Trololo Guy",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["trololo", "music", "meme", "funny"],
category: "Biogas Generation",
subcategory: "Energy Solutions"
},
{
title: "Biogas for Home Energy",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["biogas", "diy", "home", "energy"],
category: "Biogas Generation",
subcategory: "Energy Solutions"
}
],
"Microgrids": [
{
title: "Dramatic Chipmunk",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["meme", "funny", "chipmunk", "dramatic"],
category: "Microgrids",
subcategory: "Energy Solutions"
},
{
title: "Introduction to Microgrids",
url: "https://www.youtube.com/watch?v=your-video-id-here",
tags: ["microgrid", "energy", "electricity", "grid"],
category: "Microgrids",
subcategory: "Energy Solutions"
},
{
title: "Leeroy Jenkins",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["leeroy", "jenkins", "meme", "gaming", "funny"],
category: "Microgrids",
subcategory: "Energy Solutions"
},
{
title: "Microgrid Technology Explained",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["microgrid", "technology", "energy", "electricity"],
category: "Microgrids",
subcategory: "Energy Solutions"
}
],
"Urban Gardening": [
{
title: "Urban Gardening 101",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["urban", "gardening", "diy", "food", "grow"],
category: "Urban Gardening",
subcategory: "Food Production"
},
{
title: "Vertical Gardening Ideas",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["urban", "gardening", "vertical", "diy", "space"],
category: "Urban Gardening",
subcategory: "Food Production"
},
{
title: "Epic Sax Guy",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["epic", "sax", "guy", "music", "meme"],
category: "Urban Gardening",
subcategory: "Food Production"
},
{
title: "Building a Raised Garden Bed",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["urban", "gardening", "raised", "bed", "diy"],
category: "Urban Gardening",
subcategory: "Food Production"
}
],
"Hydroponics": [
{
title: "Hydroponics for Beginners",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["hydroponics", "diy", "grow", "food", "water"],
category: "Hydroponics",
subcategory: "Food Production"
},
{
title: "DIY Hydroponic System",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["hydroponics", "diy", "system", "build"],
category: "Hydroponics",
subcategory: "Food Production"
},
{
title: "David After Dentist",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["david", "dentist", "funny", "kid", "meme"],
category: "Hydroponics",
subcategory: "Food Production"
},
{
title: "Hydroponic Tomatoes at Home",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["hydroponics", "tomatoes", "grow", "home"],
category: "Hydroponics",
subcategory: "Food Production"
}
],
"Sustainable Agriculture": [
{
title: "Sustainable Farming Practices",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["sustainable", "agriculture", "farming", "practices"],
category: "Sustainable Agriculture",
subcategory: "Food Production"
},
{
title: "Permaculture Design",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["sustainable", "agriculture", "permaculture", "design"],
category: "Sustainable Agriculture",
subcategory: "Food Production"
},
{
title: "O Fortuna (Carmina Burana)",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID (use a dramatic/intense version)
tags: ["o", "fortuna", "carmina", "burana", "music", "meme"],
category: "Sustainable Agriculture",
subcategory: "Food Production"
},
{
title: "No-Till Farming",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["sustainable", "agriculture", "no-till", "farming"],
category: "Sustainable Agriculture",
subcategory: "Food Production"
}
],
"Low-cost Durable Construction Methods": [
{
title: "Building with Earthbags",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["low-cost", "construction", "earthbags", "diy"],
category: "Low-cost Construction",
subcategory: "Shelter"
},
{
title: "Bamboo Construction Techniques",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["low-cost", "construction", "bamboo", "diy"],
category: "Low-cost Construction",
subcategory: "Shelter"
},
{
title: "Yelling Goat",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["goat", "yelling", "funny", "animal", "meme"],
category: "Low-cost Construction",
subcategory: "Shelter"
},
{
title: "Building a Tiny House",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["low-cost", "construction", "tiny", "house", "diy"],
category: "Low-cost Construction",
subcategory: "Shelter"
}
],
"Creative & Effective Local Materials for Shelter.": [
// ... (existing entries)
{
title: "Building a Straw Bale House",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["local", "materials", "straw", "bale", "house", "diy"],
category: "Local Materials",
subcategory: "Shelter"
},
{
title: "Using Adobe Bricks",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["local", "materials", "adobe", "bricks", "building"],
category: "Local Materials",
subcategory: "Shelter"
},
{
title: "Dramatic Gopher",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["gopher", "dramatic", "funny", "animal", "meme"],
category: "Local Materials",
subcategory: "Shelter"
},
{
title: "Making Lime Plaster",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["local", "materials", "lime", "plaster", "diy"],
category: "Local Materials",
subcategory: "Shelter"
}
],
"Emergency Medical Training": [
// ... (existing entries)
{
title: "Wilderness First Aid",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["emergency", "medical", "training", "wilderness", "first aid"],
category: "Emergency Medical Training",
subcategory: "Healthcare"
},
{
title: "How to Perform the Heimlich Maneuver",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["emergency", "medical", "training", "heimlich", "choking"],
category: "Emergency Medical Training",
subcategory: "Healthcare"
},
{
title: "It's a Trap!",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["it's a trap", "star wars", "admiral ackbar", "meme", "funny"],
category: "Emergency Medical Training",
subcategory: "Healthcare"
},
{
title: "Basic Life Support (BLS)",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["emergency", "medical", "training", "bls", "life support"],
category: "Emergency Medical Training",
subcategory: "Healthcare"
}
],
"Telemedicine": [
// ... (existing entries)
{
title: "Telemedicine for Rural Areas",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["telemedicine", "rural", "healthcare", "access"],
category: "Telemedicine",
subcategory: "Healthcare"
},
{
title: "Telemedicine and Chronic Diseases",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["telemedicine", "chronic", "diseases", "management"],
category: "Telemedicine",
subcategory: "Healthcare"
},
{
title: "We Are Number One",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["we are number one", "lazy town", "robbie rotten", "music", "meme"],
category: "Telemedicine",
subcategory: "Healthcare"
},
{
title: "The Future of Telemedicine",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["telemedicine", "future", "technology", "healthcare"],
category: "Telemedicine",
subcategory: "Healthcare"
}
],
"Self-Sufficient Healthcare": [
// ... (existing entries)
{
title: "Foraging for Wild Edibles",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["self-sufficient", "healthcare", "foraging", "wild", "edibles"],
category: "Self-Sufficient Healthcare",
subcategory: "Healthcare"
},
{
title: "Making Herbal Salves",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["self-sufficient", "healthcare", "herbal", "salves", "diy"],
category: "Self-Sufficient Healthcare",
subcategory: "Healthcare"
},
{
title: "Distracted Boyfriend Meme",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID (find a video version of the meme)
tags: ["distracted", "boyfriend", "meme", "funny", "relationship"],
category: "Self-Sufficient Healthcare",
subcategory: "Healthcare"
},
{
title: "Home Remedies for Cold and Flu",
url: "https://www.youtube.com/watch?v=your-video-id-here", // Replace with actual ID
tags: ["self-sufficient", "healthcare", "cold", "flu", "remedies"],
category: "Self-Sufficient Healthcare",
subcategory: "Healthcare"
}
]
};
// Constants
const videosPerLoad = 6; // Number of videos to load per batch
let loadedVideos = 0; // Tracks how many videos have been loaded
// Render Videos
function renderVideos(category = null, startIndex = 0, count = videosPerLoad) {
const container = document.querySelector('.video-grid');
const videos = category
? videoData[category] || []
: Object.keys(videoData).flatMap(key => videoData[key]);
// Slice the batch of videos to render
const batch = videos.slice(startIndex, startIndex + count);
loadedVideos += batch.length;
batch.forEach(video => {
const videoCard = document.createElement('div');
videoCard.className = 'bg-white p-4 rounded shadow-md';
videoCard.innerHTML = `
<h3 class="text-lg font-bold">${video.title}</h3>
<p class="text-sm text-gray-600">${video.category} - ${video.subcategory}</p>
<a href="${video.url}" target="_blank" class="text-blue-500">Watch Video</a>
`;
container.appendChild(videoCard);
});
// Hide Load More button if all videos are loaded
const loadMoreBtn = document.getElementById('loadMoreBtn');
if (loadedVideos >= videos.length) {
loadMoreBtn.style.display = 'none';
}
}
// Infinite Scroll Setup
function setupInfiniteScroll(category = null) {
const loadMoreBtn = document.getElementById('loadMoreBtn');
loadMoreBtn.style.display = 'block'; // Ensure button is visible
loadMoreBtn.onclick = () => renderVideos(category, loadedVideos, videosPerLoad);
// Optional: Scroll-based auto-load
window.onscroll = () => {
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 100) {
renderVideos(category, loadedVideos, videosPerLoad);
}
};
}
// Search Videos
function setupSearch() {
const searchBar = document.getElementById('searchBar');
searchBar.addEventListener('input', event => {
const query = event.target.value.toLowerCase();
const allVideos = document.querySelectorAll('.video-grid div');
allVideos.forEach(video => {
const title = video.querySelector('h3').textContent.toLowerCase();
video.style.display = title.includes(query) ? 'block' : 'none';
});
});
}
// NFT Certificate Setup
function setupCertificates() {
const nftButton = document.createElement('button');
nftButton.className = 'bg-green-500 text-white p-2 rounded mt-4';
nftButton.textContent = 'Claim NFT Certificate';
nftButton.addEventListener('click', () => {
const certificate = {
title: 'Eco Ops Learning Certificate',
description: 'Awarded for completing videos.',
date: new Date().toISOString(),
};
localforage.setItem('certificate', certificate)
.then(() => alert('NFT Certificate Claimed!'))
.catch(err => console.error(err));
});
document.body.appendChild(nftButton);
}
// Initialize App
document.addEventListener('DOMContentLoaded', () => {
renderVideos(); // Load initial videos
setupInfiniteScroll(); // Setup scrolling
setupSearch(); // Setup search functionality
setupCertificates(); // Setup NFT certificates
});
</script>