Simpler code for stubs.

This commit is contained in:
Mayhem 2014-02-18 03:02:07 +01:00
parent 785f5b39dc
commit 463947820f
2 changed files with 12 additions and 15 deletions

View File

@ -153,6 +153,12 @@ class Post
$.rmClass node, 'desktop'
return
getNameBlock: ->
if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', @nodes.info).textContent.trim()
hide: (label, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
@labels.push label unless label in @labels
return if @isHidden
@ -174,11 +180,7 @@ class Post
return
a = PostHiding.makeButton false
postInfo = if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', @nodes.info).textContent.trim()
$.add a, $.tn " #{postInfo}"
$.add a, $.tn " #{@getNameBlock()}"
@nodes.stub = $.el 'div',
className: 'stub'
$.add @nodes.stub, a

View File

@ -73,18 +73,13 @@ class Thread
root.hidden = true
return
numReplies = $$('.thread > .replyContainer', root).length # Don't count clones.
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root
opInfo = if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', @OP.nodes.info).textContent.trim()
a = PostHiding.makeButton false
$.add a, $.tn " #{opInfo} (#{numReplies} repl#{if numReplies is 1 then 'y' else 'ies'})"
@stub = $.el 'div',
className: 'stub'
$.add @stub, a
{replies} = Index.liveThreadData[Index.liveThreadIDs.indexOf @ID]
$.add @stub, [
PostHiding.makeButton false
$.tn " #{@OP.getNameBlock()} (#{replies} repl#{if replies is 1 then 'y' else 'ies'})"
]
$.add @stub, Menu.makeButton() if Conf['Menu']
$.prepend root, @stub
show: ->