From f9461a2e79cd0be50937139eb9d0ad1a55e0578f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 15 Dec 2020 12:30:46 -0500 Subject: Migration general theme: fix query video tag --- youtube/static/js/common.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'youtube/static/js/common.js') diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js index 20cfddd..c15921c 100644 --- a/youtube/static/js/common.js +++ b/youtube/static/js/common.js @@ -1,5 +1,6 @@ -Q = document.querySelector.bind(document); -QA = document.querySelectorAll.bind(document); +const Q = document.querySelector.bind(document); +const QA = document.querySelectorAll.bind(document); +const QId = document.getElementById.bind(document); function text(msg) { return document.createTextNode(msg); } function clearNode(node) { while (node.firstChild) node.removeChild(node.firstChild); } function toTimestamp(seconds) { @@ -20,7 +21,7 @@ function toTimestamp(seconds) { var cur_track_idx = 0; function getActiveTranscriptTrackIdx() { - let textTracks = Q("video").textTracks; + let textTracks = QId("js-video-player").textTracks; if (!textTracks.length) return; for (let i=0; i < textTracks.length; i++) { if (textTracks[i].mode == "showing") { @@ -30,10 +31,10 @@ function getActiveTranscriptTrackIdx() { } return cur_track_idx; } -function getActiveTranscriptTrack() { return Q("video").textTracks[getActiveTranscriptTrackIdx()]; } +function getActiveTranscriptTrack() { return QId("js-video-player").textTracks[getActiveTranscriptTrackIdx()]; } function getDefaultTranscriptTrackIdx() { - let textTracks = Q("video").textTracks; + let textTracks = QId("js-video-player").textTracks; return textTracks.length - 1; } @@ -109,4 +110,4 @@ function copyTextToClipboard(text) { window.addEventListener('DOMContentLoaded', function() { cur_track_idx = getDefaultTranscriptTrackIdx(); -}); \ No newline at end of file +}); -- cgit v1.2.3