I hate checking conditionals over and over again.

This commit is contained in:
Zixaphir 2013-03-15 19:51:28 -07:00
parent 69763f87e9
commit 1e6e3f41a4
2 changed files with 53 additions and 35 deletions

View File

@ -3852,6 +3852,9 @@
if (g.VIEW === 'catalog' || !Conf['Resurrect Quotes']) { if (g.VIEW === 'catalog' || !Conf['Resurrect Quotes']) {
return; return;
} }
if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node);
}
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Resurrect Quotes', name: 'Resurrect Quotes',
cb: this.node cb: this.node
@ -3930,6 +3933,9 @@
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) { if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
return; return;
} }
if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node);
}
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Quote Inlining', name: 'Quote Inlining',
cb: this.node cb: this.node
@ -4022,6 +4028,9 @@
if (g.VIEW === 'catalog' || !Conf['Quote Previewing']) { if (g.VIEW === 'catalog' || !Conf['Quote Previewing']) {
return; return;
} }
if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node);
}
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Quote Previewing', name: 'Quote Previewing',
cb: this.node cb: this.node
@ -4217,6 +4226,9 @@
if (g.VIEW === 'catalog' || !Conf['Mark OP Quotes']) { if (g.VIEW === 'catalog' || !Conf['Mark OP Quotes']) {
return; return;
} }
if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node);
}
this.text = '\u00A0(OP)'; this.text = '\u00A0(OP)';
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Mark OP Quotes', name: 'Mark OP Quotes',
@ -4257,6 +4269,9 @@
if (g.VIEW === 'catalog' || !Conf['Mark Cross-thread Quotes']) { if (g.VIEW === 'catalog' || !Conf['Mark Cross-thread Quotes']) {
return; return;
} }
if (Conf['Comment Expansion']) {
ExpandComment.callbacks.push(this.node);
}
this.text = '\u00A0(Cross-thread)'; this.text = '\u00A0(Cross-thread)';
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Mark Cross-thread Quotes', name: 'Mark Cross-thread Quotes',
@ -5037,6 +5052,12 @@
if (g.VIEW !== 'index' || !Conf['Comment Expansion']) { if (g.VIEW !== 'index' || !Conf['Comment Expansion']) {
return; return;
} }
if (g.BOARD.ID === 'g') {
this.callbacks.push(Fourchan.code);
}
if (g.BOARD.ID === 'sci') {
this.callbacks.push(Fourchan.math);
}
return Post.prototype.callbacks.push({ return Post.prototype.callbacks.push({
name: 'Comment Expansion', name: 'Comment Expansion',
cb: this.node cb: this.node
@ -5048,6 +5069,7 @@
return $.on(a, 'click', ExpandComment.cb); return $.on(a, 'click', ExpandComment.cb);
} }
}, },
callbacks: [],
cb: function(e) { cb: function(e) {
var post; var post;
e.preventDefault(); e.preventDefault();
@ -5080,7 +5102,7 @@
return post.nodes.comment = post.nodes.shortComment; return post.nodes.comment = post.nodes.shortComment;
}, },
parse: function(req, a, post) { parse: function(req, a, post) {
var clone, comment, href, postObj, posts, quote, spoilerRange, status, _i, _j, _len, _len1, _ref; var callback, clone, comment, href, postObj, posts, quote, spoilerRange, status, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _results;
status = req.status; status = req.status;
if (![200, 304].contains(status)) { if (![200, 304].contains(status)) {
a.textContent = "Error " + req.statusText + " (" + status + ")"; a.textContent = "Error " + req.statusText + " (" + status + ")";
@ -5117,27 +5139,13 @@
post.nodes.comment = post.nodes.longComment = clone; post.nodes.comment = post.nodes.longComment = clone;
post.parseComment(); post.parseComment();
post.parseQuotes(); post.parseQuotes();
if (Conf['Resurrect Quotes']) { _ref1 = ExpandComment.callbacks;
Quotify.node.call(post); _results = [];
} for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
if (Conf['Quote Previewing']) { callback = _ref1[_k];
QuotePreview.node.call(post); _results.push(callback.call(post));
}
if (Conf['Quote Inlining']) {
QuoteInline.node.call(post);
}
if (Conf['Mark OP Quotes']) {
QuoteOP.node.call(post);
}
if (Conf['Mark Cross-thread Quotes']) {
QuoteCT.node.call(post);
}
if (g.BOARD.ID === 'g') {
Fourchan.code.call(post);
}
if (g.BOARD.ID === 'sci') {
return Fourchan.math.call(post);
} }
return _results;
} }
}; };

