diff options
author | Jesús <heckyel@hyperbola.info> | 2021-12-16 17:46:16 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-12-16 17:46:16 -0500 |
commit | df7e41b61a83320cd2b2ffb9a4a45234162672af (patch) | |
tree | d16e3b953fda8b10618478d793dd0096d98b8c35 /youtube/static/js/watch.js | |
parent | dd498e63d96c5b4465e3f7c65f81433aa28f2f10 (diff) | |
download | yt-local-df7e41b61a83320cd2b2ffb9a4a45234162672af.tar.lz yt-local-df7e41b61a83320cd2b2ffb9a4a45234162672af.tar.xz yt-local-df7e41b61a83320cd2b2ffb9a4a45234162672af.zip |
[frontend]: fix global scope, change var to let
Diffstat (limited to 'youtube/static/js/watch.js')
-rw-r--r-- | youtube/static/js/watch.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/youtube/static/js/watch.js b/youtube/static/js/watch.js index acc6b28..95d9fa7 100644 --- a/youtube/static/js/watch.js +++ b/youtube/static/js/watch.js @@ -1,10 +1,10 @@ const video = document.getElementById('js-video-player'); function changeQuality(selection) { - var currentVideoTime = video.currentTime; - var videoPaused = video.paused; - var videoSpeed = video.playbackRate; - var srcInfo; + let currentVideoTime = video.currentTime; + let videoPaused = video.paused; + let videoSpeed = video.playbackRate; + let srcInfo; if (avMerge) avMerge.close(); if (selection.type == 'uni'){ @@ -22,9 +22,9 @@ function changeQuality(selection) { } // Initialize av-merge -var avMerge; +let avMerge; if (data.using_pair_sources) { - var srcPair = data['pair_sources'][data['pair_idx']]; + let srcPair = data['pair_sources'][data['pair_idx']]; // Do it dynamically rather than as the default in jinja // in case javascript is disabled avMerge = new AVMerge(video, srcPair, 0); @@ -42,10 +42,10 @@ if (qs) { if (data.time_start != 0 && video) {video.currentTime = data.time_start}; // External video speed control -var speedInput = document.getElementById('speed-control'); +let speedInput = document.getElementById('speed-control'); speedInput.addEventListener('keyup', (event) => { if (event.key === 'Enter') { - var speed = parseFloat(speedInput.value); + let speed = parseFloat(speedInput.value); if(!isNaN(speed)){ video.playbackRate = speed; } @@ -61,7 +61,7 @@ if (data.playlist && data.playlist['id'] !== null) { // IntersectionObserver isn't supported in pre-quantum // firefox versions, but the alternative of making it // manually is a performance drain, so oh well - var observer = new IntersectionObserver(lazyLoad, { + let observer = new IntersectionObserver(lazyLoad, { // where in relation to the edge of the viewport, we are observing rootMargin: "100px", @@ -86,7 +86,7 @@ if (data.playlist && data.playlist['id'] !== null) { }; // Tell our observer to observe all img elements with a "lazy" class - var lazyImages = document.querySelectorAll('img.lazy'); + let lazyImages = document.querySelectorAll('img.lazy'); lazyImages.forEach(img => { observer.observe(img); }); |