Remove some now useless code in ExpandThread and small cleanup in ThreadHiding.

This commit is contained in:
Mayhem 2013-11-04 21:32:58 +01:00
parent 5db85bc454
commit 8f56d3e415
2 changed files with 7 additions and 15 deletions

View File

@ -19,8 +19,7 @@ ThreadHiding =
for threadID, thread of g.BOARD.threads when thread.isHidden for threadID, thread of g.BOARD.threads when thread.isHidden
root = thread.OP.nodes.root.parentNode root = thread.OP.nodes.root.parentNode
if thread.stub if thread.stub
thread.stub = ThreadHiding.makeStub thread, root ThreadHiding.makeStub thread, root
$.prepend root, thread.stub
else else
root.nextElementSibling.hidden = true root.nextElementSibling.hidden = true
return return
@ -120,13 +119,13 @@ ThreadHiding =
a = ThreadHiding.makeButton thread, 'show' a = ThreadHiding.makeButton thread, 'show'
$.add a, $.tn " #{opInfo} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})" $.add a, $.tn " #{opInfo} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})"
stub = $.el 'div', thread.stub = $.el 'div',
className: 'stub' className: 'stub'
if Conf['Menu'] if Conf['Menu']
$.add stub, [a, $.tn(' '), Menu.makeButton()] $.add thread.stub, [a, $.tn(' '), Menu.makeButton()]
else else
$.add stub, a $.add thread.stub, a
stub $.prepend root, thread.stub
saveHiddenState: (thread, makeStub) -> saveHiddenState: (thread, makeStub) ->
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {} hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
@ -154,16 +153,14 @@ ThreadHiding =
hide: (thread, makeStub=Conf['Stubs']) -> hide: (thread, makeStub=Conf['Stubs']) ->
return if thread.isHidden return if thread.isHidden
{OP} = thread threadRoot = thread.OP.nodes.root.parentNode
threadRoot = OP.nodes.root.parentNode
thread.isHidden = true thread.isHidden = true
unless makeStub unless makeStub
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr> threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
return return
thread.stub = ThreadHiding.makeStub thread, threadRoot ThreadHiding.makeStub thread, threadRoot
$.prepend threadRoot, thread.stub
show: (thread) -> show: (thread) ->
if thread.stub if thread.stub

View File

@ -3,11 +3,6 @@ ExpandThread =
return if g.VIEW isnt 'index' or !Conf['Thread Expansion'] return if g.VIEW isnt 'index' or !Conf['Thread Expansion']
@statuses = {} @statuses = {}
$.on d, 'IndexRefresh', @onIndexRefresh $.on d, 'IndexRefresh', @onIndexRefresh
Thread.callbacks.push
name: 'Thread Expansion'
cb: @node
node: ->
ExpandThread.setButton @
setButton: (thread) -> setButton: (thread) ->
return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root