diff --git a/assets/js/community.js b/assets/js/community.js index 5bc1ee2e5..eebaf5d8b 100644 --- a/assets/js/community.js +++ b/assets/js/community.js @@ -64,8 +64,8 @@ function get_youtube_replies(target, load_more) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { if (load_more) { body = body.parentNode.parentNode; body.removeChild(body.lastElementChild); diff --git a/assets/js/embed.js b/assets/js/embed.js index 11d940600..d3c530cb0 100644 --- a/assets/js/embed.js +++ b/assets/js/embed.js @@ -2,7 +2,7 @@ var video_data = JSON.parse(document.getElementById('video_data').innerHTML); function get_playlist(plid, retries) { - if (retries == undefined) retries = 5; + if (retries === undefined) retries = 5; if (retries <= 0) { console.log('Failed to pull playlist'); diff --git a/assets/js/handlers.js b/assets/js/handlers.js index 84e1d7c29..1bf11364e 100644 --- a/assets/js/handlers.js +++ b/assets/js/handlers.js @@ -102,8 +102,8 @@ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { count.innerText = parseInt(count.innerText) + 1; row.style.display = ''; } @@ -131,8 +131,8 @@ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { count.innerText = parseInt(count.innerText) + 1; row.style.display = ''; } @@ -159,7 +159,7 @@ } // Focus search bar on '/' - if (event.key == "/") { + if (event.key === "/") { document.getElementById('searchbox').focus(); event.preventDefault(); } diff --git a/assets/js/notifications.js b/assets/js/notifications.js index 9c77895b8..1235fb41e 100644 --- a/assets/js/notifications.js +++ b/assets/js/notifications.js @@ -4,7 +4,7 @@ var notification_data = JSON.parse(document.getElementById('notification_data'). var notifications, delivered; function get_subscriptions(callback, retries) { - if (retries == undefined) retries = 5; + if (retries === undefined) retries = 5; if (retries <= 0) { return; diff --git a/assets/js/player.js b/assets/js/player.js index a0cef29e7..9903e6149 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -225,7 +225,7 @@ player.playbackRate(video_data.params.speed); function getCookieValue(name) { var value = document.cookie.split(";").filter(item => item.includes(name + "=")); - return (value != null && value.length >= 1) + return (value.length >= 1) ? value[0].substring((name + "=").length, value[0].length) : null; } @@ -237,13 +237,13 @@ function getCookieValue(name) { * @param {number} newSpeed New speed defined (null if unchanged) */ function updateCookie(newVolume, newSpeed) { - var volumeValue = newVolume != null ? newVolume : video_data.params.volume; - var speedValue = newSpeed != null ? newSpeed : video_data.params.speed; + var volumeValue = newVolume !== null ? newVolume : video_data.params.volume; + var speedValue = newSpeed !== null ? newSpeed : video_data.params.speed; var cookieValue = getCookieValue('PREFS'); var cookieData; - if (cookieValue != null) { + if (cookieValue !== null) { var cookieJson = JSON.parse(decodeURIComponent(cookieValue)); cookieJson.volume = volumeValue; cookieJson.speed = speedValue; @@ -260,7 +260,7 @@ function updateCookie(newVolume, newSpeed) { var domainUsed = window.location.hostname; // Fix for a bug in FF where the leading dot in the FQDN is not ignored - if (domainUsed.charAt(0) != '.' && !ipRegex.test(domainUsed) && domainUsed != 'localhost') + if (domainUsed.charAt(0) !== '.' && !ipRegex.test(domainUsed) && domainUsed !== 'localhost') domainUsed = '.' + window.location.hostname; document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' + @@ -334,7 +334,7 @@ if (video_data.params.autoplay) { if (!video_data.params.listen && video_data.params.quality === 'dash') { player.httpSourceSelector(); - if (video_data.params.quality_dash != "auto") { + if (video_data.params.quality_dash !== "auto") { player.ready(() => { player.on("loadedmetadata", () => { const qualityLevels = Array.from(player.qualityLevels()).sort((a, b) => a.height - b.height); @@ -357,7 +357,7 @@ if (!video_data.params.listen && video_data.params.quality === 'dash') { } } for (let i = 0; i < qualityLevels.length; i++) { - qualityLevels[i].enabled = (i == targetQualityLevel); + qualityLevels[i].enabled = (i === targetQualityLevel); } }); }); @@ -703,7 +703,7 @@ window.addEventListener('keydown', e => { var volumeHover = false; var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel'); - if (volumeSelector != null) { + if (volumeSelector !== null) { volumeSelector.onmouseover = function () { volumeHover = true; }; volumeSelector.onmouseout = function () { volumeHover = false; }; } @@ -723,9 +723,9 @@ window.addEventListener('keydown', e => { var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail))); event.preventDefault(); - if (delta == 1) { + if (delta === 1) { increase_volume(volumeStep); - } else if (delta == -1) { + } else if (delta === -1) { increase_volume(-volumeStep); } } @@ -750,7 +750,7 @@ if (player_data.preferred_caption_found) { } // Safari audio double duration fix -if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { +if (navigator.vendor === "Apple Computer, Inc." && video_data.params.listen) { player.on('loadedmetadata', function () { player.on('timeupdate', function () { if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) { diff --git a/assets/js/playlist_widget.js b/assets/js/playlist_widget.js index 0cf721a11..c7f4805f4 100644 --- a/assets/js/playlist_widget.js +++ b/assets/js/playlist_widget.js @@ -15,8 +15,8 @@ function add_playlist_video(target) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { option.innerText = '✓' + option.innerText; } } @@ -39,8 +39,8 @@ function add_playlist_item(target) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { tile.style.display = ''; } } @@ -63,8 +63,8 @@ function remove_playlist_item(target) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { tile.style.display = ''; } } diff --git a/assets/js/subscribe_widget.js b/assets/js/subscribe_widget.js index bdd5d5812..d44d65da6 100644 --- a/assets/js/subscribe_widget.js +++ b/assets/js/subscribe_widget.js @@ -29,8 +29,8 @@ function subscribe(retries = 5) { subscribe_button.innerHTML = '' + subscribe_data.unsubscribe_text + ' | ' + subscribe_data.sub_count_text + ''; xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { subscribe_button.onclick = subscribe; subscribe_button.innerHTML = fallback; } @@ -69,8 +69,8 @@ function unsubscribe(retries = 5) { subscribe_button.innerHTML = '' + subscribe_data.subscribe_text + ' | ' + subscribe_data.sub_count_text + ''; xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { subscribe_button.onclick = unsubscribe; subscribe_button.innerHTML = fallback; } diff --git a/assets/js/watch.js b/assets/js/watch.js index 578d4ac0b..ebc779057 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -117,7 +117,7 @@ function number_with_separator(val) { } function get_playlist(plid, retries) { - if (retries == undefined) retries = 5; + if (retries === undefined) retries = 5; playlist = document.getElementById('playlist'); if (retries <= 0) { @@ -147,8 +147,8 @@ function get_playlist(plid, retries) { xhr.open('GET', plid_url, true); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { playlist.innerHTML = xhr.response.playlistHtml; var nextVideo = document.getElementById(xhr.response.nextVideo); nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop; @@ -210,7 +210,7 @@ function get_playlist(plid, retries) { } function get_reddit_comments(retries) { - if (retries == undefined) retries = 5; + if (retries === undefined) retries = 5; comments = document.getElementById('comments'); if (retries <= 0) { @@ -232,8 +232,8 @@ function get_reddit_comments(retries) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { comments.innerHTML = ' \
\

\ @@ -287,7 +287,7 @@ function get_reddit_comments(retries) { } function get_youtube_comments(retries) { - if (retries == undefined) retries = 5; + if (retries === undefined) retries = 5; comments = document.getElementById('comments'); if (retries <= 0) { @@ -310,8 +310,8 @@ function get_youtube_comments(retries) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { comments.innerHTML = ' \
\

\ @@ -384,8 +384,8 @@ function get_youtube_replies(target, load_more, load_replies) { xhr.open('GET', url, true); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { if (load_more) { body = body.parentNode.parentNode; body.removeChild(body.lastElementChild); diff --git a/assets/js/watched_widget.js b/assets/js/watched_widget.js index 22afb0542..bd037c2be 100644 --- a/assets/js/watched_widget.js +++ b/assets/js/watched_widget.js @@ -14,8 +14,8 @@ function mark_watched(target) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { tile.style.display = ''; } } @@ -39,8 +39,8 @@ function mark_unwatched(target) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status != 200) { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { count.innerText = count.innerText - 1 + 2; tile.style.display = ''; }