|
|
@ -124,46 +124,86 @@ player.offset({
|
|
|
|
end: <%= video_end %>
|
|
|
|
end: <%= video_end %>
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<% if !listen %>
|
|
|
|
|
|
|
|
var currentSources = player.currentSources();
|
|
|
|
|
|
|
|
for ( var i = 0; i < currentSources.length; i++ ) {
|
|
|
|
|
|
|
|
if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
|
|
|
|
|
|
|
|
currentSources.splice(i);
|
|
|
|
|
|
|
|
i--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.src(currentSources);
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
function toggle(target) {
|
|
|
|
function toggle(target) {
|
|
|
|
body = target.parentNode.parentNode.children[1];
|
|
|
|
body = target.parentNode.parentNode.children[1];
|
|
|
|
if (body.style.display === null || body.style.display === '') {
|
|
|
|
if (body.style.display === null || body.style.display === "") {
|
|
|
|
target.innerHTML = '[ + ]';
|
|
|
|
target.innerHTML = "[ + ]";
|
|
|
|
body.style.display = 'none';
|
|
|
|
body.style.display = "none";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
target.innerHTML = '[ - ]';
|
|
|
|
target.innerHTML = "[ - ]";
|
|
|
|
body.style.display = '';
|
|
|
|
body.style.display = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggle_comments(target) {
|
|
|
|
function toggle_comments(target) {
|
|
|
|
body = target.parentNode.parentNode.parentNode.children[1];
|
|
|
|
body = target.parentNode.parentNode.parentNode.children[1];
|
|
|
|
if (body.style.display === null || body.style.display === '') {
|
|
|
|
if (body.style.display === null || body.style.display === "") {
|
|
|
|
target.innerHTML = '[ + ]';
|
|
|
|
target.innerHTML = "[ + ]";
|
|
|
|
body.style.display = 'none';
|
|
|
|
body.style.display = "none";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
target.innerHTML = '[ - ]';
|
|
|
|
target.innerHTML = "[ - ]";
|
|
|
|
body.style.display = '';
|
|
|
|
body.style.display = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<% if !listen %>
|
|
|
|
|
|
|
|
var currentSources = player.currentSources();
|
|
|
|
|
|
|
|
for ( var i = 0; i < currentSources.length; i++ ) {
|
|
|
|
|
|
|
|
if (player.canPlayType(currentSources[i]["type"].split(";")[0]) === "") {
|
|
|
|
|
|
|
|
currentSources.splice(i);
|
|
|
|
|
|
|
|
i--;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function timeout(ms, promise) {
|
|
|
|
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
|
|
reject(new Error("timeout"));
|
|
|
|
|
|
|
|
}, ms);
|
|
|
|
|
|
|
|
promise.then(resolve, reject);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
player.src(currentSources);
|
|
|
|
function load_comments(target) {
|
|
|
|
<% end %>
|
|
|
|
var continuation = target.getAttribute("data-continuation");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var body = target.parentNode.parentNode;
|
|
|
|
|
|
|
|
var fallback = body.innerHTML;
|
|
|
|
|
|
|
|
body.innerHTML =
|
|
|
|
|
|
|
|
'<h3><center><i class="loading fas fa-spinner"></i></center></h3>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var url =
|
|
|
|
|
|
|
|
"/api/v1/comments/<%= video.id %>?format=html&continuation=" + continuation;
|
|
|
|
|
|
|
|
timeout(5000, fetch(url))
|
|
|
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
|
|
|
return response.json();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(
|
|
|
|
|
|
|
|
function(jsonResponse) {
|
|
|
|
|
|
|
|
body.innerHTML = jsonResponse.content_html;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function(error) {
|
|
|
|
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
|
|
|
|
console.log(response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_reddit_comments() {
|
|
|
|
fetch("/api/v1/comments/<%= video.id %>?source=reddit")
|
|
|
|
fetch("/api/v1/comments/<%= video.id %>?source=reddit")
|
|
|
|
.then(function(response) {
|
|
|
|
.then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(function(jsonResponse) {
|
|
|
|
.then(
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
function(jsonResponse) {
|
|
|
|
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
comments.innerHTML = `
|
|
|
|
comments.innerHTML = `
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h3>
|
|
|
|
<h3>
|
|
|
@ -175,25 +215,52 @@ fetch("/api/v1/comments/<%= video.id %>?source=reddit")
|
|
|
|
</b>
|
|
|
|
</b>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>{content_html}</div>
|
|
|
|
<div>{content_html}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr style="margin-left:1em; margin-right:1em;">`.supplant({
|
|
|
|
<hr style="margin-left:1em; margin-right:1em;">`.supplant({
|
|
|
|
title: jsonResponse.title,
|
|
|
|
title: jsonResponse.title,
|
|
|
|
permalink: jsonResponse.permalink,
|
|
|
|
permalink: jsonResponse.permalink,
|
|
|
|
content_html: jsonResponse.content_html
|
|
|
|
content_html: jsonResponse.content_html
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function(response) {
|
|
|
|
|
|
|
|
get_youtube_comments();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_youtube_comments() {
|
|
|
|
|
|
|
|
fetch("/api/v1/comments/<%= video.id %>?format=html")
|
|
|
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}, function(response){
|
|
|
|
.then(
|
|
|
|
comments.innerHTML = "";
|
|
|
|
function(jsonResponse) {
|
|
|
|
|
|
|
|
comments = document.getElementById("comments");
|
|
|
|
|
|
|
|
comments.innerHTML = `
|
|
|
|
|
|
|
|
<div>{content_html}</div>
|
|
|
|
|
|
|
|
<hr style="margin-left:1em; margin-right:1em;">`.supplant({
|
|
|
|
|
|
|
|
content_html: jsonResponse.content_html
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function(response) {
|
|
|
|
|
|
|
|
comments.innerHTML = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String.prototype.supplant = function(o) {
|
|
|
|
String.prototype.supplant = function(o) {
|
|
|
|
return this.replace(/{([^{}]*)}/g,
|
|
|
|
return this.replace(/{([^{}]*)}/g, function(a, b) {
|
|
|
|
function (a, b) {
|
|
|
|
|
|
|
|
var r = o[b];
|
|
|
|
var r = o[b];
|
|
|
|
return typeof r === 'string' || typeof r === 'number' ? r : a;
|
|
|
|
return typeof r === "string" || typeof r === "number" ? r : a;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<% if preferences && preferences.comments == "reddit" %>
|
|
|
|
|
|
|
|
get_reddit_comments();
|
|
|
|
|
|
|
|
<% else %>
|
|
|
|
|
|
|
|
get_youtube_comments();
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="h-box">
|
|
|
|
<div class="h-box">
|
|
|
|