Update transcript-tracer.js
Browse files- transcript-tracer.js +53 -9
transcript-tracer.js
CHANGED
|
@@ -566,10 +566,14 @@ function handleSelection() {
|
|
| 566 |
var startWordElement = startNode.parentNode;
|
| 567 |
|
| 568 |
// Used for highlight
|
| 569 |
-
var startWordElementForHighlight = startWordElement
|
|
|
|
| 570 |
while (startWordElementForHighlight.className == "tt-whitespace") {
|
| 571 |
-
|
|
|
|
|
|
|
| 572 |
}
|
|
|
|
| 573 |
// This could be `undefined`!
|
| 574 |
var startWordIndexForHighlight = startWordElementForHighlight.dataset.ttWord;
|
| 575 |
// This is always defined.
|
|
@@ -579,16 +583,22 @@ function handleSelection() {
|
|
| 579 |
var startWordElementForTime = startWordElementForHighlight;
|
| 580 |
|
| 581 |
// No time specified for some words --> we compute the starting time with the first element where the time information is provided.
|
| 582 |
-
//
|
| 583 |
while (startWordElementForTime.className == "tt-whitespace" || (startWordElementForTime.dataset.ttWord === undefined)) {
|
| 584 |
-
|
|
|
|
|
|
|
| 585 |
}
|
| 586 |
|
| 587 |
-
// This
|
| 588 |
var startWordIndexForTime = startWordElementForTime.dataset.ttWord;
|
| 589 |
-
//
|
| 590 |
var startWordListIndexForTime = startWordElementForTime.listIndex;
|
| 591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
|
| 593 |
console.log(startWordElement);
|
| 594 |
console.log(startWordElementForHighlight);
|
|
@@ -608,20 +618,54 @@ function handleSelection() {
|
|
| 608 |
|
| 609 |
// Used for highlight
|
| 610 |
var endWordElementForHighlight = endWordElement;
|
|
|
|
| 611 |
while (endWordElementForHighlight.className == "tt-whitespace") {
|
| 612 |
-
|
|
|
|
|
|
|
| 613 |
}
|
| 614 |
|
| 615 |
// This could be `undefined`!
|
| 616 |
var endWordIndexForHighlight = endWordElementForHighlight.dataset.ttWord;
|
| 617 |
// This is always defined.
|
| 618 |
var endWordListIndexForHighlight = endWordElementForHighlight.listIndex;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 619 |
|
| 620 |
console.log(endWordElement);
|
| 621 |
console.log(endWordElementForHighlight);
|
| 622 |
console.log(endWordIndexForHighlight);
|
| 623 |
console.log(endWordListIndexForHighlight);
|
| 624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
return
|
| 626 |
|
| 627 |
// ====================================================================================================
|
|
|
|
| 566 |
var startWordElement = startNode.parentNode;
|
| 567 |
|
| 568 |
// Used for highlight
|
| 569 |
+
var startWordElementForHighlight = startWordElement
|
| 570 |
+
|
| 571 |
while (startWordElementForHighlight.className == "tt-whitespace") {
|
| 572 |
+
var index = startWordElementForTime.listIndex + 1;
|
| 573 |
+
if (index >= nodes.length) break;
|
| 574 |
+
startWordElementForHighlight = nodes[index];
|
| 575 |
}
|
| 576 |
+
|
| 577 |
// This could be `undefined`!
|
| 578 |
var startWordIndexForHighlight = startWordElementForHighlight.dataset.ttWord;
|
| 579 |
// This is always defined.
|
|
|
|
| 583 |
var startWordElementForTime = startWordElementForHighlight;
|
| 584 |
|
| 585 |
// No time specified for some words --> we compute the starting time with the first element where the time information is provided.
|
| 586 |
+
// (This could go beyond the selected religon!)
|
| 587 |
while (startWordElementForTime.className == "tt-whitespace" || (startWordElementForTime.dataset.ttWord === undefined)) {
|
| 588 |
+
var index = startWordElementForTime.listIndex + 1;
|
| 589 |
+
if (index >= nodes.length) break;
|
| 590 |
+
startWordElementForTime = nodes[index];
|
| 591 |
}
|
| 592 |
|
| 593 |
+
// This could still be `undefined`.
|
| 594 |
var startWordIndexForTime = startWordElementForTime.dataset.ttWord;
|
| 595 |
+
// Let's get the `listIndex`.
|
| 596 |
var startWordListIndexForTime = startWordElementForTime.listIndex;
|
| 597 |
+
|
| 598 |
+
var startSeconds = null;
|
| 599 |
+
if (startWordIndexForTime !== undefined) {
|
| 600 |
+
startSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[startWordIndexForTime].startSeconds;
|
| 601 |
+
}
|
| 602 |
|
| 603 |
console.log(startWordElement);
|
| 604 |
console.log(startWordElementForHighlight);
|
|
|
|
| 618 |
|
| 619 |
// Used for highlight
|
| 620 |
var endWordElementForHighlight = endWordElement;
|
| 621 |
+
|
| 622 |
while (endWordElementForHighlight.className == "tt-whitespace") {
|
| 623 |
+
var index = endWordElementForHighlight.listIndex - 1;
|
| 624 |
+
if (index < 0) break;
|
| 625 |
+
endWordElementForHighlight = nodes[index];
|
| 626 |
}
|
| 627 |
|
| 628 |
// This could be `undefined`!
|
| 629 |
var endWordIndexForHighlight = endWordElementForHighlight.dataset.ttWord;
|
| 630 |
// This is always defined.
|
| 631 |
var endWordListIndexForHighlight = endWordElementForHighlight.listIndex;
|
| 632 |
+
|
| 633 |
+
// Used for computing the end seconds
|
| 634 |
+
var endWordElementForTime = endWordElementForHighlight;
|
| 635 |
+
|
| 636 |
+
// Forward to the next element (if possible)
|
| 637 |
+
if ((endWordElementForTime.listIndex + 1) < nodes.length) {
|
| 638 |
+
endWordElementForTime = nodes[endWordElementForTime.listIndex + 1];
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
while (endWordElementForTime.className == "tt-whitespace" || (endWordElementForTime.dataset.ttWord === undefined)) {
|
| 642 |
+
var index = endWordElementForTime.listIndex + 1;
|
| 643 |
+
if (index >= nodes.length) break;
|
| 644 |
+
endWordElementForTime = nodes[index];
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
// This could still be `undefined`.
|
| 648 |
+
var endWordIndexForTime = endWordIndexForTime.dataset.ttWord;
|
| 649 |
+
// Let's get the `listIndex`.
|
| 650 |
+
var endWordListIndexForTime = endWordIndexForTime.listIndex;
|
| 651 |
+
|
| 652 |
+
var endSeconds = null;
|
| 653 |
+
if (endWordIndexForTime !== undefined) {
|
| 654 |
+
endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[endWordIndexForTime].startSeconds;
|
| 655 |
+
if (endWordListIndexForTime == nodes.length - 1) {
|
| 656 |
+
endSeconds = ttLinkedDataByMediaUrl[mediaUrl].wordTimings[endWordIndexForTime].endSeconds;
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
|
| 660 |
console.log(endWordElement);
|
| 661 |
console.log(endWordElementForHighlight);
|
| 662 |
console.log(endWordIndexForHighlight);
|
| 663 |
console.log(endWordListIndexForHighlight);
|
| 664 |
+
console.log(endWordElementForTime);
|
| 665 |
+
console.log(endWordIndexForTime);
|
| 666 |
+
console.log(endWordListIndexForTime);
|
| 667 |
+
console.log(endSeconds);
|
| 668 |
+
|
| 669 |
return
|
| 670 |
|
| 671 |
// ====================================================================================================
|