cleanup logging

This commit is contained in:
simon 2021-09-11 18:42:37 +07:00
parent 3376412c8f
commit 7d60af1491
2 changed files with 4 additions and 24 deletions

View File

@ -16,11 +16,9 @@ function checkMessage() {
req.onload = function() { req.onload = function() {
var dlProgress = req.response; var dlProgress = req.response;
if (dlProgress['status']) { if (dlProgress['status']) {
console.log('start interval');
buildDownloadMessage(dlProgress); buildDownloadMessage(dlProgress);
handleInterval(); handleInterval();
}; };
console.log(JSON.stringify(dlProgress));
}; };
req.send(); req.send();
} }
@ -34,14 +32,11 @@ function handleInterval() {
req.onload = function() { req.onload = function() {
var dlProgress = req.response; var dlProgress = req.response;
if (dlProgress['status']) { if (dlProgress['status']) {
console.log('continue interval');
buildDownloadMessage(dlProgress); buildDownloadMessage(dlProgress);
} else { } else {
console.log('stop interval');
clearInterval(watchDownload); clearInterval(watchDownload);
location.reload(); location.reload();
}; };
console.log(JSON.stringify(dlProgress));
}; };
req.send(); req.send();
}, 3000); }, 3000);
@ -81,6 +76,5 @@ function animate(elementId, animationClass) {
var toAnimate = document.getElementById(elementId); var toAnimate = document.getElementById(elementId);
if (toAnimate.className !== animationClass) { if (toAnimate.className !== animationClass) {
toAnimate.className = animationClass; toAnimate.className = animationClass;
console.log(elementId, animationClass);
} }
} }

View File

@ -65,7 +65,6 @@ function dlPending() {
function toIgnore(button) { function toIgnore(button) {
var youtube_id = button.getAttribute('data-id'); var youtube_id = button.getAttribute('data-id');
var payload = JSON.stringify({'ignore': youtube_id}); var payload = JSON.stringify({'ignore': youtube_id});
console.log(payload);
sendPost(payload); sendPost(payload);
document.getElementById('dl-' + youtube_id).remove(); document.getElementById('dl-' + youtube_id).remove();
} }
@ -151,17 +150,13 @@ function searchChannels(query) {
if (query.length > 1) { if (query.length > 1) {
var payload = JSON.stringify({'channel-search': query}) var payload = JSON.stringify({'channel-search': query})
sendSearchAsYouType(payload); sendSearchAsYouType(payload);
console.log(payload);
}; };
} }
function populateChannelResults(allResults) { function populateChannelResults(allResults) {
var searchResultBox = document.getElementById('resultBox'); var searchResultBox = document.getElementById('resultBox');
for (let i = 0; i < allResults.length; i++) { for (let i = 0; i < allResults.length; i++) {
var singleResult = allResults[i]; var singleResult = allResults[i];
var source = singleResult['source']; var source = singleResult['source'];
var channelName = source['channel_name']; var channelName = source['channel_name'];
@ -170,10 +165,7 @@ function populateChannelResults(allResults) {
optionElement.value = channelName; optionElement.value = channelName;
optionElement.setAttribute('data', channelId); optionElement.setAttribute('data', channelId);
searchResultBox.appendChild(optionElement); searchResultBox.appendChild(optionElement);
console.log(channelId, channelName); };
}
} }
function channelRedirect(){ function channelRedirect(){
@ -181,24 +173,20 @@ function channelRedirect(){
var firstChild = response.firstChild var firstChild = response.firstChild
if (firstChild) { if (firstChild) {
var redirectId = firstChild.getAttribute('data'); var redirectId = firstChild.getAttribute('data');
console.log('redirecting: ' + redirectId);
location = '/channel/' + redirectId; location = '/channel/' + redirectId;
} };
return false; return false;
} }
function sendSearchAsYouType(payload) { function sendSearchAsYouType(payload) {
console.log(payload);
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
http.onreadystatechange = function() { http.onreadystatechange = function() {
if (http.readyState === 4) { if (http.readyState === 4) {
allResults = JSON.parse(http.response)['results']; allResults = JSON.parse(http.response)['results'];
populateChannelResults(allResults); populateChannelResults(allResults);
} };
} };
http.open("POST", "/process/", true); http.open("POST", "/process/", true);
http.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); http.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
http.setRequestHeader("Content-type", "application/json"); http.setRequestHeader("Content-type", "application/json");
@ -206,10 +194,8 @@ function sendSearchAsYouType(payload) {
} }
// generic // generic
function sendPost(payload) { function sendPost(payload) {
console.log(payload);
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
http.open("POST", "/process/", true); http.open("POST", "/process/", true);
http.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); http.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));