From 823eace903a7af05a2b37bdb66a8cbd5373487d1 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 19 Apr 2014 21:44:13 -0700 Subject: [PATCH] begin work on restoring comment expansion --- src/General/Build.coffee | 6 +++++- src/General/Config.coffee | 4 ++++ src/General/Main.coffee | 1 + src/Miscellaneous/ExpandComment.coffee | 10 +++++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 6ecd74d87..2aeda4b85 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -197,10 +197,14 @@ Build = className: "postContainer #{if isOP then 'op' else 'reply'}Container" innerHTML: <%= grunt.file.read('src/General/html/Build/post.html').replace(/>\s+/g, '>').replace(/\s+ + # Fix pathnames for quote in $$ '.quotelink', container href = quote.getAttribute 'href' continue if href[0] is '/' # Cross-board quote, or board link - quote.href = "/#{boardID}/thread/#{href}" # Fix pathnames + if href[0] is '#' + quote.href = "/#{boardID}/thread/#{threadID}#{href}" + else + quote.href = "/#{boardID}/thread/#{href}" container diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 630312cdd..1757f8579 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -41,6 +41,10 @@ Config = true 'Display dates like "3 minutes ago". Tooltip shows the timestamp.' ] + 'Comment Expansion': [ + true + 'Add buttons to expand too long comments.' + ] 'File Info Formatting': [ true 'Reformat the file information.' diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 8af1e3aae..a56288c40 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -332,6 +332,7 @@ Main = ['Reveal Spoiler Thumbnails', RevealSpoilers] ['Image Loading', ImageLoader] ['Image Hover', ImageHover] + ['Comment Expansion', ExpandComment] ['Thread Expansion', ExpandThread] ['Thread Excerpt', ThreadExcerpt] ['Favicon', Favicon] diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index a3c1c7362..1790b55b8 100755 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -23,7 +23,7 @@ ExpandComment = return return unless a = $ '.abbr > a', post.nodes.comment a.textContent = "Post No.#{post} Loading..." - $.cache "//a.4cdn.org#{a.pathname}.json", -> ExpandComment.parse @, a, post + $.cache "//a.4cdn.org#{a.pathname.split('/').splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post contract: (post) -> return unless post.nodes.shortComment a = $ '.abbr > a', post.nodes.shortComment @@ -36,7 +36,7 @@ ExpandComment = a.textContent = "Error #{req.statusText} (#{status})" return - posts = JSON.parse(req.response).posts + posts = req.response if spoilerRange = posts[0].custom_spoiler Build.spoilerRange[g.BOARD] = spoilerRange @@ -49,10 +49,14 @@ ExpandComment = {comment} = post.nodes clone = comment.cloneNode false clone.innerHTML = postObj.com + # Fix pathnames for quote in $$ '.quotelink', clone href = quote.getAttribute 'href' continue if href[0] is '/' # Cross-board quote, or board link - quote.href = "/#{post.board}/thread/#{href}" # Fix pathnames + if href[0] is '#' + quote.href = "#{a.pathname.split('/').splice(0,4).join('/')}#{href}" + else + quote.href = "#{a.pathname.split('/').splice(0,3).join('/')}/#{href}" post.nodes.shortComment = comment $.replace comment, clone post.nodes.comment = post.nodes.longComment = clone