Merge branch 'expandcomment'
This commit is contained in:
commit
ac59c19991
@ -41,6 +41,10 @@ Config =
|
|||||||
true
|
true
|
||||||
'Display dates like "3 minutes ago". Tooltip shows the timestamp.'
|
'Display dates like "3 minutes ago". Tooltip shows the timestamp.'
|
||||||
]
|
]
|
||||||
|
'Comment Expansion': [
|
||||||
|
true
|
||||||
|
'Add buttons to expand too long comments.'
|
||||||
|
]
|
||||||
'File Info Formatting': [
|
'File Info Formatting': [
|
||||||
true
|
true
|
||||||
'Reformat the file information.'
|
'Reformat the file information.'
|
||||||
|
|||||||
@ -332,6 +332,7 @@ Main =
|
|||||||
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
||||||
['Image Loading', ImageLoader]
|
['Image Loading', ImageLoader]
|
||||||
['Image Hover', ImageHover]
|
['Image Hover', ImageHover]
|
||||||
|
['Comment Expansion', ExpandComment]
|
||||||
['Thread Expansion', ExpandThread]
|
['Thread Expansion', ExpandThread]
|
||||||
['Thread Excerpt', ThreadExcerpt]
|
['Thread Excerpt', ThreadExcerpt]
|
||||||
['Favicon', Favicon]
|
['Favicon', Favicon]
|
||||||
|
|||||||
@ -23,7 +23,7 @@ ExpandComment =
|
|||||||
return
|
return
|
||||||
return unless a = $ '.abbr > a', post.nodes.comment
|
return unless a = $ '.abbr > a', post.nodes.comment
|
||||||
a.textContent = "Post No.#{post} Loading..."
|
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) ->
|
contract: (post) ->
|
||||||
return unless post.nodes.shortComment
|
return unless post.nodes.shortComment
|
||||||
a = $ '.abbr > a', post.nodes.shortComment
|
a = $ '.abbr > a', post.nodes.shortComment
|
||||||
@ -36,7 +36,7 @@ ExpandComment =
|
|||||||
a.textContent = "Error #{req.statusText} (#{status})"
|
a.textContent = "Error #{req.statusText} (#{status})"
|
||||||
return
|
return
|
||||||
|
|
||||||
posts = JSON.parse(req.response).posts
|
posts = req.response.posts
|
||||||
if spoilerRange = posts[0].custom_spoiler
|
if spoilerRange = posts[0].custom_spoiler
|
||||||
Build.spoilerRange[g.BOARD] = spoilerRange
|
Build.spoilerRange[g.BOARD] = spoilerRange
|
||||||
|
|
||||||
@ -49,10 +49,14 @@ ExpandComment =
|
|||||||
{comment} = post.nodes
|
{comment} = post.nodes
|
||||||
clone = comment.cloneNode false
|
clone = comment.cloneNode false
|
||||||
clone.innerHTML = postObj.com
|
clone.innerHTML = postObj.com
|
||||||
|
# Fix pathnames
|
||||||
for quote in $$ '.quotelink', clone
|
for quote in $$ '.quotelink', clone
|
||||||
href = quote.getAttribute 'href'
|
href = quote.getAttribute 'href'
|
||||||
continue if href[0] is '/' # Cross-board quote, or board link
|
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
|
post.nodes.shortComment = comment
|
||||||
$.replace comment, clone
|
$.replace comment, clone
|
||||||
post.nodes.comment = post.nodes.longComment = clone
|
post.nodes.comment = post.nodes.longComment = clone
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user