Commit whitespace

This commit is contained in:
Omar Roth 2018-08-09 16:07:11 -05:00
parent 02a4bbccb6
commit d4e37c0201
2 changed files with 120 additions and 121 deletions

View file

@ -93,7 +93,7 @@ var shareOptions = {
description: "<%= description %>", description: "<%= description %>",
image: "<%= thumbnail %>", image: "<%= thumbnail %>",
embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360' embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360'
src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>` src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>`
}; };
var player = videojs("player", options, function() { var player = videojs("player", options, function() {
@ -102,37 +102,37 @@ var player = videojs("player", options, function() {
seekStep: 5, seekStep: 5,
enableModifiersForNumbers: false, enableModifiersForNumbers: false,
customKeys: { customKeys: {
play: { play: {
key: function(e) { key: function(e) {
// Toggle play with K Key // Toggle play with K Key
return e.which === 75; return e.which === 75;
},
handler: function(player, options, e) {
if (player.paused()) {
player.play();
} else {
player.pause();
}
}
}, },
backward: { handler: function(player, options, e) {
key: function(e) { if (player.paused()) {
// Go backward 5 seconds player.play();
return e.which === 74; } else {
}, player.pause();
handler: function(player, options, e) { }
player.currentTime(player.currentTime() - 5);
}
},
forward: {
key: function(e) {
// Go forward 5 seconds
return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
}
} }
},
backward: {
key: function(e) {
// Go backward 5 seconds
return e.which === 74;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() - 5);
}
},
forward: {
key: function(e) {
// Go forward 5 seconds
return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
}
}
} }
}); });
}); });
@ -141,23 +141,23 @@ player.share(shareOptions);
<% if video_start > 0 || video_end > 0 %> <% if video_start > 0 || video_end > 0 %>
player.markers({ player.markers({
onMarkerReached: function(marker) { onMarkerReached: function(marker) {
if (marker.text === "End") { if (marker.text === "End") {
if (player.loop()) { if (player.loop()) {
player.markers.prev("Start"); player.markers.prev("Start");
} else { } else {
player.pause(); player.pause();
} }
} }
}, },
markers: [ markers: [
{ time: <%= video_start %>, text: "Start" }, { time: <%= video_start %>, text: "Start" },
<% if video_end < 0 %> <% 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 %> <% else %>
{ time: <%= video_end %>, text: "End" } { time: <%= video_end %>, text: "End" }
<% end %> <% end %>
] ]
}); });
player.currentTime(<%= video_start %>); player.currentTime(<%= video_start %>);
@ -167,9 +167,9 @@ player.currentTime(<%= video_start %>);
var currentSources = player.currentSources(); var currentSources = player.currentSources();
for (var i = 0; i < currentSources.length; i++) { for (var i = 0; i < currentSources.length; i++) {
if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") { if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
currentSources.splice(i); currentSources.splice(i);
i--; i--;
} }
} }
player.src(currentSources); player.src(currentSources);

View file

