diff --git a/js/functions.js b/js/functions.js
index d216607..03416f2 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -1,17 +1,3 @@
-
-// HTML parsing
-const HTML = (function () {
- return {
- parse(htmlString) {
- const tmpDiv = document.createElement('div')
- tmpDiv.innerHTML = htmlString
- return tmpDiv.childNodes.length === 0 ? '' : tmpDiv.childNodes[0].nodeValue
- },
- main: document.getElementById('main'),
- }
-}())
-
-
// UTC time handling, very usefull when dealing with elasticsearch
var Time = (function () {
return {
diff --git a/js/subreddit.js b/js/subreddit.js
deleted file mode 100644
index 950de8d..0000000
--- a/js/subreddit.js
+++ /dev/null
@@ -1,36 +0,0 @@
-'use strict';
-
-let app = (function () {
- return {
- loadPage() {
- Status.loading("Loading subreddit...");
- document.title = Reddit.isAll ? "all subreddits" : Reddit.subreddit;
- HTML.main.innerHTML += _.templates.subredditInfo({subreddit: Reddit.subreddit, time: Vars.time});
-
- var urlData = {
- subreddit: Reddit.subreddit,
- time: Time.difference(Vars.time),
- page: Vars.page,
- postPerPage: Vars.postPerPage
- };
-
- Fetch2.get(ElasticSearch.threadURL+_.templates.elasticSubreddit(urlData), "Could not get removed posts")
- .then(Fetch2.json)
- .then(function(json){
- var startPostNr = (Vars.page - 1) * Vars.postPerPage + 1;
-
- _.forEach(json.hits.hits, function(subreddit, i){
- HTML.main.innerHTML += _.templates.thread({thread: subreddit._source, postNr: startPostNr+i});
- });
-
- var start = Math.max(Vars.page - 3, 1);
- var end = Math.min(start + 9, Math.ceil(json.hits.total/Vars.postPerPage));
- var urlBase = document.location.href.split("?")[0] + "?t=" + Vars.time + "&page=";
- HTML.main.innerHTML += _.templates.subredditPagination({start:start,end:end,currentPage:Vars.page,urlBase:urlBase});
- Status.success();
- })
- .catch(Fetch2.handleError);
- },
- }
-}());
-
diff --git a/js/thread.js b/js/thread.js
deleted file mode 100644
index be3a9f8..0000000
--- a/js/thread.js
+++ /dev/null
@@ -1,206 +0,0 @@
-"use strict";
-
-var app = (function(){
-return {
- loadPage: function() {
- Status.loading("Loading thread...");
- var urlData = {id: parseInt(Reddit.threadID, 36)};
-
- Promise.all([
- Fetch2.get(ElasticSearch.threadURL+_.templates.elasticThread(urlData), "Could not get thread")
- .then(Fetch2.json)
- .then(function(json){
- HTML.main.innerHTML += _.templates.thread({thread: json.hits.hits[0]._source});
- return json;
- })
- .catch(Fetch2.handleError),
-
- Fetch2.get(ElasticSearch.commentURL+_.templates.elasticComments(urlData), "Could not get removed comments")
- .then(Fetch2.json)
- .catch(Fetch2.handleError)
- ])
- .then(function(promises){
- var commentData = {
- removedComments: promises[1].hits.total,
- totalComments: promises[0].hits.hits[0]._source.num_comments
- };
-
- HTML.main.innerHTML += _.templates.threadInfo(commentData);
- Comments.addComments(promises[1]);
- Status.loading("Getting remaining comments...");
- })
- .then(function getRemainingComments() {
- return Fetch2.get(ElasticSearch.commentURL+_.templates.elasticCommentIDs({ids:Comments.missing}), "Could not get remaining comments")
- .then(Fetch2.json)
- .then(function(json){
- Comments.addComments(json);
-
- if(Comments.missing.length !== 0) {
- return getRemainingComments();
- }
- });
- })
- .then(function(){
- // Make sure to get the permalink comment (even if it's not related to removed/deleted stuff)
- if(Comments.isPermalink && !_.includes(Comments.IDs, Comments.getRoot())) {
- var urlData = {ids: [Comments.to10(Comments.getRoot())]};
- return Fetch2.get(ElasticSearch.commentURL+_.templates.elasticCommentIDs(urlData), "Could not find the specific comment asked for")
- .then(Fetch2.json)
- .then(function(json){
- Comments.addComments(json);
- });
- }
- })
- .then(function(){
- HTML.main.innerHTML += '
';
- Status.loading("Generating comments...");
- Comments.generate();
- Status.success();
- })
- .catch(Fetch2.handleError);
- }
-}})();
-
-
-var Comments = (function() {
-return {
- IDs: [], // The comments we found
- lookup: {},
- missing: [],
- isPermalink: (Reddit.permalink !== undefined && Reddit.permalink !== ""),
-
-
-
- addComments: function(json){
-
- Comments.IDs = _.union(Comments.IDs, _.map(json.hits.hits, function(comment){
- return Comments.to36(comment._id);
- }));
-
- _.forEach(json.hits.hits, function(comment){
- comment._source.parent_id = _.isNil(comment._source.parent_id) ? Reddit.threadID : Comments.to36(comment._source.parent_id);
- Comments.lookup[Comments.to36(comment._id)] = comment._source;
- });
-
- Comments.missing = _.reduce(json.hits.hits, function(array, comment){
- if(comment._source.parent_id !== Reddit.threadID && !_.includes(Comments.IDs, comment._source.parent_id)) {
- array.push(Comments.to10(comment._source.parent_id));
- }
- return array;
- }, []);
- },
-
- getRoot: function() {
- if(Reddit.permalink !== undefined && Reddit.permalink !== "") {
- return Reddit.permalink;
- }
-
- return Reddit.threadID;
- },
-
- generate: function(){
- //console.log("asdf ",_.includes(Comments.ids, "dms36h7"))
- Comments.IDs = _.sortBy(_.uniq(Comments.IDs), function(id) {
- return Comments.lookup[id].score;
- });
-
- var createdComments = [];
-
- if(Comments.isPermalink) {
- var urlData = {
- id: Comments.permalink,
- comment: Comments.lookup[Reddit.permalink]
- }
- document.getElementById(Reddit.threadID).innerHTML += _.templates.comment(urlData);
- createdComments.push(Reddit.permalink);
- } else {
- createdComments.push(Reddit.threadID);
- }
-
- var didSomething;
-
- while(Comments.IDs.length > 0) {
- didSomething = false;
-
- for(var i = Comments.IDs.length - 1; i >= 0; i--) {
- var id = Comments.IDs[i];
- var parentID = Comments.lookup[id].parent_id;
-
- if(_.includes(createdComments, parentID)) {
- document.getElementById(parentID).innerHTML += (_.templates.comment({id:id, comment: Comments.lookup[id]}));
- createdComments.push(id);
- Comments.IDs.splice(i, 1);
- didSomething = true;
- }
- }
-
- // Fail safe (parents missing for the rest of the comments, shouldn't happend but oh well :D)
- if(!didSomething) {
- console.error("Didn't generate all comments correctly");
- break;
- }
- }
- }
-};
-})();
-
-/*
-
-var ThreadHTML = (function(){
- // I actually haven't found a better way of doing this...
- // Imgur has image-links with no indication that they are actually images
- var imageHosts = ["i.redd.it", "flickr.com", "i.imgur.com", "imgur.com", "m.imgur.com"];
-
- var createThread = function(data) {
- var thread = data[0].data.children[0].data;
- Comments.setTotalComments(thread.num_comments);
- document.title = thread.title+" : "+thread.subreddit;
-
- var defaultThumbnails = ["self", "default", "image", "nsfw"];
- var thumbnail = '';
- } else {
- thumbnail += '">
';
- }
-
- var threadDiv = document.createElement("div");
- threadDiv.className = "thread";
- threadDiv.innerHTML = ' \
- \
-
\
-
'+Format.prettyScore(thread.score)+'
\
-
\
-
'+
- thumbnail+
- ' \
- '+(thread.link_flair_text !== null ? '
'+thread.link_flair_text+'' : '') +
- '
'+thread.title+' \
-
('+thread.domain+') \
-
' +
- (thread.selftext !== '' ? '
'+Format.parse(thread.selftext)+'
':'') +
- '' +
- (thread.media !== null ? HTML.parse(thread.media_embed.content) : '') +
- (_.includes(imageHosts, thread.domain) && _.has(thread, "preview") ? '

' : '') +
- '
\
- ';
- mainDiv.appendChild(threadDiv);
- return data;
- };
-
-
-
-})();*/
-
-if(isSupported) {
- app.loadPage();
-}
\ No newline at end of file
diff --git a/jst/elasticCommentIDs.jst b/jst/elasticCommentIDs.jst
deleted file mode 100644
index 2b8a06c..0000000
--- a/jst/elasticCommentIDs.jst
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "query":{
- "ids":{
- "values":[<%= ids.join() %>]
- }
- },
- "_source":[
- "author","body","created_utc","parent_id","score"
- ]
-}
\ No newline at end of file
diff --git a/jst/elasticComments.jst b/jst/elasticComments.jst
deleted file mode 100644
index 46141a7..0000000
--- a/jst/elasticComments.jst
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "query":{
- "term":{
- "link_id":<%= id %>
- }
- },
- "_source":[
- "author","body","created_utc","parent_id","score"
- ],
- "size":5
-}
\ No newline at end of file
diff --git a/jst/elasticSubreddit.jst b/jst/elasticSubreddit.jst
deleted file mode 100644
index cc7bca8..0000000
--- a/jst/elasticSubreddit.jst
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "query":{
- "bool":{
- "must":[
- <% if(_.toLower(subreddit) !== "all") { %>
- {
- "term":{
- "subreddit":"<%= _.toLower(subreddit) %>"
- }
- },
- <% } %>
- {
- "range":{
- "created_utc":{
- "gt":<%= time %>
- }
- }
- }
- ]
- }
- },
- "_source":[
- "author","url","subreddit","link_flair_text","score","title","created_utc","num_comments","domain","permalink","id","thumbnail","thumbnail_height","thumbnail_width"
- ],
- "sort":[
- {"score":"desc"}
- ],
- "from":<%= (page-1)*postPerPage %>,
- "size":<%= postPerPage %>
-}
\ No newline at end of file
diff --git a/jst/elasticThread.jst b/jst/elasticThread.jst
deleted file mode 100644
index 09e8b7a..0000000
--- a/jst/elasticThread.jst
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "query":{
- "term":{
- "id":"<%= id %>"
- }
- },
- "_source":[
- "author","created_utc","domain","link_flair_text","num_comments","url","subreddit","score","title","selftext","permalink","thumbnail","thumbnail_height","thumbnail_width"
- ],
- "size":1
-}
\ No newline at end of file
diff --git a/src/js/api/reddit/comment.js b/src/js/api/reddit/comment.js
index 9401db8..f1e4dbc 100644
--- a/src/js/api/reddit/comment.js
+++ b/src/js/api/reddit/comment.js
@@ -14,8 +14,3 @@ export const fetchComments = (commentIDs, auth) => (
.then(results => results.data.children)
.then(commentsData => commentsData.map(commentData => commentData.data))
)
-
-const debug = results => {
- console.log(JSON.parse(JSON.stringify(results)))
-}
-
diff --git a/src/js/api/reddit/index.js b/src/js/api/reddit/index.js
index 64b67ab..180eab3 100644
--- a/src/js/api/reddit/index.js
+++ b/src/js/api/reddit/index.js
@@ -1,182 +1,2 @@
export { getPost } from './thread'
export { getComments } from './comment'
-// Status.loading("Getting removed comments...");
-// HandleIDs.removed();
-// ThreadHTML.createCommentInfo(Comments.removed.length);
-// return Fetch2.multiple(URLs.format(URLs.pushshiftComments, Comments.removed), null, "data")
-// .catch(function(error){
-// return Promise.reject("Could not get removed comments");
-// });
-// })
-// .then(function(removedComments){
-// Status.loading("Generating comments...");
-// return Comments.generate(removedComments);
-// })
-// .then(function(){
-// Status.success();
-// })
-// .catch(function(error) {
-// if(_.includes(_.toLower(error), "error")) {
-// Status.error(error);
-// } else {
-// Status.error("Error: "+error);
-// }
-// });
-// }
-// }})();
-
-// // ------------------------------------------------------------------------------
-// // ----------------------- Store and genrates comments --------------------------
-// // ------------------------------------------------------------------------------
-// var Comments = (function() {
-// var totalComments;
-// var toBeCreated = [];
-
-// var getParentComments = function(toLookup){
-// var newCommentsToLookup = [];
-// var commentsToFetch = [];
-
-// _.forEach(toLookup, function(id){
-// var parentID = lookup[id].parent_id.split("_")[1];
-
-// if(parentID === Reddit.threadID) {} // Has no parent (is parent of thread)
-// else if(_.includes(Comments.toBeCreated, parentID)) {} // Parent already exists, do nothing
-// else if(_.includes(newCommentsToLookup, parentID)) {} // Parent already exists (this iteration)
-// else if(_.has(lookup, parentID)) {
-// newCommentsToLookup.push(parentID);
-// } else{
-// commentsToFetch.push(parentID);
-// }
-
-// Comments.toBeCreated.push(id);
-// });
-
-// return new Promise(function(resolve, reject){
-// if(_.uniq(commentsToFetch).length !== 0) {
-// fetch(URLs.singleComments + _.join(_.map(_.uniq(commentsToFetch),function(comments){
-// return "t1_" + comments;
-// })), Reddit.init)
-// .then(Fetch2.json)
-// .then(function(json){
-// _.forEach(json.data.children, function(comment) {
-// lookup[comment.data.id] = comment.data;
-// newCommentsToLookup.push(comment.data.id);
-// });
-// })
-// .then(function(){
-// resolve();
-// });
-
-// } else {
-// resolve();
-// }
-// })
-// .then(function(){
-// if(newCommentsToLookup.length !== 0) {
-// return getParentComments(newCommentsToLookup)
-// }
-// });
-
-// };
-
-// allIDs: [], // All the comments that we were suppose to find
-// removed: [],
-// deleted: [],
-// toBeCreated: toBeCreated,
-
-// getTotalComments: function() { return totalComments; },
-// setTotalComments: function(total) { totalComments = total; },
-
-// getRoot: function() {
-// if(Reddit.permalink !== undefined && Reddit.permalink === "") {
-// return Reddit.threadID;
-// }
-
-// if(Reddit.permalink === undefined) {
-// return Reddit.threadID;
-// }
-
-// if(_.has(Comments.lookup, Reddit.permalink)) {
-// return Comments.lookup[Reddit.permalink].parent_id.split("_")[1];
-// }
-// return "";
-// },
-// generate: function(removedComments) {
-// removedComments.forEach(function(comment){
-// if(_.includes(Comments.deleted, comment.id)) {
-// comment["deleted"] = true;
-// } else {
-// comment["removed"] = true;
-// }
-
-// Comments.lookup[comment.id] = comment;
-// });
-
-// Comments.removed = _.map(removedComments, function(comment){
-// return comment.id;
-// });
-
-// return getParentComments(Comments.removed)
-// .then(function(){
-// ThreadHTML.createCommentSection();
-// ThreadHTML.createComments();
-// })
-// }
-// }})();
-
-// var removed = function(){
-// Comments.removed = _.difference(Comments.allIDs, Comments.ids);
-
-// Comments.ids.forEach(function(id){
-// if(! _.has(Comments.lookup, id)) {
-// return;
-// }
-
-// if(Comments.lookup[id].body === "[removed]") {
-// Comments.removed.push(id);
-// } else if (Comments.lookup[id].body === "[deleted]"){
-// Comments.removed.push(id);
-// Comments.deleted.push(id);
-// }
-// });
-
-// Comments.removed = _.uniq(Comments.removed);
-// };
-
-
-// // ------------------------------------------------------------------------------
-// // ---------------------------- Generating HTML ---------------------------------
-// // ------------------------------------------------------------------------------
-
-
-// var createComments = function(){
-// var commentsToCreate = _.sortBy(_.uniq(Comments.toBeCreated), function(id) {
-// return Comments.lookup[id].score;
-// });
-
-// var createdComments = [Comments.getRoot()];
-// var didSomething = false;
-
-// while(commentsToCreate.length > 0) {
-// didSomething = false;
-
-// for(var i = commentsToCreate.length - 1; i >= 0; i--) {
-// var id = commentsToCreate[i];
-// var parentID = Comments.lookup[id].parent_id.split("_")[1];
-
-// if(_.includes(createdComments, parentID)) {
-// document.getElementById(parentID).appendChild(createComment(Comments.lookup[id]));
-// createdComments.push(id);
-// commentsToCreate.splice(i, 1);
-// didSomething = true;
-// }
-// }
-
-// // Fail safe (parents missing for the rest of the comments, shouldn't happend but oh well :D)
-// if(!didSomething) {
-// console.error("Didn't generate all comments correctly");
-// break;
-// }
-// }
-// };
-
diff --git a/src/js/index.js b/src/js/index.js
index 09e1df4..4a9a9ea 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -13,31 +13,3 @@ import '../sass/main.sass'
// ,
// document.getElementById('app')
// )
-import { getComments } from 'api/reddit'
-import { getComments as getAllComments } from 'api/pushshift'
-
-getAllComments('6z1hch')
- // .then(comments => comments.filter((val, i) => i < 100))
- .then(comments => {
- const ids = comments.map(comment => comment.id)
- // push to state
- return getComments(ids)
- })
-//
-// .then(getComments)
- .then(redditComments => {
- const removed = []
- const deleted = []
-
- redditComments.forEach(comment => {
- if (comment.body === '[removed]') {
- removed.push(comment.id)
- } else if (comment.body === '[deleted]') {
- deleted.push(comment.id)
- }
- })
-
- console.log('deleted', deleted)
- console.log('removed', removed)
- })
-