From d00597f53d6d9740c79433dfd33623373480969d Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 2 Nov 2013 17:33:39 +0100 Subject: [PATCH] Remove comment expansion-related code. --- src/General/Config.coffee | 1 - src/General/Main.coffee | 1 - src/Miscellaneous/ExpandComment.coffee | 70 -------------------------- src/Miscellaneous/ExpandThread.coffee | 11 +--- 4 files changed, 2 insertions(+), 81 deletions(-) delete mode 100644 src/Miscellaneous/ExpandComment.coffee diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 95f1f2a48..715822858 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -9,7 +9,6 @@ Config = 'Time Formatting': [true, 'Localize and format timestamps.'] 'Relative Post Dates': [false, 'Display dates like "3 minutes ago". Tooltip shows the timestamp.'] 'File Info Formatting': [true, 'Reformat the file information.'] - 'Comment Expansion': [true, 'Add buttons to expand too long comments.'] 'Thread Expansion': [true, 'Add buttons to expand threads.'] 'Index Navigation': [false, 'Add buttons to navigate between threads.'] 'Reply Navigation': [false, 'Add buttons to navigate to top / bottom of thread.'] diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 0528e4f08..9756b15e2 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -106,7 +106,6 @@ Main = initFeature 'Reveal Spoilers', RevealSpoilers initFeature 'Auto-GIF', AutoGIF initFeature 'Image Hover', ImageHover - initFeature 'Comment Expansion', ExpandComment initFeature 'Thread Expansion', ExpandThread initFeature 'Thread Excerpt', ThreadExcerpt initFeature 'Favicon', Favicon diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee deleted file mode 100644 index 12fee2935..000000000 --- a/src/Miscellaneous/ExpandComment.coffee +++ /dev/null @@ -1,70 +0,0 @@ -ExpandComment = - init: -> - return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] - - Post.callbacks.push - name: 'Comment Expansion' - cb: @node - node: -> - if a = $ '.abbr > a:not([onclick])', @nodes.comment - $.on a, 'click', ExpandComment.cb - cb: (e) -> - e.preventDefault() - ExpandComment.expand Get.postFromNode @ - expand: (post) -> - if post.nodes.longComment and !post.nodes.longComment.parentNode - $.replace post.nodes.shortComment, post.nodes.longComment - post.nodes.comment = post.nodes.longComment - return - return unless a = $ '.abbr > a', post.nodes.comment - a.textContent = "Post No.#{post} Loading..." - $.cache "//api.4chan.org#{a.pathname}.json", -> ExpandComment.parse @, a, post - contract: (post) -> - return unless post.nodes.shortComment - a = $ '.abbr > a', post.nodes.shortComment - a.textContent = 'here' - $.replace post.nodes.longComment, post.nodes.shortComment - post.nodes.comment = post.nodes.shortComment - parse: (req, a, post) -> - {status} = req - if status not in [200, 304] - a.textContent = "Error #{req.statusText} (#{status})" - return - - posts = JSON.parse(req.response).posts - Build.spoilerRange[g.BOARD] = posts[0].custom_spoiler - - for postObj in posts - break if postObj.no is post.ID - if postObj.no isnt post.ID - a.textContent = "Post No.#{post} not found." - return - - {comment} = post.nodes - clone = comment.cloneNode false - clone.innerHTML = postObj.com - for quote in $$ '.quotelink', clone - href = quote.getAttribute 'href' - continue if href[0] is '/' # Cross-board quote, or board link - quote.href = "/#{post.board}/res/#{href}" # Fix pathnames - post.nodes.shortComment = comment - $.replace comment, clone - 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 - if Conf['Linkify'] - Linkify.node.call post diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index c1ca5229b..fb3a24699 100644 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -38,16 +38,13 @@ ExpandThread = toggle: (thread) -> threadRoot = thread.OP.nodes.root.parentNode - a = $ '.summary', threadRoot + return unless a = $ '.summary', threadRoot if thread.ID of ExpandThread.statuses ExpandThread.contract thread, a, threadRoot else ExpandThread.expand thread, a, threadRoot expand: (thread, a, threadRoot) -> ExpandThread.statuses[thread] = status = {} - for post in $$ '.thread > .postContainer', threadRoot - ExpandComment.expand Get.postFromRoot post - return unless a a.textContent = ExpandThread.text '...', a.textContent.match(/\d+/g)... status.req = $.cache "//api.4chan.org/#{thread.board}/res/#{thread}.json", -> delete status.req @@ -67,13 +64,9 @@ ExpandThread = when 'b', 'vg' then 3 when 't' then 1 else 5 - posts = $$ '.thread > .replyContainer', threadRoot - for post in [thread.OP.nodes.root].concat posts[-num..] - ExpandComment.contract Get.postFromRoot post - return unless a postsCount = 0 filesCount = 0 - for reply in posts[...-num] + for reply in $$('.thread > .replyContainer', threadRoot)[...-num] # rm clones inlined.click() while inlined = $ '.inlined', reply if Conf['Quote Inlining'] postsCount++