Small refactor.

This commit is contained in:
Mayhem 2013-05-31 22:19:53 +02:00
parent 1752e15da9
commit 448273441d

View File

@ -231,10 +231,22 @@ ThreadUpdater =
post.kill true post.kill true
deletedFiles.push post deletedFiles.push post
sendEvent = ->
$.event 'ThreadUpdate',
404: false
thread: ThreadUpdater.thread
newPosts: posts
deletedPosts: deletedPosts
deletedFiles: deletedFiles
postCount: OP.replies + 1
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file and !ThreadUpdater.thread.OP.file.isDead)
unless count unless count
ThreadUpdater.set 'status', null, null ThreadUpdater.set 'status', null, null
ThreadUpdater.outdateCount++ ThreadUpdater.outdateCount++
else sendEvent()
return
ThreadUpdater.set 'status', "+#{count}", 'new' ThreadUpdater.set 'status', "+#{count}", 'new'
ThreadUpdater.outdateCount = 0 ThreadUpdater.outdateCount = 0
if Conf['Beep'] and d.hidden and Unread.posts and !Unread.posts.length if Conf['Beep'] and d.hidden and Unread.posts and !Unread.posts.length
@ -248,13 +260,13 @@ ThreadUpdater =
scroll = Conf['Auto Scroll'] and ThreadUpdater.scrollBG() and scroll = Conf['Auto Scroll'] and ThreadUpdater.scrollBG() and
ThreadUpdater.root.getBoundingClientRect().bottom - doc.clientHeight < 25 ThreadUpdater.root.getBoundingClientRect().bottom - doc.clientHeight < 25
$.add ThreadUpdater.root, nodes $.add ThreadUpdater.root, nodes
sendEvent()
if scroll if scroll
if Conf['Bottom Scroll'] if Conf['Bottom Scroll']
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight
else else
Header.scrollToPost nodes[0] Header.scrollToPost nodes[0]
$.queueTask ->
# Enable 4chan features. # Enable 4chan features.
threadID = ThreadUpdater.thread.ID threadID = ThreadUpdater.thread.ID
{length} = $$ '.thread > .postContainer', ThreadUpdater.root {length} = $$ '.thread > .postContainer', ThreadUpdater.root
@ -262,12 +274,3 @@ ThreadUpdater =
$.globalEval "Parser.parseThread(#{threadID}, #{-count})" $.globalEval "Parser.parseThread(#{threadID}, #{-count})"
else else
Fourchan.parseThread threadID, length - count, length Fourchan.parseThread threadID, length - count, length
$.event 'ThreadUpdate',
404: false
thread: ThreadUpdater.thread
newPosts: posts
deletedPosts: deletedPosts
deletedFiles: deletedFiles
postCount: OP.replies + 1
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file and !ThreadUpdater.thread.OP.file.isDead)