Minor optimizations
This commit is contained in:
parent
b9f2702daf
commit
77d97277c9
@ -4936,14 +4936,14 @@
|
|||||||
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
||||||
});
|
});
|
||||||
input = $('input', this.controls);
|
input = $('input', this.controls);
|
||||||
$.on(input, 'change', QuoteThreading.toggle);
|
$.on(input, 'change', this.toggle);
|
||||||
$.event('AddMenuEntry', {
|
$.event('AddMenuEntry', {
|
||||||
type: 'header',
|
type: 'header',
|
||||||
el: this.controls,
|
el: this.controls,
|
||||||
order: 98
|
order: 98
|
||||||
});
|
});
|
||||||
if (!Conf['Unread Count']) {
|
if (!Conf['Unread Count']) {
|
||||||
$.on(d, '4chanXInitFinished', QuoteThreading.setup);
|
$.on(d, '4chanXInitFinished', this.setup);
|
||||||
}
|
}
|
||||||
return Post.callbacks.push({
|
return Post.callbacks.push({
|
||||||
name: 'Quote Threading',
|
name: 'Quote Threading',
|
||||||
@ -4963,35 +4963,27 @@
|
|||||||
return QuoteThreading.hasRun = true;
|
return QuoteThreading.hasRun = true;
|
||||||
},
|
},
|
||||||
node: function() {
|
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) {
|
if (this.isClone || !QuoteThreading.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Conf['Unread Count']) {
|
if (Conf['Unread Count']) {
|
||||||
Unread.posts.push(this);
|
Unread.posts.push(this);
|
||||||
}
|
}
|
||||||
if (this.thread.OP === this) {
|
if (this.thread.OP === this || !(post = posts[this.fullID]) || post.isHidden) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
quotes = this.quotes, ID = this.ID, fullID = this.fullID;
|
|
||||||
posts = g.posts;
|
|
||||||
if (!(post = posts[fullID]) || post.isHidden) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keys = [];
|
keys = [];
|
||||||
len = ("" + g.BOARD).length + 1;
|
len = g.BOARD.ID.length + 1;
|
||||||
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
|
_ref = this.quotes;
|
||||||
quote = quotes[_i];
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
if (quote.slice(len) < ID) {
|
quote = _ref[_i];
|
||||||
if (quote in posts) {
|
if ((quote.slice(len) < this.ID) && quote in posts) {
|
||||||
keys.push(quote);
|
keys.push(quote);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keys.length !== 1) {
|
if (keys.length !== 1) {
|
||||||
if (Conf['Unread Count']) {
|
|
||||||
Unread.posts.push(this);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.threaded = keys[0];
|
this.threaded = keys[0];
|
||||||
|
|||||||
@ -4939,14 +4939,14 @@
|
|||||||
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
||||||
});
|
});
|
||||||
input = $('input', this.controls);
|
input = $('input', this.controls);
|
||||||
$.on(input, 'change', QuoteThreading.toggle);
|
$.on(input, 'change', this.toggle);
|
||||||
$.event('AddMenuEntry', {
|
$.event('AddMenuEntry', {
|
||||||
type: 'header',
|
type: 'header',
|
||||||
el: this.controls,
|
el: this.controls,
|
||||||
order: 98
|
order: 98
|
||||||
});
|
});
|
||||||
if (!Conf['Unread Count']) {
|
if (!Conf['Unread Count']) {
|
||||||
$.on(d, '4chanXInitFinished', QuoteThreading.setup);
|
$.on(d, '4chanXInitFinished', this.setup);
|
||||||
}
|
}
|
||||||
return Post.callbacks.push({
|
return Post.callbacks.push({
|
||||||
name: 'Quote Threading',
|
name: 'Quote Threading',
|
||||||
@ -4966,35 +4966,27 @@
|
|||||||
return QuoteThreading.hasRun = true;
|
return QuoteThreading.hasRun = true;
|
||||||
},
|
},
|
||||||
node: function() {
|
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) {
|
if (this.isClone || !QuoteThreading.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Conf['Unread Count']) {
|
if (Conf['Unread Count']) {
|
||||||
Unread.posts.push(this);
|
Unread.posts.push(this);
|
||||||
}
|
}
|
||||||
if (this.thread.OP === this) {
|
if (this.thread.OP === this || !(post = posts[this.fullID]) || post.isHidden) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
quotes = this.quotes, ID = this.ID, fullID = this.fullID;
|
|
||||||
posts = g.posts;
|
|
||||||
if (!(post = posts[fullID]) || post.isHidden) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keys = [];
|
keys = [];
|
||||||
len = ("" + g.BOARD).length + 1;
|
len = g.BOARD.ID.length + 1;
|
||||||
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
|
_ref = this.quotes;
|
||||||
quote = quotes[_i];
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
if (quote.slice(len) < ID) {
|
quote = _ref[_i];
|
||||||
if (quote in posts) {
|
if ((quote.slice(len) < this.ID) && quote in posts) {
|
||||||
keys.push(quote);
|
keys.push(quote);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keys.length !== 1) {
|
if (keys.length !== 1) {
|
||||||
if (Conf['Unread Count']) {
|
|
||||||
Unread.posts.push(this);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.threaded = keys[0];
|
this.threaded = keys[0];
|
||||||
|
|||||||
@ -11,14 +11,14 @@ QuoteThreading =
|
|||||||
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
innerHTML: '<label><input id=threadingControl type=checkbox checked> Threading</label>'
|
||||||
|
|
||||||
input = $ 'input', @controls
|
input = $ 'input', @controls
|
||||||
$.on input, 'change', QuoteThreading.toggle
|
$.on input, 'change', @toggle
|
||||||
|
|
||||||
$.event 'AddMenuEntry',
|
$.event 'AddMenuEntry',
|
||||||
type: 'header'
|
type: 'header'
|
||||||
el: @controls
|
el: @controls
|
||||||
order: 98
|
order: 98
|
||||||
|
|
||||||
$.on d, '4chanXInitFinished', QuoteThreading.setup unless Conf['Unread Count']
|
$.on d, '4chanXInitFinished', @setup unless Conf['Unread Count']
|
||||||
|
|
||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Quote Threading'
|
name: 'Quote Threading'
|
||||||
@ -32,23 +32,17 @@ QuoteThreading =
|
|||||||
QuoteThreading.hasRun = true
|
QuoteThreading.hasRun = true
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
|
{posts} = g
|
||||||
return if @isClone or not QuoteThreading.enabled
|
return if @isClone or not QuoteThreading.enabled
|
||||||
Unread.posts.push @ if Conf['Unread Count']
|
Unread.posts.push @ if Conf['Unread Count']
|
||||||
|
|
||||||
return if @thread.OP is @
|
return if @thread.OP is @ or !(post = posts[@fullID]) or post.isHidden # Filtered
|
||||||
|
|
||||||
{quotes, ID, fullID} = @
|
|
||||||
{posts} = g
|
|
||||||
return if !(post = posts[fullID]) or post.isHidden # Filtered
|
|
||||||
|
|
||||||
keys = []
|
keys = []
|
||||||
len = "#{g.BOARD}".length + 1
|
len = g.BOARD.ID.length + 1
|
||||||
for quote in quotes when quote[len..] < ID
|
keys.push quote for quote in @quotes when (quote[len..] < @ID) and quote of posts
|
||||||
keys.push quote if quote of posts
|
|
||||||
|
|
||||||
unless keys.length is 1
|
return unless keys.length is 1
|
||||||
Unread.posts.push @ if Conf['Unread Count']
|
|
||||||
return
|
|
||||||
|
|
||||||
@threaded = keys[0]
|
@threaded = keys[0]
|
||||||
@cb = QuoteThreading.nodeinsert
|
@cb = QuoteThreading.nodeinsert
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user