aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/static/js/common.js
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/static/js/common.js')
-rw-r--r--youtube/static/js/common.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js
index c15921c..79f8834 100644
--- a/youtube/static/js/common.js
+++ b/youtube/static/js/common.js
@@ -1,16 +1,19 @@
const Q = document.querySelector.bind(document);
const QA = document.querySelectorAll.bind(document);
const QId = document.getElementById.bind(document);
+let seconds,
+ minutes,
+ hours;
function text(msg) { return document.createTextNode(msg); }
function clearNode(node) { while (node.firstChild) node.removeChild(node.firstChild); }
function toTimestamp(seconds) {
- var seconds = Math.floor(seconds);
+ seconds = Math.floor(seconds);
- var minutes = Math.floor(seconds/60);
- var seconds = seconds % 60;
+ minutes = Math.floor(seconds/60);
+ seconds = seconds % 60;
- var hours = Math.floor(minutes/60);
- var minutes = minutes % 60;
+ hours = Math.floor(minutes/60);
+ minutes = minutes % 60;
if (hours) {
return `0${hours}:`.slice(-3) + `0${minutes}:`.slice(-3) + `0${seconds}`.slice(-2);
@@ -18,8 +21,7 @@ function toTimestamp(seconds) {
return `0${minutes}:`.slice(-3) + `0${seconds}`.slice(-2);
}
-
-var cur_track_idx = 0;
+let cur_track_idx = 0;
function getActiveTranscriptTrackIdx() {
let textTracks = QId("js-video-player").textTracks;
if (!textTracks.length) return;
@@ -39,7 +41,7 @@ function getDefaultTranscriptTrackIdx() {
}
function doXhr(url, callback=null) {
- var xhr = new XMLHttpRequest();
+ let xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onload = (e) => {
callback(e.currentTarget.response);
@@ -50,7 +52,7 @@ function doXhr(url, callback=null) {
// https://stackoverflow.com/a/30810322
function copyTextToClipboard(text) {
- var textArea = document.createElement("textarea");
+ let textArea = document.createElement("textarea");
//
// *** This styling is an extra step which is likely not required. ***
@@ -97,8 +99,8 @@ function copyTextToClipboard(text) {
textArea.select();
try {
- var successful = document.execCommand('copy');
- var msg = successful ? 'successful' : 'unsuccessful';
+ let successful = document.execCommand('copy');
+ let msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');