-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplate.html
More file actions
1286 lines (1097 loc) · 53.7 KB
/
plate.html
File metadata and controls
1286 lines (1097 loc) · 53.7 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
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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plateforme de diffusion de l'institut des sciences cognitives</title>
<meta name="description"
content="Plateforme de diffusion vidéo de l'Institut des Sciences Cognitives de l'UQAM. Explorez des conférences, cours et présentations sur la cognition, l'IA, les neurosciences et la philosophie de l'esprit.">
<meta name="keywords" content="ISC, UQAM, sciences cognitives, neurosciences, IA, philosophie, conférences, vidéos">
<meta property="og:title" content="Plateforme ISC - Institut des Sciences Cognitives UQAM">
<meta property="og:description"
content="Explorez des vidéos sur les sciences cognitives, l'IA et les neurosciences.">
<meta property="og:type" content="website">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--uqam-dark-blue: #003366;
--uqam-light-blue: #337ab7;
--uqam-grey: #f5f5f5;
--uqam-dark-grey: #cccccc;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--uqam-grey);
}
.header-bg {
background: linear-gradient(135deg, var(--uqam-dark-blue) 0%, #004488 100%);
}
.button-primary {
background-color: var(--uqam-light-blue);
color: white;
transition: all 0.3s ease;
}
.button-primary:hover {
background-color: #286090;
transform: translateY(-1px);
}
.button-secondary {
background-color: var(--uqam-dark-grey);
color: var(--uqam-dark-blue);
transition: all 0.3s ease;
}
.button-secondary:hover {
background-color: #b3b3b3;
}
.video-card {
background-color: white;
border: 1px solid #e0e0e0;
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.video-card:hover {
transform: translateY(-5px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
cursor: pointer;
}
.search-input {
border: 2px solid var(--uqam-dark-blue);
}
.search-input:focus {
border-color: var(--uqam-light-blue);
box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.25);
outline: none;
}
.video-player-container {
background-color: black;
}
.video-info {
background-color: white;
}
/* Boutons de partage */
.share-button {
padding: 10px 16px;
border-radius: 8px;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 0.875rem;
font-weight: 500;
transition: all 0.2s ease;
border: none;
cursor: pointer;
}
.share-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.share-facebook {
background-color: #1877F2;
color: white;
}
.share-twitter {
background-color: #1DA1F2;
color: white;
}
.share-linkedin {
background-color: #0A66C2;
color: white;
}
.share-whatsapp {
background-color: #25D366;
color: white;
}
.share-telegram {
background-color: #0088cc;
color: white;
}
.share-email {
background-color: #6c757d;
color: white;
}
.share-copy {
background-color: var(--uqam-dark-blue);
color: white;
}
/* Modals */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.modal-overlay.show {
opacity: 1;
visibility: visible;
}
.modal-content {
background-color: white;
padding: 28px;
border-radius: 12px;
text-align: left;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
width: 90%;
max-width: 550px;
transform: scale(0.9);
transition: all 0.3s ease;
}
.modal-overlay.show .modal-content {
transform: scale(1);
}
.modal-content h3 {
color: var(--uqam-dark-blue);
margin-bottom: 20px;
font-size: 1.25rem;
font-weight: 700;
}
.modal-content label {
display: block;
margin-bottom: 6px;
font-weight: 600;
color: #333;
font-size: 0.875rem;
}
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content textarea,
.modal-content select {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 8px;
margin-bottom: 16px;
font-size: 0.95rem;
transition: border-color 0.2s ease;
}
.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
border-color: var(--uqam-light-blue);
outline: none;
box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.15);
}
.modal-content textarea {
min-height: 100px;
resize: vertical;
}
.modal-content input:disabled,
.modal-content textarea:disabled {
background-color: #f9f9f9;
cursor: not-allowed;
}
/* Tags de mots-clés */
.keyword-tag {
background-color: #e8f4fc;
color: var(--uqam-dark-blue);
padding: 4px 10px;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 600;
margin-right: 4px;
margin-bottom: 4px;
display: inline-block;
}
.keyword-tag-detail {
background-color: var(--uqam-light-blue);
color: white;
padding: 6px 14px;
border-radius: 8px;
font-size: 0.875rem;
font-weight: 600;
margin-right: 8px;
margin-bottom: 8px;
display: inline-block;
}
/* Container miniature */
.video-thumbnail-container {
width: 100%;
height: 12rem;
background-color: #e0e0e0;
position: relative;
overflow: hidden;
}
.video-thumbnail-container img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s ease;
}
.video-card:hover .video-thumbnail-container img {
transform: scale(1.05);
}
/* Indicateur de thème */
.theme-badge {
position: absolute;
top: 8px;
left: 8px;
padding: 4px 10px;
border-radius: 6px;
font-size: 0.7rem;
font-weight: 600;
color: white;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
/* Loading spinner */
.loading-spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid #f3f3f3;
border-top: 2px solid var(--uqam-light-blue);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Toast notifications */
.toast {
position: fixed;
bottom: 20px;
right: 20px;
padding: 14px 24px;
border-radius: 10px;
color: white;
font-weight: 500;
z-index: 2000;
transform: translateX(120%);
transition: transform 0.3s ease;
}
.toast.show {
transform: translateX(0);
}
.toast-success {
background-color: #10B981;
}
.toast-error {
background-color: #EF4444;
}
.toast-info {
background-color: var(--uqam-light-blue);
}
/* Formatage des nombres de vues */
.view-count {
color: #666;
font-size: 0.875rem;
}
</style>
</head>
<body class="bg-gray-100 text-gray-800">
<!-- Toast Container -->
<div id="toastContainer"></div>
<header class="header-bg text-white p-4 shadow-lg">
<div class="container mx-auto flex flex-wrap items-center justify-between">
<a href="#" onclick="showHomePage(); return false;"
class="text-xl sm:text-2xl font-bold hover:opacity-90 transition-opacity">
<i class="fas fa-brain mr-2"></i>Plateforme de diffusion ISC
</a>
<div
class="w-full md:w-auto mt-4 md:mt-0 flex flex-col md:flex-row items-center md:ml-auto space-y-2 md:space-y-0 md:space-x-2">
<!-- Recherche -->
<div class="relative w-full md:w-auto">
<input type="search" id="searchInput"
class="search-input w-full md:w-64 lg:w-80 p-2 pl-10 rounded-md text-gray-800 focus:outline-none"
placeholder="Rechercher...">
<span class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"><i
class="fas fa-search"></i></span>
</div>
<!-- Filtre par mot-clé -->
<div class="relative w-full md:w-auto">
<select id="keywordFilter"
class="search-input w-full md:w-48 p-2 pr-10 rounded-md text-gray-800 focus:outline-none appearance-none">
<option value="">Tous les mots-clés</option>
</select>
<span
class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 pointer-events-none"><i
class="fas fa-chevron-down"></i></span>
</div>
<!-- Filtre par thème -->
<div class="relative w-full md:w-auto">
<select id="themeFilter"
class="search-input w-full md:w-48 p-2 pr-10 rounded-md text-gray-800 focus:outline-none appearance-none">
<option value="">Tous les thèmes</option>
</select>
<span
class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 pointer-events-none"><i
class="fas fa-chevron-down"></i></span>
</div>
<!-- Section Admin -->
<div id="adminControlsContainer"
class="flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-2 w-full md:w-auto">
<button id="adminLoginButton"
class="button-secondary font-semibold py-2 px-4 rounded-md w-full md:w-auto">
<i class="fas fa-lock mr-1"></i>Accès Admin
</button>
<button id="addYoutubeVideoBtn"
class="button-primary font-semibold py-2 px-4 rounded-md w-full md:w-auto hidden">
<i class="fab fa-youtube mr-2"></i>Ajouter Vidéo
</button>
</div>
</div>
</div>
</header>
<main id="mainContent" class="container mx-auto p-4">
<!-- Page grille de vidéos -->
<section id="videoGridPage">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-semibold text-gray-700">
<i class="fas fa-play-circle mr-2 text-[var(--uqam-light-blue)]"></i>Vidéos disponibles
</h2>
<span id="videoCount" class="text-gray-500"></span>
</div>
<!-- Loader -->
<div id="gridLoader" class="text-center py-12 hidden">
<div class="loading-spinner mx-auto mb-4" style="width: 40px; height: 40px;"></div>
<p class="text-gray-500">Chargement des vidéos...</p>
</div>
<div id="videoGrid" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Les cartes de vidéos seront insérées ici par JS -->
</div>
<div class="text-center mt-8">
<button id="viewMoreButton" class="button-primary font-semibold py-2 px-6 rounded-md hidden">
Voir Toutes les Vidéos
</button>
</div>
</section>
<!-- Page détail vidéo -->
<section id="videoPlayerPage" class="hidden">
<div class="max-w-4xl mx-auto">
<button onclick="showHomePage(); return false;" class="button-primary mb-4 py-2 px-4 rounded-md">
<i class="fas fa-arrow-left mr-2"></i>Retour
</button>
<!-- Lecteur Vidéo (iframe YouTube) -->
<div class="video-player-container rounded-lg shadow-xl overflow-hidden">
<iframe id="mainVideoPlayerIframe" width="100%" class="aspect-video" src="" title="Lecteur vidéo"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>
<!-- Informations sur la vidéo -->
<div class="video-info p-6 mt-4 rounded-lg shadow-lg">
<div class="flex items-start justify-between mb-4">
<div>
<h2 id="videoTitleElem" class="text-2xl md:text-3xl font-bold text-gray-800"></h2>
<div class="flex flex-wrap items-center gap-3 mt-2 text-gray-600">
<span id="videoUploader"><i class="fas fa-user mr-1"></i><span
class="font-semibold"></span></span>
<span id="videoViews"><i class="fas fa-eye mr-1"></i><span
class="font-semibold"></span></span>
<span id="videoTheme"
class="px-3 py-1 rounded-full text-sm font-semibold text-white"></span>
</div>
</div>
<!-- Boutons Admin (visible seulement si admin) -->
<div id="videoDetailAdminBtns" class="hidden flex-shrink-0 space-x-2">
<button id="editCurrentVideoBtn" class="button-secondary py-2 px-3 rounded-md text-sm">
<i class="fas fa-edit"></i>
</button>
<button id="deleteCurrentVideoBtn"
class="bg-red-500 hover:bg-red-600 text-white py-2 px-3 rounded-md text-sm">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
<!-- Résumé IA -->
<div class="mb-6">
<h3
class="text-xl font-bold mb-3 text-[var(--uqam-dark-blue)] border-b-2 border-[var(--uqam-light-blue)] pb-1">
<i class="fas fa-robot mr-2"></i>Résumé (généré par IA)
</h3>
<p id="videoAiSummary" class="text-gray-700 whitespace-pre-line leading-relaxed"></p>
</div>
<!-- Mots-clés -->
<div class="mb-6">
<h3
class="text-xl font-bold mb-3 text-[var(--uqam-dark-blue)] border-b-2 border-[var(--uqam-light-blue)] pb-1">
<i class="fas fa-tags mr-2"></i>Mots-clés
</h3>
<div id="videoKeywordsContainer" class="flex flex-wrap"></div>
</div>
<!-- Annotation Admin -->
<div class="mb-6">
<h3
class="text-xl font-bold mb-3 text-[var(--uqam-dark-blue)] border-b-2 border-[var(--uqam-light-blue)] pb-1">
<i class="fas fa-comment-dots mr-2"></i>Annotation de l'administrateur
</h3>
<p id="videoAdminAnnotation"
class="text-gray-700 whitespace-pre-line bg-blue-50 p-4 border-l-4 border-blue-400 rounded-r-md">
</p>
</div>
<!-- Description Originale -->
<details class="mb-6">
<summary class="cursor-pointer text-gray-600 hover:text-black font-medium">
<i class="fab fa-youtube mr-1"></i>Voir la description YouTube originale
</summary>
<p id="videoOriginalDescription"
class="text-gray-600 mt-2 p-3 bg-gray-50 border rounded-md whitespace-pre-line"></p>
</details>
<!-- Boutons de Partage Étendus -->
<div class="share-buttons border-t pt-5">
<h3 class="text-lg font-semibold mb-3 text-gray-700">
<i class="fas fa-share-alt mr-2"></i>Partager cette vidéo
</h3>
<div class="flex flex-wrap gap-2">
<a href="#" id="shareFacebook" target="_blank" class="share-button share-facebook">
<i class="fab fa-facebook-f"></i> Facebook
</a>
<a href="#" id="shareTwitter" target="_blank" class="share-button share-twitter">
<i class="fab fa-x-twitter"></i> X (Twitter)
</a>
<a href="#" id="shareLinkedIn" target="_blank" class="share-button share-linkedin">
<i class="fab fa-linkedin-in"></i> LinkedIn
</a>
<a href="#" id="shareWhatsApp" target="_blank" class="share-button share-whatsapp">
<i class="fab fa-whatsapp"></i> WhatsApp
</a>
<a href="#" id="shareTelegram" target="_blank" class="share-button share-telegram">
<i class="fab fa-telegram-plane"></i> Telegram
</a>
<a href="#" id="shareEmail" class="share-button share-email">
<i class="fas fa-envelope"></i> Email
</a>
<button id="copyLinkButton" class="share-button share-copy">
<i class="fas fa-link"></i> Copier le lien
</button>
</div>
</div>
</div>
</div>
</section>
</main>
<footer class="text-center p-4 mt-8 text-gray-600 border-t border-gray-300 bg-white">
<p>© 2025 Institut des Sciences Cognitives - UQAM</p>
<p class="text-sm mt-1">Développement par l'équipe ISC</p>
</footer>
<!-- Modal de connexion Admin -->
<div id="adminLoginModal" class="modal-overlay">
<div class="modal-content">
<h3><i class="fas fa-lock mr-2"></i>Accès Administrateur</h3>
<label for="adminPassword">Mot de passe :</label>
<input type="password" id="adminPassword" placeholder="Entrez le mot de passe admin">
<div class="flex justify-end space-x-2 mt-4">
<button id="closeAdminLoginModal" class="button-secondary py-2 px-4 rounded-md">Annuler</button>
<button id="submitAdminLogin" class="button-primary py-2 px-4 rounded-md">
<i class="fas fa-sign-in-alt mr-1"></i>Se Connecter
</button>
</div>
</div>
</div>
<!-- Modal pour Ajouter/Modifier une vidéo YouTube -->
<div id="addYoutubeVideoModal" class="modal-overlay">
<div class="modal-content max-h-[90vh] overflow-y-auto">
<h3 id="videoModalTitle"><i class="fab fa-youtube mr-2"></i>Ajouter une Vidéo YouTube</h3>
<label for="youtubeVideoUrl">URL de la vidéo YouTube :</label>
<input type="text" id="youtubeVideoUrl" placeholder="https://www.youtube.com/watch?v=VIDEO_ID">
<button id="fetchYoutubeInfoBtn" class="button-secondary py-2 px-4 rounded-md mb-3 w-full">
<i class="fas fa-download mr-2"></i>Récupérer Infos YouTube
</button>
<!-- Aperçu des informations récupérées -->
<div id="youtubeInfoPreview" class="mb-3 hidden border p-4 rounded-md bg-gray-50">
<h4 class="font-semibold text-lg text-[var(--uqam-dark-blue)] mb-3">
<i class="fas fa-info-circle mr-1"></i>Informations Récupérées
</h4>
<img id="previewThumbnail" src="" alt="Miniature" class="w-40 h-auto my-2 rounded shadow">
<label for="previewTitle">Titre :</label>
<input type="text" id="previewTitle" placeholder="Titre de la vidéo">
<label for="previewChannel">Chaîne :</label>
<input type="text" id="previewChannel" placeholder="Nom de la chaîne">
<label for="previewAiSummary">Résumé :</label>
<textarea id="previewAiSummary" rows="3" placeholder="Résumé de la vidéo..."></textarea>
<label for="previewKeywords">Mots-clés (séparés par virgule) :</label>
<input type="text" id="previewKeywords" placeholder="IA, Cognition, Neurosciences">
<label for="previewTheme">Thématique :</label>
<select id="previewTheme">
<option value="">-- Sélectionner --</option>
</select>
</div>
<!-- Annotation personnelle admin -->
<label for="adminCustomDescription">Annotation personnelle (visible sur la page de détail) :</label>
<textarea id="adminCustomDescription"
placeholder="Ajoutez votre analyse, notes ou commentaires..."></textarea>
<input type="hidden" id="editingVideoId">
<div class="flex justify-end space-x-2 mt-4">
<button id="closeAddYoutubeVideoModal" class="button-secondary py-2 px-4 rounded-md">Annuler</button>
<button id="saveYoutubeVideoBtn" class="button-primary py-2 px-4 rounded-md">
<i class="fas fa-save mr-1"></i>Sauvegarder
</button>
</div>
</div>
</div>
<!-- Modal de confirmation de suppression -->
<div id="deleteConfirmModal" class="modal-overlay">
<div class="modal-content">
<h3 class="text-red-600"><i class="fas fa-exclamation-triangle mr-2"></i>Confirmer la suppression</h3>
<p class="text-gray-700 mb-4">Êtes-vous sûr de vouloir supprimer cette vidéo ? Cette action est
irréversible.</p>
<div class="flex justify-end space-x-2 mt-4">
<button id="cancelDeleteBtn" class="button-secondary py-2 px-4 rounded-md">Annuler</button>
<button id="confirmDeleteBtn" class="bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-md">
<i class="fas fa-trash mr-1"></i>Supprimer
</button>
</div>
</div>
</div>
<script>
// ============================================
// CONFIGURATION
// ============================================
// URL de l'API backend (changer selon l'environnement)
const API_BASE_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
? '' // En local, utilise le même serveur
: 'https://isc-video-platform.onrender.com'; // En production
// ============================================
// ÉTAT GLOBAL
// ============================================
let isAdmin = false;
let adminToken = null;
let currentVideos = [];
let themes = [];
let currentVideoId = null;
const initialDisplayCount = 6;
let showingAllVideos = false;
// ============================================
// ÉLÉMENTS DOM
// ============================================
const videoGrid = document.getElementById('videoGrid');
const gridLoader = document.getElementById('gridLoader');
const searchInput = document.getElementById('searchInput');
const keywordFilter = document.getElementById('keywordFilter');
const themeFilter = document.getElementById('themeFilter');
const videoGridPage = document.getElementById('videoGridPage');
const videoPlayerPage = document.getElementById('videoPlayerPage');
const mainVideoPlayerIframe = document.getElementById('mainVideoPlayerIframe');
const videoTitleElem = document.getElementById('videoTitleElem');
const videoUploaderElem = document.getElementById('videoUploader').querySelector('span');
const videoViewsElem = document.getElementById('videoViews').querySelector('span');
const videoThemeElem = document.getElementById('videoTheme');
const videoAiSummaryElem = document.getElementById('videoAiSummary');
const videoKeywordsContainerElem = document.getElementById('videoKeywordsContainer');
const videoAdminAnnotationElem = document.getElementById('videoAdminAnnotation');
const videoOriginalDescriptionElem = document.getElementById('videoOriginalDescription');
const videoDetailAdminBtns = document.getElementById('videoDetailAdminBtns');
const adminLoginButton = document.getElementById('adminLoginButton');
const addYoutubeVideoBtn = document.getElementById('addYoutubeVideoBtn');
const viewMoreButton = document.getElementById('viewMoreButton');
const videoCountElem = document.getElementById('videoCount');
// ============================================
// UTILITAIRES
// ============================================
function showModal(modalElement) {
modalElement.classList.add('show');
}
function hideModal(modalElement) {
modalElement.classList.remove('show');
}
function showToast(message, type = 'info') {
const container = document.getElementById('toastContainer');
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
toast.innerHTML = `<i class="fas fa-${type === 'success' ? 'check-circle' : type === 'error' ? 'times-circle' : 'info-circle'} mr-2"></i>${message}`;
container.appendChild(toast);
setTimeout(() => toast.classList.add('show'), 10);
setTimeout(() => {
toast.classList.remove('show');
setTimeout(() => toast.remove(), 300);
}, 3500);
}
function formatViews(views) {
if (!views || views === 0) return 'N/A';
if (views >= 1000000) return (views / 1000000).toFixed(1) + 'M vues';
if (views >= 1000) return (views / 1000).toFixed(0) + 'K vues';
return views + ' vues';
}
function getYouTubeVideoId(url) {
const patterns = [
/(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]{11})/,
/(?:https?:\/\/)?youtu\.be\/([a-zA-Z0-9_-]{11})/,
/(?:https?:\/\/)?(?:www\.)?youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/,
/(?:https?:\/\/)?(?:www\.)?youtube\.com\/v\/([a-zA-Z0-9_-]{11})/,
/(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/
];
for (const pattern of patterns) {
const match = url.match(pattern);
if (match && match[1]) return match[1];
}
return null;
}
async function apiRequest(endpoint, options = {}) {
const url = API_BASE_URL + endpoint;
const headers = { 'Content-Type': 'application/json', ...options.headers };
if (adminToken) {
headers['Authorization'] = `Bearer ${adminToken}`;
}
try {
const response = await fetch(url, { ...options, headers });
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || 'Erreur serveur');
}
return data;
} catch (err) {
console.error('API Error:', err);
throw err;
}
}
// ============================================
// CHARGEMENT DES DONNÉES
// ============================================
async function loadVideos() {
gridLoader.classList.remove('hidden');
videoGrid.innerHTML = '';
try {
const params = new URLSearchParams();
if (searchInput.value) params.set('search', searchInput.value);
if (keywordFilter.value) params.set('keyword', keywordFilter.value);
if (themeFilter.value) params.set('theme', themeFilter.value);
const queryString = params.toString() ? '?' + params.toString() : '';
currentVideos = await apiRequest('/api/videos' + queryString);
displayVideos(currentVideos);
} catch (err) {
videoGrid.innerHTML = `<p class="col-span-full text-center text-red-500">
<i class="fas fa-exclamation-circle mr-2"></i>Erreur de chargement: ${err.message}
</p>`;
showToast('Erreur de chargement des vidéos', 'error');
} finally {
gridLoader.classList.add('hidden');
}
}
async function loadThemes() {
try {
themes = await apiRequest('/api/themes');
// Mettre à jour le filtre de thèmes
themeFilter.innerHTML = '<option value="">Tous les thèmes</option>';
themes.forEach(theme => {
themeFilter.innerHTML += `<option value="${theme.id}">${theme.name}</option>`;
});
// Mettre à jour le select du modal
const previewTheme = document.getElementById('previewTheme');
previewTheme.innerHTML = '<option value="">-- Sélectionner --</option>';
themes.forEach(theme => {
previewTheme.innerHTML += `<option value="${theme.id}">${theme.name}</option>`;
});
} catch (err) {
console.error('Erreur chargement thèmes:', err);
}
}
async function loadKeywords() {
try {
const keywords = await apiRequest('/api/keywords');
keywordFilter.innerHTML = '<option value="">Tous les mots-clés</option>';
keywords.forEach(kw => {
keywordFilter.innerHTML += `<option value="${kw}">${kw}</option>`;
});
} catch (err) {
console.error('Erreur chargement mots-clés:', err);
}
}
// ============================================
// AFFICHAGE DES VIDÉOS
// ============================================
function displayVideos(videosToDisplay) {
videoGrid.innerHTML = '';
const videosToShow = showingAllVideos ? videosToDisplay : videosToDisplay.slice(0, initialDisplayCount);
videoCountElem.textContent = `${videosToDisplay.length} vidéo${videosToDisplay.length > 1 ? 's' : ''}`;
if (videosToShow.length === 0) {
videoGrid.innerHTML = '<p class="col-span-full text-center text-gray-500 py-8"><i class="fas fa-video-slash mr-2"></i>Aucune vidéo ne correspond à vos critères.</p>';
viewMoreButton.classList.add('hidden');
return;
}
videosToShow.forEach(video => {
const card = document.createElement('div');
card.className = 'video-card rounded-lg shadow-lg overflow-hidden flex flex-col';
const thumbnailUrl = video.thumbnailUrl ||
`https://img.youtube.com/vi/${video.youtubeVideoId}/hqdefault.jpg`;
const keywordsHtml = (video.keywords || []).slice(0, 4).map(kw =>
`<span class="keyword-tag">${kw}</span>`
).join('');
const themeHtml = video.theme ?
`<span class="theme-badge" style="background-color: ${video.theme.color}">${video.theme.name}</span>` : '';
card.innerHTML = `
<div class="video-thumbnail-container">
${themeHtml}
<img src="${thumbnailUrl}" alt="${video.title}" loading="lazy" onerror="this.src='https://placehold.co/400x225/e0e0e0/999?text=Miniature'">
</div>
<div class="p-4 flex-grow flex flex-col">
<h3 class="font-semibold text-lg mb-1 line-clamp-2" title="${video.title}">${video.title}</h3>
<p class="text-gray-600 text-sm mb-2">${video.uploader || 'ISC'} • ${formatViews(video.views)}</p>
<p class="text-gray-700 text-sm mb-3 line-clamp-2" title="${video.aiSummary || ''}">
${video.aiSummary || 'Aucun résumé disponible.'}
</p>
<div class="mb-3 flex flex-wrap">${keywordsHtml}</div>
<div class="mt-auto pt-2 flex items-center admin-controls ${isAdmin ? '' : 'hidden'}">
<button class="edit-video-btn text-xs text-blue-600 hover:text-blue-800 mr-3" data-id="${video.id}">
<i class="fas fa-edit mr-1"></i>Modifier
</button>
<button class="delete-video-btn text-xs text-red-600 hover:text-red-800" data-id="${video.id}">
<i class="fas fa-trash mr-1"></i>Supprimer
</button>
</div>
</div>
`;
card.addEventListener('click', (e) => {
if (!e.target.closest('.edit-video-btn') && !e.target.closest('.delete-video-btn')) {
showVideoPlayer(video);
}
});
if (isAdmin) {
card.querySelector('.edit-video-btn').addEventListener('click', (e) => {
e.stopPropagation();
openEditVideoModal(video.id);
});
card.querySelector('.delete-video-btn').addEventListener('click', (e) => {
e.stopPropagation();
confirmDeleteVideo(video.id);
});
}
videoGrid.appendChild(card);
});
if (videosToDisplay.length > initialDisplayCount) {
viewMoreButton.classList.remove('hidden');
viewMoreButton.textContent = showingAllVideos
? 'Voir Moins'
: `Voir Toutes les Vidéos (${videosToDisplay.length})`;
} else {
viewMoreButton.classList.add('hidden');
}
}
viewMoreButton.addEventListener('click', () => {
showingAllVideos = !showingAllVideos;
displayVideos(currentVideos);
});
// ============================================
// PAGE DE DÉTAIL VIDÉO
// ============================================
function showVideoPlayer(video) {
currentVideoId = video.id;
videoGridPage.classList.add('hidden');
videoPlayerPage.classList.remove('hidden');
if (video.youtubeVideoId) {
mainVideoPlayerIframe.src = `https://www.youtube.com/embed/${video.youtubeVideoId}?autoplay=1&rel=0`;
} else {
mainVideoPlayerIframe.src = '';
}
videoTitleElem.textContent = video.title;
videoUploaderElem.textContent = video.uploader || 'ISC';
videoViewsElem.textContent = formatViews(video.views);
if (video.theme) {
videoThemeElem.textContent = video.theme.name;
videoThemeElem.style.backgroundColor = video.theme.color;
videoThemeElem.classList.remove('hidden');
} else {
videoThemeElem.classList.add('hidden');
}
videoAiSummaryElem.textContent = video.aiSummary || 'Aucun résumé généré disponible.';
videoAdminAnnotationElem.textContent = video.adminDescription || 'Aucune annotation de l\'administrateur.';
videoOriginalDescriptionElem.textContent = video.originalDescription || 'Aucune description originale disponible.';
videoKeywordsContainerElem.innerHTML = '';
if (video.keywords && video.keywords.length > 0) {
video.keywords.forEach(kw => {
videoKeywordsContainerElem.innerHTML += `<span class="keyword-tag-detail">${kw}</span>`;
});
} else {
videoKeywordsContainerElem.innerHTML = '<p class="text-gray-500">Aucun mot-clé.</p>';
}
// Boutons admin
videoDetailAdminBtns.classList.toggle('hidden', !isAdmin);
// Mise à jour des boutons de partage
const pageUrl = window.location.origin + window.location.pathname + '#video=' + video.id;
const shareTitle = encodeURIComponent(video.title);
const shareText = encodeURIComponent(`Regardez cette vidéo: ${video.title}`);
document.getElementById('shareFacebook').href = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(pageUrl)}`;
document.getElementById('shareTwitter').href = `https://twitter.com/intent/tweet?url=${encodeURIComponent(pageUrl)}&text=${shareText}`;
document.getElementById('shareLinkedIn').href = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(pageUrl)}`;
document.getElementById('shareWhatsApp').href = `https://wa.me/?text=${shareText}%20${encodeURIComponent(pageUrl)}`;
document.getElementById('shareTelegram').href = `https://t.me/share/url?url=${encodeURIComponent(pageUrl)}&text=${shareText}`;
document.getElementById('shareEmail').href = `mailto:?subject=${shareTitle}&body=${shareText}%0A%0A${encodeURIComponent(pageUrl)}`;
document.getElementById('copyLinkButton').onclick = () => {
navigator.clipboard.writeText(pageUrl).then(() => {
showToast('Lien copié dans le presse-papiers!', 'success');
}).catch(() => {
// Fallback pour navigateurs anciens
const tempInput = document.createElement('input');
tempInput.value = pageUrl;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
showToast('Lien copié!', 'success');
});
};
window.scrollTo(0, 0);
window.location.hash = 'video=' + video.id;
}
function showHomePage() {
videoPlayerPage.classList.add('hidden');
videoGridPage.classList.remove('hidden');
mainVideoPlayerIframe.src = '';
currentVideoId = null;
window.location.hash = '';
}
// Boutons admin sur page détail
document.getElementById('editCurrentVideoBtn').addEventListener('click', () => {
if (currentVideoId) openEditVideoModal(currentVideoId);
});
document.getElementById('deleteCurrentVideoBtn').addEventListener('click', () => {
if (currentVideoId) confirmDeleteVideo(currentVideoId);
});
// ============================================
// AUTHENTIFICATION ADMIN
// ============================================