From 463947820f6029f164249b35b84fb9ccde6f85b0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 18 Feb 2014 03:02:07 +0100 Subject: [PATCH] Simpler code for stubs. --- src/General/Post.coffee | 12 +++++++----- src/General/Thread.coffee | 15 +++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/General/Post.coffee b/src/General/Post.coffee index d18c8d6bc..d836c91d1 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -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 diff --git a/src/General/Thread.coffee b/src/General/Thread.coffee index 9a8b90b45..4d5fda36f 100644 --- a/src/General/Thread.coffee +++ b/src/General/Thread.coffee @@ -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: ->