Simpler summary creation, tiny Build.thread() optimization.
This commit is contained in:
parent
d00597f53d
commit
0eb224e077
@ -367,6 +367,9 @@ a[href="javascript:;"] {
|
||||
:root.index-loading .pagelist {
|
||||
display: none;
|
||||
}
|
||||
.summary {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Announcement Hiding */
|
||||
:root.hide-announcement #globalMessage,
|
||||
|
||||
@ -259,28 +259,31 @@ Build =
|
||||
|
||||
container
|
||||
|
||||
summary: (boardID, threadID, posts, files) ->
|
||||
text = []
|
||||
text.push "#{posts} post#{if posts > 1 then 's' else ''}"
|
||||
text.push "and #{files} image repl#{if files > 1 then 'ies' else 'y'}" if files
|
||||
text.push 'omitted.'
|
||||
$.el 'a',
|
||||
className: 'summary'
|
||||
textContent: text.join ' '
|
||||
href: "/#{boardID}/res/#{threadID}"
|
||||
thread: (board, data) ->
|
||||
root = $.el 'div',
|
||||
className: 'thread'
|
||||
id: "t#{data.no}"
|
||||
|
||||
Build.spoilerRange[board] = data.custom_spoiler
|
||||
|
||||
nodes = []
|
||||
for obj in [data].concat data.last_replies or []
|
||||
$.add root, if post = g.posts["#{board}.#{obj.no}"]
|
||||
nodes.push if post = board.posts[obj.no]
|
||||
post.nodes.root
|
||||
else
|
||||
Build.postFromObject obj, board.ID
|
||||
|
||||
# build if necessary
|
||||
if data.omitted_posts
|
||||
{omitted_posts, omitted_images} = data
|
||||
html = []
|
||||
html.push "#{omitted_posts} post#{if omitted_posts > 1 then 's' else ''}"
|
||||
html.push "and #{omitted_images} image repl#{if omitted_images > 1 then 'ies' else 'y'}" if omitted_images
|
||||
html.push "omitted. Click <a href='/#{board}/res/#{data.no}' class=replylink>here</a> to view."
|
||||
$.after root.firstChild, $.el 'span',
|
||||
className: 'summary'
|
||||
innerHTML: html.join ' '
|
||||
nodes.splice 1, 0, Build.summary board.ID, data.no, data.omitted_posts, data.omitted_images
|
||||
|
||||
root = $.el 'div',
|
||||
className: 'thread'
|
||||
id: "t#{data.no}"
|
||||
$.add root, nodes
|
||||
root
|
||||
|
||||
@ -158,7 +158,6 @@ Index =
|
||||
try
|
||||
Index.parse JSON.parse req.response if req.status is 200
|
||||
catch err
|
||||
c.error err.stack
|
||||
# network error or non-JSON content for example.
|
||||
notice.setType 'error'
|
||||
notice.el.lastElementChild.textContent = 'Index refresh failed.'
|
||||
|
||||
@ -10,13 +10,9 @@ ExpandThread =
|
||||
ExpandThread.setButton @
|
||||
|
||||
setButton: (thread) ->
|
||||
return unless span = $.x 'following-sibling::span[contains(@class,"summary")][1]', thread.OP.nodes.root
|
||||
a = $.el 'a',
|
||||
textContent: ExpandThread.text '+', span.textContent.match(/\d+/g)...
|
||||
className: 'summary'
|
||||
href: 'javascript:;'
|
||||
return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root
|
||||
a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)...
|
||||
$.on a, 'click', ExpandThread.cbToggle
|
||||
$.replace span, a
|
||||
|
||||
onIndexRefresh: ->
|
||||
for threadID, status of ExpandThread.statuses
|
||||
@ -33,7 +29,9 @@ ExpandThread =
|
||||
text.push if status is '-' then 'shown' else 'omitted'
|
||||
text.join(' ') + '.'
|
||||
|
||||
cbToggle: ->
|
||||
cbToggle: (e) ->
|
||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||
e.preventDefault()
|
||||
ExpandThread.toggle Get.threadFromNode @
|
||||
|
||||
toggle: (thread) ->
|
||||
@ -92,7 +90,7 @@ ExpandThread =
|
||||
root = Build.postFromObject postData, thread.board.ID
|
||||
post = new Post root, thread, thread.board
|
||||
filesCount++ if 'file' of post
|
||||
posts.push post
|
||||
posts.push post
|
||||
postsRoot.push root
|
||||
Main.callbackNodes Post, posts
|
||||
$.after a, postsRoot
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user