Small reflow to QuoteBacklink I.
I don't like concatenating for temporary data.
This commit is contained in:
parent
000ca6f9ce
commit
e451410ef1
@ -5185,21 +5185,25 @@
|
||||
});
|
||||
},
|
||||
firstNode: function() {
|
||||
var container, post, quoteID, _base, _i, _j, _len, _len1, _ref, _ref1;
|
||||
var addNodes, container, post, quoteID, _base, _i, _j, _len, _len1, _ref, _ref1;
|
||||
if (this.isClone) {
|
||||
return;
|
||||
}
|
||||
addNodes = function(post, that) {
|
||||
return $.add(post.nodes.backlinkContainer, QuoteBacklink.buildBacklink(post, that));
|
||||
};
|
||||
_ref = this.quotes;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quoteID = _ref[_i];
|
||||
((_base = QuoteBacklink.map)[quoteID] || (_base[quoteID] = [])).push(this.fullID);
|
||||
if (!((post = g.posts[quoteID]) && (container = post != null ? post.nodes.backlinkContainer : void 0))) {
|
||||
if (!(((post = g.posts[quoteID]) != null) && (container = post.nodes.backlinkContainer))) {
|
||||
continue;
|
||||
}
|
||||
_ref1 = [post].concat(post.clones);
|
||||
addNodes(post, this);
|
||||
_ref1 = post.clones;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
post = _ref1[_j];
|
||||
$.add(post.nodes.backlinkContainer, QuoteBacklink.buildBacklink(post, this));
|
||||
addNodes(post, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -12566,7 +12570,9 @@
|
||||
g.threads.forEach(function(thread) {
|
||||
return thread.collect();
|
||||
});
|
||||
QuoteBacklink.containers = {};
|
||||
if (Conf['Quote Backlinks']) {
|
||||
QuoteBacklink.map = {};
|
||||
}
|
||||
return $.rmAll($('.board'));
|
||||
},
|
||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||
|
||||
@ -5237,21 +5237,25 @@
|
||||
});
|
||||
},
|
||||
firstNode: function() {
|
||||
var container, post, quoteID, _base, _i, _j, _len, _len1, _ref, _ref1;
|
||||
var addNodes, container, post, quoteID, _base, _i, _j, _len, _len1, _ref, _ref1;
|
||||
if (this.isClone) {
|
||||
return;
|
||||
}
|
||||
addNodes = function(post, that) {
|
||||
return $.add(post.nodes.backlinkContainer, QuoteBacklink.buildBacklink(post, that));
|
||||
};
|
||||
_ref = this.quotes;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quoteID = _ref[_i];
|
||||
((_base = QuoteBacklink.map)[quoteID] || (_base[quoteID] = [])).push(this.fullID);
|
||||
if (!((post = g.posts[quoteID]) && (container = post != null ? post.nodes.backlinkContainer : void 0))) {
|
||||
if (!(((post = g.posts[quoteID]) != null) && (container = post.nodes.backlinkContainer))) {
|
||||
continue;
|
||||
}
|
||||
_ref1 = [post].concat(post.clones);
|
||||
addNodes(post, this);
|
||||
_ref1 = post.clones;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
post = _ref1[_j];
|
||||
$.add(post.nodes.backlinkContainer, QuoteBacklink.buildBacklink(post, this));
|
||||
addNodes(post, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -12580,7 +12584,9 @@
|
||||
g.threads.forEach(function(thread) {
|
||||
return thread.collect();
|
||||
});
|
||||
QuoteBacklink.containers = {};
|
||||
if (Conf['Quote Backlinks']) {
|
||||
QuoteBacklink.map = {};
|
||||
}
|
||||
return $.rmAll($('.board'));
|
||||
},
|
||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||
|
||||
@ -36,8 +36,7 @@ Navigate =
|
||||
clean: ->
|
||||
# Garbage collection
|
||||
g.threads.forEach (thread) -> thread.collect()
|
||||
QuoteBacklink.containers = {}
|
||||
|
||||
QuoteBacklink.map = {} if Conf['Quote Backlinks'] # Containers can get pretty icky.
|
||||
$.rmAll $ '.board'
|
||||
|
||||
features: [
|
||||
|
||||
@ -16,20 +16,27 @@ QuoteBacklink =
|
||||
@funk = Function 'id', "return '#{format}'"
|
||||
@frag = $.nodes [$.tn(' '), $.el 'a', className: 'backlink']
|
||||
@map = {}
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Quote Backlinking Part 1'
|
||||
cb: @firstNode
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Quote Backlinking Part 2'
|
||||
cb: @secondNode
|
||||
|
||||
firstNode: ->
|
||||
return if @isClone
|
||||
addNodes = (post, that) ->
|
||||
$.add post.nodes.backlinkContainer, QuoteBacklink.buildBacklink post, that
|
||||
for quoteID in @quotes
|
||||
(QuoteBacklink.map[quoteID] or= []).push @fullID
|
||||
continue unless (post = g.posts[quoteID]) and container = post?.nodes.backlinkContainer
|
||||
for post in [post].concat post.clones
|
||||
$.add post.nodes.backlinkContainer, QuoteBacklink.buildBacklink post, @
|
||||
continue unless (post = g.posts[quoteID])? and container = post.nodes.backlinkContainer
|
||||
addNodes post, @
|
||||
for post in post.clones
|
||||
addNodes post, @
|
||||
return
|
||||
|
||||
secondNode: ->
|
||||
# Don't backlink the OP.
|
||||
return unless @isReply or Conf['OP Backlinks']
|
||||
@ -46,6 +53,7 @@ QuoteBacklink =
|
||||
if post = g.posts[quoteID] # Post hasn't been collected since.
|
||||
$.add container, QuoteBacklink.buildBacklink @, post
|
||||
$.add @nodes.info, container
|
||||
|
||||
buildBacklink: (quoted, quoter) ->
|
||||
frag = QuoteBacklink.frag.cloneNode true
|
||||
a = frag.lastElementChild
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user