From 2e1dc0088d8e42751a68194e848b9a3ec08a7427 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 13 Jan 2014 01:01:02 -0700 Subject: [PATCH] Sometimes we can just do it better when we give it a second look. --- builds/4chan-X.user.js | 24 +++++++++++------------- builds/crx/script.js | 24 +++++++++++------------- src/General/Get.coffee | 21 +++++++++------------ 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index ddf285674..2424976a7 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3108,36 +3108,34 @@ }; }, allQuotelinksLinkingTo: function(post) { - var ID, handleClones, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2; + var ID, handleQuotes, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2; quotelinks = []; qLconcat = function(links) { return quotelinks = quotelinks.concat(links); }; - handleClones = function(clones) { - var clone, _i, _len; - for (_i = 0, _len = clones.length; _i < _len; _i++) { - clone = clones[_i]; + handleQuotes = function(post) { + var clone, _i, _len, _ref; + qLconcat(post.nodes.quotelinks); + _ref = post.clones; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + clone = _ref[_i]; qLconcat(clone.nodes.quotelinks); } }; _ref = g.posts; for (ID in _ref) { quoterPost = _ref[ID]; - if (!(_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0)) { - continue; + if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) { + handleQuotes(quoterPost); } - qLconcat(quoterPost.nodes.quotelinks); - handleClones(quoterPost.clones); } if (Conf['Quote Backlinks']) { _ref2 = post.quotes; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { quote = _ref2[_i]; - if (!(quotedPost = g.posts[quote])) { - continue; + if (quotedPost = g.posts[quote]) { + handleQuotes(quotedPost); } - qLconcat(quotedPost.nodes.quotelinks); - handleClones(quotedPost.clones); } } return quotelinks.filter(function(quotelink) { diff --git a/builds/crx/script.js b/builds/crx/script.js index a571ad837..3e48bfafc 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3118,36 +3118,34 @@ }; }, allQuotelinksLinkingTo: function(post) { - var ID, handleClones, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2; + var ID, handleQuotes, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2; quotelinks = []; qLconcat = function(links) { return quotelinks = quotelinks.concat(links); }; - handleClones = function(clones) { - var clone, _i, _len; - for (_i = 0, _len = clones.length; _i < _len; _i++) { - clone = clones[_i]; + handleQuotes = function(post) { + var clone, _i, _len, _ref; + qLconcat(post.nodes.quotelinks); + _ref = post.clones; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + clone = _ref[_i]; qLconcat(clone.nodes.quotelinks); } }; _ref = g.posts; for (ID in _ref) { quoterPost = _ref[ID]; - if (!(_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0)) { - continue; + if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) { + handleQuotes(quoterPost); } - qLconcat(quoterPost.nodes.quotelinks); - handleClones(quoterPost.clones); } if (Conf['Quote Backlinks']) { _ref2 = post.quotes; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { quote = _ref2[_i]; - if (!(quotedPost = g.posts[quote])) { - continue; + if (quotedPost = g.posts[quote]) { + handleQuotes(quotedPost); } - qLconcat(quotedPost.nodes.quotelinks); - handleClones(quotedPost.clones); } } return quotelinks.filter(function(quotelink) { diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 5dffe7a80..d9480a052 100755 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -40,28 +40,25 @@ Get = allQuotelinksLinkingTo: (post) -> # Get quotelinks & backlinks linking to the given post. quotelinks = [] + qLconcat = (links) -> + quotelinks = quotelinks.concat links + handleQuotes = (post) -> + qLconcat post.nodes.quotelinks + for clone in post.clones + qLconcat clone.nodes.quotelinks + return # First: # In every posts, # if it did quote this post, # get all their backlinks. - qLconcat = (links) -> - quotelinks = quotelinks.concat links - handleClones = (clones) -> - for clone in clones - qLconcat clone.nodes.quotelinks - return - for ID, quoterPost of g.posts when post.fullID in quoterPost.quotes - qLconcat quoterPost.nodes.quotelinks - handleClones quoterPost.clones + handleQuotes quoterPost for ID, quoterPost of g.posts when post.fullID in quoterPost.quotes # Second: # If we have quote backlinks: # in all posts this post quoted # and their clones, # get all of their backlinks. if Conf['Quote Backlinks'] - for quote in post.quotes when quotedPost = g.posts[quote] - qLconcat quotedPost.nodes.quotelinks - handleClones quotedPost.clones + handleQuotes quotedPost for quote in post.quotes when quotedPost = g.posts[quote] # Third: # Filter out irrelevant quotelinks. quotelinks.filter (quotelink) ->