begin work on restoring comment expansion

This commit is contained in:
ccd0 2014-04-19 21:44:13 -07:00
parent 253de9b2cb
commit 823eace903
4 changed files with 17 additions and 4 deletions

View File

@ -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+</g, '<').replace(/\s+/g, ' ').trim() %>
# 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

View File

@ -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.'

View File

@ -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]

View File

@ -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