aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-06-23 14:42:59 -0500
committerJesús <heckyel@hyperbola.info>2021-06-23 14:43:10 -0500
commit7f79269cf3811971b76834640c96af8069a61725 (patch)
tree55d05655612e7af071311b4ae9c92a51972eb0fc
parent2d1794889aa3591b31a62f325a0c11a8553ba2d9 (diff)
downloadyt-local-7f79269cf3811971b76834640c96af8069a61725.tar.lz
yt-local-7f79269cf3811971b76834640c96af8069a61725.tar.xz
yt-local-7f79269cf3811971b76834640c96af8069a61725.zip
usage `let` not `var`
-rw-r--r--youtube/templates/watch.html34
1 files changed, 17 insertions, 17 deletions
diff --git a/youtube/templates/watch.html b/youtube/templates/watch.html
index 47880b8..798e783 100644
--- a/youtube/templates/watch.html
+++ b/youtube/templates/watch.html
@@ -184,7 +184,7 @@
// 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",
@@ -205,7 +205,7 @@
};
// 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);
});
@@ -220,7 +220,7 @@
{% if settings.related_videos_mode != 0 or playlist %}
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
- var playability_error = {{ 'true' if playability_error else 'false' }};
+ let playability_error = {{ 'true' if playability_error else 'false' }};
{% if playlist and playlist['current_index'] is not none %}
{% set isPlaylist = true %}
{% endif %}
@@ -230,7 +230,7 @@
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
- var playlist_id = {{ playlist['id']|tojson }};
+ let playlist_id = {{ playlist['id']|tojson }};
playlist_id = escapeRegExp(playlist_id);
{% endif %}
@@ -238,14 +238,14 @@
// pain in the ass:
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
{% if isPlaylist %}
- var cookieValue = document.cookie.replace(new RegExp(
+ let cookieValue = document.cookie.replace(new RegExp(
'(?:(?:^|.*;\\s*)autoplay_' + playlist_id + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
{% else %}
- var cookieValue = document.cookie.replace(new RegExp(
+ let cookieValue = document.cookie.replace(new RegExp(
'(?:(?:^|.*;\\s*)autoplay\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
{% endif %}
- var autoplayEnabled = 0;
+ let autoplayEnabled = 0;
if(cookieValue.length === 0){
autoplayEnabled = 0;
} else {
@@ -253,13 +253,13 @@
}
// check the checkbox if autoplay is on
- var checkbox = document.querySelector('#autoplay-toggle');
+ let checkbox = document.querySelector('#autoplay-toggle');
if(autoplayEnabled){
checkbox.checked = true;
}
// listen for checkbox to turn autoplay on and off
- var cookie = 'autoplay'
+ let cookie = 'autoplay'
{% if isPlaylist %}
cookie += '_' + playlist_id;
{% endif %}
@@ -275,7 +275,7 @@
if(!playability_error){
// play the video if autoplay is on
- var vid = document.querySelector('video');
+ let vid = document.querySelector('video');
if(autoplayEnabled){
vid.play();
}
@@ -283,25 +283,25 @@
// determine next video url
{% if isPlaylist %}
- var currentIndex = {{ playlist['current_index']|tojson }};
+ let currentIndex = {{ playlist['current_index']|tojson }};
{% if playlist['current_index']+1 == playlist['items']|length %}
- var nextVideoUrl = null;
+ let nextVideoUrl = null;
{% else %}
- var nextVideoUrl = {{ (playlist['items'][playlist['current_index']+1]['url'])|tojson }};
+ let nextVideoUrl = {{ (playlist['items'][playlist['current_index']+1]['url'])|tojson }};
{% endif %}
// scroll playlist to proper position
// item height + gap == 100
- var pl = document.querySelector('.playlist-videos');
+ let pl = document.querySelector('.playlist-videos');
pl.scrollTop = 100*currentIndex;
{% else %}
{% if related|length == 0 %}
- var nextVideoUrl = null;
+ let nextVideoUrl = null;
{% else %}
- var nextVideoUrl = {{ (related[0]['url'])|tojson }};
+ let nextVideoUrl = {{ (related[0]['url'])|tojson }};
{% endif %}
{% endif %}
- var nextVideoDelay = 1000;
+ let nextVideoDelay = 1000;
// go to next video when video ends
// https://stackoverflow.com/a/2880950