mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Fix fallback for comments
This commit is contained in:
parent
e46e6183ae
commit
57d88ffcc8
2 changed files with 32 additions and 31 deletions
|
@ -21,11 +21,6 @@ function toggle_comments(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function swap_comments(source) {
|
function swap_comments(source) {
|
||||||
comments = document.getElementById("comments");
|
|
||||||
var fallback = comments.innerHTML;
|
|
||||||
comments.innerHTML =
|
|
||||||
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
|
|
||||||
|
|
||||||
if (source == "youtube") {
|
if (source == "youtube") {
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (source == "reddit") {
|
} else if (source == "reddit") {
|
||||||
|
@ -46,3 +41,19 @@ String.prototype.supplant = function(o) {
|
||||||
return typeof r === "string" || typeof r === "number" ? r : a;
|
return typeof r === "string" || typeof r === "number" ? r : a;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function show_youtube_replies(target) {
|
||||||
|
body = target.parentNode.parentNode.children[1];
|
||||||
|
body.style.display = "";
|
||||||
|
|
||||||
|
target.innerHTML = "Hide replies";
|
||||||
|
target.setAttribute("onclick", "hide_youtube_replies(this)");
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide_youtube_replies(target) {
|
||||||
|
body = target.parentNode.parentNode.children[1];
|
||||||
|
body.style.display = "none";
|
||||||
|
|
||||||
|
target.innerHTML = "Show replies";
|
||||||
|
target.setAttribute("onclick", "show_youtube_replies(this)");
|
||||||
|
}
|
||||||
|
|
|
@ -121,15 +121,12 @@
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="comments">
|
<div id="comments">
|
||||||
<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-1-5">
|
<div class="pure-u-1 pure-u-md-1-5">
|
||||||
<% if plid %>
|
<% if plid %>
|
||||||
<div id="playlist" class="h-box">
|
<div id="playlist" class="h-box">
|
||||||
<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>
|
|
||||||
<hr>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -200,6 +197,11 @@ function unsubscribe() {
|
||||||
|
|
||||||
<% if plid %>
|
<% if plid %>
|
||||||
function get_playlist() {
|
function get_playlist() {
|
||||||
|
playlist = document.getElementById("playlist");
|
||||||
|
playlist.innerHTML = ' \
|
||||||
|
<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3> \
|
||||||
|
<hr>'
|
||||||
|
|
||||||
var plid = "<%= plid %>"
|
var plid = "<%= plid %>"
|
||||||
|
|
||||||
if (plid.startsWith("RD")) {
|
if (plid.startsWith("RD")) {
|
||||||
|
@ -217,7 +219,6 @@ function get_playlist() {
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4) {
|
if (xhr.readyState == 4) {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
playlist = document.getElementById("playlist");
|
|
||||||
playlist.innerHTML = xhr.response.playlistHtml;
|
playlist.innerHTML = xhr.response.playlistHtml;
|
||||||
|
|
||||||
if (xhr.response.nextVideo) {
|
if (xhr.response.nextVideo) {
|
||||||
|
@ -257,6 +258,11 @@ get_playlist();
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
function get_reddit_comments() {
|
function get_reddit_comments() {
|
||||||
|
comments = document.getElementById("comments");
|
||||||
|
var fallback = comments.innerHTML;
|
||||||
|
comments.innerHTML =
|
||||||
|
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
|
||||||
|
|
||||||
var url = "/api/v1/comments/<%= video.id %>?source=reddit&format=html";
|
var url = "/api/v1/comments/<%= video.id %>?source=reddit&format=html";
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = "json";
|
xhr.responseType = "json";
|
||||||
|
@ -267,7 +273,6 @@ function get_reddit_comments() {
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4) {
|
if (xhr.readyState == 4) {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
comments = document.getElementById("comments");
|
|
||||||
comments.innerHTML = ' \
|
comments.innerHTML = ' \
|
||||||
<div> \
|
<div> \
|
||||||
<h3> \
|
<h3> \
|
||||||
|
@ -295,8 +300,7 @@ function get_reddit_comments() {
|
||||||
<% if preferences && preferences.comments[1] == "youtube" %>
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
<% else %>
|
<% else %>
|
||||||
comments = document.getElementById("comments");
|
comments.innerHTML = fallback;
|
||||||
comments.innerHTML = "";
|
|
||||||
<% end %>
|
<% end %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,6 +314,11 @@ function get_reddit_comments() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_youtube_comments() {
|
function get_youtube_comments() {
|
||||||
|
comments = document.getElementById("comments");
|
||||||
|
var fallback = comments.innerHTML;
|
||||||
|
comments.innerHTML =
|
||||||
|
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
|
||||||
|
|
||||||
var url = "/api/v1/comments/<%= video.id %>?format=html";
|
var url = "/api/v1/comments/<%= video.id %>?format=html";
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = "json";
|
xhr.responseType = "json";
|
||||||
|
@ -320,7 +329,6 @@ function get_youtube_comments() {
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4) {
|
if (xhr.readyState == 4) {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
comments = document.getElementById("comments");
|
|
||||||
if (xhr.response.commentCount > 0) {
|
if (xhr.response.commentCount > 0) {
|
||||||
comments.innerHTML = ' \
|
comments.innerHTML = ' \
|
||||||
<div> \
|
<div> \
|
||||||
|
@ -346,7 +354,6 @@ function get_youtube_comments() {
|
||||||
<% if preferences && preferences.comments[1] == "youtube" %>
|
<% if preferences && preferences.comments[1] == "youtube" %>
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
<% else %>
|
<% else %>
|
||||||
comments = document.getElementById("comments");
|
|
||||||
comments.innerHTML = "";
|
comments.innerHTML = "";
|
||||||
<% end %>
|
<% end %>
|
||||||
}
|
}
|
||||||
|
@ -356,7 +363,6 @@ function get_youtube_comments() {
|
||||||
xhr.ontimeout = function() {
|
xhr.ontimeout = function() {
|
||||||
console.log("Pulling comments timed out.");
|
console.log("Pulling comments timed out.");
|
||||||
|
|
||||||
comments = document.getElementById("comments");
|
|
||||||
comments.innerHTML =
|
comments.innerHTML =
|
||||||
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
|
'<h3><center class="loading"><i class="icon ion-ios-refresh"></i></center></h3>';
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
|
@ -402,22 +408,6 @@ function get_youtube_replies(target) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_youtube_replies(target) {
|
|
||||||
body = target.parentNode.parentNode.children[1];
|
|
||||||
body.style.display = "";
|
|
||||||
|
|
||||||
target.innerHTML = "Hide replies";
|
|
||||||
target.setAttribute('onclick', 'hide_youtube_replies(this)');
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide_youtube_replies(target) {
|
|
||||||
body = target.parentNode.parentNode.children[1];
|
|
||||||
body.style.display = "none";
|
|
||||||
|
|
||||||
target.innerHTML = "Show replies";
|
|
||||||
target.setAttribute('onclick', 'show_youtube_replies(this)');
|
|
||||||
}
|
|
||||||
|
|
||||||
<% if preferences %>
|
<% if preferences %>
|
||||||
<% if preferences.comments[0] == "youtube" %>
|
<% if preferences.comments[0] == "youtube" %>
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
|
|
Loading…
Reference in a new issue