ydshieh HF staff commited on
Commit
18786c3
1 Parent(s): 8b58aac

Update transcript-tracer.js

Browse files
Files changed (1) hide show
  1. transcript-tracer.js +13 -0
transcript-tracer.js CHANGED
@@ -460,4 +460,17 @@ function handleWordClick(e) {
460
  var mediaUrl = transcript.dataset.ttCurrentMediaUrl;
461
  var startSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].startSeconds
462
  ttLinkedDataByMediaUrl[mediaUrl].mediaElement.currentTime = startSeconds;
 
 
 
 
 
 
 
 
 
 
 
 
 
463
  }
 
460
  var mediaUrl = transcript.dataset.ttCurrentMediaUrl;
461
  var startSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].startSeconds
462
  ttLinkedDataByMediaUrl[mediaUrl].mediaElement.currentTime = startSeconds;
463
+
464
+ // Make sure the correct transcript is selected
465
+ if (!ttCurrentTranscript || ttCurrentTranscript.dataset.ttTranscript != ttData.transcriptIndex) {
466
+ ttCurrentTranscript = document.querySelector(`[data-tt-transcript="${ttData.transcriptIndex}"]`);
467
+ }
468
+
469
+ // Mark words
470
+ wordElement.classList.add('tt-current-word');
471
+
472
+ for (const wordElement of ttCurrentTranscript.getElementsByClassName('tt-word')) {
473
+ if (wordElement.classList.contains('tt-current-word')) break;
474
+ wordElement.classList.add('tt-previous-word');
475
+ }
476
  }