forked from midou/invidious
single quotes
This commit is contained in:
parent
577a2356a0
commit
7940e91cbe
@ -152,14 +152,14 @@
|
|||||||
let focused_tag = document.activeElement.tagName.toLowerCase();
|
let focused_tag = document.activeElement.tagName.toLowerCase();
|
||||||
const allowed = /^(button|checkbox|file|radio|submit)$/;
|
const allowed = /^(button|checkbox|file|radio|submit)$/;
|
||||||
|
|
||||||
if (focused_tag === "textarea") return;
|
if (focused_tag === 'textarea') return;
|
||||||
if (focused_tag === "input") {
|
if (focused_tag === 'input') {
|
||||||
let focused_type = document.activeElement.type.toLowerCase();
|
let focused_type = document.activeElement.type.toLowerCase();
|
||||||
if (!focused_type.match(allowed)) return;
|
if (!focused_type.match(allowed)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Focus search bar on '/'
|
// Focus search bar on '/'
|
||||||
if (event.key === "/") {
|
if (event.key === '/') {
|
||||||
document.getElementById('searchbox').focus();
|
document.getElementById('searchbox').focus();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ embed_url.searchParams.delete('v');
|
|||||||
var short_url = location.origin + '/' + video_data.id + embed_url.search;
|
var short_url = location.origin + '/' + video_data.id + embed_url.search;
|
||||||
embed_url = location.origin + '/embed/' + 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) {
|
videojs.Vhs.xhr.beforeRequest = function(options) {
|
||||||
if (options.uri.indexOf('videoplayback') === -1 && options.uri.indexOf('local=true') === -1) {
|
if (options.uri.indexOf('videoplayback') === -1 && options.uri.indexOf('local=true') === -1) {
|
||||||
@ -112,8 +112,8 @@ var shareOptions = {
|
|||||||
description: player_data.description,
|
description: player_data.description,
|
||||||
image: player_data.thumbnail,
|
image: player_data.thumbnail,
|
||||||
get embedCode() {
|
get embedCode() {
|
||||||
return "<iframe id='ivplayer' width='640' height='360' src='" +
|
return '<iframe id="ivplayer" width="640" height="360" src="' +
|
||||||
addCurrentTimeToURL(embed_url) + "' style='border:none;'></iframe>";
|
addCurrentTimeToURL(embed_url) + '" style="border:none;"></iframe>';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,19 +138,19 @@ if (location.pathname.startsWith('/embed/')) {
|
|||||||
// Detection code taken from https://stackoverflow.com/a/20293441
|
// Detection code taken from https://stackoverflow.com/a/20293441
|
||||||
|
|
||||||
function isMobile() {
|
function isMobile() {
|
||||||
try{ document.createEvent("TouchEvent"); return true; }
|
try{ document.createEvent('TouchEvent'); return true; }
|
||||||
catch(e){ return false; }
|
catch(e){ return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
player.mobileUi();
|
player.mobileUi();
|
||||||
|
|
||||||
buttons = ["playToggle", "volumePanel", "captionsButton"];
|
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
|
// Create new control bar object for operation buttons
|
||||||
const ControlBar = videojs.getComponent("controlBar");
|
const ControlBar = videojs.getComponent('controlBar');
|
||||||
let operations_bar = new ControlBar(player, {
|
let operations_bar = new ControlBar(player, {
|
||||||
children: [],
|
children: [],
|
||||||
playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
|
playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
|
||||||
@ -158,24 +158,24 @@ if (isMobile()) {
|
|||||||
buttons.slice(1).forEach(function (child) {operations_bar.addChild(child);});
|
buttons.slice(1).forEach(function (child) {operations_bar.addChild(child);});
|
||||||
|
|
||||||
// Remove operation buttons from primary control bar
|
// Remove operation buttons from primary control bar
|
||||||
primary_control_bar = player.getChild("controlBar");
|
primary_control_bar = player.getChild('controlBar');
|
||||||
buttons.forEach(function (child) {primary_control_bar.removeChild(child);});
|
buttons.forEach(function (child) {primary_control_bar.removeChild(child);});
|
||||||
|
|
||||||
operations_bar_element = operations_bar.el();
|
operations_bar_element = operations_bar.el();
|
||||||
operations_bar_element.className += " mobile-operations-bar";
|
operations_bar_element.className += ' mobile-operations-bar';
|
||||||
player.addChild(operations_bar);
|
player.addChild(operations_bar);
|
||||||
|
|
||||||
// Playback menu doesn't work when it's initialized outside of the primary control bar
|
// Playback menu doesn't work when it's initialized outside of the primary control bar
|
||||||
playback_element = document.getElementsByClassName("vjs-playback-rate")[0];
|
playback_element = document.getElementsByClassName('vjs-playback-rate')[0];
|
||||||
operations_bar_element.append(playback_element);
|
operations_bar_element.append(playback_element);
|
||||||
|
|
||||||
// The share and http source selector element can't be fetched till the players ready.
|
// The share and http source selector element can't be fetched till the players ready.
|
||||||
player.one("playing", function () {
|
player.one('playing', function () {
|
||||||
share_element = document.getElementsByClassName("vjs-share-control")[0];
|
share_element = document.getElementsByClassName('vjs-share-control')[0];
|
||||||
operations_bar_element.append(share_element);
|
operations_bar_element.append(share_element);
|
||||||
|
|
||||||
if (video_data.params.quality === 'dash') {
|
if (video_data.params.quality === 'dash') {
|
||||||
http_source_selector = document.getElementsByClassName("vjs-http-source-selector vjs-menu-button")[0];
|
http_source_selector = document.getElementsByClassName('vjs-http-source-selector vjs-menu-button')[0];
|
||||||
operations_bar_element.append(http_source_selector);
|
operations_bar_element.append(http_source_selector);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -183,12 +183,12 @@ if (isMobile()) {
|
|||||||
|
|
||||||
// Enable VR video support
|
// Enable VR video support
|
||||||
if (!video_data.params.listen && video_data.vr && video_data.params.vr_mode) {
|
if (!video_data.params.listen && video_data.vr && video_data.params.vr_mode) {
|
||||||
player.crossOrigin("anonymous");
|
player.crossOrigin('anonymous');
|
||||||
switch (video_data.projection_type) {
|
switch (video_data.projection_type) {
|
||||||
case "EQUIRECTANGULAR":
|
case 'EQUIRECTANGULAR':
|
||||||
player.vr({projection: "equirectangular"});
|
player.vr({projection: 'equirectangular'});
|
||||||
default: // Should only be "MESH" but we'll use this as a fallback.
|
default: // Should only be 'MESH' but we'll use this as a fallback.
|
||||||
player.vr({projection: "EAC"});
|
player.vr({projection: 'EAC'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,15 +223,15 @@ player.playbackRate(video_data.params.speed);
|
|||||||
* @returns cookieValue
|
* @returns cookieValue
|
||||||
*/
|
*/
|
||||||
function getCookieValue(name) {
|
function getCookieValue(name) {
|
||||||
var value = document.cookie.split(";").filter(function (item) {return item.includes(name + "=");});
|
var value = document.cookie.split(';').filter(function (item) {return item.includes(name + '=');});
|
||||||
|
|
||||||
return (value.length >= 1)
|
return (value.length >= 1)
|
||||||
? value[0].substring((name + "=").length, value[0].length)
|
? value[0].substring((name + '=').length, value[0].length)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for updating the "PREFS" cookie (or creating it if missing)
|
* Method for updating the 'PREFS' cookie (or creating it if missing)
|
||||||
*
|
*
|
||||||
* @param {number} newVolume New volume defined (null if unchanged)
|
* @param {number} newVolume New volume defined (null if unchanged)
|
||||||
* @param {number} newSpeed New speed defined (null if unchanged)
|
* @param {number} newSpeed New speed defined (null if unchanged)
|
||||||
@ -291,7 +291,7 @@ if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.
|
|||||||
|
|
||||||
if (video_data.params.save_player_pos) {
|
if (video_data.params.save_player_pos) {
|
||||||
const url = new URL(location);
|
const url = new URL(location);
|
||||||
const hasTimeParam = url.searchParams.has("t");
|
const hasTimeParam = url.searchParams.has('t');
|
||||||
const remeberedTime = get_video_time();
|
const remeberedTime = get_video_time();
|
||||||
let lastUpdated = 0;
|
let lastUpdated = 0;
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ if (video_data.params.save_player_pos) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
player.on("timeupdate", updateTime);
|
player.on('timeupdate', updateTime);
|
||||||
}
|
}
|
||||||
else remove_all_video_times();
|
else remove_all_video_times();
|
||||||
|
|
||||||
@ -334,16 +334,16 @@ if (video_data.params.autoplay) {
|
|||||||
if (!video_data.params.listen && video_data.params.quality === 'dash') {
|
if (!video_data.params.listen && video_data.params.quality === 'dash') {
|
||||||
player.httpSourceSelector();
|
player.httpSourceSelector();
|
||||||
|
|
||||||
if (video_data.params.quality_dash !== "auto") {
|
if (video_data.params.quality_dash !== 'auto') {
|
||||||
player.ready(function () {
|
player.ready(function () {
|
||||||
player.on("loadedmetadata", function () {
|
player.on('loadedmetadata', function () {
|
||||||
const qualityLevels = Array.from(player.qualityLevels()).sort(function (a, b) {return a.height - b.height;});
|
const qualityLevels = Array.from(player.qualityLevels()).sort(function (a, b) {return a.height - b.height;});
|
||||||
let targetQualityLevel;
|
let targetQualityLevel;
|
||||||
switch (video_data.params.quality_dash) {
|
switch (video_data.params.quality_dash) {
|
||||||
case "best":
|
case 'best':
|
||||||
targetQualityLevel = qualityLevels.length - 1;
|
targetQualityLevel = qualityLevels.length - 1;
|
||||||
break;
|
break;
|
||||||
case "worst":
|
case 'worst':
|
||||||
targetQualityLevel = 0;
|
targetQualityLevel = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -734,7 +734,7 @@ window.addEventListener('keydown', function (e) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
player.on('mousewheel', mouseScroll);
|
player.on('mousewheel', mouseScroll);
|
||||||
player.on("DOMMouseScroll", mouseScroll);
|
player.on('DOMMouseScroll', mouseScroll);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// Since videojs-share can sometimes be blocked, we defer it until last
|
// Since videojs-share can sometimes be blocked, we defer it until last
|
||||||
@ -750,7 +750,7 @@ if (player_data.preferred_caption_found) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Safari audio double duration fix
|
// 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('loadedmetadata', function () {
|
||||||
player.on('timeupdate', function () {
|
player.on('timeupdate', function () {
|
||||||
if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) {
|
if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) {
|
||||||
@ -761,17 +761,17 @@ if (navigator.vendor === "Apple Computer, Inc." && video_data.params.listen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Watch on Invidious link
|
// Watch on Invidious link
|
||||||
if (window.location.pathname.startsWith("/embed/")) {
|
if (window.location.pathname.startsWith('/embed/')) {
|
||||||
const Button = videojs.getComponent('Button');
|
const Button = videojs.getComponent('Button');
|
||||||
let watch_on_invidious_button = new Button(player);
|
let watch_on_invidious_button = new Button(player);
|
||||||
|
|
||||||
// Create hyperlink for current instance
|
// Create hyperlink for current instance
|
||||||
redirect_element = document.createElement("a");
|
redirect_element = document.createElement('a');
|
||||||
redirect_element.setAttribute("href", `//${window.location.host}/watch?v=${window.location.pathname.replace("/embed/","")}`);
|
redirect_element.setAttribute('href', `//${window.location.host}/watch?v=${window.location.pathname.replace('/embed/','')}`);
|
||||||
redirect_element.appendChild(document.createTextNode("Invidious"));
|
redirect_element.appendChild(document.createTextNode('Invidious'));
|
||||||
|
|
||||||
watch_on_invidious_button.el().appendChild(redirect_element);
|
watch_on_invidious_button.el().appendChild(redirect_element);
|
||||||
watch_on_invidious_button.addClass("watch-on-invidious");
|
watch_on_invidious_button.addClass('watch-on-invidious');
|
||||||
|
|
||||||
cb = player.getChild('ControlBar');
|
cb = player.getChild('ControlBar');
|
||||||
cb.addChild(watch_on_invidious_button);
|
cb.addChild(watch_on_invidious_button);
|
||||||
|
@ -3,7 +3,7 @@ var toggle_theme = document.getElementById('toggle_theme');
|
|||||||
toggle_theme.href = 'javascript:void(0);';
|
toggle_theme.href = 'javascript:void(0);';
|
||||||
|
|
||||||
toggle_theme.addEventListener('click', function () {
|
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 url = '/toggle_theme?redirect=false';
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@ -49,9 +49,9 @@ function scheme_switch (e) {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
if (e.matches) {
|
if (e.matches) {
|
||||||
if (e.media.includes("dark")) {
|
if (e.media.includes('dark')) {
|
||||||
set_mode(true);
|
set_mode(true);
|
||||||
} else if (e.media.includes("light")) {
|
} else if (e.media.includes('light')) {
|
||||||
set_mode(false);
|
set_mode(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user