@ -59,7 +59,6 @@
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= i == 0 ? true : false %>"> <source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= i == 0 ? true : false %>">
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% preferred_captions.each_with_index do |caption, i| %> <% preferred_captions.each_with_index do |caption, i| %>
@ -105,7 +104,7 @@ var shareOptions = {
description: "<%= description %>", description: "<%= description %>",
image: "<%= thumbnail %>", image: "<%= thumbnail %>",
embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360' embedCode: `<iframe id='ivplayer' type='text/html' width='640' height='360'
src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>` src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>`
}; };
var player = videojs("player", options, function() { var player = videojs("player", options, function() {
@ -114,37 +113,37 @@ var player = videojs("player", options, function() {
seekStep: 5, seekStep: 5,
enableModifiersForNumbers: false, enableModifiersForNumbers: false,
customKeys: { customKeys: {
play: { play: {
key: function(e) { key: function(e) {
// Toggle play with K Key // Toggle play with K Key
return e.which === 75; return e.which === 75;
},
handler: function(player, options, e) {
if (player.paused()) {
player.play();
} else {
player.pause();
}
}
}, },
backward: { handler: function(player, options, e) {
key: function(e) { if (player.paused()) {
// Go backward 5 seconds player.play();
return e.which === 74; } else {
}, player.pause();
handler: function(player, options, e) { }
player.currentTime(player.currentTime() - 5);
}
},
forward: {
key: function(e) {
// Go forward 5 seconds
return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
}
} }
},
backward: {
key: function(e) {
// Go backward 5 seconds
return e.which === 74;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() - 5);
}
},
forward: {
key: function(e) {
// Go forward 5 seconds
return e.which === 76;
},
handler: function(player, options, e) {
player.currentTime(player.currentTime() + 5);
}
}
} }
}); });
}); });
@ -153,23 +152,23 @@ player.share(shareOptions);
<% if video_start > 0 || video_end > 0 %> <% if video_start > 0 || video_end > 0 %>
player.markers({ player.markers({
onMarkerReached: function(marker) { onMarkerReached: function(marker) {
if (marker.text === "End") { if (marker.text === "End") {
if (player.loop()) { if (player.loop()) {
player.markers.prev("Start"); player.markers.prev("Start");
} else { } else {
player.pause(); player.pause();
} }
} }
}, },
markers: [ markers: [
{ time: <%= video_start %>, text: "Start" }, { time: <%= video_start %>, text: "Start" },
<% if video_end < 0 %> <% 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 %> <% else %>
{ time: <%= video_end %>, text: "End" } { time: <%= video_end %>, text: "End" }
<% end %> <% end %>
] ]
}); });
player.currentTime(<%= video_start %>); player.currentTime(<%= video_start %>);
@ -179,9 +178,9 @@ player.currentTime(<%= video_start %>);
var currentSources = player.currentSources(); var currentSources = player.currentSources();
for (var i = 0; i < currentSources.length; i++) { for (var i = 0; i < currentSources.length; i++) {
if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") { if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
currentSources.splice(i); currentSources.splice(i);
i--; i--;
} }
} }
player.src(currentSources); player.src(currentSources);
@ -233,15 +232,15 @@ function load_comments(target) {
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { if (xhr.readyState == 4) {
if (xhr.statusCode == 200) { if (xhr.statusCode == 200) {
body.innerHTML = xhr.response.content_html; body.innerHTML = xhr.response.content_html;
} else { } else {
body.innerHTML = fallback; body.innerHTML = fallback;
}
} }
}
}; };
xhr.ontimeout = function() { xhr.ontimeout = function() {
body.innerHTML = fallback; body.innerHTML = fallback;
}; };
} }
@ -257,30 +256,30 @@ function get_reddit_comments() {
if (xhr.readyState == 4) if (xhr.readyState == 4)
if (xhr.status == 200) { if (xhr.status == 200) {
comments = document.getElementById("comments"); comments = document.getElementById("comments");
comments.innerHTML = ` comments.innerHTML = `
<div> <div>
<h3> <h3>
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> <a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a>
{title} {title}
</h3> </h3>
<b> <b>
<a target="_blank" href="https://reddit.com{permalink}">View more comments on Reddit</a> <a target="_blank" href="https://reddit.com{permalink}">View more comments on Reddit</a>
</b> </b>
</div> </div>
<div>{content_html}</div> <div>{content_html}</div>
<hr>`.supplant({ <hr>`.supplant({
title: xhr.response.title, title: xhr.response.title,
permalink: xhr.response.permalink, permalink: xhr.response.permalink,
content_html: xhr.response.content_html content_html: xhr.response.content_html
}); });
} else { } else {
get_youtube_comments(); get_youtube_comments();
} }
}; };
xhr.ontimeout = function() { xhr.ontimeout = function() {
get_reddit_comments(); get_reddit_comments();
}; };
} }
@ -297,20 +296,20 @@ function get_youtube_comments() {
if (xhr.status == 200) { if (xhr.status == 200) {
comments = document.getElementById("comments"); comments = document.getElementById("comments");
comments.innerHTML = ` comments.innerHTML = `
<div> <div>
<h3> <h3>
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a> <a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a>
<a target="_blank" href="https://www.youtube.com/watch?v=<%= video.id %>">View more comments on YouTube</a> <a target="_blank" href="https://www.youtube.com/watch?v=<%= video.id %>">View more comments on YouTube</a>
</h3> </h3>
</div> </div>
<div>{content_html}</div> <div>{content_html}</div>
<hr>`.supplant({ <hr>`.supplant({
content_html: xhr.response.content_html content_html: xhr.response.content_html
}); });
} else { } else {
comments = document.getElementById("comments"); comments = document.getElementById("comments");
comments.innerHTML = ""; comments.innerHTML = "";
} }
}; };
xhr.ontimeout = function() { xhr.ontimeout = function() {