Add user ID and developper support in parseArchivedPost.

This commit is contained in:
Nicolas Stepien 2012-08-08 17:40:02 +02:00
parent 2de968891c
commit f2ff7ab1be
2 changed files with 111 additions and 39 deletions

View File

@ -3526,7 +3526,7 @@
} }
}, },
parseArchivedPost: function(req, board, postID, root, cb) { parseArchivedPost: function(req, board, postID, root, cb) {
var bq, br, capcode, data, email, file, filename, filesize, isOP, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, threshold, thumb_src, timestamp, trip; var bq, br, capcode, data, email, file, filename, filesize, isOP, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, threshold, thumb_src, timestamp, trip, userID;
data = JSON.parse(req.response); data = JSON.parse(req.response);
$.addClass(root, 'archivedPost'); $.addClass(root, 'archivedPost');
if (data.error) { if (data.error) {
@ -3537,6 +3537,7 @@
isOP = postID === threadID; isOP = postID === threadID;
name = data.name, trip = data.trip, timestamp = data.timestamp; name = data.name, trip = data.trip, timestamp = data.timestamp;
subject = data.title; subject = data.title;
userID = data.poster_hash;
piM = $.el('div', { piM = $.el('div', {
id: "pim" + postID, id: "pim" + postID,
className: 'postInfoM mobile', className: 'postInfoM mobile',
@ -3571,7 +3572,7 @@
pi = $.el('div', { pi = $.el('div', {
id: "pi" + postID, id: "pi" + postID,
className: 'postInfo desktop', className: 'postInfo desktop',
innerHTML: "<input type=checkbox name=" + postID + " value=delete> <span class=subject></span> <span class=nameBlock></span> <span class=dateTime data-utc=" + timestamp + ">data.fourchan_date</span> <span class='postNum desktop'><a href='/" + board + "/res/" + threadID + "#p" + postID + "' title='Highlight this post'>No.</a><a href='/" + board + "/res/" + threadID + "#q" + postID + "' title='Quote this post'>" + postID + "</a>" + (isOP ? ' &nbsp; ' : '') + "</span> " innerHTML: "<input type=checkbox name=" + postID + " value=delete> <span class=subject></span> <span class=nameBlock></span> <span class=dateTime data-utc=" + timestamp + ">data.fourchan_date</span> <span class='postNum desktop'><a href='/" + board + "/res/" + threadID + "#p" + postID + "' title='Highlight this post'>No.</a><a href='/" + board + "/res/" + threadID + "#q" + postID + "' title='Quote this post'>" + postID + "</a></span>"
}); });
$('.subject', pi).textContent = subject; $('.subject', pi).textContent = subject;
nameBlock = $('.nameBlock', pi); nameBlock = $('.nameBlock', pi);
@ -3587,6 +3588,14 @@
className: 'name', className: 'name',
textContent: data.name textContent: data.name
})); }));
if (userID) {
$.add(nameBlock, [
$.tn(' '), $.el('span', {
className: "posteruid id_" + userID,
innerHTML: "(ID: <span class=hand title='Highlight posts by this ID'>" + userID + "</span>)"
})
]);
}
if (trip) { if (trip) {
$.add(nameBlock, [ $.add(nameBlock, [
$.tn(' '), $.el('span', { $.tn(' '), $.el('span', {
@ -3595,23 +3604,49 @@
}) })
]); ]);
} }
if (capcode !== 'N') { nameBlock = $('.nameBlock', pi);
$.add(nameBlock, [ switch (capcode) {
$.tn(' '), $.el('strong', { case 'A':
className: capcode === 'A' ? 'capcode capcodeAdmin' : 'capcode', $.addClass(nameBlock, 'capcodeAdmin');
textContent: capcode === 'A' ? '## Admin' : '## Mod' $.add(nameBlock, [
}) $.tn(' '), $.el('strong', {
]); className: 'capcode',
nameBlock = $('.nameBlock', pi); textContent: '## Admin'
$.addClass(nameBlock, capcode === 'A' ? 'capcodeAdmin' : 'capcodeMod'); }), $.tn(' '), $.el('img', {
$.add(nameBlock, [ src: '//static.4chan.org/image/adminicon.gif',
$.tn(' '), $.el('img', { alt: 'This user is the 4chan Administrator.',
src: capcode === 'A' ? '//static.4chan.org/image/adminicon.gif' : '//static.4chan.org/image/modicon.gif', title: 'This user is the 4chan Administrator.',
alt: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.', className: 'identityIcon'
title: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.', })
className: 'identityIcon' ]);
}) break;
]); case 'M':
$.addClass(nameBlock, 'capcodeMod');
$.add(nameBlock, [
$.tn(' '), $.el('strong', {
className: 'capcode',
textContent: '## Mod'
}), $.tn(' '), $.el('img', {
src: '//static.4chan.org/image/modicon.gif',
alt: 'This user is a 4chan Moderator.',
title: 'This user is a 4chan Moderator.',
className: 'identityIcon'
})
]);
break;
case 'D':
$.addClass(nameBlock, 'capcodeDeveloper');
$.add(nameBlock, [
$.tn(' '), $.el('strong', {
className: 'capcode',
textContent: '## Developer'
}), $.tn(' '), $.el('img', {
src: '//static.4chan.org/image/developericon.gif',
alt: 'This user is a 4chan Developer.',
title: 'title="This user is a 4chan Developer.',
className: 'identityIcon'
})
]);
} }
bq = $.el('blockquote', { bq = $.el('blockquote', {
id: "m" + postID, id: "m" + postID,

View File

@ -2778,6 +2778,7 @@ Get =
isOP = postID is threadID isOP = postID is threadID
{name, trip, timestamp} = data {name, trip, timestamp} = data
subject = data.title subject = data.title
userID = data.poster_hash
# post info (mobile) # post info (mobile)
piM = $.el 'div', piM = $.el 'div',
@ -2814,7 +2815,7 @@ Get =
pi = $.el 'div', pi = $.el 'div',
id: "pi#{postID}" id: "pi#{postID}"
className: 'postInfo desktop' className: 'postInfo desktop'
innerHTML: "<input type=checkbox name=#{postID} value=delete> <span class=subject></span> <span class=nameBlock></span> <span class=dateTime data-utc=#{timestamp}>data.fourchan_date</span> <span class='postNum desktop'><a href='/#{board}/res/#{threadID}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{threadID}#q#{postID}' title='Quote this post'>#{postID}</a>#{if isOP then ' &nbsp; ' else ''}</span> " innerHTML: "<input type=checkbox name=#{postID} value=delete> <span class=subject></span> <span class=nameBlock></span> <span class=dateTime data-utc=#{timestamp}>data.fourchan_date</span> <span class='postNum desktop'><a href='/#{board}/res/#{threadID}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{threadID}#q#{postID}' title='Quote this post'>#{postID}</a></span>"
# subject # subject
$('.subject', pi).textContent = subject $('.subject', pi).textContent = subject
nameBlock = $ '.nameBlock', pi nameBlock = $ '.nameBlock', pi
@ -2827,27 +2828,63 @@ Get =
$.add nameBlock, $.el 'span', $.add nameBlock, $.el 'span',
className: 'name' className: 'name'
textContent: data.name textContent: data.name
if userID
$.add nameBlock, [$.tn(' '), $.el('span',
className: "posteruid id_#{userID}"
innerHTML: "(ID: <span class=hand title='Highlight posts by this ID'>#{userID}</span>)"
)]
if trip if trip
$.add nameBlock, [$.tn(' '), $.el('span', className: 'postertrip', textContent: trip)] $.add nameBlock, [$.tn(' '), $.el('span', className: 'postertrip', textContent: trip)]
if capcode isnt 'N' # 'A'dmin or 'M'od nameBlock = $ '.nameBlock', pi
$.add nameBlock, [ switch capcode # 'A'dmin or 'M'od or 'D'eveloper
$.tn(' '), when 'A'
$.el('strong', $.addClass nameBlock, 'capcodeAdmin'
className: if capcode is 'A' then 'capcode capcodeAdmin' else 'capcode', $.add nameBlock, [
textContent: if capcode is 'A' then '## Admin' else '## Mod' $.tn(' '),
) $.el('strong',
] className: 'capcode'
nameBlock = $ '.nameBlock', pi textContent: '## Admin'
$.addClass nameBlock, if capcode is 'A' then 'capcodeAdmin' else 'capcodeMod' ),
$.add nameBlock, [ $.tn(' '),
$.tn(' '), $.el('img',
$.el('img', src: '//static.4chan.org/image/adminicon.gif'
src: if capcode is 'A' then '//static.4chan.org/image/adminicon.gif' else '//static.4chan.org/image/modicon.gif', alt: 'This user is the 4chan Administrator.'
alt: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.', title: 'This user is the 4chan Administrator.'
title: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.', className: 'identityIcon'
className: 'identityIcon' )
) ]
] when 'M'
$.addClass nameBlock, 'capcodeMod'
$.add nameBlock, [
$.tn(' '),
$.el('strong',
className: 'capcode'
textContent: '## Mod'
),
$.tn(' '),
$.el('img',
src: '//static.4chan.org/image/modicon.gif'
alt: 'This user is a 4chan Moderator.'
title: 'This user is a 4chan Moderator.'
className: 'identityIcon'
)
]
when 'D'
$.addClass nameBlock, 'capcodeDeveloper'
$.add nameBlock, [
$.tn(' '),
$.el('strong',
className: 'capcode'
textContent: '## Developer'
),
$.tn(' '),
$.el('img',
src: '//static.4chan.org/image/developericon.gif'
alt: 'This user is a 4chan Developer.'
title: 'title="This user is a 4chan Developer.'
className: 'identityIcon'
)
]
# comment # comment
bq = $.el 'blockquote', bq = $.el 'blockquote',