Spaces:
Running
Running
Update scripts/app.js
Browse files- scripts/app.js +1019 -985
scripts/app.js
CHANGED
@@ -1,986 +1,1020 @@
|
|
1 |
-
<script>
|
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 |
-
sendBtn.
|
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 |
-
rankTab.classList.remove('active');
|
326 |
-
rankTab.classList.add('inactive');
|
327 |
-
recordSection.classList.
|
328 |
-
editSection.classList.add('hidden');
|
329 |
-
shareSection.classList.
|
330 |
-
rankSection.classList.add('hidden');
|
331 |
-
});
|
332 |
-
|
333 |
-
|
334 |
-
if (
|
335 |
-
showNotification("No
|
336 |
-
return;
|
337 |
-
}
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
recordTab.classList.remove('active');
|
342 |
-
recordTab.classList.add('inactive');
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
recordSection.classList.add('hidden');
|
348 |
-
editSection.classList.
|
349 |
-
shareSection.classList.add('hidden');
|
350 |
-
rankSection.classList.
|
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 |
-
const
|
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 |
-
// Scroll to bottom
|
455 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
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 |
-
if (
|
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 |
-
const
|
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 |
-
<i class="fas fa-video"></i>
|
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 |
</script>
|
|
|
1 |
+
<script>
|
2 |
+
// scripts/app.js
|
3 |
+
|
4 |
+
import { initUI } from './ui.js';
|
5 |
+
import { initChat } from './chat.js';
|
6 |
+
import { initVideo } from './video.js';
|
7 |
+
|
8 |
+
document.addEventListener('DOMContentLoaded', () => {
|
9 |
+
// To handle dependencies between modules without a complex event system,
|
10 |
+
// we can expose some functions globally. This is a pragmatic approach for this stage.
|
11 |
+
window.showNotification = (title, message) => {
|
12 |
+
// A simplified version for video.js to call
|
13 |
+
const notification = document.getElementById('notification');
|
14 |
+
document.getElementById('notification-title').textContent = title;
|
15 |
+
document.getElementById('notification-message').textContent = message;
|
16 |
+
notification.classList.remove('hidden');
|
17 |
+
notification.classList.add('show');
|
18 |
+
setTimeout(() => notification.classList.remove('show'), 3000);
|
19 |
+
};
|
20 |
+
|
21 |
+
window.loadRecommendations = (filter) => {
|
22 |
+
// A simplified version for chat.js to call
|
23 |
+
// In a real app, ui.js would export loadRecommendations for chat.js to import.
|
24 |
+
const container = document.getElementById('recommendations-container');
|
25 |
+
// ... Add logic to load recommendations based on filter
|
26 |
+
};
|
27 |
+
|
28 |
+
|
29 |
+
// Initialize all modules
|
30 |
+
initUI();
|
31 |
+
initChat();
|
32 |
+
initVideo();
|
33 |
+
|
34 |
+
console.log("StreamAI application initialized.");
|
35 |
+
});
|
36 |
+
// Configuration for Cloudflare Workers AI
|
37 |
+
const AI_CONFIG = {
|
38 |
+
accountId: 'oFD0IMs0aV8eKMMMdTEF2zRQmtzvKMH43LX5ZWUJ',
|
39 |
+
gatewayId: 'streamai_gateway',
|
40 |
+
apiToken: 'masked_for_security', // In a real app, this would be handled server-side
|
41 |
+
model: '@cf/meta/llama-2-7b-chat-int8'
|
42 |
+
};
|
43 |
+
|
44 |
+
|
45 |
+
// Sample streaming data with SMPlus VHX added to the top
|
46 |
+
const streamingData = [
|
47 |
+
{
|
48 |
+
title: "SMPlus Exclusive Series",
|
49 |
+
type: "TV Series",
|
50 |
+
genre: "Drama, Action",
|
51 |
+
platform: "SMPlus VHX",
|
52 |
+
rating: "4.9",
|
53 |
+
year: "2023",
|
54 |
+
description: "An exclusive action-packed drama series only available on SMPlus VHX.",
|
55 |
+
broadcastTime: "2023-12-15T20:00:00"
|
56 |
+
},
|
57 |
+
{
|
58 |
+
title: "The Grand Adventure",
|
59 |
+
type: "Movie",
|
60 |
+
genre: "Adventure, Comedy",
|
61 |
+
platform: "Netflix",
|
62 |
+
rating: "4.8",
|
63 |
+
year: "2022",
|
64 |
+
description: "A hilarious journey across continents with unexpected twists.",
|
65 |
+
broadcastTime: "2023-12-10T19:30:00"
|
66 |
+
},
|
67 |
+
{
|
68 |
+
title: "Dark Secrets",
|
69 |
+
type: "TV Series",
|
70 |
+
genre: "Drama, Thriller",
|
71 |
+
platform: "HBO Max",
|
72 |
+
rating: "4.7",
|
73 |
+
year: "2021",
|
74 |
+
description: "A small town's dark past resurfaces with shocking revelations.",
|
75 |
+
broadcastTime: "2023-12-12T21:00:00"
|
76 |
+
},
|
77 |
+
{
|
78 |
+
title: "Space Explorers",
|
79 |
+
type: "Documentary",
|
80 |
+
genre: "Science, Space",
|
81 |
+
platform: "Disney+",
|
82 |
+
rating: "4.9",
|
83 |
+
year: "2023",
|
84 |
+
description: "The latest discoveries from the frontiers of space exploration.",
|
85 |
+
broadcastTime: "2023-12-14T18:00:00"
|
86 |
+
},
|
87 |
+
{
|
88 |
+
title: "Romantic Getaway",
|
89 |
+
type: "Movie",
|
90 |
+
genre: "Romance, Comedy",
|
91 |
+
platform: "Amazon Prime",
|
92 |
+
rating: "4.5",
|
93 |
+
year: "2021",
|
94 |
+
description: "Two strangers find love during an unexpected vacation.",
|
95 |
+
broadcastTime: "2023-12-16T20:30:00"
|
96 |
+
},
|
97 |
+
{
|
98 |
+
title: "Tech Today",
|
99 |
+
type: "News Show",
|
100 |
+
genre: "Technology, News",
|
101 |
+
platform: "SMPlus VHX",
|
102 |
+
rating: "4.6",
|
103 |
+
year: "2023",
|
104 |
+
description: "Daily tech news and gadget reviews from around the world.",
|
105 |
+
broadcastTime: "2023-12-17T09:00:00"
|
106 |
+
},
|
107 |
+
{
|
108 |
+
title: "Cooking Masters",
|
109 |
+
type: "Reality Show",
|
110 |
+
genre: "Food, Competition",
|
111 |
+
platform: "Netflix",
|
112 |
+
rating: "4.7",
|
113 |
+
year: "2023",
|
114 |
+
description: "Top chefs compete in intense culinary challenges.",
|
115 |
+
broadcastTime: "2023-12-18T20:00:00"
|
116 |
+
},
|
117 |
+
{
|
118 |
+
title: "History Unearthed",
|
119 |
+
type: "Documentary",
|
120 |
+
genre: "History, Education",
|
121 |
+
platform: "HBO Max",
|
122 |
+
rating: "4.8",
|
123 |
+
year: "2023",
|
124 |
+
description: "Fascinating historical discoveries and their modern implications.",
|
125 |
+
broadcastTime: "2023-12-19T21:00:00"
|
126 |
+
}
|
127 |
+
];
|
128 |
+
// Sample RSS feed data
|
129 |
+
const rssFeedData = {
|
130 |
+
all: [
|
131 |
+
{
|
132 |
+
title: "New Episode: SMPlus Exclusive Series",
|
133 |
+
source: "SMPlus VHX",
|
134 |
+
time: "2 hours ago",
|
135 |
+
excerpt: "The latest episode of our exclusive series is now streaming with intense action scenes.",
|
136 |
+
category: "personalized"
|
137 |
+
},
|
138 |
+
{
|
139 |
+
title: "Trending: The Grand Adventure hits #1",
|
140 |
+
source: "Netflix",
|
141 |
+
time: "5 hours ago",
|
142 |
+
excerpt: "The comedy adventure movie is now the most-watched title on Netflix this week.",
|
143 |
+
category: "trending"
|
144 |
+
},
|
145 |
+
{
|
146 |
+
title: "Breaking: New streaming partnership announced",
|
147 |
+
source: "Streaming News",
|
148 |
+
time: "1 day ago",
|
149 |
+
excerpt: "Major platforms announce new content sharing agreement starting next month.",
|
150 |
+
category: "news"
|
151 |
+
},
|
152 |
+
{
|
153 |
+
title: "Recommended for you: Space Explorers",
|
154 |
+
source: "Disney+",
|
155 |
+
time: "1 day ago",
|
156 |
+
excerpt: "Based on your interest in science documentaries, we recommend this new series.",
|
157 |
+
category: "personalized"
|
158 |
+
},
|
159 |
+
{
|
160 |
+
title: "Upcoming: Romantic Getaway special event",
|
161 |
+
source: "Amazon Prime",
|
162 |
+
time: "2 days ago",
|
163 |
+
excerpt: "Join the cast for a live Q&A before the movie premiere this weekend.",
|
164 |
+
category: "trending"
|
165 |
+
}
|
166 |
+
],
|
167 |
+
news: [
|
168 |
+
{
|
169 |
+
title: "Breaking: New streaming partnership announced",
|
170 |
+
source: "Streaming News",
|
171 |
+
time: "1 day ago",
|
172 |
+
excerpt: "Major platforms announce new content sharing agreement starting next month.",
|
173 |
+
category: "news"
|
174 |
+
},
|
175 |
+
{
|
176 |
+
title: "Streaming industry report Q4 2023",
|
177 |
+
source: "Tech Insights",
|
178 |
+
time: "3 days ago",
|
179 |
+
excerpt: "Latest statistics show continued growth in streaming subscriptions worldwide.",
|
180 |
+
category: "news"
|
181 |
+
}
|
182 |
+
],
|
183 |
+
trending: [
|
184 |
+
{
|
185 |
+
title: "Trending: The Grand Adventure hits #1",
|
186 |
+
source: "Netflix",
|
187 |
+
time: "5 hours ago",
|
188 |
+
excerpt: "The comedy adventure movie is now the most-watched title on Netflix this week.",
|
189 |
+
category: "trending"
|
190 |
+
},
|
191 |
+
{
|
192 |
+
title: "Upcoming: Romantic Getaway special event",
|
193 |
+
source: "Amazon Prime",
|
194 |
+
time: "2 days ago",
|
195 |
+
excerpt: "Join the cast for a live Q&A before the movie premiere this weekend.",
|
196 |
+
category: "trending"
|
197 |
+
}
|
198 |
+
],
|
199 |
+
personalized: [
|
200 |
+
{
|
201 |
+
title: "New Episode: SMPlus Exclusive Series",
|
202 |
+
source: "SMPlus VHX",
|
203 |
+
time: "2 hours ago",
|
204 |
+
excerpt: "The latest episode of our exclusive series is now streaming with intense action scenes.",
|
205 |
+
category: "personalized"
|
206 |
+
},
|
207 |
+
{
|
208 |
+
title: "Recommended for you: Space Explorers",
|
209 |
+
source: "Disney+",
|
210 |
+
time: "1 day ago",
|
211 |
+
excerpt: "Based on your interest in science documentaries, we recommend this new series.",
|
212 |
+
category: "personalized"
|
213 |
+
}
|
214 |
+
]
|
215 |
+
};
|
216 |
+
// Video production variables
|
217 |
+
let isRecording = false;
|
218 |
+
let recordingInterval;
|
219 |
+
let recordedClips = [];
|
220 |
+
let mediaRecorder;
|
221 |
+
let audioContext;
|
222 |
+
let audioStream;
|
223 |
+
let videoStream;
|
224 |
+
let currentClipTime = 0;
|
225 |
+
let currentClipInterval;
|
226 |
+
|
227 |
+
|
228 |
+
// Bluetooth sharing variables
|
229 |
+
let isBluetoothConnected = false;
|
230 |
+
let bluetoothDevice;
|
231 |
+
let bluetoothServer;
|
232 |
+
let bluetoothService;
|
233 |
+
let bluetoothCharacteristic;
|
234 |
+
let sharedClips = [];
|
235 |
+
let groupMembers = [];
|
236 |
+
let username = "User" + Math.floor(Math.random() * 1000);
|
237 |
+
let currentCategory = "general";
|
238 |
+
|
239 |
+
|
240 |
+
// Initialize chat
|
241 |
+
document.addEventListener('DOMContentLoaded', function() {
|
242 |
+
const sendBtn = document.getElementById('send-btn');
|
243 |
+
const userInput = document.getElementById('user-input');
|
244 |
+
const chatMessages = document.getElementById('chat-messages');
|
245 |
+
const productionButton = document.getElementById('production-button');
|
246 |
+
const productionPanel = document.getElementById('production-panel');
|
247 |
+
const startRecordingBtn = document.getElementById('start-recording');
|
248 |
+
const stopRecordingBtn = document.getElementById('stop-recording');
|
249 |
+
const generateVideoBtn = document.getElementById('generate-video');
|
250 |
+
const clearClipsBtn = document.getElementById('clear-clips');
|
251 |
+
const rssFilterBtns = document.querySelectorAll('.rss-filter-btn');
|
252 |
+
const recordTab = document.getElementById('record-tab');
|
253 |
+
const editTab = document.getElementById('edit-tab');
|
254 |
+
const shareTab = document.getElementById('share-tab');
|
255 |
+
const rankTab = document.getElementById('rank-tab');
|
256 |
+
const recordSection = document.getElementById('record-section');
|
257 |
+
const editSection = document.getElementById('edit-section');
|
258 |
+
const shareSection = document.getElementById('share-section');
|
259 |
+
const rankSection = document.getElementById('rank-section');
|
260 |
+
const bluetoothConnectBtn = document.getElementById('bluetooth-connect');
|
261 |
+
const shareClipsBtn = document.getElementById('share-clips');
|
262 |
+
const usernameInput = document.getElementById('username');
|
263 |
+
const contentCategorySelect = document.getElementById('content-category');
|
264 |
+
const rankingAlgorithmSelect = document.getElementById('ranking-algorithm');
|
265 |
+
|
266 |
+
// Set default username
|
267 |
+
usernameInput.value = username;
|
268 |
+
|
269 |
+
// Load sample recommendations
|
270 |
+
loadRecommendations();
|
271 |
+
|
272 |
+
// Load RSS feed
|
273 |
+
loadRSSFeed('all');
|
274 |
+
|
275 |
+
// Send message on button click
|
276 |
+
sendBtn.addEventListener('click', sendMessage);
|
277 |
+
|
278 |
+
// Send message on Enter key
|
279 |
+
userInput.addEventListener('keypress', function(e) {
|
280 |
+
if (e.key === 'Enter') {
|
281 |
+
sendMessage();
|
282 |
+
}
|
283 |
+
});
|
284 |
+
// Toggle production panel
|
285 |
+
productionButton.addEventListener('click', function() {
|
286 |
+
productionPanel.classList.toggle('open');
|
287 |
+
});
|
288 |
+
|
289 |
+
// Start recording
|
290 |
+
startRecordingBtn.addEventListener('click', startRecording);
|
291 |
+
|
292 |
+
// Stop recording
|
293 |
+
stopRecordingBtn.addEventListener('click', stopRecording);
|
294 |
+
|
295 |
+
// Generate video
|
296 |
+
generateVideoBtn.addEventListener('click', generateShortVideo);
|
297 |
+
|
298 |
+
// Clear clips
|
299 |
+
clearClipsBtn.addEventListener('click', clearClips);
|
300 |
+
|
301 |
+
// Filter RSS feed
|
302 |
+
rssFilterBtns.forEach(btn => {
|
303 |
+
btn.addEventListener('click', function() {
|
304 |
+
// Update active button
|
305 |
+
rssFilterBtns.forEach(b => {
|
306 |
+
b.classList.remove('bg-indigo-100', 'text-indigo-700');
|
307 |
+
b.classList.add('bg-gray-100', 'text-gray-700');
|
308 |
+
});
|
309 |
+
this.classList.remove('bg-gray-100', 'text-gray-700');
|
310 |
+
this.classList.add('bg-indigo-100', 'text-indigo-700');
|
311 |
+
|
312 |
+
// Load filtered feed
|
313 |
+
loadRSSFeed(this.dataset.filter);
|
314 |
+
});
|
315 |
+
});
|
316 |
+
|
317 |
+
// Switch between record and edit tabs
|
318 |
+
recordTab.addEventListener('click', function() {
|
319 |
+
recordTab.classList.remove('inactive');
|
320 |
+
recordTab.classList.add('active');
|
321 |
+
editTab.classList.remove('active');
|
322 |
+
editTab.classList.add('inactive');
|
323 |
+
shareTab.classList.remove('active');
|
324 |
+
shareTab.classList.add('inactive');
|
325 |
+
rankTab.classList.remove('active');
|
326 |
+
rankTab.classList.add('inactive');
|
327 |
+
recordSection.classList.remove('hidden');
|
328 |
+
editSection.classList.add('hidden');
|
329 |
+
shareSection.classList.add('hidden');
|
330 |
+
rankSection.classList.add('hidden');
|
331 |
+
});
|
332 |
+
|
333 |
+
editTab.addEventListener('click', function() {
|
334 |
+
if (recordedClips.length === 0) {
|
335 |
+
showNotification("No Clips", "Record some clips first to edit them");
|
336 |
+
return;
|
337 |
+
}
|
338 |
+
|
339 |
+
editTab.classList.remove('inactive');
|
340 |
+
editTab.classList.add('active');
|
341 |
+
recordTab.classList.remove('active');
|
342 |
+
recordTab.classList.add('inactive');
|
343 |
+
shareTab.classList.remove('active');
|
344 |
+
shareTab.classList.add('inactive');
|
345 |
+
rankTab.classList.remove('active');
|
346 |
+
rankTab.classList.add('inactive');
|
347 |
+
recordSection.classList.add('hidden');
|
348 |
+
editSection.classList.remove('hidden');
|
349 |
+
shareSection.classList.add('hidden');
|
350 |
+
rankSection.classList.add('hidden');
|
351 |
+
});
|
352 |
+
shareTab.addEventListener('click', function() {
|
353 |
+
shareTab.classList.remove('inactive');
|
354 |
+
shareTab.classList.add('active');
|
355 |
+
recordTab.classList.remove('active');
|
356 |
+
recordTab.classList.add('inactive');
|
357 |
+
editTab.classList.remove('active');
|
358 |
+
editTab.classList.add('inactive');
|
359 |
+
rankTab.classList.remove('active');
|
360 |
+
rankTab.classList.add('inactive');
|
361 |
+
recordSection.classList.add('hidden');
|
362 |
+
editSection.classList.add('hidden');
|
363 |
+
shareSection.classList.remove('hidden');
|
364 |
+
rankSection.classList.add('hidden');
|
365 |
+
});
|
366 |
+
|
367 |
+
rankTab.addEventListener('click', function() {
|
368 |
+
if (sharedClips.length === 0) {
|
369 |
+
showNotification("No Shared Clips", "Share some clips first to see rankings");
|
370 |
+
return;
|
371 |
+
}
|
372 |
+
|
373 |
+
rankTab.classList.remove('inactive');
|
374 |
+
rankTab.classList.add('active');
|
375 |
+
recordTab.classList.remove('active');
|
376 |
+
recordTab.classList.add('inactive');
|
377 |
+
editTab.classList.remove('active');
|
378 |
+
editTab.classList.add('inactive');
|
379 |
+
shareTab.classList.remove('active');
|
380 |
+
shareTab.classList.add('inactive');
|
381 |
+
recordSection.classList.add('hidden');
|
382 |
+
editSection.classList.add('hidden');
|
383 |
+
shareSection.classList.add('hidden');
|
384 |
+
rankSection.classList.remove('hidden');
|
385 |
+
|
386 |
+
// Update rankings when tab is opened
|
387 |
+
updateRankings();
|
388 |
+
});
|
389 |
+
|
390 |
+
// Connect to Bluetooth
|
391 |
+
bluetoothConnectBtn.addEventListener('click', connectBluetooth);
|
392 |
+
|
393 |
+
// Share clips
|
394 |
+
shareClipsBtn.addEventListener('click', shareClipsWithGroup);
|
395 |
+
|
396 |
+
// Update username when changed
|
397 |
+
usernameInput.addEventListener('change', function() {
|
398 |
+
username = this.value || "User" + Math.floor(Math.random() * 1000);
|
399 |
+
});
|
400 |
+
|
401 |
+
// Update category when changed
|
402 |
+
contentCategorySelect.addEventListener('change', function() {
|
403 |
+
currentCategory = this.value;
|
404 |
+
});
|
405 |
+
|
406 |
+
// Update rankings when algorithm changes
|
407 |
+
rankingAlgorithmSelect.addEventListener('change', updateRankings);
|
408 |
+
});
|
409 |
+
|
410 |
+
|
411 |
+
// Show notification
|
412 |
+
function showNotification(title, message) {
|
413 |
+
const notification = document.getElementById('notification');
|
414 |
+
const titleElement = document.getElementById('notification-title');
|
415 |
+
const messageElement = document.getElementById('notification-message');
|
416 |
+
|
417 |
+
titleElement.textContent = title;
|
418 |
+
messageElement.textContent = message;
|
419 |
+
|
420 |
+
notification.classList.remove('hidden');
|
421 |
+
notification.classList.add('show');
|
422 |
+
|
423 |
+
setTimeout(() => {
|
424 |
+
notification.classList.remove('show');
|
425 |
+
setTimeout(() => notification.classList.add('hidden'), 300);
|
426 |
+
}, 3000);
|
427 |
+
}
|
428 |
+
// Quick prompt buttons
|
429 |
+
function quickPrompt(prompt) {
|
430 |
+
document.getElementById('user-input').value = prompt;
|
431 |
+
sendMessage();
|
432 |
+
}
|
433 |
+
|
434 |
+
|
435 |
+
// Send message to AI
|
436 |
+
async function sendMessage() {
|
437 |
+
const userInput = document.getElementById('user-input');
|
438 |
+
const chatMessages = document.getElementById('chat-messages');
|
439 |
+
|
440 |
+
if (userInput.value.trim() === '') return;
|
441 |
+
|
442 |
+
// Add user message to chat
|
443 |
+
const userMessage = document.createElement('div');
|
444 |
+
userMessage.className = 'chat-bubble user-bubble p-4 w-3/4 ml-auto mb-4 fade-in';
|
445 |
+
userMessage.innerHTML = `<p>${userInput.value}</p>`;
|
446 |
+
chatMessages.appendChild(userMessage);
|
447 |
+
|
448 |
+
// Show typing indicator
|
449 |
+
const typingIndicator = document.createElement('div');
|
450 |
+
typingIndicator.className = 'chat-bubble ai-bubble p-4 w-1/2 mb-4';
|
451 |
+
typingIndicator.innerHTML = '<div class="typing-indicator"><span></span><span></span><span></span></div>';
|
452 |
+
chatMessages.appendChild(typingIndicator);
|
453 |
+
|
454 |
+
// Scroll to bottom
|
455 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
456 |
+
|
457 |
+
// Save user message
|
458 |
+
const userMessageText = userInput.value;
|
459 |
+
userInput.value = '';
|
460 |
+
|
461 |
+
try {
|
462 |
+
// Call Cloudflare Workers AI
|
463 |
+
const aiResponse = await queryCloudflareAI(userMessageText);
|
464 |
+
|
465 |
+
// Remove typing indicator
|
466 |
+
chatMessages.removeChild(typingIndicator);
|
467 |
+
|
468 |
+
// Add AI response to chat
|
469 |
+
const aiMessage = document.createElement('div');
|
470 |
+
aiMessage.className = 'chat-bubble ai-bubble p-4 w-3/4 fade-in';
|
471 |
+
aiMessage.innerHTML = `<p>${aiResponse}</p>`;
|
472 |
+
chatMessages.appendChild(aiMessage);
|
473 |
+
|
474 |
+
// Update recommendations based on AI response
|
475 |
+
updateRecommendationsFromAI(aiResponse);
|
476 |
+
|
477 |
+
} catch (error) {
|
478 |
+
// Remove typing indicator
|
479 |
+
chatMessages.removeChild(typingIndicator);
|
480 |
+
|
481 |
+
// Show error message
|
482 |
+
const errorMessage = document.createElement('div');
|
483 |
+
errorMessage.className = 'chat-bubble ai-bubble p-4 w-3/4 fade-in';
|
484 |
+
errorMessage.innerHTML = `<p class="text-red-500">Sorry, I'm having trouble connecting to the AI service. Please try again later.</p>`;
|
485 |
+
chatMessages.appendChild(errorMessage);
|
486 |
+
}
|
487 |
+
|
488 |
+
// Scroll to bottom
|
489 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
490 |
+
}
|
491 |
+
// Query Cloudflare Workers AI
|
492 |
+
async function queryCloudflareAI(prompt) {
|
493 |
+
// In a production environment, this would be handled by a backend service
|
494 |
+
// to keep the API token secure. For this demo, we'll simulate the response.
|
495 |
+
|
496 |
+
console.log(`[DEBUG] Would call Cloudflare AI with prompt: "${prompt}"`);
|
497 |
+
|
498 |
+
// Simulate API call delay
|
499 |
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
500 |
+
|
501 |
+
// Simulate different responses based on prompt
|
502 |
+
const lowerPrompt = prompt.toLowerCase();
|
503 |
+
|
504 |
+
if (lowerPrompt.includes('comedy') || lowerPrompt.includes('funny')) {
|
505 |
+
return "I'd recommend these comedy options that should give you a good laugh:\n\n1. 'The Grand Adventure' (Netflix) - A hilarious journey with unexpected twists\n2. 'Office Shenanigans' (Hulu) - Workplace comedy at its finest\n\nComedy can really lift your mood! Would you like more suggestions?";
|
506 |
+
}
|
507 |
+
else if (lowerPrompt.includes('thriller') || lowerPrompt.includes('suspense')) {
|
508 |
+
return "For thrilling content that will keep you on the edge of your seat, consider:\n\n1. 'Dark Secrets' (HBO Max) - A town's dark past resurfaces\n2. 'Midnight Caller' (Amazon Prime) - A psychological thriller about a mysterious phone call\n\nThese should provide plenty of suspense!";
|
509 |
+
}
|
510 |
+
else if (lowerPrompt.includes('romance') || lowerPrompt.includes('love')) {
|
511 |
+
return "Romantic stories can be so heartwarming! Here are my top picks:\n\n1. 'Romantic Getaway' (Amazon Prime) - Two strangers find love on vacation\n2. 'Love in Paris' (Netflix) - A classic romantic tale set in the City of Love\n\nLet me know if you'd like something more specific!";
|
512 |
+
}
|
513 |
+
else if (lowerPrompt.includes('recommend') || lowerPrompt.includes('suggest')) {
|
514 |
+
return "Based on your request, I'd recommend these excellent streaming options:\n\n1. 'SMPlus Exclusive Series' (SMPlus VHX) - Action-packed drama series\n2. 'Space Explorers' (Disney+) - Fascinating documentary about space\n\nI've updated the recommendations section with more options for you!";
|
515 |
+
}
|
516 |
+
else {
|
517 |
+
return "I'm here to help you find the perfect streaming content! Could you tell me more about what you're looking for? For example, you could say 'recommend a sci-fi movie' or 'what should I watch if I feel like laughing?'";
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
// Update recommendations based on AI response
|
523 |
+
function updateRecommendationsFromAI(aiResponse) {
|
524 |
+
let filter = 'all';
|
525 |
+
|
526 |
+
if (aiResponse.includes('comedy')) {
|
527 |
+
filter = 'comedy';
|
528 |
+
} else if (aiResponse.includes('thriller') || aiResponse.includes('suspense')) {
|
529 |
+
filter = 'thriller';
|
530 |
+
} else if (aiResponse.includes('romance') || aiResponse.includes('love')) {
|
531 |
+
filter = 'romance';
|
532 |
+
}
|
533 |
+
|
534 |
+
loadRecommendations(filter);
|
535 |
+
}
|
536 |
+
|
537 |
+
|
538 |
+
// Save show and set broadcast reminder
|
539 |
+
function saveShow(title, broadcastTime) {
|
540 |
+
// In a real app, this would save to a database
|
541 |
+
console.log(`Saved show: ${title}`);
|
542 |
+
|
543 |
+
// Show notification
|
544 |
+
showNotification("Reminder Set!", `We'll notify you when "${title}" is about to broadcast.`);
|
545 |
+
|
546 |
+
// In a real app, you would schedule a notification for the broadcast time
|
547 |
+
if (broadcastTime) {
|
548 |
+
const broadcastDate = new Date(broadcastTime);
|
549 |
+
const now = new Date();
|
550 |
+
|
551 |
+
// Only schedule if broadcast is in the future
|
552 |
+
if (broadcastDate > now) {
|
553 |
+
const timeUntilBroadcast = broadcastDate - now;
|
554 |
+
|
555 |
+
// Schedule notification 30 minutes before broadcast
|
556 |
+
setTimeout(() => {
|
557 |
+
showNotification("Starting Soon!", `"${title}" will begin broadcasting in 30 minutes!`);
|
558 |
+
}, timeUntilBroadcast - (30 * 60 * 1000));
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
// Load recommendations
|
563 |
+
function loadRecommendations(filter = 'all') {
|
564 |
+
const container = document.getElementById('recommendations-container');
|
565 |
+
container.innerHTML = '';
|
566 |
+
|
567 |
+
let filteredData = streamingData;
|
568 |
+
|
569 |
+
if (filter === 'comedy') {
|
570 |
+
filteredData = streamingData.filter(item => item.genre.toLowerCase().includes('comedy'));
|
571 |
+
} else if (filter === 'thriller') {
|
572 |
+
filteredData = streamingData.filter(item => item.genre.toLowerCase().includes('thriller'));
|
573 |
+
} else if (filter === 'romance') {
|
574 |
+
filteredData = streamingData.filter(item => item.genre.toLowerCase().includes('romance'));
|
575 |
+
}
|
576 |
+
|
577 |
+
filteredData.forEach(item => {
|
578 |
+
const card = document.createElement('div');
|
579 |
+
card.className = 'stream-card bg-white rounded-lg overflow-hidden shadow-md hover:shadow-xl transition duration-300 fade-in p-4';
|
580 |
+
card.innerHTML = `
|
581 |
+
<div class="mb-3">
|
582 |
+
<div class="flex justify-between items-start">
|
583 |
+
<h3 class="font-bold text-base">${item.title}</h3>
|
584 |
+
<span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded-full flex items-center">
|
585 |
+
<i class="fas fa-star text-yellow-500 mr-1 text-xs"></i> ${item.rating}
|
586 |
+
</span>
|
587 |
+
</div>
|
588 |
+
<p class="text-gray-600 text-xs mb-1">${item.type} • ${item.genre} • ${item.year}</p>
|
589 |
+
<div class="text-xs text-indigo-600 mb-2">${item.platform}</div>
|
590 |
+
</div>
|
591 |
+
<p class="text-gray-700 text-sm mb-4">${item.description}</p>
|
592 |
+
<div class="flex justify-between items-center">
|
593 |
+
<button class="text-indigo-600 hover:text-indigo-800 text-xs font-medium" onclick="saveShow('${item.title}', '${item.broadcastTime}')">
|
594 |
+
<i class="far fa-bookmark mr-1"></i> Save
|
595 |
+
</button>
|
596 |
+
<a href="${item.platform === 'SMPlus VHX' ? 'https://smplus.vhx.tv' : '#'}" target="_blank" class="bg-indigo-600 hover:bg-indigo-700 text-white px-3 py-1 rounded-full text-xs font-medium transition">
|
597 |
+
<i class="fas fa-play mr-1"></i> Watch
|
598 |
+
</a>
|
599 |
+
</div>
|
600 |
+
`;
|
601 |
+
container.appendChild(card);
|
602 |
+
});
|
603 |
+
}
|
604 |
+
|
605 |
+
|
606 |
+
// Load RSS feed
|
607 |
+
function loadRSSFeed(filter) {
|
608 |
+
const container = document.getElementById('rss-feed');
|
609 |
+
container.innerHTML = '';
|
610 |
+
|
611 |
+
const feedItems = rssFeedData[filter] || rssFeedData.all;
|
612 |
+
|
613 |
+
feedItems.forEach(item => {
|
614 |
+
const feedItem = document.createElement('div');
|
615 |
+
feedItem.className = 'rss-item bg-gray-50 p-3 rounded-lg';
|
616 |
+
feedItem.innerHTML = `
|
617 |
+
<h4 class="font-medium text-sm mb-1">${item.title}</h4>
|
618 |
+
<div class="flex items-center text-xs text-gray-500 mb-2">
|
619 |
+
<span>${item.source}</span>
|
620 |
+
<span class="mx-2">•</span>
|
621 |
+
<span>${item.time}</span>
|
622 |
+
</div>
|
623 |
+
<p class="text-xs text-gray-700">${item.excerpt}</p>
|
624 |
+
`;
|
625 |
+
container.appendChild(feedItem);
|
626 |
+
});
|
627 |
+
}
|
628 |
+
// Start recording video and audio
|
629 |
+
async function startRecording() {
|
630 |
+
try {
|
631 |
+
// Get user media
|
632 |
+
videoStream = await navigator.mediaDevices.getDisplayMedia({
|
633 |
+
video: true,
|
634 |
+
audio: true
|
635 |
+
});
|
636 |
+
|
637 |
+
audioStream = await navigator.mediaDevices.getUserMedia({
|
638 |
+
audio: true
|
639 |
+
});
|
640 |
+
|
641 |
+
// Create audio context
|
642 |
+
audioContext = new AudioContext();
|
643 |
+
const source = audioContext.createMediaStreamSource(audioStream);
|
644 |
+
const destination = audioContext.createMediaStreamDestination();
|
645 |
+
source.connect(destination);
|
646 |
+
|
647 |
+
// Combine video and audio streams
|
648 |
+
const combinedStream = new MediaStream([
|
649 |
+
...videoStream.getVideoTracks(),
|
650 |
+
...destination.stream.getAudioTracks()
|
651 |
+
]);
|
652 |
+
|
653 |
+
// Create media recorder
|
654 |
+
mediaRecorder = new MediaRecorder(combinedStream, {
|
655 |
+
mimeType: 'video/webm'
|
656 |
+
});
|
657 |
+
|
658 |
+
// Update preview with live recording
|
659 |
+
const preview = document.getElementById('clip-preview');
|
660 |
+
preview.innerHTML = '<video autoplay muted></video>';
|
661 |
+
const previewVideo = preview.querySelector('video');
|
662 |
+
previewVideo.srcObject = combinedStream;
|
663 |
+
|
664 |
+
// Set recording state
|
665 |
+
isRecording = true;
|
666 |
+
document.getElementById('recording-indicator').classList.remove('hidden');
|
667 |
+
document.getElementById('start-recording').classList.add('hidden');
|
668 |
+
document.getElementById('stop-recording').classList.remove('hidden');
|
669 |
+
|
670 |
+
// Start progress bar animation
|
671 |
+
currentClipTime = 0;
|
672 |
+
const progressFill = document.getElementById('progress-fill');
|
673 |
+
progressFill.style.width = '0%';
|
674 |
+
|
675 |
+
currentClipInterval = setInterval(() => {
|
676 |
+
currentClipTime += 100;
|
677 |
+
const progressPercent = (currentClipTime / 5000) * 100;
|
678 |
+
progressFill.style.width = `${progressPercent}%`;
|
679 |
+
}, 100);
|
680 |
+
|
681 |
+
// Start recording in 5-second clips
|
682 |
+
let clipCount = 0;
|
683 |
+
recordingInterval = setInterval(() => {
|
684 |
+
if (clipCount > 0) {
|
685 |
+
// Stop current recording
|
686 |
+
mediaRecorder.stop();
|
687 |
+
}
|
688 |
+
|
689 |
+
// Start new recording
|
690 |
+
mediaRecorder.start();
|
691 |
+
clipCount++;
|
692 |
+
|
693 |
+
// Reset progress bar
|
694 |
+
currentClipTime = 0;
|
695 |
+
progressFill.style.width = '0%';
|
696 |
+
|
697 |
+
// Store clip data when available
|
698 |
+
mediaRecorder.ondataavailable = (e) => {
|
699 |
+
const clip = {
|
700 |
+
blob: e.data,
|
701 |
+
timestamp: new Date().toLocaleTimeString(),
|
702 |
+
url: URL.createObjectURL(e.data),
|
703 |
+
username: username,
|
704 |
+
category: currentCategory,
|
705 |
+
engagementScore: Math.random() * 5, // Simulated metrics
|
706 |
+
qualityScore: 3 + Math.random() * 2,
|
707 |
+
consistencyScore: 3 + Math.random() * 2
|
708 |
+
};
|
709 |
+
recordedClips.push(clip);
|
710 |
+
updateClipsList();
|
711 |
+
};
|
712 |
+
}, 5000);
|
713 |
+
|
714 |
+
showNotification("Recording Started", "Recording 5-second clips of your screen and audio");
|
715 |
+
|
716 |
+
} catch (error) {
|
717 |
+
console.error("Error starting recording:", error);
|
718 |
+
showNotification("Recording Error", "Could not start recording. Please check permissions.");
|
719 |
+
stopRecording();
|
720 |
+
}
|
721 |
+
}
|
722 |
+
// Stop recording
|
723 |
+
function stopRecording() {
|
724 |
+
if (mediaRecorder && mediaRecorder.state !== 'inactive') {
|
725 |
+
mediaRecorder.stop();
|
726 |
+
}
|
727 |
+
|
728 |
+
clearInterval(recordingInterval);
|
729 |
+
clearInterval(currentClipInterval);
|
730 |
+
isRecording = false;
|
731 |
+
|
732 |
+
// Stop all tracks
|
733 |
+
if (videoStream) {
|
734 |
+
videoStream.getTracks().forEach(track => track.stop());
|
735 |
+
}
|
736 |
+
if (audioStream) {
|
737 |
+
audioStream.getTracks().forEach(track => track.stop());
|
738 |
+
}
|
739 |
+
|
740 |
+
// Close audio context
|
741 |
+
if (audioContext && audioContext.state !== 'closed') {
|
742 |
+
audioContext.close();
|
743 |
+
}
|
744 |
+
|
745 |
+
// Reset preview
|
746 |
+
const preview = document.getElementById('clip-preview');
|
747 |
+
preview.innerHTML = `
|
748 |
+
<div class="clip-preview-placeholder">
|
749 |
+
<i class="fas fa-video"></i>
|
750 |
+
<p>Preview will appear here</p>
|
751 |
+
</div>
|
752 |
+
`;
|
753 |
+
|
754 |
+
// Reset progress bar
|
755 |
+
document.getElementById('progress-fill').style.width = '0%';
|
756 |
+
|
757 |
+
// Update UI
|
758 |
+
document.getElementById('recording-indicator').classList.add('hidden');
|
759 |
+
document.getElementById('start-recording').classList.remove('hidden');
|
760 |
+
document.getElementById('stop-recording').classList.add('hidden');
|
761 |
+
|
762 |
+
showNotification("Recording Stopped", `Captured ${recordedClips.length} clips ready for production`);
|
763 |
+
}
|
764 |
+
|
765 |
+
|
766 |
+
// Update clips list
|
767 |
+
function updateClipsList() {
|
768 |
+
const container = document.getElementById('clips-container');
|
769 |
+
container.innerHTML = '';
|
770 |
+
|
771 |
+
if (recordedClips.length === 0) {
|
772 |
+
container.innerHTML = '<p class="text-gray-500 text-sm">Clips will appear here...</p>';
|
773 |
+
return;
|
774 |
+
}
|
775 |
+
|
776 |
+
recordedClips.forEach((clip, index) => {
|
777 |
+
const clipItem = document.createElement('div');
|
778 |
+
clipItem.className = 'clip-item';
|
779 |
+
clipItem.innerHTML = `
|
780 |
+
<i class="fas fa-video text-gray-500 mr-2"></i>
|
781 |
+
<span class="text-sm flex-1">Clip ${index + 1}</span>
|
782 |
+
<span class="text-xs text-gray-500">${clip.timestamp}</span>
|
783 |
+
`;
|
784 |
+
|
785 |
+
// Add click handler to preview clip
|
786 |
+
clipItem.addEventListener('click', () => {
|
787 |
+
const preview = document.getElementById('clip-preview');
|
788 |
+
preview.innerHTML = '<video controls></video>';
|
789 |
+
const previewVideo = preview.querySelector('video');
|
790 |
+
previewVideo.src = clip.url;
|
791 |
+
});
|
792 |
+
|
793 |
+
container.appendChild(clipItem);
|
794 |
+
});
|
795 |
+
}
|
796 |
+
// Clear all clips
|
797 |
+
function clearClips() {
|
798 |
+
if (recordedClips.length === 0) return;
|
799 |
+
|
800 |
+
// In a real app, we would properly revoke the object URLs
|
801 |
+
recordedClips.forEach(clip => {
|
802 |
+
if (clip.url) {
|
803 |
+
URL.revokeObjectURL(clip.url);
|
804 |
+
}
|
805 |
+
});
|
806 |
+
|
807 |
+
recordedClips = [];
|
808 |
+
updateClipsList();
|
809 |
+
|
810 |
+
// Reset preview
|
811 |
+
const preview = document.getElementById('clip-preview');
|
812 |
+
preview.innerHTML = `
|
813 |
+
<div class="clip-preview-placeholder">
|
814 |
+
<i class="fas fa-video"></i>
|
815 |
+
<p>Preview will appear here</p>
|
816 |
+
</div>
|
817 |
+
`;
|
818 |
+
|
819 |
+
showNotification("Clips Cleared", "All recorded clips have been removed");
|
820 |
+
}
|
821 |
+
|
822 |
+
|
823 |
+
// Generate short video from clips
|
824 |
+
function generateShortVideo() {
|
825 |
+
if (recordedClips.length === 0) {
|
826 |
+
showNotification("No Clips", "Please record some clips first");
|
827 |
+
return;
|
828 |
+
}
|
829 |
+
|
830 |
+
// In a real app, this would use a video editing library to combine clips
|
831 |
+
// and sync with audio. For this demo, we'll simulate the process.
|
832 |
+
|
833 |
+
showNotification("Video Generation", "Processing your clips into a short video...");
|
834 |
+
|
835 |
+
setTimeout(() => {
|
836 |
+
// Simulate processing time
|
837 |
+
const videoUrl = URL.createObjectURL(new Blob(["Simulated video content"], { type: 'video/mp4' }));
|
838 |
+
|
839 |
+
// Create download link
|
840 |
+
const a = document.createElement('a');
|
841 |
+
a.href = videoUrl;
|
842 |
+
a.download = 'streamai-short.mp4';
|
843 |
+
a.click();
|
844 |
+
|
845 |
+
showNotification("Video Ready", "Your short video has been generated and downloaded");
|
846 |
+
}, 3000);
|
847 |
+
}
|
848 |
+
|
849 |
+
|
850 |
+
// Connect to Bluetooth devices
|
851 |
+
async function connectBluetooth() {
|
852 |
+
try {
|
853 |
+
// Request Bluetooth device
|
854 |
+
bluetoothDevice = await navigator.bluetooth.requestDevice({
|
855 |
+
acceptAllDevices: true,
|
856 |
+
optionalServices: ['generic_access']
|
857 |
+
});
|
858 |
+
|
859 |
+
// Connect to the GATT Server
|
860 |
+
bluetoothServer = await bluetoothDevice.gatt.connect();
|
861 |
+
|
862 |
+
// Get the service
|
863 |
+
bluetoothService = await bluetoothServer.getPrimaryService('generic_access');
|
864 |
+
|
865 |
+
// Get the characteristic
|
866 |
+
bluetoothCharacteristic = await bluetoothService.getCharacteristic('device_name');
|
867 |
+
|
868 |
+
// Update connection status
|
869 |
+
isBluetoothConnected = true;
|
870 |
+
const statusElement = document.getElementById('connection-status');
|
871 |
+
statusElement.innerHTML = `
|
872 |
+
<i class="fas fa-circle bluetooth-connected mr-1"></i>
|
873 |
+
<span>Connected to ${bluetoothDevice.name || 'device'}</span>
|
874 |
+
`;
|
875 |
+
|
876 |
+
// Simulate discovering group members
|
877 |
+
groupMembers = [
|
878 |
+
{ name: "User" + Math.floor(Math.random() * 1000), device: "Device 1" },
|
879 |
+
{ name: "User" + Math.floor(Math.random() * 1000), device: "Device 2" },
|
880 |
+
{ name: "User" + Math.floor(Math.random() * 1000), device: "Device 3" }
|
881 |
+
];
|
882 |
+
showNotification("Bluetooth Connected", `Connected to ${bluetoothDevice.name}. Found ${groupMembers.length} group members.`);
|
883 |
+
|
884 |
+
} catch (error) {
|
885 |
+
console.error("Bluetooth connection error:", error);
|
886 |
+
isBluetoothConnected = false;
|
887 |
+
document.getElementById('connection-status').innerHTML = `
|
888 |
+
<i class="fas fa-circle bluetooth-disconnected mr-1"></i>
|
889 |
+
<span>Not connected</span>
|
890 |
+
`;
|
891 |
+
showNotification("Connection Failed", "Could not connect to Bluetooth device");
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
|
896 |
+
// Share clips with Bluetooth group
|
897 |
+
async function shareClipsWithGroup() {
|
898 |
+
if (!isBluetoothConnected) {
|
899 |
+
showNotification("Not Connected", "Please connect to Bluetooth first");
|
900 |
+
return;
|
901 |
+
}
|
902 |
+
|
903 |
+
if (recordedClips.length === 0) {
|
904 |
+
showNotification("No Clips", "Please record some clips first");
|
905 |
+
return;
|
906 |
+
}
|
907 |
+
|
908 |
+
// In a real app, this would actually send the clips over Bluetooth
|
909 |
+
// For this demo, we'll simulate the sharing process
|
910 |
+
|
911 |
+
showNotification("Sharing Clips", "Sharing your clips with the group...");
|
912 |
+
|
913 |
+
// Simulate sharing delay
|
914 |
+
setTimeout(() => {
|
915 |
+
// Add metadata to clips and add to shared clips
|
916 |
+
recordedClips.forEach(clip => {
|
917 |
+
const sharedClip = {
|
918 |
+
...clip,
|
919 |
+
sharedBy: username,
|
920 |
+
category: currentCategory,
|
921 |
+
timestamp: new Date().toLocaleTimeString(),
|
922 |
+
likes: Math.floor(Math.random() * 10),
|
923 |
+
views: Math.floor(Math.random() * 50)
|
924 |
+
};
|
925 |
+
sharedClips.push(sharedClip);
|
926 |
+
});
|
927 |
+
|
928 |
+
// Update shared clips display
|
929 |
+
updateSharedClipsList();
|
930 |
+
|
931 |
+
showNotification("Clips Shared", `Shared ${recordedClips.length} clips with ${groupMembers.length} group members`);
|
932 |
+
}, 2000);
|
933 |
+
}
|
934 |
+
// Update shared clips list
|
935 |
+
function updateSharedClipsList() {
|
936 |
+
const container = document.getElementById('shared-clips-container');
|
937 |
+
container.innerHTML = '';
|
938 |
+
|
939 |
+
if (sharedClips.length === 0) {
|
940 |
+
container.innerHTML = '<p class="text-gray-500 text-sm">Shared clips will appear here...</p>';
|
941 |
+
return;
|
942 |
+
}
|
943 |
+
|
944 |
+
sharedClips.forEach((clip, index) => {
|
945 |
+
const clipItem = document.createElement('div');
|
946 |
+
clipItem.className = 'clip-item';
|
947 |
+
clipItem.innerHTML = `
|
948 |
+
<i class="fas fa-video text-gray-500 mr-2"></i>
|
949 |
+
<span class="text-sm flex-1">Clip ${index + 1}</span>
|
950 |
+
<span class="user-tag">${clip.sharedBy}</span>
|
951 |
+
<span class="category-tag">${clip.category}</span>
|
952 |
+
`;
|
953 |
+
|
954 |
+
// Add click handler to preview clip
|
955 |
+
clipItem.addEventListener('click', () => {
|
956 |
+
const preview = document.getElementById('clip-preview');
|
957 |
+
preview.innerHTML = '<video controls></video>';
|
958 |
+
const previewVideo = preview.querySelector('video');
|
959 |
+
previewVideo.src = clip.url;
|
960 |
+
});
|
961 |
+
|
962 |
+
container.appendChild(clipItem);
|
963 |
+
});
|
964 |
+
}
|
965 |
+
|
966 |
+
|
967 |
+
// Benchmarking algorithm to rank clips
|
968 |
+
function benchmarkClips() {
|
969 |
+
if (sharedClips.length === 0) return [];
|
970 |
+
|
971 |
+
// Calculate scores for each clip
|
972 |
+
sharedClips.forEach(clip => {
|
973 |
+
// Composite score is weighted average of all metrics
|
974 |
+
clip.compositeScore = (
|
975 |
+
clip.engagementScore * 0.4 +
|
976 |
+
clip.qualityScore * 0.3 +
|
977 |
+
clip.consistencyScore * 0.3
|
978 |
+
);
|
979 |
+
|
980 |
+
// Add some randomness to simulate different algorithms
|
981 |
+
clip.engagementScore = Math.min(5, clip.engagementScore + Math.random() * 0.5 - 0.25);
|
982 |
+
clip.qualityScore = Math.min(5, clip.qualityScore + Math.random() * 0.5 - 0.25);
|
983 |
+
clip.consistencyScore = Math.min(5, clip.consistencyScore + Math.random() * 0.5 - 0.25);
|
984 |
+
});
|
985 |
+
|
986 |
+
// Sort based on selected algorithm
|
987 |
+
const algorithm = document.getElementById('ranking-algorithm').value;
|
988 |
+
let sortedClips = [...sharedClips];
|
989 |
+
|
990 |
+
switch (algorithm) {
|
991 |
+
case 'engagement':
|
992 |
+
sortedClips.sort((a, b) => b.engagementScore - a.engagementScore);
|
993 |
+
break;
|
994 |
+
case 'quality':
|
995 |
+
sortedClips.sort((a, b) => b.qualityScore - a.qualityScore);
|
996 |
+
break;
|
997 |
+
case 'consistency':
|
998 |
+
sortedClips.sort((a, b) => b.consistencyScore - a.consistencyScore);
|
999 |
+
break;
|
1000 |
+
case 'composite':
|
1001 |
+
default:
|
1002 |
+
sortedClips.sort((a, b) => b.compositeScore - a.compositeScore);
|
1003 |
+
break;
|
1004 |
+
}
|
1005 |
+
return sortedClips;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
|
1009 |
+
// Update rankings display
|
1010 |
+
function updateRankings() {
|
1011 |
+
const container = document.getElementById('rankings-container');
|
1012 |
+
container.innerHTML = '';
|
1013 |
+
|
1014 |
+
const rankedClips = benchmarkClips();
|
1015 |
+
|
1016 |
+
if (rankedClips.length === 0) {
|
1017 |
+
container.innerHTML = '<p class="text-gray-500 text-sm">Rankings will appear here when available...</p>';
|
1018 |
+
return;
|
1019 |
+
}
|
1020 |
</script>
|