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

View File

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