summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/css/default.css29
-rw-r--r--assets/css/player.css3
-rw-r--r--assets/css/search.css118
-rw-r--r--assets/js/community.js27
-rw-r--r--assets/js/embed.js26
-rw-r--r--assets/js/handlers.js22
-rw-r--r--assets/js/notifications.js31
-rw-r--r--assets/js/player.js264
-rw-r--r--assets/js/playlist_widget.js23
-rw-r--r--assets/js/silvermine-videojs-quality-selector.min.js4
-rw-r--r--assets/js/subscribe_widget.js48
-rw-r--r--assets/js/themes.js23
-rw-r--r--assets/js/watch.js130
-rw-r--r--assets/js/watched_widget.js19
14 files changed, 481 insertions, 286 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index 8b2b3578..49069c92 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -15,6 +15,11 @@ body {
background-color: rgb(255, 0, 0, 0.5);
}
+.underlined {
+ border-bottom: 1px solid;
+ margin-bottom: 20px;
+}
+
.channel-profile > * {
font-size: 1.17em;
font-weight: bold;
@@ -475,30 +480,6 @@ body.dark-theme {
}
}
-#filters {
- display: inline;
- margin-top: 15px;
-}
-
-#filters > div {
- display: inline-block;
-}
-
-#filters > summary {
- display: block;
- margin-bottom: 15px;
-}
-
-#filters > summary::before {
- content: "[ + ]";
- font-size: 1.5em;
-}
-
-#filters[open] > summary::before {
- content: "[ - ]";
- font-size: 1.5em;
-}
-
/*With commit d9528f5 all contents of the page is now within a flexbox. However,
the hr element is rendered improperly within one.
See https://stackoverflow.com/a/34372979 for more info */
diff --git a/assets/css/player.css b/assets/css/player.css
index 120fd2f8..304375b5 100644
--- a/assets/css/player.css
+++ b/assets/css/player.css
@@ -70,6 +70,9 @@
margin-bottom: 2em;
}
+.video-js.player-style-youtube .vjs-progress-control .vjs-progress-holder, .video-js.player-style-youtube .vjs-progress-control {height: 5px;
+margin-bottom: 10px;}
+
ul.vjs-menu-content::-webkit-scrollbar {
display: none;
}
diff --git a/assets/css/search.css b/assets/css/search.css
new file mode 100644
index 00000000..5ca141d0
--- /dev/null
+++ b/assets/css/search.css
@@ -0,0 +1,118 @@
+summary {
+ /* This should hide the marker */
+ display: block;
+
+ font-size: 1.17em;
+ font-weight: bold;
+ margin: 0 auto 10px auto;
+ cursor: pointer;
+}
+
+summary::-webkit-details-marker,
+summary::marker { display: none; }
+
+summary:before {
+ border-radius: 5px;
+ content: "[ + ]";
+ margin: -2px 10px 0 10px;
+ padding: 1px 0 3px 0;
+ text-align: center;
+ width: 40px;
+}
+
+details[open] > summary:before { content: "[ − ]"; }
+
+
+#filters-box {
+ padding: 10px 20px 20px 10px;
+ margin: 10px 15px;
+}
+#filters-flex {
+ display: flex;
+ flex-wrap: wrap;
+ flex-direction: row;
+ align-items: flex-start;
+ align-content: flex-start;
+ justify-content: flex-start;
+}
+
+
+fieldset, legend {
+ display: contents !important;
+ border: none !important;
+ margin: 0 !important;
+ padding: 0 !important;
+}
+
+
+.filter-column {
+ display: inline-block;
+ display: inline-flex;
+ width: max-content;
+ min-width: max-content;
+ max-width: 16em;
+ margin: 15px;
+ flex-grow: 2;
+ flex-basis: auto;
+ flex-direction: column;
+}
+.filter-name, .filter-options {
+ display: block;
+ padding: 5px 10px;
+ margin: 0;
+ text-align: start;
+}
+
+.filter-options div { margin: 6px 0; }
+.filter-options div * { vertical-align: middle; }
+.filter-options label { margin: 0 10px; }
+
+
+#filters-apply { text-align: end; }
+
+/* Error message */
+
+.no-results-error {
+ text-align: center;
+ line-height: 180%;
+ font-size: 110%;
+ padding: 15px 15px 125px 15px;
+}
+
+/* Responsive rules */
+
+@media only screen and (max-width: 800px) {
+ summary { font-size: 1.30em; }
+ #filters-box {
+ margin: 10px 0 0 0;
+ padding: 0;
+ }
+ #filters-apply {
+ text-align: center;
+ padding: 15px;
+ }
+}
+
+/* Light theme */
+
+.light-theme #filters-box {
+ background: #dfdfdf;
+}
+
+@media (prefers-color-scheme: light) {
+ .no-theme #filters-box {
+ background: #dfdfdf;
+ }
+}
+
+/* Dark theme */
+
+.dark-theme #filters-box {
+ background: #373737;
+}
+
+@media (prefers-color-scheme: dark) {
+ .no-theme #filters-box {
+ background: #373737;
+ }
+}
diff --git a/assets/js/community.js b/assets/js/community.js
index 4077f1cd..44066a58 100644
--- a/assets/js/community.js
+++ b/assets/js/community.js
@@ -1,19 +1,20 @@
-var community_data = JSON.parse(document.getElementById('community_data').innerHTML);
+'use strict';
+var community_data = JSON.parse(document.getElementById('community_data').textContent);
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
-}
+};
function hide_youtube_replies(event) {
var target = event.target;
- sub_text = target.getAttribute('data-inner-text');
- inner_text = target.getAttribute('data-sub-text');
+ var sub_text = target.getAttribute('data-inner-text');
+ var inner_text = target.getAttribute('data-sub-text');
- body = target.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.children[1];
body.style.display = 'none';
target.innerHTML = sub_text;
@@ -25,10 +26,10 @@ function hide_youtube_replies(event) {
function show_youtube_replies(event) {
var target = event.target;
- sub_text = target.getAttribute('data-inner-text');
- inner_text = target.getAttribute('data-sub-text');
+ var sub_text = target.getAttribute('data-inner-text');
+ var inner_text = target.getAttribute('data-sub-text');
- body = target.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.children[1];
body.style.display = '';
target.innerHTML = sub_text;
@@ -63,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);
@@ -92,12 +93,12 @@ function get_youtube_replies(target, load_more) {
body.innerHTML = fallback;
}
}
- }
+ };
xhr.ontimeout = function () {
- console.log('Pulling comments failed.');
+ console.warn('Pulling comments failed.');
body.innerHTML = fallback;
- }
+ };
xhr.send();
}
diff --git a/assets/js/embed.js b/assets/js/embed.js
index 9d0be0ea..7e9ac605 100644
--- a/assets/js/embed.js
+++ b/assets/js/embed.js
@@ -1,19 +1,21 @@
-var video_data = JSON.parse(document.getElementById('video_data').innerHTML);
+'use strict';
+var video_data = JSON.parse(document.getElementById('video_data').textContent);
function get_playlist(plid, retries) {
- if (retries == undefined) retries = 5;
+ if (retries === undefined) retries = 5;
if (retries <= 0) {
- console.log('Failed to pull playlist');
+ console.warn('Failed to pull playlist');
return;
}
+ var plid_url;
if (plid.startsWith('RD')) {
- var plid_url = '/api/v1/mixes/' + plid +
+ plid_url = '/api/v1/mixes/' + plid +
'?continuation=' + video_data.id +
'&format=html&hl=' + video_data.preferences.locale;
} else {
- var plid_url = '/api/v1/playlists/' + plid +
+ plid_url = '/api/v1/playlists/' + plid +
'?index=' + video_data.index +
'&continuation' + video_data.id +
'&format=html&hl=' + video_data.preferences.locale;
@@ -57,17 +59,17 @@ function get_playlist(plid, retries) {
}
}
}
- }
+ };
xhr.onerror = function () {
- console.log('Pulling playlist failed... ' + retries + '/5');
- setTimeout(function () { get_playlist(plid, retries - 1) }, 1000);
- }
+ console.warn('Pulling playlist failed... ' + retries + '/5');
+ setTimeout(function () { get_playlist(plid, retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
- console.log('Pulling playlist failed... ' + retries + '/5');
+ console.warn('Pulling playlist failed... ' + retries + '/5');
get_playlist(plid, retries - 1);
- }
+ };
xhr.send();
}
@@ -96,7 +98,7 @@ window.addEventListener('load', function (e) {
}
if (video_data.video_series.length !== 0) {
- url.searchParams.set('playlist', video_data.video_series.join(','))
+ url.searchParams.set('playlist', video_data.video_series.join(','));
}
location.assign(url.pathname + url.search);
diff --git a/assets/js/handlers.js b/assets/js/handlers.js
index 02175957..3224e668 100644
--- a/assets/js/handlers.js
+++ b/assets/js/handlers.js
@@ -76,7 +76,7 @@
});
n2a(document.querySelectorAll('[data-onrange="update_volume_value"]')).forEach(function (e) {
- var cb = function () { update_volume_value(e); }
+ var cb = function () { update_volume_value(e); };
e.oninput = cb;
e.onchange = cb;
});
@@ -102,13 +102,13 @@
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 = '';
}
}
- }
+ };
var csrf_token = target.parentNode.querySelector('input[name="csrf_token"]').value;
xhr.send('csrf_token=' + csrf_token);
@@ -131,20 +131,20 @@
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 = '';
}
}
- }
+ };
var csrf_token = target.parentNode.querySelector('input[name="csrf_token"]').value;
xhr.send('csrf_token=' + csrf_token);
}
// Handle keypresses
- window.addEventListener('keydown', (event) => {
+ window.addEventListener('keydown', function (event) {
// Ignore modifier keys
if (event.ctrlKey || event.metaKey) return;
@@ -152,14 +152,14 @@
let focused_tag = document.activeElement.tagName.toLowerCase();
const allowed = /^(button|checkbox|file|radio|submit)$/;
- if (focused_tag === "textarea") return;
- if (focused_tag === "input") {
+ if (focused_tag === 'textarea') return;
+ if (focused_tag === 'input') {
let focused_type = document.activeElement.type.toLowerCase();
if (!focused_type.match(allowed)) return;
}
// 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 3d1ec1ed..ec5f6dd3 100644
--- a/assets/js/notifications.js
+++ b/assets/js/notifications.js
@@ -1,9 +1,10 @@
-var notification_data = JSON.parse(document.getElementById('notification_data').innerHTML);
+'use strict';
+var notification_data = JSON.parse(document.getElementById('notification_data').textContent);
var notifications, delivered;
function get_subscriptions(callback, retries) {
- if (retries == undefined) retries = 5;
+ if (retries === undefined) retries = 5;
if (retries <= 0) {
return;
@@ -17,21 +18,21 @@ function get_subscriptions(callback, retries) {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
- subscriptions = xhr.response;
+ var subscriptions = xhr.response;
callback(subscriptions);
}
}
- }
+ };
xhr.onerror = function () {
- console.log('Pulling subscriptions failed... ' + retries + '/5');
- setTimeout(function () { get_subscriptions(callback, retries - 1) }, 1000);
- }
+ console.warn('Pulling subscriptions failed... ' + retries + '/5');
+ setTimeout(function () { get_subscriptions(callback, retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
- console.log('Pulling subscriptions failed... ' + retries + '/5');
+ console.warn('Pulling subscriptions failed... ' + retries + '/5');
get_subscriptions(callback, retries - 1);
- }
+ };
xhr.send();
}
@@ -40,7 +41,7 @@ function create_notification_stream(subscriptions) {
notifications = new SSE(
'/api/v1/auth/notifications?fields=videoId,title,author,authorId,publishedText,published,authorThumbnails,liveNow', {
withCredentials: true,
- payload: 'topics=' + subscriptions.map(function (subscription) { return subscription.authorId }).join(','),
+ payload: 'topics=' + subscriptions.map(function (subscription) { return subscription.authorId; }).join(','),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
delivered = [];
@@ -53,7 +54,7 @@ function create_notification_stream(subscriptions) {
}
var notification = JSON.parse(event.data);
- console.log('Got notification:', notification);
+ console.info('Got notification:', notification);
if (start_time < notification.published && !delivered.includes(notification.videoId)) {
if (Notification.permission === 'granted') {
@@ -67,7 +68,7 @@ function create_notification_stream(subscriptions) {
system_notification.onclick = function (event) {
window.open('/watch?v=' + event.currentTarget.tag, '_blank');
- }
+ };
}
delivered.push(notification.videoId);
@@ -82,16 +83,16 @@ function create_notification_stream(subscriptions) {
'<i class="icon ion-ios-notifications-outline"></i>';
}
}
- }
+ };
notifications.addEventListener('error', handle_notification_error);
notifications.stream();
}
function handle_notification_error(event) {
- console.log('Something went wrong with notifications, trying to reconnect...');
+ console.warn('Something went wrong with notifications, trying to reconnect...');
notifications = { close: function () { } };
- setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
+ setTimeout(function () { get_subscriptions(create_notification_stream); }, 1000);
}
window.addEventListener('load', function (e) {
diff --git a/assets/js/player.js b/assets/js/player.js
index a1a2cd16..6ddb1158 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -1,5 +1,6 @@
-var player_data = JSON.parse(document.getElementById('player_data').innerHTML);
-var video_data = JSON.parse(document.getElementById('video_data').innerHTML);
+'use strict';
+var player_data = JSON.parse(document.getElementById('player_data').textContent);
+var video_data = JSON.parse(document.getElementById('video_data').textContent);
var options = {
preload: 'auto',
@@ -27,7 +28,7 @@ var options = {
overrideNative: true
}
}
-}
+};
if (player_data.aspect_ratio) {
options.aspectRatio = player_data.aspect_ratio;
@@ -38,7 +39,7 @@ embed_url.searchParams.delete('v');
var short_url = location.origin + '/' + video_data.id + embed_url.search;
embed_url = location.origin + '/embed/' + video_data.id + embed_url.search;
-var save_player_pos_key = "save_player_pos";
+var save_player_pos_key = 'save_player_pos';
videojs.Vhs.xhr.beforeRequest = function(options) {
if (options.uri.indexOf('videoplayback') === -1 && options.uri.indexOf('local=true') === -1) {
@@ -49,6 +50,42 @@ videojs.Vhs.xhr.beforeRequest = function(options) {
var player = videojs('player', options);
+player.on('error', () => {
+ if (video_data.params.quality !== 'dash') {
+ if (!player.currentSrc().includes("local=true") && !video_data.local_disabled) {
+ var currentSources = player.currentSources();
+ for (var i = 0; i < currentSources.length; i++) {
+ currentSources[i]["src"] += "&local=true"
+ }
+ player.src(currentSources)
+ }
+ else if (player.error().code === 2 || player.error().code === 4) {
+ setTimeout(function (event) {
+ console.log('An error occurred in the player, reloading...');
+
+ var currentTime = player.currentTime();
+ var playbackRate = player.playbackRate();
+ var paused = player.paused();
+
+ player.load();
+
+ if (currentTime > 0.5) currentTime -= 0.5;
+
+ player.currentTime(currentTime);
+ player.playbackRate(playbackRate);
+
+ if (!paused) player.play();
+ }, 10000);
+ }
+ }
+});
+
+if (video_data.params.quality == 'dash') {
+ player.reloadSourceOnError({
+ errorInterval: 10
+ });
+}
+
/**
* Function for add time argument to url
* @param {String} url
@@ -75,12 +112,12 @@ var shareOptions = {
description: player_data.description,
image: player_data.thumbnail,
get embedCode() {
- return "<iframe id='ivplayer' width='640' height='360' src='" +
- addCurrentTimeToURL(embed_url) + "' style='border:none;'></iframe>";
+ return '<iframe id="ivplayer" width="640" height="360" src="' +
+ addCurrentTimeToURL(embed_url) + '" style="border:none;"></iframe>';
}
};
-const storage = (() => {
+const storage = (function () {
try { if (localStorage.length !== -1) return localStorage; }
catch (e) { console.info('No storage available: ' + e); }
@@ -101,78 +138,57 @@ if (location.pathname.startsWith('/embed/')) {
// Detection code taken from https://stackoverflow.com/a/20293441
function isMobile() {
- try{ document.createEvent("TouchEvent"); return true; }
+ try{ document.createEvent('TouchEvent'); return true; }
catch(e){ return false; }
}
if (isMobile()) {
player.mobileUi();
- buttons = ["playToggle", "volumePanel", "captionsButton"];
+ var buttons = ['playToggle', 'volumePanel', 'captionsButton'];
- if (video_data.params.quality !== 'dash') buttons.push("qualitySelector")
+ if (video_data.params.quality !== 'dash') buttons.push('qualitySelector');
// Create new control bar object for operation buttons
- const ControlBar = videojs.getComponent("controlBar");
+ const ControlBar = videojs.getComponent('controlBar');
let operations_bar = new ControlBar(player, {
children: [],
playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
});
- buttons.slice(1).forEach(child => operations_bar.addChild(child))
+ buttons.slice(1).forEach(function (child) {operations_bar.addChild(child);});
// Remove operation buttons from primary control bar
- primary_control_bar = player.getChild("controlBar");
- buttons.forEach(child => primary_control_bar.removeChild(child));
+ var primary_control_bar = player.getChild('controlBar');
+ buttons.forEach(function (child) {primary_control_bar.removeChild(child);});
- operations_bar_element = operations_bar.el();
- operations_bar_element.className += " mobile-operations-bar"
- player.addChild(operations_bar)
+ var operations_bar_element = operations_bar.el();
+ operations_bar_element.className += ' mobile-operations-bar';
+ player.addChild(operations_bar);
// Playback menu doesn't work when it's initialized outside of the primary control bar
- playback_element = document.getElementsByClassName("vjs-playback-rate")[0]
- operations_bar_element.append(playback_element)
+ var playback_element = document.getElementsByClassName('vjs-playback-rate')[0];
+ operations_bar_element.append(playback_element);
// The share and http source selector element can't be fetched till the players ready.
- player.one("playing", () => {
- share_element = document.getElementsByClassName("vjs-share-control")[0]
- operations_bar_element.append(share_element)
-
- if (video_data.params.quality === 'dash') {
- http_source_selector = document.getElementsByClassName("vjs-http-source-selector vjs-menu-button")[0]
- operations_bar_element.append(http_source_selector)
- }
- })
-}
+ player.one('playing', function () {
+ var share_element = document.getElementsByClassName('vjs-share-control')[0];
+ operations_bar_element.append(share_element);
-player.on('error', function (event) {
- if (player.error().code === 2 || player.error().code === 4) {
- setTimeout(function (event) {
- console.log('An error occurred in the player, reloading...');
-
- var currentTime = player.currentTime();
- var playbackRate = player.playbackRate();
- var paused = player.paused();
-
- player.load();
-
- if (currentTime > 0.5) currentTime -= 0.5;
-
- player.currentTime(currentTime);
- player.playbackRate(playbackRate);
-
- if (!paused) player.play();
- }, 5000);
- }
-});
+ if (video_data.params.quality === 'dash') {
+ var http_source_selector = document.getElementsByClassName('vjs-http-source-selector vjs-menu-button')[0];
+ operations_bar_element.append(http_source_selector);
+ }
+ });
+}
// Enable VR video support
if (!video_data.params.listen && video_data.vr && video_data.params.vr_mode) {
- player.crossOrigin("anonymous")
+ player.crossOrigin('anonymous');
switch (video_data.projection_type) {
- case "EQUIRECTANGULAR":
- player.vr({projection: "equirectangular"});
- default: // Should only be "MESH" but we'll use this as a fallback.
- player.vr({projection: "EAC"});
+ case 'EQUIRECTANGULAR':
+ player.vr({projection: 'equirectangular'});
+ default: // Should only be 'MESH' but we'll use this as a fallback.
+ player.vr({projection: 'EAC'});
}
}
@@ -200,9 +216,71 @@ if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
player.volume(video_data.params.volume / 100);
player.playbackRate(video_data.params.speed);
+/**
+ * Method for getting the contents of a cookie
+ *
+ * @param {String} name Name of cookie
+ * @returns cookieValue
+ */
+function getCookieValue(name) {
+ var value = document.cookie.split(';').filter(function (item) {return item.includes(name + '=');});
+
+ return (value.length >= 1)
+ ? value[0].substring((name + '=').length, value[0].length)
+ : null;
+}
+
+/**
+ * Method for updating the 'PREFS' cookie (or creating it if missing)
+ *
+ * @param {number} newVolume New volume defined (null if unchanged)
+ * @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 cookieValue = getCookieValue('PREFS');
+ var cookieData;
+
+ if (cookieValue !== null) {
+ var cookieJson = JSON.parse(decodeURIComponent(cookieValue));
+ cookieJson.volume = volumeValue;
+ cookieJson.speed = speedValue;
+ cookieData = encodeURIComponent(JSON.stringify(cookieJson));
+ } else {
+ cookieData = encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue }));
+ }
+
+ // Set expiration in 2 year
+ var date = new Date();
+ date.setTime(date.getTime() + 63115200);
+
+ var ipRegex = /^((\d+\.){3}\d+|[A-Fa-f0-9]*:[A-Fa-f0-9:]*:[A-Fa-f0-9:]+)$/;
+ 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')
+ domainUsed = '.' + window.location.hostname;
+
+ document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
+ domainUsed + '; expires=' + date.toGMTString() + ';';
+
+ video_data.params.volume = volumeValue;
+ video_data.params.speed = speedValue;
+}
+
+player.on('ratechange', function () {
+ updateCookie(null, player.playbackRate());
+});
+
+player.on('volumechange', function () {
+ updateCookie(Math.ceil(player.volume() * 100), null);
+});
+
player.on('waiting', function () {
if (player.playbackRate() > 1 && player.liveTracker.isLive() && player.liveTracker.atLiveEdge()) {
- console.log('Player has caught up to source, resetting playbackRate.')
+ console.info('Player has caught up to source, resetting playbackRate.');
player.playbackRate(1);
}
});
@@ -213,13 +291,13 @@ if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.
if (video_data.params.save_player_pos) {
const url = new URL(location);
- const hasTimeParam = url.searchParams.has("t");
+ const hasTimeParam = url.searchParams.has('t');
const remeberedTime = get_video_time();
let lastUpdated = 0;
if(!hasTimeParam) set_seconds_after_start(remeberedTime);
- const updateTime = () => {
+ const updateTime = function () {
const raw = player.currentTime();
const time = Math.floor(raw);
@@ -229,7 +307,7 @@ if (video_data.params.save_player_pos) {
}
};
- player.on("timeupdate", updateTime);
+ player.on('timeupdate', updateTime);
}
else remove_all_video_times();
@@ -239,13 +317,13 @@ if (video_data.params.autoplay) {
player.ready(function () {
new Promise(function (resolve, reject) {
- setTimeout(() => resolve(1), 1);
+ setTimeout(function () {resolve(1);}, 1);
}).then(function (result) {
var promise = player.play();
if (promise !== undefined) {
- promise.then(_ => {
- }).catch(error => {
+ promise.then(function () {
+ }).catch(function (error) {
bpb.show();
});
}
@@ -256,16 +334,16 @@ if (video_data.params.autoplay) {
if (!video_data.params.listen && video_data.params.quality === 'dash') {
player.httpSourceSelector();
- 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);
+ if (video_data.params.quality_dash !== 'auto') {
+ player.ready(function () {
+ player.on('loadedmetadata', function () {
+ const qualityLevels = Array.from(player.qualityLevels()).sort(function (a, b) {return a.height - b.height;});
let targetQualityLevel;
switch (video_data.params.quality_dash) {
- case "best":
+ case 'best':
targetQualityLevel = qualityLevels.length - 1;
break;
- case "worst":
+ case 'worst':
targetQualityLevel = 0;
break;
default:
@@ -279,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);
}
});
});
@@ -313,10 +391,12 @@ if (!video_data.params.listen && video_data.params.annotations) {
}
}
}
- }
+ };
- window.addEventListener('__ar_annotation_click', e => {
- const { url, target, seconds } = e.detail;
+ window.addEventListener('__ar_annotation_click', function (e) {
+ const url = e.detail.url,
+ target = e.detail.target,
+ seconds = e.detail.seconds;
var path = new URL(url);
if (path.href.startsWith('https://www.youtube.com/watch?') && seconds) {
@@ -386,7 +466,7 @@ function get_video_time() {
return timestamp || 0;
}
- catch {
+ catch (e) {
return 0;
}
}
@@ -397,7 +477,7 @@ function set_all_video_times(times) {
try {
storage.setItem(save_player_pos_key, JSON.stringify(times));
} catch (e) {
- console.debug('set_all_video_times: ' + e);
+ console.warn('set_all_video_times: ' + e);
}
} else {
storage.removeItem(save_player_pos_key);
@@ -412,7 +492,7 @@ function get_all_video_times() {
try {
return JSON.parse(raw);
} catch (e) {
- console.debug('get_all_video_times: ' + e);
+ console.warn('get_all_video_times: ' + e);
}
}
}
@@ -506,7 +586,7 @@ function increase_playback_rate(steps) {
player.playbackRate(options.playbackRates[newIndex]);
}
-window.addEventListener('keydown', e => {
+window.addEventListener('keydown', function (e) {
if (e.target.tagName.toLowerCase() === 'input') {
// Ignore input when focus is on certain elements, e.g. form fields.
return;
@@ -625,7 +705,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; };
}
@@ -645,9 +725,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);
}
}
@@ -656,7 +736,7 @@ window.addEventListener('keydown', e => {
};
player.on('mousewheel', mouseScroll);
- player.on("DOMMouseScroll", mouseScroll);
+ player.on('DOMMouseScroll', mouseScroll);
}());
// Since videojs-share can sometimes be blocked, we defer it until last
@@ -666,35 +746,35 @@ if (player.share) {
// show the preferred caption by default
if (player_data.preferred_caption_found) {
- player.ready(() => {
+ player.ready(function () {
player.textTracks()[1].mode = 'showing';
});
}
// 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.currentTime(player.duration() + 1);
+ if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) {
+ player.currentTime(player.duration() - 1);
}
});
});
}
// Watch on Invidious link
-if (window.location.pathname.startsWith("/embed/")) {
+if (window.location.pathname.startsWith('/embed/')) {
const Button = videojs.getComponent('Button');
let watch_on_invidious_button = new Button(player);
// Create hyperlink for current instance
- redirect_element = document.createElement("a");
- redirect_element.setAttribute("href", `http://${window.location.host}/watch?v=${window.location.pathname.replace("/embed/","")}`)
- redirect_element.appendChild(document.createTextNode("Invidious"))
+ var redirect_element = document.createElement('a');
+ redirect_element.setAttribute('href', location.pathname.replace('/embed/', '/watch?v='));
+ redirect_element.appendChild(document.createTextNode('Invidious'));
- watch_on_invidious_button.el().appendChild(redirect_element)
- watch_on_invidious_button.addClass("watch-on-invidious")
+ watch_on_invidious_button.el().appendChild(redirect_element);
+ watch_on_invidious_button.addClass('watch-on-invidious');
- cb = player.getChild('ControlBar')
- cb.addChild(watch_on_invidious_button)
-};
+ var cb = player.getChild('ControlBar');
+ cb.addChild(watch_on_invidious_button);
+}
diff --git a/assets/js/playlist_widget.js b/assets/js/playlist_widget.js
index 0ec27859..c2565874 100644
--- a/assets/js/playlist_widget.js
+++ b/assets/js/playlist_widget.js
@@ -1,4 +1,5 @@
-var playlist_data = JSON.parse(document.getElementById('playlist_data').innerHTML);
+'use strict';
+var playlist_data = JSON.parse(document.getElementById('playlist_data').textContent);
function add_playlist_video(target) {
var select = target.parentNode.children[0].children[1];
@@ -14,12 +15,12 @@ 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;
}
}
- }
+ };
xhr.send('csrf_token=' + playlist_data.csrf_token);
}
@@ -38,12 +39,12 @@ 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 = '';
}
}
- }
+ };
xhr.send('csrf_token=' + playlist_data.csrf_token);
}
@@ -62,12 +63,12 @@ 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 = '';
}
}
- }
+ };
xhr.send('csrf_token=' + playlist_data.csrf_token);
-} \ No newline at end of file
+}
diff --git a/assets/js/silvermine-videojs-quality-selector.min.js b/assets/js/silvermine-videojs-quality-selector.min.js
index 88621e8d..1877047d 100644
--- a/assets/js/silvermine-videojs-quality-selector.min.js
+++ b/assets/js/silvermine-videojs-quality-selector.min.js
@@ -1,4 +1,4 @@
-/*! @silvermine/videojs-quality-selector 2020-03-02 v1.1.2-36-g64d620a-dirty */
+/*! @silvermine/videojs-quality-selector 2022-04-13 v1.1.2-43-gaa06e72-dirty */
-!function u(o,c,a){function l(e,n){if(!c[e]){if(!o[e]){var t="function"==typeof require&&require;if(!n&&t)return t(e,!0);if(s)return s(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var i=c[e]={exports:{}};o[e][0].call(i.exports,function(n){return l(o[e][1][n]||n)},i,i.exports,u,o,c,a)}return c[e].exports}for(var s="function"==typeof require&&require,n=0;n<a.length;n++)l(a[n]);return l}({1:[function(n,e,t){!function(){var u=!1,o=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(n){var i=this.prototype;u=!0;var e=new this;for(var t in u=!1,n)e[t]="function"==typeof n[t]&&"function"==typeof i[t]&&o.test(n[t])?function(t,r){return function(){var n=this._super;this._super=i[t];var e=r.apply(this,arguments);return this._super=n,e}}(t,n[t]):n[t];function r(){!u&&this.init&&this.init.apply(this,arguments)}return((r.prototype=e).constructor=r).extend=arguments.callee,r},e.exports=Class}()},{}],2:[function(n,J,$){(function(V){!function(){function t(){}var n="object"==typeof self&&self.self===self&&self||"object"==typeof V&&V.global===V&&V||this||{},e=n._,r=Array.prototype,o=Object.prototype,f="undefined"!=typeof Symbol?Symbol.prototype:null,i=r.push,a=r.slice,p=o.toString,u=o.hasOwnProperty,c=Array.isArray,l=Object.keys,s=Object.create,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};void 0===$||$.nodeType?n._=h:(void 0!==J&&!J.nodeType&&J.exports&&($=J.exports=h),$._=h),h.VERSION="1.9.1";function d(i,u,n){if(void 0===u)return i;switch(null==n?3:n){case 1:return function(n){return i.call(u,n)};case 3:return function(n,e,t){return i.call(u,n,e,t)};case 4:return function(n,e,t,r){return i.call(u,n,e,t,r)}}return function(){return i.apply(u,arguments)}}function v(n,e,t){return h.iteratee!==y?h.iteratee(n,e):null==n?h.identity:h.isFunction(n)?d(n,e,t):h.isObject(n)&&!h.isArray(n)?h.matcher(n):h.property(n)}var y;h.iteratee=y=function(n,e){return v(n,e,1/0)};function g(i,u){return u=null==u?i.length-1:+u,function(){for(var n=Math.max(arguments.length-u,0),e=Array(n),t=0;t<n;t++)e[t]=arguments[t+u];switch(u){case 0:return i.call(this,e);case 1:return i.call(this,arguments[0],e);case 2:return i.call(this,arguments[0],arguments[1],e)}var r=Array(u+1);for(t=0;t<u;t++)r[t]=arguments[t];return r[u]=e,i.apply(this,r)}}function S(n){if(!h.isObject(n))return{};if(s)return s(n);t.prototype=n;var e=new t;return t.prototype=null,e}function m(e){return function(n){return null==n?void 0:n[e]}}function _(n,e){return null!=n&&u.call(n,e)}function b(n,e){for(var t=e.length,r=0;r<t;r++){if(null==n)return;n=n[e[r]]}return t?n:void 0}function x(n){var e=j(n);return"number"==typeof e&&0<=e&&e<=k}var k=Math.pow(2,53)-1,j=m("length");h.each=h.forEach=function(n,e,t){var r,i;if(e=d(e,t),x(n))for(r=0,i=n.length;r<i;r++)e(n[r],r,n);else{var u=h.keys(n);for(r=0,i=u.length;r<i;r++)e(n[u[r]],u[r],n)}return n},h.map=h.collect=function(n,e,t){e=v(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var c=r?r[o]:o;u[o]=e(n[c],c,n)}return u};function E(a){return function(n,e,t,r){var i=3<=arguments.length;return function(n,e,t,r){var i=!x(n)&&h.keys(n),u=(i||n).length,o=0<a?0:u-1;for(r||(t=n[i?i[o]:o],o+=a);0<=o&&o<u;o+=a){var c=i?i[o]:o;t=e(t,n[c],c,n)}return t}(n,d(e,r,4),t,i)}}h.reduce=h.foldl=h.inject=E(1),h.reduceRight=h.foldr=E(-1),h.find=h.detect=function(n,e,t){var r=(x(n)?h.findIndex:h.findKey)(n,e,t);if(void 0!==r&&-1!==r)return n[r]},h.filter=h.select=function(n,r,e){var i=[];return r=v(r,e),h.each(n,function(n,e,t){r(n,e,t)&&i.push(n)}),i},h.reject=function(n,e,t){return h.filter(n,h.negate(v(e)),t)},h.every=h.all=function(n,e,t){e=v(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!e(n[o],o,n))return!1}return!0},h.some=h.any=function(n,e,t){e=v(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(e(n[o],o,n))return!0}return!1},h.contains=h.includes=h.include=function(n,e,t,r){return x(n)||(n=h.values(n)),"number"==typeof t&&!r||(t=0),0<=h.indexOf(n,e,t)},h.invoke=g(function(n,t,r){var i,u;return h.isFunction(t)?u=t:h.isArray(t)&&(i=t.slice(0,-1),t=t[t.length-1]),h.map(n,function(n){var e=u;if(!e){if(i&&i.length&&(n=b(n,i)),null==n)return;e=n[t]}return null==e?e:e.apply(n,r)})}),h.pluck=function(n,e){return h.map(n,h.property(e))},h.where=function(n,e){return h.filter(n,h.matcher(e))},h.findWhere=function(n,e){return h.find(n,h.matcher(e))},h.max=function(n,r,e){var t,i,u=-1/0,o=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&u<t&&(u=t);else r=v(r,e),h.each(n,function(n,e,t){i=r(n,e,t),(o<i||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},h.min=function(n,r,e){var t,i,u=1/0,o=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&t<u&&(u=t);else r=v(r,e),h.each(n,function(n,e,t){((i=r(n,e,t))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},h.shuffle=function(n){return h.sample(n,1/0)},h.sample=function(n,e,t){if(null==e||t)return x(n)||(n=h.values(n)),n[h.random(n.length-1)];var r=x(n)?h.clone(n):h.values(n),i=j(r);e=Math.max(Math.min(e,i),0);for(var u=i-1,o=0;o<e;o++){var c=h.random(o,u),a=r[o];r[o]=r[c],r[c]=a}return r.slice(0,e)},h.sortBy=function(n,r,e){var i=0;return r=v(r,e),h.pluck(h.map(n,function(n,e,t){return{value:n,index:i++,criteria:r(n,e,t)}}).sort(function(n,e){var t=n.criteria,r=e.criteria;if(t!==r){if(r<t||void 0===t)return 1;if(t<r||void 0===r)return-1}return n.index-e.index}),"value")};function w(o,e){return function(r,i,n){var u=e?[[],[]]:{};return i=v(i,n),h.each(r,function(n,e){var t=i(n,e,r);o(u,n,t)}),u}}h.groupBy=w(function(n,e,t){_(n,t)?n[t].push(e):n[t]=[e]}),h.indexBy=w(function(n,e,t){n[t]=e}),h.countBy=w(function(n,e,t){_(n,t)?n[t]++:n[t]=1});var A=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;h.toArray=function(n){return n?h.isArray(n)?a.call(n):h.isString(n)?n.match(A):x(n)?h.map(n,h.identity):h.values(n):[]},h.size=function(n){return null==n?0:x(n)?n.length:h.keys(n).length},h.partition=w(function(n,e,t){n[t?0:1].push(e)},!0),h.first=h.head=h.take=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[0]:h.initial(n,n.length-e)},h.initial=function(n,e,t){return a.call(n,0,Math.max(0,n.length-(null==e||t?1:e)))},h.last=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[n.length-1]:h.rest(n,Math.max(0,n.length-e))},h.rest=h.tail=h.drop=function(n,e,t){return a.call(n,null==e||t?1:e)},h.compact=function(n){return h.filter(n,Boolean)};var T=function(n,e,t,r){for(var i=(r=r||[]).length,u=0,o=j(n);u<o;u++){var c=n[u];if(x(c)&&(h.isArray(c)||h.isArguments(c)))if(e)for(var a=0,l=c.length;a<l;)r[i++]=c[a++];else T(c,e,t,r),i=r.length;else t||(r[i++]=c)}return r};h.flatten=function(n,e){return T(n,e,!1)},h.without=g(function(n,e){return h.difference(n,e)}),h.uniq=h.unique=function(n,e,t,r){h.isBoolean(e)||(r=t,t=e,e=!1),null!=t&&(t=v(t,r));for(var i=[],u=[],o=0,c=j(n);o<c;o++){var a=n[o],l=t?t(a,o,n):a;e&&!t?(o&&u===l||i.push(a),u=l):t?h.contains(u,l)||(u.push(l),i.push(a)):h.contains(i,a)||i.push(a)}return i},h.union=g(function(n){return h.uniq(T(n,!0,!0))}),h.intersection=function(n){for(var e=[],t=arguments.length,r=0,i=j(n);r<i;r++){var u=n[r];if(!h.contains(e,u)){var o;for(o=1;o<t&&h.contains(arguments[o],u);o++);o===t&&e.push(u)}}return e},h.difference=g(function(n,e){return e=T(e,!0,!0),h.filter(n,function(n){return!h.contains(e,n)})}),h.unzip=function(n){for(var e=n&&h.max(n,j).length||0,t=Array(e),r=0;r<e;r++)t[r]=h.pluck(n,r);return t},h.zip=g(h.unzip),h.object=function(n,e){for(var t={},r=0,i=j(n);r<i;r++)e?t[n[r]]=e[r]:t[n[r][0]]=n[r][1];return t};function O(u){return function(n,e,t){e=v(e,t);for(var r=j(n),i=0<u?0:r-1;0<=i&&i<r;i+=u)if(e(n[i],i,n))return i;return-1}}h.findIndex=O(1),h.findLastIndex=O(-1),h.sortedIndex=function(n,e,t,r){for(var i=(t=v(t,r,1))(e),u=0,o=j(n);u<o;){var c=Math.floor((u+o)/2);t(n[c])<i?u=c+1:o=c}return u};function C(u,o,c){return function(n,e,t){var r=0,i=j(n);if("number"==typeof t)0<u?r=0<=t?t:Math.max(t+i,r):i=0<=t?Math.min(t+1,i):t+i+1;else if(c&&t&&i)return n[t=c(n,e)]===e?t:-1;if(e!=e)return 0<=(t=o(a.call(n,r,i),h.isNaN))?t+r:-1;for(t=0<u?r:i-1;0<=t&&t<i;t+=u)if(n[t]===e)return t;return-1}}h.indexOf=C(1,h.findIndex,h.sortedIndex),h.lastIndexOf=C(-1,h.findLastIndex),h.range=function(n,e,t){null==e&&(e=n||0,n=0),t=t||(e<n?-1:1);for(var r=Math.max(Math.ceil((e-n)/t),0),i=Array(r),u=0;u<r;u++,n+=t)i[u]=n;return i},h.chunk=function(n,e){if(null==e||e<1)return[];for(var t=[],r=0,i=n.length;r<i;)t.push(a.call(n,r,r+=e));return t};function I(n,e,t,r,i){if(!(r instanceof e))return n.apply(t,i);var u=S(n.prototype),o=n.apply(u,i);return h.isObject(o)?o:u}h.bind=g(function(e,t,r){if(!h.isFunction(e))throw new TypeError("Bind must be called on a function");var i=g(function(n){return I(e,i,t,this,r.concat(n))});return i}),h.partial=g(function(i,u){var o=h.partial.placeholder,c=function(){for(var n=0,e=u.length,t=Array(e),r=0;r<e;r++)t[r]=u[r]===o?arguments[n++]:u[r];for(;n<arguments.length;)t.push(arguments[n++]);return I(i,c,this,this,t)};return c}),(h.partial.placeholder=h).bindAll=g(function(n,e){var t=(e=T(e,!1,!1)).length;if(t<1)throw new Error("bindAll must be passed function names");for(;t--;){var r=e[t];n[r]=h.bind(n[r],n)}}),h.memoize=function(r,i){var u=function(n){var e=u.cache,t=""+(i?i.apply(this,arguments):n);return _(e,t)||(e[t]=r.apply(this,arguments)),e[t]};return u.cache={},u},h.delay=g(function(n,e,t){return setTimeout(function(){return n.apply(null,t)},e)}),h.defer=h.partial(h.delay,h,1),h.throttle=function(t,r,i){var u,o,c,a,l=0;i=i||{};function s(){l=!1===i.leading?0:h.now(),u=null,a=t.apply(o,c),u||(o=c=null)}function n(){var n=h.now();l||!1!==i.leading||(l=n);var e=r-(n-l);return o=this,c=arguments,e<=0||r<e?(u&&(clearTimeout(u),u=null),l=n,a=t.apply(o,c),u||(o=c=null)):u||!1===i.trailing||(u=setTimeout(s,e)),a}return n.cancel=function(){clearTimeout(u),l=0,u=o=c=null},n},h.debounce=function(t,r,i){function u(n,e){o=null,e&&(c=t.apply(n,e))}var o,c,n=g(function(n){if(o&&clearTimeout(o),i){var e=!o;o=setTimeout(u,r),e&&(c=t.apply(this,n))}else o=h.delay(u,r,this,n);return c});return n.cancel=function(){clearTimeout(o),o=null},n},h.wrap=function(n,e){return h.partial(e,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var t=arguments,r=t.length-1;return function(){for(var n=r,e=t[r].apply(this,arguments);n--;)e=t[n].call(this,e);return e}},h.after=function(n,e){return function(){if(--n<1)return e.apply(this,arguments)}},h.before=function(n,e){var t;return function(){return 0<--n&&(t=e.apply(this,arguments)),n<=1&&(e=null),t}},h.once=h.partial(h.before,2),h.restArguments=g;function F(n,e){var t=M.length,r=n.constructor,i=h.isFunction(r)&&r.prototype||o,u="constructor";for(_(n,u)&&!h.contains(e,u)&&e.push(u);t--;)(u=M[t])in n&&n[u]!==i[u]&&!h.contains(e,u)&&e.push(u)}var q=!{toString:null}.propertyIsEnumerable("toString"),M=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];h.keys=function(n){if(!h.isObject(n))return[];if(l)return l(n);var e=[];for(var t in n)_(n,t)&&e.push(t);return q&&F(n,e),e},h.allKeys=function(n){if(!h.isObject(n))return[];var e=[];for(var t in n)e.push(t);return q&&F(n,e),e},h.values=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=n[e[i]];return r},h.mapObject=function(n,e,t){e=v(e,t);for(var r=h.keys(n),i=r.length,u={},o=0;o<i;o++){var c=r[o];u[c]=e(n[c],c,n)}return u},h.pairs=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=[e[i],n[e[i]]];return r},h.invert=function(n){for(var e={},t=h.keys(n),r=0,i=t.length;r<i;r++)e[n[t[r]]]=t[r];return e},h.functions=h.methods=function(n){var e=[];for(var t in n)h.isFunction(n[t])&&e.push(t);return e.sort()};function N(a,l){return function(n){var e=arguments.length;if(l&&(n=Object(n)),e<2||null==n)return n;for(var t=1;t<e;t++)for(var r=arguments[t],i=a(r),u=i.length,o=0;o<u;o++){var c=i[o];l&&void 0!==n[c]||(n[c]=r[c])}return n}}h.extend=N(h.allKeys),h.extendOwn=h.assign=N(h.keys),h.findKey=function(n,e,t){e=v(e,t);for(var r,i=h.keys(n),u=0,o=i.length;u<o;u++)if(e(n[r=i[u]],r,n))return r};function R(n,e,t){return e in t}var Q,L;h.pick=g(function(n,e){var t={},r=e[0];if(null==n)return t;h.isFunction(r)?(1<e.length&&(r=d(r,e[1])),e=h.allKeys(n)):(r=R,e=T(e,!1,!1),n=Object(n));for(var i=0,u=e.length;i<u;i++){var o=e[i],c=n[o];r(c,o,n)&&(t[o]=c)}return t}),h.omit=g(function(n,t){var e,r=t[0];return h.isFunction(r)?(r=h.negate(r),1<t.length&&(e=t[1])):(t=h.map(T(t,!1,!1),String),r=function(n,e){return!h.contains(t,e)}),h.pick(n,r,e)}),h.defaults=N(h.allKeys,!0),h.create=function(n,e){var t=S(n);return e&&h.extendOwn(t,e),t},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,e){return e(n),n},h.isMatch=function(n,e){var t=h.keys(e),r=t.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=t[u];if(e[o]!==i[o]||!(o in i))return!1}return!0},Q=function(n,e,t,r){if(n===e)return 0!==n||1/n==1/e;if(null==n||null==e)return!1;if(n!=n)return e!=e;var i=typeof n;return("function"==i||"object"==i||"object"==typeof e)&&L(n,e,t,r)},L=function(n,e,t,r){n instanceof h&&(n=n._wrapped),e instanceof h&&(e=e._wrapped);var i=p.call(n);if(i!==p.call(e))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+e;case"[object Number]":return+n!=+n?+e!=+e:0==+n?1/+n==1/e:+n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object Symbol]":return f.valueOf.call(n)===f.valueOf.call(e)}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof e)return!1;var o=n.constructor,c=e.constructor;if(o!==c&&!(h.isFunction(o)&&o instanceof o&&h.isFunction(c)&&c instanceof c)&&"constructor"in n&&"constructor"in e)return!1}r=r||[];for(var a=(t=t||[]).length;a--;)if(t[a]===n)return r[a]===e;if(t.push(n),r.push(e),u){if((a=n.length)!==e.length)return!1;for(;a--;)if(!Q(n[a],e[a],t,r))return!1}else{var l,s=h.keys(n);if(a=s.length,h.keys(e).length!==a)return!1;for(;a--;)if(l=s[a],!_(e,l)||!Q(n[l],e[l],t,r))return!1}return t.pop(),r.pop(),!0},h.isEqual=function(n,e){return Q(n,e)},h.isEmpty=function(n){return null==n||(x(n)&&(h.isArray(n)||h.isString(n)||h.isArguments(n))?0===n.length:0===h.keys(n).length)},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=c||function(n){return"[object Array]"===p.call(n)},h.isObject=function(n){var e=typeof n;return"function"==e||"object"==e&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(e){h["is"+e]=function(n){return p.call(n)==="[object "+e+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return _(n,"callee")});var U=n.document&&n.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof U&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return!h.isSymbol(n)&&isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&isNaN(n)},h.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===p.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return void 0===n},h.has=function(n,e){if(!h.isArray(e))return _(n,e);for(var t=e.length,r=0;r<t;r++){var i=e[r];if(null==n||!u.call(n,i))return!1;n=n[i]}return!!t},h.noConflict=function(){return n._=e,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(e){return h.isArray(e)?function(n){return b(n,e)}:m(e)},h.propertyOf=function(e){return null==e?function(){}:function(n){return h.isArray(n)?b(e,n):e[n]}},h.matcher=h.matches=function(e){return e=h.extendOwn({},e),function(n){return h.isMatch(n,e)}},h.times=function(n,e,t){var r=Array(Math.max(0,n));e=d(e,t,1);for(var i=0;i<n;i++)r[i]=e(i);return r},h.random=function(n,e){return null==e&&(e=n,n=0),n+Math.floor(Math.random()*(e-n+1))},h.now=Date.now||function(){return(new Date).getTime()};function D(e){function t(n){return e[n]}var n="(?:"+h.keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}}var P={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},W=h.invert(P);h.escape=D(P),h.unescape=D(W),h.result=function(n,e,t){h.isArray(e)||(e=[e]);var r=e.length;if(!r)return h.isFunction(t)?t.call(n):t;for(var i=0;i<r;i++){var u=null==n?void 0:n[e[i]];void 0===u&&(u=t,i=r),n=h.isFunction(u)?u.call(n):u}return n};var B=0;h.uniqueId=function(n){var e=++B+"";return n?n+e:e},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function Y(n){return"\\"+K[n]}var z=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},G=/\\|'|\r|\n|\u2028|\u2029/g;h.template=function(u,n,e){!n&&e&&(n=e),n=h.defaults({},n,h.templateSettings);var t,r=RegExp([(n.escape||z).source,(n.interpolate||z).source,(n.evaluate||z).source].join("|")+"|$","g"),o=0,c="__p+='";u.replace(r,function(n,e,t,r,i){return c+=u.slice(o,i).replace(G,Y),o=i+n.length,e?c+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":t?c+="'+\n((__t=("+t+"))==null?'':__t)+\n'":r&&(c+="';\n"+r+"\n__p+='"),n}),c+="';\n",n.variable||(c="with(obj||{}){\n"+c+"}\n"),c="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+c+"return __p;\n";try{t=new Function(n.variable||"obj","_",c)}catch(n){throw n.source=c,n}function i(n){return t.call(this,n,h)}var a=n.variable||"obj";return i.source="function("+a+"){\n"+c+"}",i},h.chain=function(n){var e=h(n);return e._chain=!0,e};function H(n,e){return n._chain?h(e).chain():e}h.mixin=function(t){return h.each(h.functions(t),function(n){var e=h[n]=t[n];h.prototype[n]=function(){var n=[this._wrapped];return i.apply(n,arguments),H(this,e.apply(h,n))}}),h},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];h.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],H(this,n)}}),h.each(["concat","join","slice"],function(n){var e=r[n];h.prototype[n]=function(){return H(this,e.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},h.prototype.valueOf=h.prototype.toJSON=h.prototype.value,h.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events");e.exports=function(n){var r=n.getComponent("MenuItem");return n.extend(r,{constructor:function(n,e){var t=e.source;if(!i.isObject(t))throw new Error('was not provided a "source" object, but rather: '+typeof t);e=i.extend({selectable:!0,label:t.label},e),r.call(this,n,e),this.source=t},handleClick:function(n){r.prototype.handleClick.call(this,n),this.player().trigger(u.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events"),o=n("./QualityOption"),c="vjs-quality-changing";e.exports=function(n){var e,r=n.getComponent("MenuButton"),t=o(n);return e=n.extend(r,{constructor:function(t,n){r.call(this,t,n),t.on(u.QUALITY_REQUESTED,function(n,e){this.setSelectedSource(e),t.addClass(c),t.one("loadeddata",function(){t.removeClass(c)})}.bind(this)),t.on(u.PLAYER_SOURCES_CHANGED,function(){this.update()}.bind(this)),t.on(u.QUALITY_SELECTED,function(n,e){this.setSelectedSource(e)}.bind(this)),t.one("ready",function(){this.selectedSrc=t.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var e=n?n.src:void 0;this.selectedSrc!==e&&(this.selectedSrc=e,i.each(this.items,function(n){n.selected(n.source.src===e)}))},createItems:function(){var e=this.player(),n=e.currentSources();return i.map(n,function(n){return new t(e,{source:n,selected:n.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+r.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",e),e}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,e,t){"use strict";e.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected",PLAYER_SOURCES_CHANGED:"playerSourcesChanged"}},{}],6:[function(n,e,t){"use strict";var c=n("underscore"),r=n("./events"),i=n("./components/QualitySelector"),u=n("./middleware/SourceInterceptor"),a=n("./util/SafeSeek");e.exports=function(n){n=n||window.videojs,i(n),u(n),n.hook("setup",function(o){o.on(r.QUALITY_REQUESTED,function(n,e){var t=o.currentSources(),r=o.currentTime(),i=o.playbackRate(),u=o.paused();c.each(t,function(n){n.selected=!1}),c.findWhere(t,{src:e.src}).selected=!0,o._qualitySelectorSafeSeek&&o._qualitySelectorSafeSeek.onQualitySelectionChange(),o.src(t),o.ready(function(){o._qualitySelectorSafeSeek&&!o._qualitySelectorSafeSeek.hasFinished()||(o._qualitySelectorSafeSeek=new a(o,r),o.playbackRate(i)),u||o.play()})})})},e.exports.EVENTS=r},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,e,t){"use strict";var u=n("underscore"),o=n("../events");e.exports=function(n){n.use("*",function(i){return{setSource:function(n,e){var t,r=i.currentSources();i._qualitySelectorSafeSeek&&i._qualitySelectorSafeSeek.onPlayerSourcesChange(),u.isEqual(r,i._qualitySelectorPreviousSources)||(i.trigger(o.PLAYER_SOURCES_CHANGED,r),i._qualitySelectorPreviousSources=r),t=u.find(r,function(n){return!0===n.selected||"true"===n.selected||"selected"===n.selected})||n,i.trigger(o.QUALITY_SELECTED,t),e(null,t)}}})}},{"../events":5,underscore:2}],8:[function(n,e,t){"use strict";n("./index")()},{"./index":6}],9:[function(n,e,t){"use strict";var r=n("class.extend");e.exports=r.extend({init:function(n,e){this._player=n,this._seekToTime=e,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]);
+!function u(o,c,a){function l(e,n){if(!c[e]){if(!o[e]){var t="function"==typeof require&&require;if(!n&&t)return t(e,!0);if(s)return s(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var i=c[e]={exports:{}};o[e][0].call(i.exports,function(n){return l(o[e][1][n]||n)},i,i.exports,u,o,c,a)}return c[e].exports}for(var s="function"==typeof require&&require,n=0;n<a.length;n++)l(a[n]);return l}({1:[function(n,e,t){!function(){var u=!1,o=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(n){var i=this.prototype;u=!0;var e=new this;for(var t in u=!1,n)e[t]="function"==typeof n[t]&&"function"==typeof i[t]&&o.test(n[t])?function(t,r){return function(){var n=this._super;this._super=i[t];var e=r.apply(this,arguments);return this._super=n,e}}(t,n[t]):n[t];function r(){!u&&this.init&&this.init.apply(this,arguments)}return((r.prototype=e).constructor=r).extend=arguments.callee,r},e.exports=Class}()},{}],2:[function(n,J,$){(function(V){!function(){function t(){}var n="object"==typeof self&&self.self===self&&self||"object"==typeof V&&V.global===V&&V||this||{},e=n._,r=Array.prototype,o=Object.prototype,f="undefined"!=typeof Symbol?Symbol.prototype:null,i=r.push,a=r.slice,p=o.toString,u=o.hasOwnProperty,c=Array.isArray,l=Object.keys,s=Object.create,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};void 0===$||$.nodeType?n._=h:(void 0!==J&&!J.nodeType&&J.exports&&($=J.exports=h),$._=h),h.VERSION="1.9.1";function d(i,u,n){if(void 0===u)return i;switch(null==n?3:n){case 1:return function(n){return i.call(u,n)};case 3:return function(n,e,t){return i.call(u,n,e,t)};case 4:return function(n,e,t,r){return i.call(u,n,e,t,r)}}return function(){return i.apply(u,arguments)}}function y(n,e,t){return h.iteratee!==v?h.iteratee(n,e):null==n?h.identity:h.isFunction(n)?d(n,e,t):h.isObject(n)&&!h.isArray(n)?h.matcher(n):h.property(n)}var v;h.iteratee=v=function(n,e){return y(n,e,1/0)};function g(i,u){return u=null==u?i.length-1:+u,function(){for(var n=Math.max(arguments.length-u,0),e=Array(n),t=0;t<n;t++)e[t]=arguments[t+u];switch(u){case 0:return i.call(this,e);case 1:return i.call(this,arguments[0],e);case 2:return i.call(this,arguments[0],arguments[1],e)}var r=Array(u+1);for(t=0;t<u;t++)r[t]=arguments[t];return r[u]=e,i.apply(this,r)}}function S(n){if(!h.isObject(n))return{};if(s)return s(n);t.prototype=n;var e=new t;return t.prototype=null,e}function m(e){return function(n){return null==n?void 0:n[e]}}function _(n,e){return null!=n&&u.call(n,e)}function b(n,e){for(var t=e.length,r=0;r<t;r++){if(null==n)return;n=n[e[r]]}return t?n:void 0}function x(n){var e=j(n);return"number"==typeof e&&0<=e&&e<=k}var k=Math.pow(2,53)-1,j=m("length");h.each=h.forEach=function(n,e,t){var r,i;if(e=d(e,t),x(n))for(r=0,i=n.length;r<i;r++)e(n[r],r,n);else{var u=h.keys(n);for(r=0,i=u.length;r<i;r++)e(n[u[r]],u[r],n)}return n},h.map=h.collect=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var c=r?r[o]:o;u[o]=e(n[c],c,n)}return u};function E(a){return function(n,e,t,r){var i=3<=arguments.length;return function(n,e,t,r){var i=!x(n)&&h.keys(n),u=(i||n).length,o=0<a?0:u-1;for(r||(t=n[i?i[o]:o],o+=a);0<=o&&o<u;o+=a){var c=i?i[o]:o;t=e(t,n[c],c,n)}return t}(n,d(e,r,4),t,i)}}h.reduce=h.foldl=h.inject=E(1),h.reduceRight=h.foldr=E(-1),h.find=h.detect=function(n,e,t){var r=(x(n)?h.findIndex:h.findKey)(n,e,t);if(void 0!==r&&-1!==r)return n[r]},h.filter=h.select=function(n,r,e){var i=[];return r=y(r,e),h.each(n,function(n,e,t){r(n,e,t)&&i.push(n)}),i},h.reject=function(n,e,t){return h.filter(n,h.negate(y(e)),t)},h.every=h.all=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!e(n[o],o,n))return!1}return!0},h.some=h.any=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(e(n[o],o,n))return!0}return!1},h.contains=h.includes=h.include=function(n,e,t,r){return x(n)||(n=h.values(n)),"number"==typeof t&&!r||(t=0),0<=h.indexOf(n,e,t)},h.invoke=g(function(n,t,r){var i,u;return h.isFunction(t)?u=t:h.isArray(t)&&(i=t.slice(0,-1),t=t[t.length-1]),h.map(n,function(n){var e=u;if(!e){if(i&&i.length&&(n=b(n,i)),null==n)return;e=n[t]}return null==e?e:e.apply(n,r)})}),h.pluck=function(n,e){return h.map(n,h.property(e))},h.where=function(n,e){return h.filter(n,h.matcher(e))},h.findWhere=function(n,e){return h.find(n,h.matcher(e))},h.max=function(n,r,e){var t,i,u=-1/0,o=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&u<t&&(u=t);else r=y(r,e),h.each(n,function(n,e,t){i=r(n,e,t),(o<i||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},h.min=function(n,r,e){var t,i,u=1/0,o=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&t<u&&(u=t);else r=y(r,e),h.each(n,function(n,e,t){((i=r(n,e,t))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},h.shuffle=function(n){return h.sample(n,1/0)},h.sample=function(n,e,t){if(null==e||t)return x(n)||(n=h.values(n)),n[h.random(n.length-1)];var r=x(n)?h.clone(n):h.values(n),i=j(r);e=Math.max(Math.min(e,i),0);for(var u=i-1,o=0;o<e;o++){var c=h.random(o,u),a=r[o];r[o]=r[c],r[c]=a}return r.slice(0,e)},h.sortBy=function(n,r,e){var i=0;return r=y(r,e),h.pluck(h.map(n,function(n,e,t){return{value:n,index:i++,criteria:r(n,e,t)}}).sort(function(n,e){var t=n.criteria,r=e.criteria;if(t!==r){if(r<t||void 0===t)return 1;if(t<r||void 0===r)return-1}return n.index-e.index}),"value")};function w(o,e){return function(r,i,n){var u=e?[[],[]]:{};return i=y(i,n),h.each(r,function(n,e){var t=i(n,e,r);o(u,n,t)}),u}}h.groupBy=w(function(n,e,t){_(n,t)?n[t].push(e):n[t]=[e]}),h.indexBy=w(function(n,e,t){n[t]=e}),h.countBy=w(function(n,e,t){_(n,t)?n[t]++:n[t]=1});var A=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;h.toArray=function(n){return n?h.isArray(n)?a.call(n):h.isString(n)?n.match(A):x(n)?h.map(n,h.identity):h.values(n):[]},h.size=function(n){return null==n?0:x(n)?n.length:h.keys(n).length},h.partition=w(function(n,e,t){n[t?0:1].push(e)},!0),h.first=h.head=h.take=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[0]:h.initial(n,n.length-e)},h.initial=function(n,e,t){return a.call(n,0,Math.max(0,n.length-(null==e||t?1:e)))},h.last=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[n.length-1]:h.rest(n,Math.max(0,n.length-e))},h.rest=h.tail=h.drop=function(n,e,t){return a.call(n,null==e||t?1:e)},h.compact=function(n){return h.filter(n,Boolean)};var T=function(n,e,t,r){for(var i=(r=r||[]).length,u=0,o=j(n);u<o;u++){var c=n[u];if(x(c)&&(h.isArray(c)||h.isArguments(c)))if(e)for(var a=0,l=c.length;a<l;)r[i++]=c[a++];else T(c,e,t,r),i=r.length;else t||(r[i++]=c)}return r};h.flatten=function(n,e){return T(n,e,!1)},h.without=g(function(n,e){return h.difference(n,e)}),h.uniq=h.unique=function(n,e,t,r){h.isBoolean(e)||(r=t,t=e,e=!1),null!=t&&(t=y(t,r));for(var i=[],u=[],o=0,c=j(n);o<c;o++){var a=n[o],l=t?t(a,o,n):a;e&&!t?(o&&u===l||i.push(a),u=l):t?h.contains(u,l)||(u.push(l),i.push(a)):h.contains(i,a)||i.push(a)}return i},h.union=g(function(n){return h.uniq(T(n,!0,!0))}),h.intersection=function(n){for(var e=[],t=arguments.length,r=0,i=j(n);r<i;r++){var u=n[r];if(!h.contains(e,u)){var o;for(o=1;o<t&&h.contains(arguments[o],u);o++);o===t&&e.push(u)}}return e},h.difference=g(function(n,e){return e=T(e,!0,!0),h.filter(n,function(n){return!h.contains(e,n)})}),h.unzip=function(n){for(var e=n&&h.max(n,j).length||0,t=Array(e),r=0;r<e;r++)t[r]=h.pluck(n,r);return t},h.zip=g(h.unzip),h.object=function(n,e){for(var t={},r=0,i=j(n);r<i;r++)e?t[n[r]]=e[r]:t[n[r][0]]=n[r][1];return t};function O(u){return function(n,e,t){e=y(e,t);for(var r=j(n),i=0<u?0:r-1;0<=i&&i<r;i+=u)if(e(n[i],i,n))return i;return-1}}h.findIndex=O(1),h.findLastIndex=O(-1),h.sortedIndex=function(n,e,t,r){for(var i=(t=y(t,r,1))(e),u=0,o=j(n);u<o;){var c=Math.floor((u+o)/2);t(n[c])<i?u=c+1:o=c}return u};function C(u,o,c){return function(n,e,t){var r=0,i=j(n);if("number"==typeof t)0<u?r=0<=t?t:Math.max(t+i,r):i=0<=t?Math.min(t+1,i):t+i+1;else if(c&&t&&i)return n[t=c(n,e)]===e?t:-1;if(e!=e)return 0<=(t=o(a.call(n,r,i),h.isNaN))?t+r:-1;for(t=0<u?r:i-1;0<=t&&t<i;t+=u)if(n[t]===e)return t;return-1}}h.indexOf=C(1,h.findIndex,h.sortedIndex),h.lastIndexOf=C(-1,h.findLastIndex),h.range=function(n,e,t){null==e&&(e=n||0,n=0),t=t||(e<n?-1:1);for(var r=Math.max(Math.ceil((e-n)/t),0),i=Array(r),u=0;u<r;u++,n+=t)i[u]=n;return i},h.chunk=function(n,e){if(null==e||e<1)return[];for(var t=[],r=0,i=n.length;r<i;)t.push(a.call(n,r,r+=e));return t};function I(n,e,t,r,i){if(!(r instanceof e))return n.apply(t,i);var u=S(n.prototype),o=n.apply(u,i);return h.isObject(o)?o:u}h.bind=g(function(e,t,r){if(!h.isFunction(e))throw new TypeError("Bind must be called on a function");var i=g(function(n){return I(e,i,t,this,r.concat(n))});return i}),h.partial=g(function(i,u){var o=h.partial.placeholder,c=function(){for(var n=0,e=u.length,t=Array(e),r=0;r<e;r++)t[r]=u[r]===o?arguments[n++]:u[r];for(;n<arguments.length;)t.push(arguments[n++]);return I(i,c,this,this,t)};return c}),(h.partial.placeholder=h).bindAll=g(function(n,e){var t=(e=T(e,!1,!1)).length;if(t<1)throw new Error("bindAll must be passed function names");for(;t--;){var r=e[t];n[r]=h.bind(n[r],n)}}),h.memoize=function(r,i){var u=function(n){var e=u.cache,t=""+(i?i.apply(this,arguments):n);return _(e,t)||(e[t]=r.apply(this,arguments)),e[t]};return u.cache={},u},h.delay=g(function(n,e,t){return setTimeout(function(){return n.apply(null,t)},e)}),h.defer=h.partial(h.delay,h,1),h.throttle=function(t,r,i){var u,o,c,a,l=0;i=i||{};function s(){l=!1===i.leading?0:h.now(),u=null,a=t.apply(o,c),u||(o=c=null)}function n(){var n=h.now();l||!1!==i.leading||(l=n);var e=r-(n-l);return o=this,c=arguments,e<=0||r<e?(u&&(clearTimeout(u),u=null),l=n,a=t.apply(o,c),u||(o=c=null)):u||!1===i.trailing||(u=setTimeout(s,e)),a}return n.cancel=function(){clearTimeout(u),l=0,u=o=c=null},n},h.debounce=function(t,r,i){function u(n,e){o=null,e&&(c=t.apply(n,e))}var o,c,n=g(function(n){if(o&&clearTimeout(o),i){var e=!o;o=setTimeout(u,r),e&&(c=t.apply(this,n))}else o=h.delay(u,r,this,n);return c});return n.cancel=function(){clearTimeout(o),o=null},n},h.wrap=function(n,e){return h.partial(e,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var t=arguments,r=t.length-1;return function(){for(var n=r,e=t[r].apply(this,arguments);n--;)e=t[n].call(this,e);return e}},h.after=function(n,e){return function(){if(--n<1)return e.apply(this,arguments)}},h.before=function(n,e){var t;return function(){return 0<--n&&(t=e.apply(this,arguments)),n<=1&&(e=null),t}},h.once=h.partial(h.before,2),h.restArguments=g;function F(n,e){var t=M.length,r=n.constructor,i=h.isFunction(r)&&r.prototype||o,u="constructor";for(_(n,u)&&!h.contains(e,u)&&e.push(u);t--;)(u=M[t])in n&&n[u]!==i[u]&&!h.contains(e,u)&&e.push(u)}var q=!{toString:null}.propertyIsEnumerable("toString"),M=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];h.keys=function(n){if(!h.isObject(n))return[];if(l)return l(n);var e=[];for(var t in n)_(n,t)&&e.push(t);return q&&F(n,e),e},h.allKeys=function(n){if(!h.isObject(n))return[];var e=[];for(var t in n)e.push(t);return q&&F(n,e),e},h.values=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=n[e[i]];return r},h.mapObject=function(n,e,t){e=y(e,t);for(var r=h.keys(n),i=r.length,u={},o=0;o<i;o++){var c=r[o];u[c]=e(n[c],c,n)}return u},h.pairs=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=[e[i],n[e[i]]];return r},h.invert=function(n){for(var e={},t=h.keys(n),r=0,i=t.length;r<i;r++)e[n[t[r]]]=t[r];return e},h.functions=h.methods=function(n){var e=[];for(var t in n)h.isFunction(n[t])&&e.push(t);return e.sort()};function N(a,l){return function(n){var e=arguments.length;if(l&&(n=Object(n)),e<2||null==n)return n;for(var t=1;t<e;t++)for(var r=arguments[t],i=a(r),u=i.length,o=0;o<u;o++){var c=i[o];l&&void 0!==n[c]||(n[c]=r[c])}return n}}h.extend=N(h.allKeys),h.extendOwn=h.assign=N(h.keys),h.findKey=function(n,e,t){e=y(e,t);for(var r,i=h.keys(n),u=0,o=i.length;u<o;u++)if(e(n[r=i[u]],r,n))return r};function R(n,e,t){return e in t}var Q,L;h.pick=g(function(n,e){var t={},r=e[0];if(null==n)return t;h.isFunction(r)?(1<e.length&&(r=d(r,e[1])),e=h.allKeys(n)):(r=R,e=T(e,!1,!1),n=Object(n));for(var i=0,u=e.length;i<u;i++){var o=e[i],c=n[o];r(c,o,n)&&(t[o]=c)}return t}),h.omit=g(function(n,t){var e,r=t[0];return h.isFunction(r)?(r=h.negate(r),1<t.length&&(e=t[1])):(t=h.map(T(t,!1,!1),String),r=function(n,e){return!h.contains(t,e)}),h.pick(n,r,e)}),h.defaults=N(h.allKeys,!0),h.create=function(n,e){var t=S(n);return e&&h.extendOwn(t,e),t},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,e){return e(n),n},h.isMatch=function(n,e){var t=h.keys(e),r=t.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=t[u];if(e[o]!==i[o]||!(o in i))return!1}return!0},Q=function(n,e,t,r){if(n===e)return 0!==n||1/n==1/e;if(null==n||null==e)return!1;if(n!=n)return e!=e;var i=typeof n;return("function"==i||"object"==i||"object"==typeof e)&&L(n,e,t,r)},L=function(n,e,t,r){n instanceof h&&(n=n._wrapped),e instanceof h&&(e=e._wrapped);var i=p.call(n);if(i!==p.call(e))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+e;case"[object Number]":return+n!=+n?+e!=+e:0==+n?1/+n==1/e:+n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object Symbol]":return f.valueOf.call(n)===f.valueOf.call(e)}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof e)return!1;var o=n.constructor,c=e.constructor;if(o!==c&&!(h.isFunction(o)&&o instanceof o&&h.isFunction(c)&&c instanceof c)&&"constructor"in n&&"constructor"in e)return!1}r=r||[];for(var a=(t=t||[]).length;a--;)if(t[a]===n)return r[a]===e;if(t.push(n),r.push(e),u){if((a=n.length)!==e.length)return!1;for(;a--;)if(!Q(n[a],e[a],t,r))return!1}else{var l,s=h.keys(n);if(a=s.length,h.keys(e).length!==a)return!1;for(;a--;)if(l=s[a],!_(e,l)||!Q(n[l],e[l],t,r))return!1}return t.pop(),r.pop(),!0},h.isEqual=function(n,e){return Q(n,e)},h.isEmpty=function(n){return null==n||(x(n)&&(h.isArray(n)||h.isString(n)||h.isArguments(n))?0===n.length:0===h.keys(n).length)},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=c||function(n){return"[object Array]"===p.call(n)},h.isObject=function(n){var e=typeof n;return"function"==e||"object"==e&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(e){h["is"+e]=function(n){return p.call(n)==="[object "+e+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return _(n,"callee")});var U=n.document&&n.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof U&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return!h.isSymbol(n)&&isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&isNaN(n)},h.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===p.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return void 0===n},h.has=function(n,e){if(!h.isArray(e))return _(n,e);for(var t=e.length,r=0;r<t;r++){var i=e[r];if(null==n||!u.call(n,i))return!1;n=n[i]}return!!t},h.noConflict=function(){return n._=e,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(e){return h.isArray(e)?function(n){return b(n,e)}:m(e)},h.propertyOf=function(e){return null==e?function(){}:function(n){return h.isArray(n)?b(e,n):e[n]}},h.matcher=h.matches=function(e){return e=h.extendOwn({},e),function(n){return h.isMatch(n,e)}},h.times=function(n,e,t){var r=Array(Math.max(0,n));e=d(e,t,1);for(var i=0;i<n;i++)r[i]=e(i);return r},h.random=function(n,e){return null==e&&(e=n,n=0),n+Math.floor(Math.random()*(e-n+1))},h.now=Date.now||function(){return(new Date).getTime()};function D(e){function t(n){return e[n]}var n="(?:"+h.keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}}var P={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},W=h.invert(P);h.escape=D(P),h.unescape=D(W),h.result=function(n,e,t){h.isArray(e)||(e=[e]);var r=e.length;if(!r)return h.isFunction(t)?t.call(n):t;for(var i=0;i<r;i++){var u=null==n?void 0:n[e[i]];void 0===u&&(u=t,i=r),n=h.isFunction(u)?u.call(n):u}return n};var B=0;h.uniqueId=function(n){var e=++B+"";return n?n+e:e},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function Y(n){return"\\"+K[n]}var z=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},G=/\\|'|\r|\n|\u2028|\u2029/g;h.template=function(u,n,e){!n&&e&&(n=e),n=h.defaults({},n,h.templateSettings);var t,r=RegExp([(n.escape||z).source,(n.interpolate||z).source,(n.evaluate||z).source].join("|")+"|$","g"),o=0,c="__p+='";u.replace(r,function(n,e,t,r,i){return c+=u.slice(o,i).replace(G,Y),o=i+n.length,e?c+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":t?c+="'+\n((__t=("+t+"))==null?'':__t)+\n'":r&&(c+="';\n"+r+"\n__p+='"),n}),c+="';\n",n.variable||(c="with(obj||{}){\n"+c+"}\n"),c="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+c+"return __p;\n";try{t=new Function(n.variable||"obj","_",c)}catch(n){throw n.source=c,n}function i(n){return t.call(this,n,h)}var a=n.variable||"obj";return i.source="function("+a+"){\n"+c+"}",i},h.chain=function(n){var e=h(n);return e._chain=!0,e};function H(n,e){return n._chain?h(e).chain():e}h.mixin=function(t){return h.each(h.functions(t),function(n){var e=h[n]=t[n];h.prototype[n]=function(){var n=[this._wrapped];return i.apply(n,arguments),H(this,e.apply(h,n))}}),h},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];h.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],H(this,n)}}),h.each(["concat","join","slice"],function(n){var e=r[n];h.prototype[n]=function(){return H(this,e.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},h.prototype.valueOf=h.prototype.toJSON=h.prototype.value,h.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events");e.exports=function(n){var r=n.getComponent("MenuItem");return n.extend(r,{constructor:function(n,e){var t=e.source;if(!i.isObject(t))throw new Error('was not provided a "source" object, but rather: '+typeof t);e=i.extend({selectable:!0,label:t.label},e),r.call(this,n,e),this.source=t},handleClick:function(n){r.prototype.handleClick.call(this,n),this.player().trigger(u.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events"),o=n("./QualityOption"),c="vjs-quality-changing";e.exports=function(n){var e,r=n.getComponent("MenuButton"),t=o(n);return e=n.extend(r,{constructor:function(t,n){r.call(this,t,n),t.on(u.QUALITY_REQUESTED,function(n,e){this.setSelectedSource(e),t.addClass(c),t.one("loadeddata",function(){t.removeClass(c)})}.bind(this)),t.on(u.PLAYER_SOURCES_CHANGED,function(){this.update()}.bind(this)),t.on(u.QUALITY_SELECTED,function(n,e){this.setSelectedSource(e)}.bind(this)),t.one("ready",function(){this.selectedSrc=t.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var e=n?n.src:void 0;this.selectedSrc!==e&&(this.selectedSrc=e,i.each(this.items,function(n){n.selected(n.source.src===e)}))},createItems:function(){var e=this.player(),n=e.currentSources();return n=n.filter(function(n){return null==n.hidequalityoption}),i.map(n,function(n){return new t(e,{source:n,selected:n.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+r.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",e),e}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,e,t){"use strict";e.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected",PLAYER_SOURCES_CHANGED:"playerSourcesChanged"}},{}],6:[function(n,e,t){"use strict";var c=n("underscore"),r=n("./events"),i=n("./components/QualitySelector"),u=n("./middleware/SourceInterceptor"),a=n("./util/SafeSeek");e.exports=function(n){n=n||window.videojs,i(n),u(n),n.hook("setup",function(o){o.on(r.QUALITY_REQUESTED,function(n,e){var t=o.currentSources(),r=o.currentTime(),i=o.playbackRate(),u=o.paused();c.each(t,function(n){n.selected=!1}),c.findWhere(t,{src:e.src}).selected=!0,o._qualitySelectorSafeSeek&&o._qualitySelectorSafeSeek.onQualitySelectionChange(),o.src(t),o.ready(function(){o._qualitySelectorSafeSeek&&!o._qualitySelectorSafeSeek.hasFinished()||(o._qualitySelectorSafeSeek=new a(o,r),o.playbackRate(i)),u||o.play()})})})},e.exports.EVENTS=r},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,e,t){"use strict";var u=n("underscore"),o=n("../events");e.exports=function(n){n.use("*",function(i){return{setSource:function(n,e){var t,r=i.currentSources();i._qualitySelectorSafeSeek&&i._qualitySelectorSafeSeek.onPlayerSourcesChange(),u.isEqual(r,i._qualitySelectorPreviousSources)||(i.trigger(o.PLAYER_SOURCES_CHANGED,r),i._qualitySelectorPreviousSources=r),t=u.find(r,function(n){return!0===n.selected||"true"===n.selected||"selected"===n.selected})||n,i.trigger(o.QUALITY_SELECTED,t),e(null,t)}}})}},{"../events":5,underscore:2}],8:[function(n,e,t){"use strict";n("./index")()},{"./index":6}],9:[function(n,e,t){"use strict";var r=n("class.extend");e.exports=r.extend({init:function(n,e){this._player=n,this._seekToTime=e,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]);
//# sourceMappingURL=silvermine-videojs-quality-selector.min.js.map \ No newline at end of file
diff --git a/assets/js/subscribe_widget.js b/assets/js/subscribe_widget.js
index 216c36fe..45ff5706 100644
--- a/assets/js/subscribe_widget.js
+++ b/assets/js/subscribe_widget.js
@@ -1,4 +1,5 @@
-var subscribe_data = JSON.parse(document.getElementById('subscribe_data').innerHTML);
+'use strict';
+var subscribe_data = JSON.parse(document.getElementById('subscribe_data').textContent);
var subscribe_button = document.getElementById('subscribe');
subscribe_button.parentNode['action'] = 'javascript:void(0)';
@@ -9,9 +10,11 @@ if (subscribe_button.getAttribute('data-type') === 'subscribe') {
subscribe_button.onclick = unsubscribe;
}
-function subscribe(retries = 5) {
+function subscribe(retries) {
+ if (retries === undefined) retries = 5;
+
if (retries <= 0) {
- console.log('Failed to subscribe.');
+ console.warn('Failed to subscribe.');
return;
}
@@ -28,30 +31,33 @@ function subscribe(retries = 5) {
subscribe_button.innerHTML = '<b>' + subscribe_data.unsubscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
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;
}
}
- }
+ };
xhr.onerror = function () {
- console.log('Subscribing failed... ' + retries + '/5');
- setTimeout(function () { subscribe(retries - 1) }, 1000);
- }
+ console.warn('Subscribing failed... ' + retries + '/5');
+ setTimeout(function () { subscribe(retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
- console.log('Subscribing failed... ' + retries + '/5');
+ console.warn('Subscribing failed... ' + retries + '/5');
subscribe(retries - 1);
- }
+ };
xhr.send('csrf_token=' + subscribe_data.csrf_token);
}
-function unsubscribe(retries = 5) {
+function unsubscribe(retries) {
+ if (retries === undefined)
+ retries = 5;
+
if (retries <= 0) {
- console.log('Failed to subscribe');
+ console.warn('Failed to subscribe');
return;
}
@@ -68,23 +74,23 @@ function unsubscribe(retries = 5) {
subscribe_button.innerHTML = '<b>' + subscribe_data.subscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
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;
}
}
- }
+ };
xhr.onerror = function () {
- console.log('Unsubscribing failed... ' + retries + '/5');
- setTimeout(function () { unsubscribe(retries - 1) }, 1000);
- }
+ console.warn('Unsubscribing failed... ' + retries + '/5');
+ setTimeout(function () { unsubscribe(retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
- console.log('Unsubscribing failed... ' + retries + '/5');
+ console.warn('Unsubscribing failed... ' + retries + '/5');
unsubscribe(retries - 1);
- }
+ };
xhr.send('csrf_token=' + subscribe_data.csrf_token);
}
diff --git a/assets/js/themes.js b/assets/js/themes.js
index 0214a7f0..3f503b38 100644
--- a/assets/js/themes.js
+++ b/assets/js/themes.js
@@ -1,8 +1,9 @@
+'use strict';
var toggle_theme = document.getElementById('toggle_theme');
toggle_theme.href = 'javascript:void(0);';
toggle_theme.addEventListener('click', function () {
- var dark_mode = document.body.classList.contains("light-theme");
+ var dark_mode = document.body.classList.contains('light-theme');
var url = '/toggle_theme?redirect=false';
var xhr = new XMLHttpRequest();
@@ -13,7 +14,7 @@ toggle_theme.addEventListener('click', function () {
set_mode(dark_mode);
try {
window.localStorage.setItem('dark_mode', dark_mode ? 'dark' : 'light');
- } catch {}
+ } catch (e) {}
xhr.send();
});
@@ -29,7 +30,7 @@ window.addEventListener('DOMContentLoaded', function () {
try {
// Update localStorage if dark mode preference changed on preferences page
window.localStorage.setItem('dark_mode', dark_mode);
- } catch {}
+ } catch (e) {}
update_mode(dark_mode);
});
@@ -46,11 +47,11 @@ function scheme_switch (e) {
if (localStorage.getItem('dark_mode')) {
return;
}
- } catch {}
+ } catch (exception) {}
if (e.matches) {
- if (e.media.includes("dark")) {
+ if (e.media.includes('dark')) {
set_mode(true);
- } else if (e.media.includes("light")) {
+ } else if (e.media.includes('light')) {
set_mode(false);
}
}
@@ -77,15 +78,13 @@ function update_mode (mode) {
// If preference for dark mode indicated
set_mode(true);
}
- else if (mode === 'false' /* for backwards compatibility */ || mode === 'light') {
- // If preference for light mode indicated
- set_mode(false);
- }
+ else if (mode === 'false' /* for backwards compatibility */ || mode === 'light') {
+ // If preference for light mode indicated
+ set_mode(false);
+ }
else if (document.getElementById('dark_mode_pref').textContent === '' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// If no preference indicated here and no preference indicated on the preferences page (backend), but the browser tells us that the operating system has a dark theme
set_mode(true);
}
// else do nothing, falling back to the mode defined by the `dark_mode` preference on the preferences page (backend)
}
-
-
diff --git a/assets/js/watch.js b/assets/js/watch.js
index 1579abf4..29d58be5 100644
--- a/assets/js/watch.js
+++ b/assets/js/watch.js
@@ -1,31 +1,32 @@
-var video_data = JSON.parse(document.getElementById('video_data').innerHTML);
+'use strict';
+var video_data = JSON.parse(document.getElementById('video_data').textContent);
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
-}
+};
function toggle_parent(target) {
- body = target.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.children[1];
if (body.style.display === null || body.style.display === '') {
- target.innerHTML = '[ + ]';
+ target.textContent = '[ + ]';
body.style.display = 'none';
} else {
- target.innerHTML = '[ - ]';
+ target.textContent = '[ − ]';
body.style.display = '';
}
}
function toggle_comments(event) {
var target = event.target;
- body = target.parentNode.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.parentNode.children[1];
if (body.style.display === null || body.style.display === '') {
- target.innerHTML = '[ + ]';
+ target.textContent = '[ + ]';
body.style.display = 'none';
} else {
- target.innerHTML = '[ - ]';
+ target.textContent = '[ − ]';
body.style.display = '';
}
}
@@ -43,13 +44,13 @@ function swap_comments(event) {
function hide_youtube_replies(event) {
var target = event.target;
- sub_text = target.getAttribute('data-inner-text');
- inner_text = target.getAttribute('data-sub-text');
+ var sub_text = target.getAttribute('data-inner-text');
+ var inner_text = target.getAttribute('data-sub-text');
- body = target.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.children[1];
body.style.display = 'none';
- target.innerHTML = sub_text;
+ target.textContent = sub_text;
target.onclick = show_youtube_replies;
target.setAttribute('data-inner-text', inner_text);
target.setAttribute('data-sub-text', sub_text);
@@ -58,13 +59,13 @@ function hide_youtube_replies(event) {
function show_youtube_replies(event) {
var target = event.target;
- sub_text = target.getAttribute('data-inner-text');
- inner_text = target.getAttribute('data-sub-text');
+ var sub_text = target.getAttribute('data-inner-text');
+ var inner_text = target.getAttribute('data-sub-text');
- body = target.parentNode.parentNode.children[1];
+ var body = target.parentNode.parentNode.children[1];
body.style.display = '';
- target.innerHTML = sub_text;
+ target.textContent = sub_text;
target.onclick = hide_youtube_replies;
target.setAttribute('data-inner-text', inner_text);
target.setAttribute('data-sub-text', sub_text);
@@ -116,25 +117,26 @@ function number_with_separator(val) {
}
function get_playlist(plid, retries) {
- if (retries == undefined) retries = 5;
- playlist = document.getElementById('playlist');
+ if (retries === undefined) retries = 5;
+ var playlist = document.getElementById('playlist');
if (retries <= 0) {
- console.log('Failed to pull playlist');
+ console.warn('Failed to pull playlist');
playlist.innerHTML = '';
return;
}
playlist.innerHTML = ' \
<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3> \
- <hr>'
+ <hr>';
+ var plid_url;
if (plid.startsWith('RD')) {
- var plid_url = '/api/v1/mixes/' + plid +
+ plid_url = '/api/v1/mixes/' + plid +
'?continuation=' + video_data.id +
'&format=html&hl=' + video_data.preferences.locale;
} else {
- var plid_url = '/api/v1/playlists/' + plid +
+ plid_url = '/api/v1/playlists/' + plid +
'?index=' + video_data.index +
'&continuation=' + video_data.id +
'&format=html&hl=' + video_data.preferences.locale;
@@ -146,8 +148,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;
@@ -185,35 +187,35 @@ function get_playlist(plid, retries) {
document.getElementById('continue').style.display = '';
}
}
- }
+ };
xhr.onerror = function () {
playlist = document.getElementById('playlist');
playlist.innerHTML =
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
- console.log('Pulling playlist timed out... ' + retries + '/5');
- setTimeout(function () { get_playlist(plid, retries - 1) }, 1000);
- }
+ console.warn('Pulling playlist timed out... ' + retries + '/5');
+ setTimeout(function () { get_playlist(plid, retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
playlist = document.getElementById('playlist');
playlist.innerHTML =
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
- console.log('Pulling playlist timed out... ' + retries + '/5');
+ console.warn('Pulling playlist timed out... ' + retries + '/5');
get_playlist(plid, retries - 1);
- }
+ };
xhr.send();
}
function get_reddit_comments(retries) {
- if (retries == undefined) retries = 5;
- comments = document.getElementById('comments');
+ if (retries === undefined) retries = 5;
+ var comments = document.getElementById('comments');
if (retries <= 0) {
- console.log('Failed to pull comments');
+ console.warn('Failed to pull comments');
comments.innerHTML = '';
return;
}
@@ -231,12 +233,12 @@ 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 = ' \
<div> \
<h3> \
- <a href="javascript:void(0)">[ - ]</a> \
+ <a href="javascript:void(0)">[ − ]</a> \
{title} \
</h3> \
<p> \
@@ -263,34 +265,34 @@ function get_reddit_comments(retries) {
comments.children[0].children[1].children[0].onclick = swap_comments;
} else {
if (video_data.params.comments[1] === 'youtube') {
- console.log('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_youtube_comments(retries - 1) }, 1000);
+ console.warn('Pulling comments failed... ' + retries + '/5');
+ setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
} else {
comments.innerHTML = fallback;
}
}
}
- }
+ };
xhr.onerror = function () {
- console.log('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_reddit_comments(retries - 1) }, 1000);
- }
+ console.warn('Pulling comments failed... ' + retries + '/5');
+ setTimeout(function () { get_reddit_comments(retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
- console.log('Pulling comments failed... ' + retries + '/5');
+ console.warn('Pulling comments failed... ' + retries + '/5');
get_reddit_comments(retries - 1);
- }
+ };
xhr.send();
}
function get_youtube_comments(retries) {
- if (retries == undefined) retries = 5;
- comments = document.getElementById('comments');
+ if (retries === undefined) retries = 5;
+ var comments = document.getElementById('comments');
if (retries <= 0) {
- console.log('Failed to pull comments');
+ console.warn('Failed to pull comments');
comments.innerHTML = '';
return;
}
@@ -309,12 +311,12 @@ 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 = ' \
<div> \
<h3> \
- <a href="javascript:void(0)">[ - ]</a> \
+ <a href="javascript:void(0)">[ − ]</a> \
{commentsText} \
</h3> \
<b> \
@@ -336,27 +338,27 @@ function get_youtube_comments(retries) {
comments.children[0].children[1].children[0].onclick = swap_comments;
} else {
if (video_data.params.comments[1] === 'youtube') {
- setTimeout(function () { get_youtube_comments(retries - 1) }, 1000);
+ setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
} else {
comments.innerHTML = '';
}
}
}
- }
+ };
xhr.onerror = function () {
comments.innerHTML =
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
- console.log('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_youtube_comments(retries - 1) }, 1000);
- }
+ console.warn('Pulling comments failed... ' + retries + '/5');
+ setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
+ };
xhr.ontimeout = function () {
comments.innerHTML =
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
- console.log('Pulling comments failed... ' + retries + '/5');
+ console.warn('Pulling comments failed... ' + retries + '/5');
get_youtube_comments(retries - 1);
- }
+ };
xhr.send();
}
@@ -373,7 +375,7 @@ function get_youtube_replies(target, load_more, load_replies) {
'?format=html' +
'&hl=' + video_data.preferences.locale +
'&thin_mode=' + video_data.preferences.thin_mode +
- '&continuation=' + continuation
+ '&continuation=' + continuation;
if (load_replies) {
url += '&action=action_get_comment_replies';
}
@@ -383,8 +385,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);
@@ -412,12 +414,12 @@ function get_youtube_replies(target, load_more, load_replies) {
body.innerHTML = fallback;
}
}
- }
+ };
xhr.ontimeout = function () {
- console.log('Pulling comments failed.');
+ console.warn('Pulling comments failed.');
body.innerHTML = fallback;
- }
+ };
xhr.send();
}
@@ -461,7 +463,7 @@ window.addEventListener('load', function (e) {
} else if (video_data.params.comments[1] === 'reddit') {
get_reddit_comments();
} else {
- comments = document.getElementById('comments');
+ var comments = document.getElementById('comments');
comments.innerHTML = '';
}
});
diff --git a/assets/js/watched_widget.js b/assets/js/watched_widget.js
index ba741974..87989a79 100644
--- a/assets/js/watched_widget.js
+++ b/assets/js/watched_widget.js
@@ -1,4 +1,5 @@
-var watched_data = JSON.parse(document.getElementById('watched_data').innerHTML);
+'use strict';
+var watched_data = JSON.parse(document.getElementById('watched_data').textContent);
function mark_watched(target) {
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
@@ -13,12 +14,12 @@ 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 = '';
}
}
- }
+ };
xhr.send('csrf_token=' + watched_data.csrf_token);
}
@@ -26,7 +27,7 @@ function mark_watched(target) {
function mark_unwatched(target) {
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
tile.style.display = 'none';
- var count = document.getElementById('count')
+ var count = document.getElementById('count');
count.innerText = count.innerText - 1;
var url = '/watch_ajax?action_mark_unwatched=1&redirect=false' +
@@ -38,13 +39,13 @@ 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 = '';
}
}
- }
+ };
xhr.send('csrf_token=' + watched_data.csrf_token);
-} \ No newline at end of file
+}