|
|
@ -109,10 +109,10 @@ function number_with_separator(val) {
|
|
|
|
return val;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_playlist(plid, timeouts = 1) {
|
|
|
|
function get_playlist(plid, retries = 5) {
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts >= 10) {
|
|
|
|
if (retries <= 0) {
|
|
|
|
console.log('Failed to pull playlist');
|
|
|
|
console.log('Failed to pull playlist');
|
|
|
|
playlist.innerHTML = '';
|
|
|
|
playlist.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -136,7 +136,6 @@ function get_playlist(plid, timeouts = 1) {
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open('GET', plid_url, true);
|
|
|
|
xhr.open('GET', plid_url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
@ -174,20 +173,31 @@ function get_playlist(plid, timeouts = 1) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onerror = function () {
|
|
|
|
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
|
|
|
|
playlist.innerHTML =
|
|
|
|
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('Pulling playlist timed out... ' + retries + '/5');
|
|
|
|
|
|
|
|
setTimeout(function () { get_playlist(plid, retries - 1) }, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
playlist = document.getElementById('playlist');
|
|
|
|
playlist.innerHTML =
|
|
|
|
playlist.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
|
|
|
|
|
|
|
|
|
|
|
|
console.log('Pulling playlist timed out... ' + timeouts + '/10');
|
|
|
|
console.log('Pulling playlist timed out... ' + retries + '/5');
|
|
|
|
get_playlist(plid, timeouts++);
|
|
|
|
get_playlist(plid, retries - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_reddit_comments(timeouts = 1) {
|
|
|
|
function get_reddit_comments(retries = 5) {
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts >= 10) {
|
|
|
|
if (retries <= 0) {
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
comments.innerHTML = '';
|
|
|
|
comments.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -204,7 +214,6 @@ function get_reddit_comments(timeouts = 1) {
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
@ -239,8 +248,8 @@ function get_reddit_comments(timeouts = 1) {
|
|
|
|
comments.children[0].children[1].children[0].onclick = swap_comments;
|
|
|
|
comments.children[0].children[1].children[0].onclick = swap_comments;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (video_data.params.comments[1] === 'youtube') {
|
|
|
|
if (video_data.params.comments[1] === 'youtube') {
|
|
|
|
console.log('Pulling comments timed out... ' + timeouts + '/10');
|
|
|
|
console.log('Pulling comments failed... ' + retries + '/5');
|
|
|
|
get_youtube_comments(timeouts++);
|
|
|
|
setTimeout(function () { get_youtube_comments(retries - 1) }, 1000);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
comments.innerHTML = fallback;
|
|
|
|
comments.innerHTML = fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -248,16 +257,23 @@ function get_reddit_comments(timeouts = 1) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onerror = function () {
|
|
|
|
|
|
|
|
console.log('Pulling comments failed... ' + retries + '/5');
|
|
|
|
|
|
|
|
setInterval(function () { get_reddit_comments(retries - 1) }, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
console.log('Pulling comments timed out... ' + timeouts + '/10');
|
|
|
|
console.log('Pulling comments failed... ' + retries + '/5');
|
|
|
|
get_reddit_comments(timeouts++);
|
|
|
|
get_reddit_comments(retries - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_youtube_comments(timeouts = 1) {
|
|
|
|
function get_youtube_comments(retries = 5) {
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
comments = document.getElementById('comments');
|
|
|
|
|
|
|
|
|
|
|
|
if (timeouts >= 10) {
|
|
|
|
if (retries <= 0) {
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
console.log('Failed to pull comments');
|
|
|
|
comments.innerHTML = '';
|
|
|
|
comments.innerHTML = '';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -275,7 +291,6 @@ function get_youtube_comments(timeouts = 1) {
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
@ -305,7 +320,7 @@ function get_youtube_comments(timeouts = 1) {
|
|
|
|
comments.children[0].children[1].children[0].onclick = swap_comments;
|
|
|
|
comments.children[0].children[1].children[0].onclick = swap_comments;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (video_data.params.comments[1] === 'youtube') {
|
|
|
|
if (video_data.params.comments[1] === 'youtube') {
|
|
|
|
get_youtube_comments(timeouts++);
|
|
|
|
setTimeout(function () { get_youtube_comments(retries - 1) }, 1000);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
comments.innerHTML = '';
|
|
|
|
comments.innerHTML = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -313,12 +328,21 @@ function get_youtube_comments(timeouts = 1) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onerror = function () {
|
|
|
|
|
|
|
|
comments.innerHTML =
|
|
|
|
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
|
|
|
|
console.log('Pulling comments failed... ' + retries + '/5');
|
|
|
|
|
|
|
|
setInterval(function () { get_youtube_comments(retries - 1) }, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
comments.innerHTML =
|
|
|
|
comments.innerHTML =
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
|
|
|
console.log('Pulling comments timed out... ' + timeouts + '/10');
|
|
|
|
console.log('Pulling comments failed... ' + retries + '/5');
|
|
|
|
get_youtube_comments(timeouts++);
|
|
|
|
get_youtube_comments(retries - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_youtube_replies(target, load_more) {
|
|
|
|
function get_youtube_replies(target, load_more) {
|
|
|
@ -338,7 +362,6 @@ function get_youtube_replies(target, load_more) {
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.timeout = 20000;
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.open('GET', url, true);
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
@ -373,9 +396,11 @@ function get_youtube_replies(target, load_more) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
console.log('Pulling comments timed out.');
|
|
|
|
console.log('Pulling comments failed.');
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
body.innerHTML = fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (video_data.play_next) {
|
|
|
|
if (video_data.play_next) {
|
|
|
|