usage let
not var
This commit is contained in:
parent
2d1794889a
commit
7f79269cf3
@ -184,7 +184,7 @@
|
|||||||
// IntersectionObserver isn't supported in pre-quantum
|
// IntersectionObserver isn't supported in pre-quantum
|
||||||
// firefox versions, but the alternative of making it
|
// firefox versions, but the alternative of making it
|
||||||
// manually is a performance drain, so oh well
|
// 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
|
// where in relation to the edge of the viewport, we are observing
|
||||||
rootMargin: "100px",
|
rootMargin: "100px",
|
||||||
@ -205,7 +205,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Tell our observer to observe all img elements with a "lazy" class
|
// 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 => {
|
lazyImages.forEach(img => {
|
||||||
observer.observe(img);
|
observer.observe(img);
|
||||||
});
|
});
|
||||||
@ -220,7 +220,7 @@
|
|||||||
{% if settings.related_videos_mode != 0 or playlist %}
|
{% if settings.related_videos_mode != 0 or playlist %}
|
||||||
<script>
|
<script>
|
||||||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
// @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 %}
|
{% if playlist and playlist['current_index'] is not none %}
|
||||||
{% set isPlaylist = true %}
|
{% set isPlaylist = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -230,7 +230,7 @@
|
|||||||
function escapeRegExp(string) {
|
function escapeRegExp(string) {
|
||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched 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);
|
playlist_id = escapeRegExp(playlist_id);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -238,14 +238,14 @@
|
|||||||
// pain in the ass:
|
// pain in the ass:
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
|
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
|
||||||
{% if isPlaylist %}
|
{% if isPlaylist %}
|
||||||
var cookieValue = document.cookie.replace(new RegExp(
|
let cookieValue = document.cookie.replace(new RegExp(
|
||||||
'(?:(?:^|.*;\\s*)autoplay_' + playlist_id + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
|
'(?:(?:^|.*;\\s*)autoplay_' + playlist_id + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
|
||||||
{% else %}
|
{% else %}
|
||||||
var cookieValue = document.cookie.replace(new RegExp(
|
let cookieValue = document.cookie.replace(new RegExp(
|
||||||
'(?:(?:^|.*;\\s*)autoplay\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
|
'(?:(?:^|.*;\\s*)autoplay\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1');
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
var autoplayEnabled = 0;
|
let autoplayEnabled = 0;
|
||||||
if(cookieValue.length === 0){
|
if(cookieValue.length === 0){
|
||||||
autoplayEnabled = 0;
|
autoplayEnabled = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -253,13 +253,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check the checkbox if autoplay is on
|
// check the checkbox if autoplay is on
|
||||||
var checkbox = document.querySelector('#autoplay-toggle');
|
let checkbox = document.querySelector('#autoplay-toggle');
|
||||||
if(autoplayEnabled){
|
if(autoplayEnabled){
|
||||||
checkbox.checked = true;
|
checkbox.checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// listen for checkbox to turn autoplay on and off
|
// listen for checkbox to turn autoplay on and off
|
||||||
var cookie = 'autoplay'
|
let cookie = 'autoplay'
|
||||||
{% if isPlaylist %}
|
{% if isPlaylist %}
|
||||||
cookie += '_' + playlist_id;
|
cookie += '_' + playlist_id;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -275,7 +275,7 @@
|
|||||||
|
|
||||||
if(!playability_error){
|
if(!playability_error){
|
||||||
// play the video if autoplay is on
|
// play the video if autoplay is on
|
||||||
var vid = document.querySelector('video');
|
let vid = document.querySelector('video');
|
||||||
if(autoplayEnabled){
|
if(autoplayEnabled){
|
||||||
vid.play();
|
vid.play();
|
||||||
}
|
}
|
||||||
@ -283,25 +283,25 @@
|
|||||||
|
|
||||||
// determine next video url
|
// determine next video url
|
||||||
{% if isPlaylist %}
|
{% if isPlaylist %}
|
||||||
var currentIndex = {{ playlist['current_index']|tojson }};
|
let currentIndex = {{ playlist['current_index']|tojson }};
|
||||||
{% if playlist['current_index']+1 == playlist['items']|length %}
|
{% if playlist['current_index']+1 == playlist['items']|length %}
|
||||||
var nextVideoUrl = null;
|
let nextVideoUrl = null;
|
||||||
{% else %}
|
{% else %}
|
||||||
var nextVideoUrl = {{ (playlist['items'][playlist['current_index']+1]['url'])|tojson }};
|
let nextVideoUrl = {{ (playlist['items'][playlist['current_index']+1]['url'])|tojson }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
// scroll playlist to proper position
|
// scroll playlist to proper position
|
||||||
// item height + gap == 100
|
// item height + gap == 100
|
||||||
var pl = document.querySelector('.playlist-videos');
|
let pl = document.querySelector('.playlist-videos');
|
||||||
pl.scrollTop = 100*currentIndex;
|
pl.scrollTop = 100*currentIndex;
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if related|length == 0 %}
|
{% if related|length == 0 %}
|
||||||
var nextVideoUrl = null;
|
let nextVideoUrl = null;
|
||||||
{% else %}
|
{% else %}
|
||||||
var nextVideoUrl = {{ (related[0]['url'])|tojson }};
|
let nextVideoUrl = {{ (related[0]['url'])|tojson }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
var nextVideoDelay = 1000;
|
let nextVideoDelay = 1000;
|
||||||
|
|
||||||
// go to next video when video ends
|
// go to next video when video ends
|
||||||
// https://stackoverflow.com/a/2880950
|
// https://stackoverflow.com/a/2880950
|
||||||
|
Loading…
x
Reference in New Issue
Block a user