1+ // 1. The data array
2+ const tutorials = [
3+ {
4+ className : "Academic Reading: Mastering True/False/Not Given" ,
5+ youtubeIframe : '<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
6+ } ,
7+ {
8+ className : "Speed Reading Techniques for Section 3" ,
9+ youtubeIframe : '<iframe width="560" height="315" src="https://www.youtube.com/embed/example2" title="YouTube video player" frameborder="0" allowfullscreen></iframe>'
10+ } ,
11+ {
12+ className : "Matching Headings: The 'Elimination' Method" ,
13+ youtubeIframe : '<iframe width="560" height="315" src="https://www.youtube.com/embed/example3" title="YouTube video player" frameborder="0" allowfullscreen></iframe>'
14+ }
15+ ] ;
16+
17+ // 2. The function to render the list
18+ function renderPlaylist ( ) {
19+ const container = document . getElementById ( 'list-wrapper' ) ;
20+
21+ // Clear existing content (optional)
22+ container . innerHTML = '' ;
23+
24+ tutorials . forEach ( ( item , index ) => {
25+ // Create the bar element
26+ const bar = document . createElement ( 'div' ) ;
27+ bar . className = 'playlist-bar' ;
28+ bar . style . cssText = `
29+ display: flex;
30+ align-items: center;
31+ padding: 15px;
32+ margin-bottom: 10px;
33+ background-color: #2a2a2a;
34+ color: white;
35+ border-radius: 8px;
36+ cursor: pointer;
37+ transition: background 0.2s;
38+ font-family: sans-serif;
39+ ` ;
40+
41+ // Inner HTML for the bar (Icon + Title)
42+ bar . innerHTML = `
43+ <span style="margin-right: 15px; opacity: 0.5;">${ index + 1 } </span>
44+ <span style="flex-grow: 1; font-weight: 500;">${ item . className } </span>
45+ <span style="font-size: 0.8em; color: #4CAF50;">▶ Play</span>
46+ ` ;
47+
48+ // Hover effect
49+ bar . onmouseenter = ( ) => bar . style . backgroundColor = '#383838' ;
50+ bar . onmouseleave = ( ) => bar . style . backgroundColor = '#2a2a2a' ;
51+
52+ // Click event to load the video (e.g., into a main player area)
53+ bar . onclick = ( ) => {
54+ console . log ( `Loading: ${ item . className } ` ) ;
55+ // You could append item.youtubeIframe to a #video-display div here
56+ } ;
57+
58+ container . appendChild ( bar ) ;
59+ } ) ;
60+ }
61+
62+ // Run the function
63+ document . addEventListener ( 'DOMContentLoaded' , renderPlaylist ) ;
0 commit comments