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