Move nameBlock into post class.

This commit is contained in:
ccd0 2014-11-15 20:41:32 -08:00
parent 5299cbf50b
commit 4ac31962a2
6 changed files with 12 additions and 23 deletions

View File

@ -190,12 +190,7 @@ PostHiding =
return
a = PostHiding.makeButton post, 'show'
postInfo =
if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', post.nodes.info).textContent
$.add a, $.tn " #{postInfo}"
$.add a, $.tn " #{post.info.nameBlock}"
post.nodes.stub = $.el 'div',
className: 'stub'
$.add post.nodes.stub, a

View File

@ -135,13 +135,9 @@ ThreadHiding =
makeStub: (thread, root) ->
numReplies = $$('.thread > .replyContainer', root).length
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root
opInfo = if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', thread.OP.nodes.info).textContent
a = ThreadHiding.makeButton thread, 'show'
$.add a, $.tn " #{opInfo} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})"
$.add a, $.tn " #{thread.OP.info.nameBlock} (#{if numReplies is 1 then '1 reply' else "#{numReplies} replies"})"
thread.stub = $.el 'div',
className: 'stub'
if Conf['Menu']

View File

@ -4,8 +4,7 @@ Get =
excerpt = "/#{thread.board}/ - " + (
OP.info.subject?.trim() or
OP.info.comment.replace(/\n+/g, ' // ') or
Conf['Anonymize'] and 'Anonymous' or
$('.nameBlock', OP.nodes.info).textContent.trim())
OP.info.nameBlock)
return "#{excerpt[...70]}..." if excerpt.length > 73
excerpt
threadFromRoot: (root) ->

View File

@ -36,6 +36,7 @@ class Post
root: root
post: post
info: info
nameBlock: $ '.nameBlock', info
comment: $ '.postMessage', post
links: []
quotelinks: []
@ -49,6 +50,10 @@ class Post
@thread.kill() if @thread.isArchived
@info = {}
@info.nameBlock = if Conf['Anonymize']
'Anonymous'
else
@nodes.nameBlock.textContent.trim()
if subject = $ '.subject', info
@nodes.subject = subject
@info.subject = subject.textContent

View File

@ -43,12 +43,10 @@ MarkNewIPs =
counter = $.el 'span',
className: 'ip-counter'
textContent: "(#{ipCount})"
nameBlock = $ '.nameBlock', post.nodes.info
nameBlock.title = "This is the #{ipCount}#{suffix} IP in the thread."
$.add nameBlock, [$.tn(' '), counter]
post.nodes.nameBlock.title = "This is the #{ipCount}#{suffix} IP in the thread."
$.add post.nodes.nameBlock, [$.tn(' '), counter]
$.addClass post.nodes.root, 'new-ip'
markOld: (post) ->
nameBlock = $ '.nameBlock', post.nodes.info
nameBlock.title = 'Not the first post from this IP.'
post.nodes.nameBlock.title = 'Not the first post from this IP.'
$.addClass post.nodes.root, 'old-ip'

View File

@ -100,11 +100,7 @@ Unread =
openNotification: (post) ->
return unless Header.areNotificationsEnabled
name = if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', post.nodes.info).textContent.trim()
notif = new Notification "#{name} replied to you",
notif = new Notification "#{post.info.nameBlock} replied to you",
body: post.info[if Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] then 'comment' else 'commentSpoilered']
icon: Favicon.logo
notif.onclick = ->