rm as many id attributes in posts as possible.
Add root.dataset.fullID, simplify Get.postFromRoot(). Also figured Menu.toggle() could be simplified since stub of threads do not exist anymore.
This commit is contained in:
parent
a853bd5e8e
commit
59f2ca6a51
@ -116,11 +116,11 @@ Build =
|
|||||||
|
|
||||||
if file?.isDeleted
|
if file?.isDeleted
|
||||||
fileHTML = if isOP
|
fileHTML = if isOP
|
||||||
"<div class=file id=f#{postID}><span class=fileThumb>" +
|
"<div class=file><span class=fileThumb>" +
|
||||||
"<img src='#{staticPath}filedeleted#{gifIcon}' class=fileDeleted>" +
|
"<img src='#{staticPath}filedeleted#{gifIcon}' class=fileDeleted>" +
|
||||||
"</span></div>"
|
"</span></div>"
|
||||||
else
|
else
|
||||||
"<div class=file id=f#{postID}><span class=fileThumb>" +
|
"<div class=file><span class=fileThumb>" +
|
||||||
"<img src='#{staticPath}filedeleted-res#{gifIcon}' class=fileDeletedRes>" +
|
"<img src='#{staticPath}filedeleted-res#{gifIcon}' class=fileDeletedRes>" +
|
||||||
"</span></div>"
|
"</span></div>"
|
||||||
else if file
|
else if file
|
||||||
@ -154,7 +154,7 @@ Build =
|
|||||||
filename = a.innerHTML.replace /'/g, '''
|
filename = a.innerHTML.replace /'/g, '''
|
||||||
|
|
||||||
fileDims = if file.name[-3..] is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
|
fileDims = if file.name[-3..] is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
|
||||||
fileInfo = "<div class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
|
fileInfo = "<div class=fileText#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
|
||||||
"-(#{fileSize}, #{fileDims}#{
|
"-(#{fileSize}, #{fileDims}#{
|
||||||
if file.isSpoiler
|
if file.isSpoiler
|
||||||
''
|
''
|
||||||
@ -162,7 +162,7 @@ Build =
|
|||||||
", <span#{if filename isnt shortFilename then " title='#{filename}'" else ''}>#{shortFilename}</span>"
|
", <span#{if filename isnt shortFilename then " title='#{filename}'" else ''}>#{shortFilename}</span>"
|
||||||
}" + ")</div>"
|
}" + ")</div>"
|
||||||
|
|
||||||
fileHTML = "<div class=file id=f#{postID}>#{fileInfo}#{imgSrc}</div>"
|
fileHTML = "<div class=file>#{fileInfo}#{imgSrc}</div>"
|
||||||
else
|
else
|
||||||
fileHTML = ''
|
fileHTML = ''
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ Build =
|
|||||||
id: "pc#{postID}"
|
id: "pc#{postID}"
|
||||||
className: "postContainer #{if isOP then 'op' else 'reply'}Container"
|
className: "postContainer #{if isOP then 'op' else 'reply'}Container"
|
||||||
innerHTML: \
|
innerHTML: \
|
||||||
(if isOP then '' else "<div class=sideArrows id=sa#{postID}>>></div>") +
|
(if isOP then '' else "<div class=sideArrows>>></div>") +
|
||||||
"<div id=p#{postID} class='post #{if isOP then 'op' else 'reply'}#{
|
"<div id=p#{postID} class='post #{if isOP then 'op' else 'reply'}#{
|
||||||
if capcode is 'admin_highlight'
|
if capcode is 'admin_highlight'
|
||||||
' highlightPost'
|
' highlightPost'
|
||||||
@ -196,7 +196,7 @@ Build =
|
|||||||
|
|
||||||
(if isOP then fileHTML else '') +
|
(if isOP then fileHTML else '') +
|
||||||
|
|
||||||
"<div class='postInfo' id=pi#{postID}>" +
|
"<div class=postInfo>" +
|
||||||
"<input type=checkbox name=#{postID} value=delete> " +
|
"<input type=checkbox name=#{postID} value=delete> " +
|
||||||
"<span class=subject>#{subject or ''}</span> " +
|
"<span class=subject>#{subject or ''}</span> " +
|
||||||
"<span class='nameBlock#{capcodeClass}'>" +
|
"<span class='nameBlock#{capcodeClass}'>" +
|
||||||
@ -219,7 +219,7 @@ Build =
|
|||||||
|
|
||||||
(if isOP then '' else fileHTML) +
|
(if isOP then '' else fileHTML) +
|
||||||
|
|
||||||
"<blockquote class=postMessage id=m#{postID}>#{comment or ''}</blockquote> " +
|
"<blockquote class=postMessage>#{comment or ''}</blockquote> " +
|
||||||
|
|
||||||
'</div>'
|
'</div>'
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,8 @@ Get =
|
|||||||
threadFromNode: (node) ->
|
threadFromNode: (node) ->
|
||||||
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
||||||
postFromRoot: (root) ->
|
postFromRoot: (root) ->
|
||||||
link = $ 'a[title="Highlight this post"]', root
|
post = g.posts[root.dataset.fullID]
|
||||||
boardID = link.pathname.split('/')[1]
|
if index = root.dataset.clone then post.clones[index] else post
|
||||||
postID = link.hash[2..]
|
|
||||||
index = root.dataset.clone
|
|
||||||
post = g.posts["#{boardID}.#{postID}"]
|
|
||||||
if index then post.clones[index] else post
|
|
||||||
postFromNode: (node) ->
|
postFromNode: (node) ->
|
||||||
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', node
|
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', node
|
||||||
contextFromNode: (node) ->
|
contextFromNode: (node) ->
|
||||||
|
|||||||
@ -266,7 +266,7 @@ Header =
|
|||||||
hashScroll: ->
|
hashScroll: ->
|
||||||
hash = @location.hash[1..]
|
hash = @location.hash[1..]
|
||||||
return unless /^p\d+$/.test(hash) and post = $.id hash
|
return unless /^p\d+$/.test(hash) and post = $.id hash
|
||||||
return if (Get.postFromRoot post).isHidden
|
return if (Get.postFromNode post).isHidden
|
||||||
Header.scrollTo post
|
Header.scrollTo post
|
||||||
scrollTo: (root, down, needed) ->
|
scrollTo: (root, down, needed) ->
|
||||||
if down
|
if down
|
||||||
|
|||||||
@ -6,9 +6,10 @@ class Post
|
|||||||
@ID = +root.id[2..]
|
@ID = +root.id[2..]
|
||||||
@fullID = "#{@board}.#{@ID}"
|
@fullID = "#{@board}.#{@ID}"
|
||||||
|
|
||||||
@cleanup root if that.isOriginalMarkup
|
|
||||||
post = $ '.post', root
|
post = $ '.post', root
|
||||||
info = $ '.postInfo', post
|
info = $ '.postInfo', post
|
||||||
|
@cleanup root, post if that.isOriginalMarkup
|
||||||
|
root.dataset.fullID = @fullID
|
||||||
@nodes =
|
@nodes =
|
||||||
root: root
|
root: root
|
||||||
post: post
|
post: post
|
||||||
@ -146,9 +147,11 @@ class Post
|
|||||||
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
||||||
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
||||||
|
|
||||||
cleanup: (root) ->
|
cleanup: (root, post) ->
|
||||||
for node in $$ '.mobile', root
|
for node in $$ '.mobile', root
|
||||||
$.rm node
|
$.rm node
|
||||||
|
for node in $$ '[id]', post
|
||||||
|
node.removeAttribute 'id'
|
||||||
for node in $$ '.desktop', root
|
for node in $$ '.desktop', root
|
||||||
$.rmClass node, 'desktop'
|
$.rmClass node, 'desktop'
|
||||||
return
|
return
|
||||||
|
|||||||
@ -30,13 +30,4 @@ Menu =
|
|||||||
clone
|
clone
|
||||||
|
|
||||||
toggle: (e) ->
|
toggle: (e) ->
|
||||||
try
|
Menu.menu.toggle e, @, Get.postFromNode @
|
||||||
# Posts, inlined posts, hidden replies.
|
|
||||||
post = Get.postFromNode @
|
|
||||||
catch
|
|
||||||
post = if fullID = @parentNode.parentNode.dataset.fullID
|
|
||||||
g.threads[fullID].OP
|
|
||||||
else
|
|
||||||
# Hidden threads.
|
|
||||||
Get.threadFromNode(@).OP
|
|
||||||
Menu.menu.toggle e, @, post
|
|
||||||
|
|||||||
@ -26,9 +26,9 @@ ThreadUpdater =
|
|||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
ThreadUpdater.thread = @
|
ThreadUpdater.thread = @
|
||||||
ThreadUpdater.root = @OP.nodes.root.parentNode
|
ThreadUpdater.root = @OP.nodes.root.parentNode
|
||||||
ThreadUpdater.lastPost = +ThreadUpdater.root.lastElementChild.id.match(/\d+/)[0]
|
ThreadUpdater.lastPost = +Object.keys(@posts).sort()[-1..][0]
|
||||||
|
|
||||||
for input in $$ 'input', ThreadUpdater.dialog
|
for input in $$ 'input', ThreadUpdater.dialog
|
||||||
if input.type is 'checkbox'
|
if input.type is 'checkbox'
|
||||||
|
|||||||
@ -60,7 +60,7 @@ ThreadWatcher =
|
|||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
$.event 'CloseMenu'
|
$.event 'CloseMenu'
|
||||||
toggle: ->
|
toggle: ->
|
||||||
ThreadWatcher.toggle Get.postFromNode(@).thread
|
ThreadWatcher.toggle Get.threadFromNode @
|
||||||
rm: ->
|
rm: ->
|
||||||
[boardID, threadID] = @parentNode.dataset.fullID.split '.'
|
[boardID, threadID] = @parentNode.dataset.fullID.split '.'
|
||||||
ThreadWatcher.rm boardID, +threadID
|
ThreadWatcher.rm boardID, +threadID
|
||||||
|
|||||||
@ -17,7 +17,7 @@ QuoteInline =
|
|||||||
if $.hasClass @, 'inlined'
|
if $.hasClass @, 'inlined'
|
||||||
QuoteInline.rm @, boardID, threadID, postID, context
|
QuoteInline.rm @, boardID, threadID, postID, context
|
||||||
else
|
else
|
||||||
return if $.x "ancestor::div[@id='p#{postID}']", @
|
return if $.x "ancestor::div[@id='pc#{postID}']", @
|
||||||
QuoteInline.add @, boardID, threadID, postID, context
|
QuoteInline.add @, boardID, threadID, postID, context
|
||||||
@classList.toggle 'inlined'
|
@classList.toggle 'inlined'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user