summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-09 16:01:39 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-09 16:01:39 -0500
commit02a4bbccb6550c0e3473c860108b5b766973cf69 (patch)
tree9ac3604f4e3afb1321209721d05c1417edf314d7 /src
parent3154f250d89b14be4998b0fc5d4e2d0fbefced2e (diff)
downloadinvidious-02a4bbccb6550c0e3473c860108b5b766973cf69.tar.gz
invidious-02a4bbccb6550c0e3473c860108b5b766973cf69.tar.bz2
invidious-02a4bbccb6550c0e3473c860108b5b766973cf69.zip
Format JavaScript
Diffstat (limited to 'src')
-rw-r--r--src/invidious/views/embed.ecr48
-rw-r--r--src/invidious/views/watch.ecr115
2 files changed, 84 insertions, 79 deletions
diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr
index 9c202ed3..6ca1da7b 100644
--- a/src/invidious/views/embed.ecr
+++ b/src/invidious/views/embed.ecr
@@ -65,22 +65,22 @@ video, #my_video, .video-js, .vjs-default-skin
<script>
var options = {
<% if autoplay %>
- preload: 'auto',
+ preload: "auto",
<% end %>
playbackRates: [0.5, 1, 1.5, 2],
controlBar: {
children: [
- 'playToggle',
- 'volumePanel',
- 'currentTimeDisplay',
- 'timeDivider',
- 'durationDisplay',
- 'progressControl',
- 'remainingTimeDisplay',
- 'captionsButton',
- 'qualitySelector',
- 'playbackRateMenuButton',
- 'fullscreenToggle'
+ "playToggle",
+ "volumePanel",
+ "currentTimeDisplay",
+ "timeDivider",
+ "durationDisplay",
+ "progressControl",
+ "remainingTimeDisplay",
+ "captionsButton",
+ "qualitySelector",
+ "playbackRateMenuButton",
+ "fullscreenToggle"
]
}
};
@@ -91,12 +91,12 @@ var shareOptions = {
url: "<%= host_url %>/<%= video.id %>?<%= host_params %>",
title: "<%= video.title.dump_unquoted %>",
description: "<%= description %>",
- image: '<%= thumbnail %>',
+ image: "<%= thumbnail %>",
embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360'
src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>`
};
-var player = videojs('player', options, function() {
+var player = videojs("player", options, function() {
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
@@ -105,7 +105,7 @@ var player = videojs('player', options, function() {
play: {
key: function(e) {
// Toggle play with K Key
- return (e.which === 75);
+ return e.which === 75;
},
handler: function(player, options, e) {
if (player.paused()) {
@@ -118,7 +118,7 @@ var player = videojs('player', options, function() {
backward: {
key: function(e) {
// Go backward 5 seconds
- return (e.which === 74);
+ return e.which === 74;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() - 5);
@@ -127,7 +127,7 @@ var player = videojs('player', options, function() {
forward: {
key: function(e) {
// Go forward 5 seconds
- return (e.which === 76);
+ return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
@@ -142,20 +142,20 @@ player.share(shareOptions);
<% if video_start > 0 || video_end > 0 %>
player.markers({
onMarkerReached: function(marker) {
- if (marker.text === 'End') {
+ if (marker.text === "End") {
if (player.loop()) {
- player.markers.prev('Start');
+ player.markers.prev("Start");
} else {
player.pause();
}
}
},
markers: [
- {time: <%= video_start %>, text: 'Start'},
+ { time: <%= video_start %>, text: "Start" },
<% if video_end < 0 %>
- {time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: 'End'}
+ { time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: "End" }
<% else %>
- {time: <%= video_end %>, text: 'End'}
+ { time: <%= video_end %>, text: "End" }
<% end %>
]
});
@@ -165,8 +165,8 @@ player.currentTime(<%= video_start %>);
<% if !listen %>
var currentSources = player.currentSources();
-for ( var i = 0; i < currentSources.length; i++ ) {
- if (player.canPlayType(currentSources[i]['type'].split(';')[0]) === '') {
+for (var i = 0; i < currentSources.length; i++) {
+ if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
currentSources.splice(i);
i--;
}
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 9a2d20f7..e439881e 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -77,22 +77,22 @@
<script>
var options = {
- aspectRatio: '16:9',
- preload: 'auto',
+ aspectRatio: "16:9",
+ preload: "auto",
playbackRates: [0.5, 1, 1.5, 2],
controlBar: {
children: [
- 'playToggle',
- 'volumePanel',
- 'currentTimeDisplay',
- 'timeDivider',
- 'durationDisplay',
- 'progressControl',
- 'remainingTimeDisplay',
- 'captionsButton',
- 'qualitySelector',
- 'playbackRateMenuButton',
- 'fullscreenToggle'
+ "playToggle",
+ "volumePanel",
+ "currentTimeDisplay",
+ "timeDivider",
+ "durationDisplay",
+ "progressControl",
+ "remainingTimeDisplay",
+ "captionsButton",
+ "qualitySelector",
+ "playbackRateMenuButton",
+ "fullscreenToggle"
]
}
};
@@ -103,12 +103,12 @@ var shareOptions = {
url: "<%= host_url %>/<%= video.id %>?<%= host_params %>",
title: "<%= video.title.dump_unquoted %>",
description: "<%= description %>",
- image: '<%= thumbnail %>',
+ image: "<%= thumbnail %>",
embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360'
src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>`
};
-var player = videojs('player', options, function() {
+var player = videojs("player", options, function() {
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
@@ -117,7 +117,7 @@ var player = videojs('player', options, function() {
play: {
key: function(e) {
// Toggle play with K Key
- return (e.which === 75);
+ return e.which === 75;
},
handler: function(player, options, e) {
if (player.paused()) {
@@ -130,7 +130,7 @@ var player = videojs('player', options, function() {
backward: {
key: function(e) {
// Go backward 5 seconds
- return (e.which === 74);
+ return e.which === 74;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() - 5);
@@ -139,7 +139,7 @@ var player = videojs('player', options, function() {
forward: {
key: function(e) {
// Go forward 5 seconds
- return (e.which === 76);
+ return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
@@ -154,20 +154,20 @@ player.share(shareOptions);
<% if video_start > 0 || video_end > 0 %>
player.markers({
onMarkerReached: function(marker) {
- if (marker.text === 'End') {
+ if (marker.text === "End") {
if (player.loop()) {
- player.markers.prev('Start');
+ player.markers.prev("Start");
} else {
player.pause();
}
}
},
markers: [
- {time: <%= video_start %>, text: 'Start'},
+ { time: <%= video_start %>, text: "Start" },
<% if video_end < 0 %>
- {time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: 'End'}
+ { time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: "End" }
<% else %>
- {time: <%= video_end %>, text: 'End'}
+ { time: <%= video_end %>, text: "End" }
<% end %>
]
});
@@ -177,8 +177,8 @@ player.currentTime(<%= video_start %>);
<% if !listen %>
var currentSources = player.currentSources();
-for ( var i = 0; i < currentSources.length; i++ ) {
- if (player.canPlayType(currentSources[i]['type'].split(';')[0]) === '') {
+for (var i = 0; i < currentSources.length; i++) {
+ if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
currentSources.splice(i);
i--;
}
@@ -194,65 +194,69 @@ player.playbackRate(<%= preferences.speed %>);
function toggle(target) {
body = target.parentNode.parentNode.children[1];
- if (body.style.display === null || body.style.display === '') {
- target.innerHTML = '[ + ]';
- body.style.display = 'none';
+ if (body.style.display === null || body.style.display === "") {
+ target.innerHTML = "[ + ]";
+ body.style.display = "none";
} else {
- target.innerHTML = '[ - ]';
- body.style.display = '';
+ target.innerHTML = "[ - ]";
+ body.style.display = "";
}
}
function toggle_comments(target) {
body = target.parentNode.parentNode.parentNode.children[1];
- if (body.style.display === null || body.style.display === '') {
- target.innerHTML = '[ + ]';
- body.style.display = 'none';
+ if (body.style.display === null || body.style.display === "") {
+ target.innerHTML = "[ + ]";
+ body.style.display = "none";
} else {
- target.innerHTML = '[ - ]';
- body.style.display = '';
+ target.innerHTML = "[ - ]";
+ body.style.display = "";
}
}
function load_comments(target) {
- var continuation = target.getAttribute('data-continuation');
+ var continuation = target.getAttribute("data-continuation");
var body = target.parentNode.parentNode;
var fallback = body.innerHTML;
body.innerHTML =
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
- var url = '/api/v1/comments/<%= video.id %>?format=html&continuation=' + continuation;
+ var url =
+ "/api/v1/comments/<%= video.id %>?format=html&continuation=" + continuation;
var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
+ xhr.responseType = "json";
xhr.timeout = 10000;
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
- if(xhr.readyState == 4 && xhr.status == 200) {
+ if (xhr.readyState == 4) {
+ if (xhr.statusCode == 200) {
body.innerHTML = xhr.response.content_html;
} else {
body.innerHTML = fallback;
}
}
+ };
xhr.ontimeout = function() {
body.innerHTML = fallback;
- }
+ };
}
function get_reddit_comments() {
- var url = '/api/v1/comments/<%= video.id %>?source=reddit';
+ var url = "/api/v1/comments/<%= video.id %>?source=reddit";
var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
+ xhr.responseType = "json";
xhr.timeout = 10000;
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
- if(xhr.readyState == 4 && xhr.status == 200) {
- comments = document.getElementById('comments');
+ if (xhr.readyState == 4)
+ if (xhr.status == 200) {
+ comments = document.getElementById("comments");
comments.innerHTML = `
<div>
<h3>
@@ -277,20 +281,21 @@ function get_reddit_comments() {
xhr.ontimeout = function() {
get_reddit_comments();
- }
+ };
}
function get_youtube_comments() {
- var url = '/api/v1/comments/<%= video.id %>?format=html';
+ var url = "/api/v1/comments/<%= video.id %>?format=html";
var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
+ xhr.responseType = "json";
xhr.timeout = 10000;
xhr.open("GET", url, true);
xhr.send();
xhr.onreadystatechange = function() {
- if(xhr.readyState == 4 && xhr.status == 200) {
- comments = document.getElementById('comments');
+ if (xhr.readyState == 4)
+ if (xhr.status == 200) {
+ comments = document.getElementById("comments");
comments.innerHTML = `
<div>
<h3>
@@ -303,20 +308,20 @@ function get_youtube_comments() {
content_html: xhr.response.content_html
});
} else {
- comments = document.getElementById('comments');
- comments.innerHTML = '';
- }
+ comments = document.getElementById("comments");
+ comments.innerHTML = "";
}
+ };
- xhr.ontimeout = function () {
+ xhr.ontimeout = function() {
get_youtube_comments();
- }
+ };
}
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;
+ return typeof r === "string" || typeof r === "number" ? r : a;
});
};