diff --git a/static/js/functions.js b/static/js/functions.js index 0e0e596..13089b0 100644 --- a/static/js/functions.js +++ b/static/js/functions.js @@ -77,7 +77,7 @@ return { init.headers.Authorization = "bearer " + json.access_token; }) .catch(function(error) { - return Promise.reject("Can't connect to Reddit API (402)"); + return Promise.reject("Can't connect to Reddit API (401)"); }) } @@ -86,10 +86,6 @@ return { // Helper functions for fetch var Fetch2 = (function(){ - var json = function(response) { - return response.json(); - }; - return { multiple: function(urls, init, jsonPath, flattening) { flattening = _.defaultTo(flattening, true); @@ -97,7 +93,7 @@ return { return Promise.all(_.map(urls, function(url) { return fetch(url, init) - .then(json) + .then(Fetch2.json) .then(function(jsonArray) { if(! _.isNil(jsonPath)) { return _.get(jsonArray, jsonPath); @@ -112,9 +108,9 @@ return { return dataArray; }); }, - json: json - - + json: function(response) { + return response.json(); + } }})(); var URLs = (function(){ diff --git a/static/js/thread.js b/static/js/thread.js index 9f9dd22..a58bb44 100644 --- a/static/js/thread.js +++ b/static/js/thread.js @@ -34,14 +34,12 @@ return { Status.loading("Loading comments from reddit..."); HandleIDs.normal(thread); - console.log("After normal", Comments.ids.length); return HandleIDs.morechildren() .catch(function(error){ return Promise.reject("Could not get comments from Reddit (moreChildren)"); }); }) .then(function(){ - console.log("After morechildren", Comments.ids.length); return Promise.all(_.map(_.uniq(Comments.countinuethread), function(id) { return fetch(URLs.thread+"/_/"+id.split("_")[1], Reddit.init) .then(Fetch2.json) @@ -55,12 +53,8 @@ return { _.forEach(smallerThreads, function(thread){ HandleIDs.normal(thread); }) - console.log("After continueThisThread", Comments.ids.length); - console.log("Total", Comments.ids.length); - console.log("Unique", _.uniq(Comments.ids).length); Status.loading("Getting removed comments..."); HandleIDs.removed(); - console.log("Removed", Comments.removed.length); ThreadHTML.createCommentInfo(Comments.removed.length); return Fetch2.multiple(URLs.format(URLs.pushshiftComments, Comments.removed), null, "data") .catch(function(error){ @@ -184,8 +178,6 @@ return { return getParentComments(Comments.removed) .then(function(){ - //console.log("Removed length", Comments.removed.length) - //console.log("ToBeCreated", Comments.toBeCreated); ThreadHTML.createCommentSection(); ThreadHTML.createComments(); }) @@ -409,5 +401,5 @@ var ThreadHTML = (function(){ })(); if(isSupported) { - app.loadPage() + app.loadPage(); } \ No newline at end of file