diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-06-07 19:56:41 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-06-07 21:13:50 -0500 |
| commit | 8c944815bcb1630739f0f5ba1994e051e67527e7 (patch) | |
| tree | 4cb778c37d316a547e6981ed87f95631e4bb8dc8 /assets | |
| parent | f065a21542fd9d7587b89c426327c3c83a24c2bc (diff) | |
| download | invidious-8c944815bcb1630739f0f5ba1994e051e67527e7.tar.gz invidious-8c944815bcb1630739f0f5ba1994e051e67527e7.tar.bz2 invidious-8c944815bcb1630739f0f5ba1994e051e67527e7.zip | |
Minor refactor
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/js/embed.js | 6 | ||||
| -rw-r--r-- | assets/js/notifications.js | 11 | ||||
| -rw-r--r-- | assets/js/player.js | 28 | ||||
| -rw-r--r-- | assets/js/subscribe_widget.js | 10 | ||||
| -rw-r--r-- | assets/js/watch.js | 30 | ||||
| -rw-r--r-- | assets/js/watched_widget.js | 2 |
6 files changed, 43 insertions, 44 deletions
diff --git a/assets/js/embed.js b/assets/js/embed.js index d2116b2e..283bc06d 100644 --- a/assets/js/embed.js +++ b/assets/js/embed.js @@ -1,5 +1,5 @@ -function get_playlist(plid, timeouts = 0) { - if (timeouts > 10) { +function get_playlist(plid, timeouts = 1) { + if (timeouts >= 10) { console.log('Failed to pull playlist'); return; } @@ -52,7 +52,7 @@ function get_playlist(plid, timeouts = 0) { } xhr.ontimeout = function () { - console.log('Pulling playlist timed out.'); + console.log('Pulling playlist timed out... ' + timeouts + '/10'); get_playlist(plid, timeouts++); } } diff --git a/assets/js/notifications.js b/assets/js/notifications.js index 90b8c4f0..7a112350 100644 --- a/assets/js/notifications.js +++ b/assets/js/notifications.js @@ -1,7 +1,7 @@ var notifications, delivered; -function get_subscriptions(callback, failures = 1) { - if (failures >= 10) { +function get_subscriptions(callback, timeouts = 1) { + if (timeouts >= 10) { return } @@ -16,16 +16,13 @@ function get_subscriptions(callback, failures = 1) { if (xhr.status === 200) { subscriptions = xhr.response; callback(subscriptions); - } else { - console.log('Pulling subscriptions failed... ' + failures + '/10'); - get_subscriptions(callback, failures++) } } } xhr.ontimeout = function () { - console.log('Pulling subscriptions failed... ' + failures + '/10'); - get_subscriptions(callback, failures++); + console.log('Pulling subscriptions timed out... ' + timeouts + '/10'); + get_subscriptions(callback, timeouts++); } } diff --git a/assets/js/player.js b/assets/js/player.js index 82372185..2b546ff4 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -1,20 +1,20 @@ var options = { - preload: "auto", + preload: 'auto', liveui: true, playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0], controlBar: { children: [ - "playToggle", - "volumePanel", - "currentTimeDisplay", - "timeDivider", - "durationDisplay", - "progressControl", - "remainingTimeDisplay", - "captionsButton", - "qualitySelector", - "playbackRateMenuButton", - "fullscreenToggle" + 'playToggle', + 'volumePanel', + 'currentTimeDisplay', + 'timeDivider', + 'durationDisplay', + 'progressControl', + 'remainingTimeDisplay', + 'captionsButton', + 'qualitySelector', + 'playbackRateMenuButton', + 'fullscreenToggle' ] } } @@ -29,7 +29,7 @@ short_url = location.origin + '/' + video_data.id + embed_url.search; embed_url = location.origin + '/embed/' + video_data.id + embed_url.search; var shareOptions = { - socials: ["fbFeed", "tw", "reddit", "email"], + socials: ['fbFeed', 'tw', 'reddit', 'email'], url: short_url, title: player_data.title, @@ -38,7 +38,7 @@ var shareOptions = { embedCode: "<iframe id='ivplayer' type='text/html' width='640' height='360' src='" + embed_url + "' frameborder='0'></iframe>" } -var player = videojs("player", options, function () { +var player = videojs('player', options, function () { this.hotkeys({ volumeStep: 0.1, seekStep: 5, diff --git a/assets/js/subscribe_widget.js b/assets/js/subscribe_widget.js index 8f055e26..7a7f806d 100644 --- a/assets/js/subscribe_widget.js +++ b/assets/js/subscribe_widget.js @@ -7,7 +7,7 @@ if (subscribe_button.getAttribute('data-type') === 'subscribe') { subscribe_button.onclick = unsubscribe; } -function subscribe(timeouts = 0) { +function subscribe(timeouts = 1) { if (timeouts >= 10) { console.log('Failed to subscribe.'); return; @@ -19,7 +19,7 @@ function subscribe(timeouts = 0) { xhr.responseType = 'json'; xhr.timeout = 20000; xhr.open('POST', url, true); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('csrf_token=' + subscribe_data.csrf_token); var fallback = subscribe_button.innerHTML; @@ -36,12 +36,12 @@ function subscribe(timeouts = 0) { } xhr.ontimeout = function () { - console.log('Subscribing timed out.'); + console.log('Subscribing timed out... ' + timeouts + '/10'); subscribe(timeouts++); } } -function unsubscribe(timeouts = 0) { +function unsubscribe(timeouts = 1) { if (timeouts >= 10) { console.log('Failed to subscribe'); return; @@ -70,7 +70,7 @@ function unsubscribe(timeouts = 0) { } xhr.ontimeout = function () { - console.log('Unsubscribing timed out.'); + console.log('Unsubscribing timed out... ' + timeouts + '/10'); unsubscribe(timeouts++); } } diff --git a/assets/js/watch.js b/assets/js/watch.js index c9cac43b..80da3ee6 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -109,10 +109,10 @@ function number_with_separator(val) { return val; } -function get_playlist(plid, timeouts = 0) { +function get_playlist(plid, timeouts = 1) { playlist = document.getElementById('playlist'); - if (timeouts > 10) { + if (timeouts >= 10) { console.log('Failed to pull playlist'); playlist.innerHTML = ''; return; @@ -175,18 +175,19 @@ function get_playlist(plid, timeouts = 0) { } xhr.ontimeout = function () { - console.log('Pulling playlist timed out.'); playlist = document.getElementById('playlist'); playlist.innerHTML = '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>'; - get_playlist(plid, timeouts + 1); + + console.log('Pulling playlist timed out... ' + timeouts + '/10'); + get_playlist(plid, timeouts++); } } -function get_reddit_comments(timeouts = 0) { +function get_reddit_comments(timeouts = 1) { comments = document.getElementById('comments'); - if (timeouts > 10) { + if (timeouts >= 10) { console.log('Failed to pull comments'); comments.innerHTML = ''; return; @@ -238,7 +239,8 @@ function get_reddit_comments(timeouts = 0) { comments.children[0].children[1].children[0].onclick = swap_comments; } else { if (video_data.params.comments[1] === 'youtube') { - get_youtube_comments(timeouts + 1); + console.log('Pulling comments timed out... ' + timeouts + '/10'); + get_youtube_comments(timeouts++); } else { comments.innerHTML = fallback; } @@ -247,15 +249,15 @@ function get_reddit_comments(timeouts = 0) { } xhr.ontimeout = function () { - console.log('Pulling comments timed out.'); - get_reddit_comments(timeouts + 1); + console.log('Pulling comments timed out... ' + timeouts + '/10'); + get_reddit_comments(timeouts++); } } -function get_youtube_comments(timeouts = 0) { +function get_youtube_comments(timeouts = 1) { comments = document.getElementById('comments'); - if (timeouts > 10) { + if (timeouts >= 10) { console.log('Failed to pull comments'); comments.innerHTML = ''; return; @@ -303,7 +305,7 @@ function get_youtube_comments(timeouts = 0) { comments.children[0].children[1].children[0].onclick = swap_comments; } else { if (video_data.params.comments[1] === 'youtube') { - get_youtube_comments(timeouts + 1); + get_youtube_comments(timeouts++); } else { comments.innerHTML = ''; } @@ -312,10 +314,10 @@ function get_youtube_comments(timeouts = 0) { } xhr.ontimeout = function () { - console.log('Pulling comments timed out.'); comments.innerHTML = '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>'; - get_youtube_comments(timeouts + 1); + console.log('Pulling comments timed out... ' + timeouts + '/10'); + get_youtube_comments(timeouts++); } } diff --git a/assets/js/watched_widget.js b/assets/js/watched_widget.js index 304a7688..280da83a 100644 --- a/assets/js/watched_widget.js +++ b/assets/js/watched_widget.js @@ -22,7 +22,7 @@ function mark_watched(target) { function mark_unwatched(target) { var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode; - tile.style.display = "none"; + tile.style.display = 'none'; var count = document.getElementById('count') count.innerText = count.innerText - 1; |