View File

@ -2447,6 +2447,9 @@ Quotify =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Resurrect Quotes'] return if g.VIEW is 'catalog' or !Conf['Resurrect Quotes']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
Post::callbacks.push Post::callbacks.push
name: 'Resurrect Quotes' name: 'Resurrect Quotes'
cb: @node cb: @node
@ -2516,6 +2519,9 @@ QuoteInline =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Inlining'] return if g.VIEW is 'catalog' or !Conf['Quote Inlining']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
Post::callbacks.push Post::callbacks.push
name: 'Quote Inlining' name: 'Quote Inlining'
cb: @node cb: @node
@ -2597,6 +2603,9 @@ QuotePreview =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Previewing'] return if g.VIEW is 'catalog' or !Conf['Quote Previewing']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
Post::callbacks.push Post::callbacks.push
name: 'Quote Previewing' name: 'Quote Previewing'
cb: @node cb: @node
@ -2740,6 +2749,9 @@ QuoteOP =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Mark OP Quotes'] return if g.VIEW is 'catalog' or !Conf['Mark OP Quotes']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
# \u00A0 is nbsp # \u00A0 is nbsp
@text = '\u00A0(OP)' @text = '\u00A0(OP)'
Post::callbacks.push Post::callbacks.push
@ -2770,6 +2782,9 @@ QuoteCT =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Mark Cross-thread Quotes'] return if g.VIEW is 'catalog' or !Conf['Mark Cross-thread Quotes']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
# \u00A0 is nbsp # \u00A0 is nbsp
@text = '\u00A0(Cross-thread)' @text = '\u00A0(Cross-thread)'
Post::callbacks.push Post::callbacks.push
@ -3343,12 +3358,18 @@ ExpandComment =
init: -> init: ->
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] return if g.VIEW isnt 'index' or !Conf['Comment Expansion']
if g.BOARD.ID is 'g'
@callbacks.push Fourchan.code
if g.BOARD.ID is 'sci'
@callbacks.push Fourchan.math
Post::callbacks.push Post::callbacks.push
name: 'Comment Expansion' name: 'Comment Expansion'
cb: @node cb: @node
node: -> node: ->
if a = $ '.abbr > a', @nodes.comment if a = $ '.abbr > a', @nodes.comment
$.on a, 'click', ExpandComment.cb $.on a, 'click', ExpandComment.cb
callbacks: []
cb: (e) -> cb: (e) ->
e.preventDefault() e.preventDefault()
post = Get.postFromNode @ post = Get.postFromNode @
@ -3395,20 +3416,9 @@ ExpandComment =
post.nodes.comment = post.nodes.longComment = clone post.nodes.comment = post.nodes.longComment = clone
post.parseComment() post.parseComment()
post.parseQuotes() post.parseQuotes()
if Conf['Resurrect Quotes']
Quotify.node.call post for callback in ExpandComment.callbacks
if Conf['Quote Previewing'] callback.call post
QuotePreview.node.call post
if Conf['Quote Inlining']
QuoteInline.node.call post
if Conf['Mark OP Quotes']
QuoteOP.node.call post
if Conf['Mark Cross-thread Quotes']
QuoteCT.node.call post
if g.BOARD.ID is 'g'
Fourchan.code.call post
if g.BOARD.ID is 'sci'
Fourchan.math.call post
ExpandThread = ExpandThread =
init: -> init: ->