@@ -36,16 +36,18 @@ class LecturePlayer extends DDDSuper(LitElement) {
36
36
this . associatedNodes = { } ;
37
37
38
38
window . onload = ( ) => {
39
- const flags = document . querySelectorAll ( "lecture-anchor" ) ;
39
+ const flags = this . querySelectorAll ( "lecture-anchor" ) ;
40
40
flags . forEach ( ( flag ) => {
41
41
console . log ( flag . associatedID ) ;
42
- this . associatedNodes [ flag . timestamp ] = flag . associatedID ;
42
+ this . associatedNodes [ flag . value ] = flag . associatedID ;
43
43
} ) ;
44
44
console . log ( this . associatedNodes ) ;
45
45
for ( const [ key , value ] of Object . entries ( this . associatedNodes ) ) {
46
46
console . log ( `${ key } : ${ value } ` ) ;
47
47
}
48
48
}
49
+
50
+ this . videoPlayer = this . querySelector ( "video-player" ) . outerHTML ;
49
51
}
50
52
51
53
static get properties ( ) {
@@ -60,12 +62,12 @@ class LecturePlayer extends DDDSuper(LitElement) {
60
62
super . updated ( changedProperties ) ;
61
63
changedProperties . forEach ( ( oldValue , propName ) => {
62
64
if ( propName === "activeIndex" ) {
63
- if ( ! document . querySelector ( "video-player" ) . playing ) {
65
+ if ( ! this . querySelector ( "video-player" ) . playing ) {
64
66
this . play ( ) ;
65
67
}
66
68
console . log ( "activeIndex changed to: " , this . activeIndex ) ;
67
- console . log ( document . querySelector ( "#" + this . activeIndex ) ) ;
68
- this . seek ( document . querySelector ( "#" + this . activeIndex ) . timestamp ) ;
69
+ console . log ( this . querySelector ( "#" + this . activeIndex ) ) ;
70
+ this . seek ( this . querySelector ( "#" + this . activeIndex ) . value ) ;
69
71
this . updateJumbotron ( ) ;
70
72
this . updatePlaylist ( ) ;
71
73
this . checkDisabledButtons ( ) ;
@@ -74,12 +76,12 @@ class LecturePlayer extends DDDSuper(LitElement) {
74
76
}
75
77
76
78
scan ( ) {
77
- const lectureAnchors = document . querySelectorAll ( "lecture-anchor" ) ;
79
+ const lectureAnchors = this . querySelectorAll ( "lecture-anchor" ) ;
78
80
console . log ( lectureAnchors ) ;
79
81
const anchorsArray = Array . from ( lectureAnchors ) ;
80
82
anchorsArray . sort ( ( a , b ) => {
81
- const timeA = parseInt ( a . getAttribute ( "timestamp " ) , 10 ) ;
82
- const timeB = parseInt ( b . getAttribute ( "timestamp " ) , 10 ) ;
83
+ const timeA = parseInt ( a . getAttribute ( "value " ) , 10 ) ;
84
+ const timeB = parseInt ( b . getAttribute ( "value " ) , 10 ) ;
83
85
return timeA - timeB ;
84
86
} ) ;
85
87
anchorsArray . forEach ( ( anchor , index ) => {
@@ -93,8 +95,8 @@ class LecturePlayer extends DDDSuper(LitElement) {
93
95
94
96
setJumbotronAttributes ( ) {
95
97
console . log ( "setJumbotronAttributes" ) ;
96
- document . querySelectorAll ( "lecture-anchor" ) . forEach ( ( anchor ) => {
97
- let header = document . getElementById ( anchor . getAttribute ( "associatedID" ) ) ;
98
+ this . querySelectorAll ( "lecture-anchor" ) . forEach ( ( anchor ) => {
99
+ let header = this . querySelector ( `# ${ anchor . getAttribute ( "associatedID" ) } ` ) ;
98
100
anchor . setAttribute ( "jumbotronHeading" , header . textContent ) ;
99
101
anchor . setAttribute ( "jumbotronContent" , this . getNextSiblingHTML ( header ) ) ;
100
102
// Scrub the ids from the lecture-anchor elements in the content
@@ -185,30 +187,30 @@ class LecturePlayer extends DDDSuper(LitElement) {
185
187
186
188
updatePlaylist ( ) {
187
189
console . log ( "updatePlaylist" ) ;
188
- const timestampList = document . querySelector ( ".timestampList " ) ;
189
- timestampList . innerHTML = "" ;
190
+ const valueList = document . querySelector ( ".valueList " ) ;
191
+ valueList . innerHTML = "" ;
190
192
const listOfAnchorElements = this . getSortedAnchors ( ) ;
191
193
listOfAnchorElements . forEach ( ( anchor ) => {
192
- const timestampBtn = document . createElement ( "button" ) ;
193
- timestampBtn . classList . add ( "timestampBtn " ) ;
194
- timestampBtn . innerText = anchor . getAttribute ( "jumbotronHeading" ) ;
195
- timestampBtn . timestamp = anchor . getAttribute ( "timestamp " ) ;
196
- timestampBtn . addEventListener ( "click" , ( ) => {
194
+ const valueBtn = document . createElement ( "button" ) ;
195
+ valueBtn . classList . add ( "valueBtn " ) ;
196
+ valueBtn . innerText = anchor . getAttribute ( "jumbotronHeading" ) ;
197
+ valueBtn . value = anchor . getAttribute ( "value " ) ;
198
+ valueBtn . addEventListener ( "click" , ( ) => {
197
199
this . activeIndex = anchor . id ;
198
200
} ) ;
199
201
if ( anchor . id === this . activeIndex ) {
200
- timestampBtn . classList . add ( "active" ) ;
202
+ valueBtn . classList . add ( "active" ) ;
201
203
}
202
- timestampList . appendChild ( timestampBtn ) ;
204
+ valueList . appendChild ( valueBtn ) ;
203
205
} ) ;
204
- document . querySelector ( ".timestampList " ) . scrollTo ( {
205
- left : document . querySelector ( ".timestampBtn .active" ) . offsetLeft - 125 ,
206
+ document . querySelector ( ".valueList " ) . scrollTo ( {
207
+ left : document . querySelector ( ".valueBtn .active" ) . offsetLeft - 125 ,
206
208
behavior : "smooth" ,
207
209
} ) ;
208
210
}
209
211
210
212
getSortedAnchors ( ) {
211
- // Returns an array of all the lecture-anchor elements sorted by timestamp , to assing their IDs in order
213
+ // Returns an array of all the lecture-anchor elements sorted by value , to assing their IDs in order
212
214
// May need to support the option for sorting by how the tags appear in the content order
213
215
let anchors = [ ] ;
214
216
let i = 1 ;
@@ -221,9 +223,9 @@ class LecturePlayer extends DDDSuper(LitElement) {
221
223
return anchors ;
222
224
}
223
225
224
- seek ( timestamp ) {
226
+ seek ( value ) {
225
227
console . log ( "seek" ) ;
226
- console . log ( timestamp ) ;
228
+ console . log ( value ) ;
227
229
console . log (
228
230
document
229
231
. querySelector ( "video-player" )
@@ -237,7 +239,7 @@ class LecturePlayer extends DDDSuper(LitElement) {
237
239
document
238
240
. querySelector ( "video-player" )
239
241
. shadowRoot . querySelector ( "a11y-media-player" )
240
- . seek ( timestamp ) ;
242
+ . seek ( value ) ;
241
243
}
242
244
}
243
245
@@ -336,7 +338,7 @@ class LecturePlayer extends DDDSuper(LitElement) {
336
338
word-break: break-word;
337
339
}
338
340
339
- .timestampList {
341
+ .valueList {
340
342
display: flex; /* Use flexbox to layout items in a row */
341
343
flex-wrap: nowrap; /* Prevent wrapping of items */
342
344
border: var(--ddd-border-xs);
@@ -346,7 +348,7 @@ class LecturePlayer extends DDDSuper(LitElement) {
346
348
overflow-y: hidden; /* Hide vertical overflow */
347
349
}
348
350
349
- .timestampBtn {
351
+ .valueBtn {
350
352
flex-shrink: 0; /* Prevent buttons from shrinking */
351
353
background: white;
352
354
border: none;
@@ -362,7 +364,7 @@ class LecturePlayer extends DDDSuper(LitElement) {
362
364
font-family: var(--ddd-font-primary, sans-serif);
363
365
}
364
366
365
- .timestampBtn :not(:last-child){
367
+ .valueBtn :not(:last-child){
366
368
border-right: 1px solid black;
367
369
}
368
370
@@ -387,15 +389,15 @@ class LecturePlayer extends DDDSuper(LitElement) {
387
389
width: calc(100% - 16px);
388
390
}
389
391
390
- .timestamp -navigation-button{
392
+ .value -navigation-button{
391
393
background: white;
392
394
cursor: pointer;
393
395
padding: 4px;
394
396
height: fit-content;
395
397
margin: auto;
396
398
}
397
399
398
- .timestampBtn .active{
400
+ .valueBtn .active{
399
401
background: #dfedf5;
400
402
}
401
403
@@ -430,16 +432,17 @@ class LecturePlayer extends DDDSuper(LitElement) {
430
432
}
431
433
</style>
432
434
<div class="videoSection">
433
- <video-player source=" ${ this . source } " source-type=" ${ this . sourceType } "></video-player>
435
+ ${ this . videoPlayer }
434
436
<div class="jumbotron"></div>
435
437
</div>
436
438
<div class="playlist">
437
- <button class="timestamp -navigation-button" id="prevSlideBtn"><simple-icon-lite icon="lrn:arrow-left"></simple-icon-lite></button>
438
- <div class="timestampList ">
439
+ <button class="value -navigation-button" id="prevSlideBtn"><simple-icon-lite icon="lrn:arrow-left"></simple-icon-lite></button>
440
+ <div class="valueList ">
439
441
</div>
440
- <button class="timestamp -navigation-button" id="nextSlideBtn"><simple-icon-lite icon="lrn:arrow-right"></simple-icon-lite></button>
442
+ <button class="value -navigation-button" id="nextSlideBtn"><simple-icon-lite icon="lrn:arrow-right"></simple-icon-lite></button>
441
443
</div>
442
444
` ;
445
+ this . querySelector ( "video-player" ) . setAttribute ( "hidden" , true ) ;
443
446
const evnt = new CustomEvent ( "simple-modal-show" , {
444
447
bubbles : true ,
445
448
cancelable : true ,
@@ -454,6 +457,7 @@ class LecturePlayer extends DDDSuper(LitElement) {
454
457
render ( ) {
455
458
return html `
456
459
< simple-cta id ="lectureActivation " @click ="${ this . showModal } "> Open Lecture Player</ simple-cta >
460
+ < slot > </ slot >
457
461
` ;
458
462
}
459
463
}
0 commit comments