Minor optimizations

This commit is contained in:
Zixaphir 2014-01-06 09:04:45 -07:00
parent b9f2702daf
commit 77d97277c9
3 changed files with 29 additions and 51 deletions

View File

@ -4936,14 +4936,14 @@
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
});
input = $('input', this.controls);
$.on(input, 'change', QuoteThreading.toggle);
$.on(input, 'change', this.toggle);
$.event('AddMenuEntry', {
type: 'header',
el: this.controls,
order: 98
});
if (!Conf['Unread Count']) {
$.on(d, '4chanXInitFinished', QuoteThreading.setup);
$.on(d, '4chanXInitFinished', this.setup);
}
return Post.callbacks.push({
name: 'Quote Threading',
@ -4963,35 +4963,27 @@
return QuoteThreading.hasRun = true;
},
node: function() {
var ID, fullID, keys, len, post, posts, quote, quotes, _i, _len;
var keys, len, post, posts, quote, _i, _len, _ref;
posts = g.posts;
if (this.isClone || !QuoteThreading.enabled) {
return;
}
if (Conf['Unread Count']) {
Unread.posts.push(this);
}
if (this.thread.OP === this) {
return;
}
quotes = this.quotes, ID = this.ID, fullID = this.fullID;
posts = g.posts;
if (!(post = posts[fullID]) || post.isHidden) {
if (this.thread.OP === this || !(post = posts[this.fullID]) || post.isHidden) {
return;
}
keys = [];
len = ("" + g.BOARD).length + 1;
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
quote = quotes[_i];
if (quote.slice(len) < ID) {
if (quote in posts) {
keys.push(quote);
}
len = g.BOARD.ID.length + 1;
_ref = this.quotes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if ((quote.slice(len) < this.ID) && quote in posts) {
keys.push(quote);
}
}
if (keys.length !== 1) {
if (Conf['Unread Count']) {
Unread.posts.push(this);
}
return;
}
this.threaded = keys[0];

View File

@ -4939,14 +4939,14 @@
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
});
input = $('input', this.controls);
$.on(input, 'change', QuoteThreading.toggle);
$.on(input, 'change', this.toggle);
$.event('AddMenuEntry', {
type: 'header',
el: this.controls,
order: 98
});
if (!Conf['Unread Count']) {
$.on(d, '4chanXInitFinished', QuoteThreading.setup);
$.on(d, '4chanXInitFinished', this.setup);
}
return Post.callbacks.push({
name: 'Quote Threading',
@ -4966,35 +4966,27 @@
return QuoteThreading.hasRun = true;
},
node: function() {
var ID, fullID, keys, len, post, posts, quote, quotes, _i, _len;
var keys, len, post, posts, quote, _i, _len, _ref;
posts = g.posts;
if (this.isClone || !QuoteThreading.enabled) {
return;
}
if (Conf['Unread Count']) {
Unread.posts.push(this);
}
if (this.thread.OP === this) {
return;
}
quotes = this.quotes, ID = this.ID, fullID = this.fullID;
posts = g.posts;
if (!(post = posts[fullID]) || post.isHidden) {
if (this.thread.OP === this || !(post = posts[this.fullID]) || post.isHidden) {
return;
}
keys = [];
len = ("" + g.BOARD).length + 1;
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
quote = quotes[_i];
if (quote.slice(len) < ID) {
if (quote in posts) {
keys.push(quote);
}
len = g.BOARD.ID.length + 1;
_ref = this.quotes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if ((quote.slice(len) < this.ID) && quote in posts) {
keys.push(quote);
}
}
if (keys.length !== 1) {
if (Conf['Unread Count']) {
Unread.posts.push(this);
}
return;
}
this.threaded = keys[0];

View File

@ -11,14 +11,14 @@ QuoteThreading =
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
input = $ 'input', @controls
$.on input, 'change', QuoteThreading.toggle
$.on input, 'change', @toggle
$.event 'AddMenuEntry',
type: 'header'
el: @controls
order: 98
$.on d, '4chanXInitFinished', QuoteThreading.setup unless Conf['Unread Count']
$.on d, '4chanXInitFinished', @setup unless Conf['Unread Count']
Post.callbacks.push
name: 'Quote Threading'
@ -32,23 +32,17 @@ QuoteThreading =
QuoteThreading.hasRun = true
node: ->
{posts} = g
return if @isClone or not QuoteThreading.enabled
Unread.posts.push @ if Conf['Unread Count']
return if @thread.OP is @
{quotes, ID, fullID} = @
{posts} = g
return if !(post = posts[fullID]) or post.isHidden # Filtered
return if @thread.OP is @ or !(post = posts[@fullID]) or post.isHidden # Filtered
keys = []
len = "#{g.BOARD}".length + 1
for quote in quotes when quote[len..] < ID
keys.push quote if quote of posts
len = g.BOARD.ID.length + 1
keys.push quote for quote in @quotes when (quote[len..] < @ID) and quote of posts
unless keys.length is 1
Unread.posts.push @ if Conf['Unread Count']
return
return unless keys.length is 1
@threaded = keys[0]
@cb = QuoteThreading.nodeinsert