-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.html
804 lines (711 loc) · 27.3 KB
/
manage.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
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ApproVideo</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js"></script>
<script src="videoData2b.js"></script>
<script src="scr3.js"></script>
<style>
:root {
--primary-color: #2C7744;
--secondary-color: #88B04B;
--background-color: #F5F7F2;
--text-color: #333;
--header-height: 60px;
}
body {
font-family: system-ui, -apple-system, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background: var(--background-color);
color: var(--text-color);
}
.header {
background: var(--primary-color);
color: white;
padding: 1rem;
position: fixed;
width: 100%;
top: 0;
z-index: 100;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
height: var(--header-height);
display: flex;
align-items: center;
}
.header-logo {
font-size: 1.5rem;
font-weight: bold;
}
.content {
max-width: 800px;
margin: calc(var(--header-height) + 2rem) auto;
padding: 2rem;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.section {
margin-bottom: 2rem;
padding-bottom: 1rem;
border-bottom: 1px solid #eee;
}
h1 {
color: var(--primary-color);
font-size: 2rem;
margin-bottom: 1.5rem;
}
h2 {
color: var(--secondary-color);
font-size: 1.5rem;
margin: 2rem 0 1rem;
}
.highlight-box {
background: #f8f9fa;
border-left: 4px solid var(--secondary-color);
padding: 1rem;
margin: 1rem 0;
border-radius: 0 4px 4px 0;
}
.tabs {
display: flex;
margin-bottom: 2rem;
border-bottom: 2px solid #eee;
overflow-x: auto;
}
.tab {
padding: 1rem 2rem;
cursor: pointer;
border-bottom: 2px solid transparent;
margin-bottom: -2px;
white-space: nowrap;
}
.tab.active {
border-bottom: 2px solid var(--primary-color);
color: var(--primary-color);
font-weight: bold;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
/* Animation for welcome message */
.welcome-animation {
animation: slideIn 1s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* SVG Styling */
.svg-icon {
width: 24px;
height: 24px;
margin-right: 0.5rem;
fill: var(--secondary-color);
vertical-align: middle;
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 30%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body class="bg-gray-50 min-h-screen">
<header class="bg-white shadow-sm fixed top-0 w-full z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16 items-center">
<div class="text-xl font-bold text-blue-600 cursor-pointer" onclick="showMainContent()">
ApproVideo.org
</div>
<div class="flex items-center gap-4">
<div id="userStatusDisplay" class="text-sm text-gray-600"></div>
<button id="dashboardButton" onclick="toggleDashboard()" class="p-2 rounded-full hover:bg-gray-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path
d="M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</button>
</div>
</div>
</div>
</header>
<div id="statusMessage"
class="fixed top-16 right-4 max-w-sm z-50 hidden transform transition-transform duration-300">
</div>
<main class="pt-16">
<div id="mainContent" class="max-w-4xl mx-auto mt-10 px-4">
<div class="bg-white shadow rounded-lg">
<div class="p-6">
<div class="welcome-animation mb-8">
<h1 class="text-2xl font-bold text-gray-900">Welcome to ApproVideo!</h1>
<p class="mt-2 text-gray-600">Explore sustainable technology and DIY projects.</p>
</div>
</div>
</div>
</div>
<div id="loginContainer" class="hidden max-w-md mx-auto mt-10 px-4">
<div class="bg-white shadow rounded-lg p-6 space-y-6">
<h1 class="text-2xl font-bold text-center text-gray-900">Login to ApproVideo</h1>
<div class="space-y-4">
<div>
<input type="text" id="username"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Username">
</div>
<div>
<input type="password" id="password"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Password">
</div>
<button onclick="handleLogin()"
class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
Login
</button>
</div>
</div>
</div>
<div id="dashboardContainer" class="hidden max-w-7xl mx-auto mt-10 px-4">
<div class="bg-white shadow rounded-lg">
<div class="border-b border-gray-200 p-6">
<div class="flex flex-col sm:flex-row gap-4 justify-between items-center">
<h1 class="text-2xl font-bold text-gray-900">Video Library</h1>
<div class="flex gap-4">
<select id="sortSelect"
class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="dateDesc">Newest First</option>
<option value="dateAsc">Oldest First</option>
<option value="ratingDesc">Highest Rated</option>
<option value="ratingAsc">Lowest Rated</option>
<option value="titleAsc">Title A-Z</option>
<option value="titleDesc">Title Z-A</option>
</select>
<select id="categoryFilter"
class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="all">All Categories</option>
</select>
</div>
</div>
<div class="mt-4">
<input type="text" id="searchInput"
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Search videos...">
</div>
</div>
<div id="videoGrid" class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
</div>
</div>
</div>
</main>
<script>
function showStatusMessage(message, type = 'success') {
const statusDiv = document.getElementById('statusMessage');
statusDiv.className = `fixed top-16 right-4 max-w-sm z-50 p-4 rounded-lg shadow-lg transform transition-all duration-300 ${
type === 'success' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'
}`;
statusDiv.textContent = message;
statusDiv.classList.remove('hidden');
setTimeout(() => {
statusDiv.classList.add('hidden');
}, 3000);
}
function updateUserStatus() {
const username = localStorage.getItem('approVideoUser');
const display = document.getElementById('userStatusDisplay');
if (username) {
display.textContent = `Welcome, ${username}`;
} else {
display.textContent = 'Guest';
}
}
function toggleDashboard() {
const isLoggedIn = localStorage.getItem('approVideoToken');
const mainContent = document.getElementById('mainContent');
const loginContainer = document.getElementById('loginContainer');
const dashboardContainer = document.getElementById('dashboardContainer');
if (isLoggedIn) {
mainContent.classList.add('hidden');
loginContainer.classList.add('hidden');
dashboardContainer.classList.remove('hidden');
VideoApp.loadFeed(); // Refresh the video grid
} else {
mainContent.classList.add('hidden');
loginContainer.classList.remove('hidden');
dashboardContainer.classList.add('hidden');
}
}
function showMainContent() {
const mainContent = document.getElementById('mainContent');
const loginContainer = document.getElementById('loginContainer');
const dashboardContainer = document.getElementById('dashboardContainer');
mainContent.classList.remove('hidden');
loginContainer.classList.add('hidden');
dashboardContainer.classList.add('hidden');
}
function handleLogin() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username === 'user' && password === 'pass') {
const token = btoa(`<span class="math-inline">\{username\}\:</span>{Date.now()}`);
localStorage.setItem('approVideoToken', token);
localStorage.setItem('approVideoUser', username);
showStatusMessage('Successfully logged in!');
updateUserStatus();
toggleDashboard();
} else {
showStatusMessage('Invalid credentials!', 'error');
}
}
// Unified Video Management Module
if (typeof VideoApp === 'undefined') {
const VideoApp = (function () {
const state = {
store: null,
currentProjects: [],
currentFilter: 'all',
searchQuery: '',
currentSort: 'dateDesc',
lastVideoLoad: 0,
favorites: new Set(),
archived: new Set(),
tags: new Map(),
loadingStates: new Map(),
initialized: false,
userReviews: {},
userRecommendations: new Set(),
encryptionKey: null
};
const CryptoUtil = {
async generateKey() {
const existingKey = localStorage.getItem('approVideo_encKey');
if (existingKey) {
state.encryptionKey = existingKey;
return;
}
const array = new Uint8Array(32);
crypto.getRandomValues(array);
state.encryptionKey = Array.from(array, b => b.toString(16).padStart(2, '0')).join('');
localStorage.setItem('approVideo_encKey', state.encryptionKey);
},
async encrypt(data) {
const text = JSON.stringify(data);
const encoder = new TextEncoder();
const dataBuffer = encoder.encode(text);
const key = await crypto.subtle.importKey(
'raw',
this.hexToBuffer(state.encryptionKey), {name: 'AES-GCM'},
false,
['encrypt']
);
const iv = crypto.getRandomValues(new Uint8Array(12));
const encryptedData = await crypto.subtle.encrypt(
{name: 'AES-GCM', iv},
key,
dataBuffer
);
return {
data: Array.from(new Uint8Array(encryptedData)),
iv: Array.from(iv)
};
},
async decrypt(encryptedData, iv) {
const key = await crypto.subtle.importKey(
'raw',
this.hexToBuffer(state.encryptionKey), {name: 'AES-GCM'},
false,
['decrypt']
);
const decryptedBuffer = await crypto.subtle.decrypt(
{name: 'AES-GCM', iv: new Uint8Array(iv)},
key,
new Uint8Array(encryptedData)
);
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(decryptedBuffer));
},
hexToBuffer(hexString) {
const pairs = hexString.match(/[\dA-F]{2}/gi);
return new Uint8Array(pairs.map(s => parseInt(s, 16)));
}
};
async function initializeStore() {
if (!state.store) {
state.store = localforage.createInstance({
name: 'approVideo',
storeName: 'projects'
});
}
await CryptoUtil.generateKey();
await loadEncryptedData();
}
async function loadEncryptedData() {
try {
const encryptedFavorites = await state.store.getItem('favorites');
const encryptedArchived = await state.store.getItem('archived');
const encryptedTags = await state.store.getItem('tags');
if (encryptedFavorites) {
const decrypted = await CryptoUtil.decrypt(encryptedFavorites.data, encryptedFavorites.iv);
state.favorites = new Set(decrypted);
}
if (encryptedArchived) {
const decrypted = await CryptoUtil.decrypt(encryptedArchived.data, encryptedArchived.iv);
state.archived = new Set(decrypted);
}
if (encryptedTags) {
const decrypted = await CryptoUtil.decrypt(encryptedTags.data, encryptedTags.iv);
state.tags = new Map(decrypted);
}
} catch (error) {
console.error('Error loading encrypted data:', error);
showError('Failed to load saved data');
}
}
async function saveEncryptedData() {
try {
const favoritesEncrypted = await CryptoUtil.encrypt([...state.favorites]);
const archivedEncrypted = await CryptoUtil.encrypt([...state.archived]);
const tagsEncrypted = await CryptoUtil.encrypt([...state.tags]);
await state.store.setItem('favorites', favoritesEncrypted);
await state.store.setItem('archived', archivedEncrypted);
await state.store.setItem('tags', tagsEncrypted);
} catch (error) {
console.error('Error saving encrypted data:', error);
showError('Failed to save data');
}
}
async function loadVideoData() {
try {
if (typeof videoData !== 'undefined') {
console.log('Loading from videoData variable');
return videoData;
}
console.log('Loading from file');
const response = await fetch('./videoData2b.js');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const text = await response.text();
const startIndex = text.indexOf('[');
const endIndex = text.lastIndexOf(']') + 1;
const jsonData = text.substring(startIndex, endIndex);
return JSON.parse(jsonData);
} catch (error) {
console.error('Error loading video data:', error);
showError('Failed to load video data');
return [];
}
}
async function initializeData() {
try {
const videoData = await loadVideoData();
console.log('Loaded video data:', videoData);
const existingData = await state.store.getItem('projects');
if (!existingData && videoData) {
await state.store.setItem('projects', videoData);
}
populateCategories(videoData);
await loadFeed();
setupEventListeners();
} catch (error) {
console.error('Error initializing data:', error);
showError('Failed to initialize data');
}
}
function populateCategories(videos) {
const categoryFilter = document.getElementById('categoryFilter');
if (!categoryFilter || !videos.length) return;
const categories = new Set();
videos.forEach(video => {
if (video.category) categories.add(video.category);
});
categoryFilter.innerHTML = '<option value="all">All Categories</option>';
[...categories].sort().forEach(category => {
const option = document.createElement('option');
option.value = category;
option.textContent = category;
categoryFilter.appendChild(option);
});
}
function setupEventListeners() {
const searchInput = document.getElementById('searchInput');
const sortSelect = document.getElementById('sortSelect');
const categoryFilter = document.getElementById('categoryFilter');
if (searchInput) {
searchInput.addEventListener('input', debounce((e) => {
state.searchQuery = e.target.value;
loadFeed();
}, 300));
}
if (sortSelect) {
sortSelect.addEventListener('change', (e) => {
state.currentSort = e.target.value;
loadFeed();
});
}
if (categoryFilter) {
categoryFilter.addEventListener('change', (e) => {
state.currentFilter = e.target.value;
loadFeed();
});
}
}
function renderProjects(projects) {
const projectsList = document.getElementById('videoGrid');
if (!projectsList) return;
projectsList.innerHTML = projects
.filter(project => !state.archived.has(project.id))
.map(project => `
<div class="project-card bg-white rounded-lg shadow-md overflow-hidden">
<div class="aspect-w-16 aspect-h-9 bg-gray-100">
<img src="<span class="math-inline">\{project\.thumbnail\}"
alt\="</span>{project.title}"
class="w-full h-48 object-cover"
onerror="this.src='/placeholder-image.jpg'"
>
</div>
<div class="p-4">
<div class="flex justify-between items-start">
<h3 class="text-lg font-semibold text-gray-900"><span class="math-inline">\{project\.title\}</h3\>
<button onclick\="VideoApp\.toggleFavorite\('</span>{project.id}')"
class="text-yellow-500 hover:text-yellow-600">
<span class="math-inline">\{state\.favorites\.has\(project\.id\) ? '★' \: '☆'\}
</button\>
</div\>
<p class\="text\-gray\-600 mb\-4"\></span>{project.description.substring(0, 100)}...</p>
<div class="mb-2 flex flex-wrap gap-1">
${Array.from(state.tags.get(project.id) || [])
.map(tag => `
<span class="inline-block bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded">
${tag}
</span>
`).join('')}
</div>
<div class="mt-2 flex items-center justify-between text-sm text-gray-500">
<span>Rating: ${project.rating}/5</span>
<span>Category: <span class="math-inline">\{project\.category\}</span\>
</div\>
<div class\="mt\-3 grid grid\-cols\-3 gap\-2"\>
<button onclick\="VideoApp\.editVideo\('</span>{project.id}')"
class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 text-sm">
Edit
</button>
<button onclick="VideoApp.manageTags('<span class="math-inline">\{project\.id\}'\)"
class\="bg\-green\-600 text\-white py\-2 px\-4 rounded\-md hover\:bg\-green\-700 text\-sm"\>
Tags
</button\>
<button onclick\="VideoApp\.archiveVideo\('</span>{project.id}')"
class="bg-gray-600 text-white py-2 px-4 rounded-md hover:bg-gray-700 text-sm">
Archive
</button>
</div>
<button onclick="VideoApp.showProjectDetails(${JSON.stringify(project)})"
class="mt-3 w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">
View Details
</button>
</div>
</div>
`).join('');
}
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
function showError(message) {
const errorDiv = document.createElement('div');
errorDiv.className = 'fixed top-16 right-4 max-w-sm z-50 p-4 rounded-lg shadow-lg bg-red-100 text-red-800';
errorDiv.textContent = message;
document.body.appendChild(errorDiv);
setTimeout(() => errorDiv.remove(), 3000);
}
function toggleFavorite(projectId) {
if (state.favorites.has(projectId)) {
state.favorites.delete(projectId);
} else {
state.favorites.add(projectId);
}
saveEncryptedData();
loadFeed();
}
async function initialize() {
if (!state.initialized) {
await initializeStore();
await initializeData();
state.initialized = true;
}
}
async function loadFeed() {
showLoading();
try {
state.currentProjects = await state.store.getItem('projects') || [];
const now = Date.now();
if (state.currentProjects.length > 0 && (now - state.lastVideoLoad) > 60000) {
const newData = await loadVideoData();
if (newData.length > 0) {
state.currentProjects = newData;
await state.store.setItem('projects', newData);
state.lastVideoLoad = now;
}
}
const filteredProjects = filterProjects(state.currentProjects);
const sortedProjects = sortProjects(filteredProjects);
renderProjects(sortedProjects);
} catch (error) {
console.error('Error loading feed:', error);
showError('Failed to load videos');
} finally {
hideLoading();
}
}
function showLoading() {
const loader = document.getElementById('loader');
if (loader) {
loader.style.display = 'flex';
}
}
function hideLoading() {
const loader = document.getElementById('loader');
if (loader) {
loader.style.display = 'none';
}
}
function filterProjects(projects) {
return projects.filter(project => {
const matchesCategory = state.currentFilter === 'all' || project.category === state.currentFilter;
const matchesSearch = state.searchQuery === '' || project.title.toLowerCase().includes(state.searchQuery.toLowerCase());
return matchesCategory && matchesSearch;
});
}
function sortProjects(projects) {
switch (state.currentSort) {
case 'dateAsc':
return [...projects].sort((a, b) => new Date(a.date) - new Date(b.date));
case 'dateDesc':
return [...projects].sort((a, b) => new Date(b.date) - new Date(a.date));
case 'ratingAsc':
return [...projects].sort((a, b) => a.rating - b.rating);
case 'ratingDesc':
return [...projects].sort((a, b) => b.rating - a.rating);
default:
return projects;
}
}
function showProjectDetails(project) {
showModal(`
<div class="p-6">
<h2 class="text-2xl font-bold mb-4">${project.title}</h2>
<div class="aspect-w-16 aspect-h-9 mb-4">
<iframe src="${project.video}" frameborder="0" allowfullscreen class="w-full"></iframe>
</div>
<p class="text-gray-700">${project.description}</p>
<div class="mt-4 flex items-center justify-between text-sm text-gray-500">
<span>Rating: ${project.rating}/5</span>
<span>Category: ${project.category}</span>
</div>
<button onclick="VideoApp.playVideo('${project.video}')"
class="mt-3 w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">
Play Video
</button>
<button onclick="VideoApp.closeModal()"
class="mt-2 w-full bg-gray-200 text-gray-800 py-2 px-4 rounded-md hover:bg-gray-300">
Close
</button>
</div>
`);
}
function playVideo(videoUrl) {
window.open(videoUrl, '_blank');
}
function closeModal() {
const modal = document.getElementById('appModal');
if (modal) {
modal.style.display = 'none';
}
}
function handleLogin() {
console.log('handleLogin called');
showDashboard();
}
function handleLogout() {
console.log('handleLogout called');
showLogin();
}
function showLogin() {
console.log('showLogin called');
}
function showDashboard() {
console.log('showDashboard called');
}
return {
initialize,
handleLogin,
handleLogout,
showProjectDetails,
playVideo,
closeModal,
toggleFavorite,
isLoggedIn: () => !!localStorage.getItem('approVideoToken'),
getState: () => ({...state})
};
})();
window.VideoApp = VideoApp;
}
document.addEventListener('DOMContentLoaded', () => {
if (window.VideoApp) {
VideoApp.initialize().catch(error => {
console.error('Failed to initialize app:', error);
});
}
});
</script>
</body>
</html>