[].push.appy and [].concat? Lets... comprehend that code better.
This commit is contained in:
parent
d41448a403
commit
56c7288d8d
@ -3108,36 +3108,43 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
allQuotelinksLinkingTo: function(post) {
|
allQuotelinksLinkingTo: function(post) {
|
||||||
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
var ID, handleClones, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2;
|
||||||
quotelinks = [];
|
quotelinks = [];
|
||||||
|
qLconcat = function(links) {
|
||||||
|
return quotelinks = quotelinks.concat(links);
|
||||||
|
};
|
||||||
|
handleClones = function(clones) {
|
||||||
|
var clone, _i, _len, _results;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = clones.length; _i < _len; _i++) {
|
||||||
|
clone = clones[_i];
|
||||||
|
_results.push(qLconcat(clone.nodes.quotelinks));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
};
|
||||||
_ref = g.posts;
|
_ref = g.posts;
|
||||||
for (ID in _ref) {
|
for (ID in _ref) {
|
||||||
quoterPost = _ref[ID];
|
quoterPost = _ref[ID];
|
||||||
if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) {
|
if (!(_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0)) {
|
||||||
_ref2 = [quoterPost].concat(quoterPost.clones);
|
continue;
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
|
||||||
quoterPost = _ref2[_i];
|
|
||||||
quotelinks.push.apply(quotelinks, quoterPost.nodes.quotelinks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
qLconcat(quoterPost.nodes.quotelinks);
|
||||||
|
handleClones(quoterPost.clones);
|
||||||
}
|
}
|
||||||
if (Conf['Quote Backlinks']) {
|
if (Conf['Quote Backlinks']) {
|
||||||
_ref3 = post.quotes;
|
_ref2 = post.quotes;
|
||||||
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
quote = _ref3[_j];
|
quote = _ref2[_i];
|
||||||
if (!(quotedPost = g.posts[quote])) {
|
if (!(quotedPost = g.posts[quote])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_ref4 = [quotedPost].concat(quotedPost.clones);
|
qLconcat(quotedPost.nodes.quotelinks);
|
||||||
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
|
handleClones(quotedPost.clones);
|
||||||
quotedPost = _ref4[_k];
|
|
||||||
quotelinks.push.apply(quotelinks, __slice.call(quotedPost.nodes.backlinks));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return quotelinks.filter(function(quotelink) {
|
return quotelinks.filter(function(quotelink) {
|
||||||
var boardID, postID, _ref5;
|
var boardID, postID, _ref3;
|
||||||
_ref5 = Get.postDataFromLink(quotelink), boardID = _ref5.boardID, postID = _ref5.postID;
|
_ref3 = Get.postDataFromLink(quotelink), boardID = _ref3.boardID, postID = _ref3.postID;
|
||||||
return boardID === post.board.ID && postID === post.ID;
|
return boardID === post.board.ID && postID === post.ID;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3118,36 +3118,43 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
allQuotelinksLinkingTo: function(post) {
|
allQuotelinksLinkingTo: function(post) {
|
||||||
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
var ID, handleClones, qLconcat, quote, quotedPost, quotelinks, quoterPost, _i, _len, _ref, _ref1, _ref2;
|
||||||
quotelinks = [];
|
quotelinks = [];
|
||||||
|
qLconcat = function(links) {
|
||||||
|
return quotelinks = quotelinks.concat(links);
|
||||||
|
};
|
||||||
|
handleClones = function(clones) {
|
||||||
|
var clone, _i, _len, _results;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = clones.length; _i < _len; _i++) {
|
||||||
|
clone = clones[_i];
|
||||||
|
_results.push(qLconcat(clone.nodes.quotelinks));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
};
|
||||||
_ref = g.posts;
|
_ref = g.posts;
|
||||||
for (ID in _ref) {
|
for (ID in _ref) {
|
||||||
quoterPost = _ref[ID];
|
quoterPost = _ref[ID];
|
||||||
if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) {
|
if (!(_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0)) {
|
||||||
_ref2 = [quoterPost].concat(quoterPost.clones);
|
continue;
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
|
||||||
quoterPost = _ref2[_i];
|
|
||||||
quotelinks.push.apply(quotelinks, quoterPost.nodes.quotelinks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
qLconcat(quoterPost.nodes.quotelinks);
|
||||||
|
handleClones(quoterPost.clones);
|
||||||
}
|
}
|
||||||
if (Conf['Quote Backlinks']) {
|
if (Conf['Quote Backlinks']) {
|
||||||
_ref3 = post.quotes;
|
_ref2 = post.quotes;
|
||||||
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
quote = _ref3[_j];
|
quote = _ref2[_i];
|
||||||
if (!(quotedPost = g.posts[quote])) {
|
if (!(quotedPost = g.posts[quote])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_ref4 = [quotedPost].concat(quotedPost.clones);
|
qLconcat(quotedPost.nodes.quotelinks);
|
||||||
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
|
handleClones(quotedPost.clones);
|
||||||
quotedPost = _ref4[_k];
|
|
||||||
quotelinks.push.apply(quotelinks, __slice.call(quotedPost.nodes.backlinks));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return quotelinks.filter(function(quotelink) {
|
return quotelinks.filter(function(quotelink) {
|
||||||
var boardID, postID, _ref5;
|
var boardID, postID, _ref3;
|
||||||
_ref5 = Get.postDataFromLink(quotelink), boardID = _ref5.boardID, postID = _ref5.postID;
|
_ref3 = Get.postDataFromLink(quotelink), boardID = _ref3.boardID, postID = _ref3.postID;
|
||||||
return boardID === post.board.ID && postID === post.ID;
|
return boardID === post.board.ID && postID === post.ID;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -44,10 +44,14 @@ Get =
|
|||||||
# In every posts,
|
# In every posts,
|
||||||
# if it did quote this post,
|
# if it did quote this post,
|
||||||
# get all their backlinks.
|
# get all their backlinks.
|
||||||
for ID, quoterPost of g.posts
|
qLconcat = (links) ->
|
||||||
if post.fullID in quoterPost.quotes
|
quotelinks = quotelinks.concat links
|
||||||
for quoterPost in [quoterPost].concat quoterPost.clones
|
handleClones = (clones) ->
|
||||||
quotelinks.push.apply quotelinks, quoterPost.nodes.quotelinks
|
for clone in clones
|
||||||
|
qLconcat clone.nodes.quotelinks
|
||||||
|
for ID, quoterPost of g.posts when post.fullID in quoterPost.quotes
|
||||||
|
qLconcat quoterPost.nodes.quotelinks
|
||||||
|
handleClones quoterPost.clones
|
||||||
# Second:
|
# Second:
|
||||||
# If we have quote backlinks:
|
# If we have quote backlinks:
|
||||||
# in all posts this post quoted
|
# in all posts this post quoted
|
||||||
@ -56,8 +60,8 @@ Get =
|
|||||||
if Conf['Quote Backlinks']
|
if Conf['Quote Backlinks']
|
||||||
for quote in post.quotes
|
for quote in post.quotes
|
||||||
continue unless quotedPost = g.posts[quote]
|
continue unless quotedPost = g.posts[quote]
|
||||||
for quotedPost in [quotedPost].concat quotedPost.clones
|
qLconcat quotedPost.nodes.quotelinks
|
||||||
quotelinks.push.apply quotelinks, [quotedPost.nodes.backlinks...]
|
handleClones quotedPost.clones
|
||||||
# Third:
|
# Third:
|
||||||
# Filter out irrelevant quotelinks.
|
# Filter out irrelevant quotelinks.
|
||||||
quotelinks.filter (quotelink) ->
|
quotelinks.filter (quotelink) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user