ydshieh HF staff commited on
Commit
e0c3771
1 Parent(s): 70b3763

Update transcript-tracer.js

Browse files
Files changed (1) hide show
  1. transcript-tracer.js +24 -2
transcript-tracer.js CHANGED
@@ -545,6 +545,9 @@ function handleSelection() {
545
  var wordIndex = wordElement.dataset.ttWord;
546
  var transcript = wordElement.closest('.tt-transcript');
547
  var mediaUrl = transcript.dataset.ttCurrentMediaUrl;
 
 
 
548
  var startSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].startSeconds;
549
 
550
  console.log(startSeconds);
@@ -564,16 +567,35 @@ function handleSelection() {
564
 
565
  var endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].endSeconds;
566
  // adjustment
567
- var targetEndIndex = (parseInt(wordIndex)+1);
568
  if (!need_adjustment) targetEndIndex = wordIndex;
569
  targetEndIndex = targetEndIndex.toString()
570
 
571
  if (targetEndIndex < ttLinkedDataByMediaUrl[mediaUrl].wordTimings.length) {
572
  endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[targetEndIndex].startSeconds;
573
  }
574
-
 
 
 
 
 
 
575
  console.log(endSeconds);
576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  }
578
 
579
  loadTranscriptTracer({ blockSelector: null, phraseSelector: null, alignmentFuzziness: 0, timeOffset: 0, autoScroll: "word", clickable: true})
 
545
  var wordIndex = wordElement.dataset.ttWord;
546
  var transcript = wordElement.closest('.tt-transcript');
547
  var mediaUrl = transcript.dataset.ttCurrentMediaUrl;
548
+
549
+ var startWordElement = wordElement;
550
+ var startWordIndex = wordIndex;
551
  var startSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].startSeconds;
552
 
553
  console.log(startSeconds);
 
567
 
568
  var endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[wordIndex].endSeconds;
569
  // adjustment
570
+ var targetEndIndex = parseInt(wordIndex)+1;
571
  if (!need_adjustment) targetEndIndex = wordIndex;
572
  targetEndIndex = targetEndIndex.toString()
573
 
574
  if (targetEndIndex < ttLinkedDataByMediaUrl[mediaUrl].wordTimings.length) {
575
  endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[targetEndIndex].startSeconds;
576
  }
577
+
578
+ var endWordIndex = parseInt(wordIndex);
579
+ if (need_adjustment) endWordIndex = endWordIndex - 1;
580
+ endWordIndex = endWordIndex.toString()
581
+ // ? How to get this
582
+ // var endWordElement = startWordElement;
583
+
584
  console.log(endSeconds);
585
 
586
+
587
+ // Mark selection
588
+ // if (ttCurrentEvent.currentWordIndexes.length > 0) {
589
+ // for (const wordIndex of ttCurrentEvent.currentWordIndexes) {
590
+ // var wordElements = ttCurrentTranscript.querySelectorAll(`[data-tt-word="${wordIndex}"]`);
591
+ // for (const wordElement of wordElements) wordElement.classList.add('tt-current-word');
592
+ // }
593
+ // for (const wordElement of ttCurrentTranscript.getElementsByClassName('tt-word')) {
594
+ // if (wordElement.classList.contains('tt-current-word')) break;
595
+ // wordElement.classList.add('tt-previous-word');
596
+ // }
597
+ // }
598
+
599
  }
600
 
601
  loadTranscriptTracer({ blockSelector: null, phraseSelector: null, alignmentFuzziness: 0, timeOffset: 0, autoScroll: "word", clickable: true})