diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-09-24 14:28:01 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2020-09-24 14:28:01 -0700 |
commit | c7c74624edafd66b5b6cb63ed5fa87aad08cb65f (patch) | |
tree | 15b6e8375ed96d52fc47da1d11f5696d82be5abe /youtube/static/js/common.js | |
parent | 97b092bf7ad9caa6e639c3672a9917cefdd18d40 (diff) | |
download | yt-local-c7c74624edafd66b5b6cb63ed5fa87aad08cb65f.tar.lz yt-local-c7c74624edafd66b5b6cb63ed5fa87aad08cb65f.tar.xz yt-local-c7c74624edafd66b5b6cb63ed5fa87aad08cb65f.zip |
Transcript: For clarity, use more verbose names and add comments
Diffstat (limited to 'youtube/static/js/common.js')
-rw-r--r-- | youtube/static/js/common.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js index 4c7ee51..8f27a64 100644 --- a/youtube/static/js/common.js +++ b/youtube/static/js/common.js @@ -1,32 +1,32 @@ Q = document.querySelector.bind(document); function text(msg) { return document.createTextNode(msg); } function clearNode(node) { while (node.firstChild) node.removeChild(node.firstChild); } -function toMS(s) { +function toTimestamp(s) { var s = Math.floor(s); var m = Math.floor(s/60); var s = s % 60; return `0${m}:`.slice(-3) + `0${s}`.slice(-2); } -var cur_tt_idx = 0; +var cur_track_idx = 0; function getActiveTranscriptTrackIdx() { - let tts = Q("video").textTracks; - if (!tts.length) return; - for (let i=0; i < tts.length; i++) { - if (tts[i].mode == "showing") { - cur_tt_idx = i; - return cur_tt_idx; + let textTracks = Q("video").textTracks; + if (!textTracks.length) return; + for (let i=0; i < textTracks.length; i++) { + if (textTracks[i].mode == "showing") { + cur_track_idx = i; + return cur_track_idx; } } - return cur_tt_idx; + return cur_track_idx; } function getActiveTranscriptTrack() { return Q("video").textTracks[getActiveTranscriptTrackIdx()]; } function getDefaultTranscriptTrackIdx() { - let tts = Q("video").textTracks; - return tts.length - 1; + let textTracks = Q("video").textTracks; + return textTracks.length - 1; } window.addEventListener('DOMContentLoaded', function() { - cur_tt_idx = getDefaultTranscriptTrackIdx(); + cur_track_idx = getDefaultTranscriptTrackIdx(); }); |