From d0dac27ca713462b7a1568e40076d0007fcca0d8 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 22 Jul 2013 15:37:25 +0200 Subject: [PATCH] Factor Post::parseQuote out of Post::parseQuotes --- src/General/Post.coffee | 47 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/General/Post.coffee b/src/General/Post.coffee index 1d94ec6bd..7faf5f343 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -78,29 +78,32 @@ class Post parseQuotes: -> @quotes = [] for quotelink in $$ '.quotelink', @nodes.comment - # Only add quotes that link to posts on an imageboard. - # Don't add: - # - board links. (>>>/b/) - # - catalog links. (>>>/b/catalog or >>>/b/search) - # - rules links. (>>>/a/rules) - # - text-board quotelinks. (>>>/img/1234) - continue unless match = quotelink.href.match /// - boards\.4chan\.org/ - ([^/]+) # boardID - /res/\d+#p - (\d+) # postID - $ - /// - - @nodes.quotelinks.push quotelink - - # Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...) - continue if @isClone or !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies' - - # ES6 Set when? - fullID = "#{match[1]}.#{match[2]}" - @quotes.push fullID if @quotes.indexOf(fullID) is -1 + @parseQuote quotelink return + + parseQuote: (quotelink) -> + # Only add quotes that link to posts on an imageboard. + # Don't add: + # - board links. (>>>/b/) + # - catalog links. (>>>/b/catalog or >>>/b/search) + # - rules links. (>>>/a/rules) + # - text-board quotelinks. (>>>/img/1234) + return unless match = quotelink.href.match /// + boards\.4chan\.org/ + ([^/]+) # boardID + /res/\d+#p + (\d+) # postID + $ + /// + + @nodes.quotelinks.push quotelink + + # Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...) + return if @isClone or !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies' + + # ES6 Set when? + fullID = "#{match[1]}.#{match[2]}" + @quotes.push fullID if @quotes.indexOf(fullID) is -1 parseFile: (that) -> return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl