A bit of cleaning in Build.post().
This commit is contained in:
parent
7fda9f1fb6
commit
6574e4aa95
@ -1,4 +1,6 @@
|
|||||||
Build =
|
Build =
|
||||||
|
staticPath: '//s.4cdn.org/image/'
|
||||||
|
gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
|
||||||
spoilerRange: {}
|
spoilerRange: {}
|
||||||
shortFilename: (filename, isReply) ->
|
shortFilename: (filename, isReply) ->
|
||||||
# FILENAME SHORTENING SCIENCE:
|
# FILENAME SHORTENING SCIENCE:
|
||||||
@ -61,9 +63,12 @@ Build =
|
|||||||
file
|
file
|
||||||
} = o
|
} = o
|
||||||
isOP = postID is threadID
|
isOP = postID is threadID
|
||||||
|
{staticPath, gifIcon} = Build
|
||||||
|
|
||||||
staticPath = '//s.4cdn.org/image/'
|
tripcode = if tripcode
|
||||||
gifIcon = if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
|
" <span class=postertrip>#{tripcode}</span>"
|
||||||
|
else
|
||||||
|
''
|
||||||
|
|
||||||
if email
|
if email
|
||||||
emailStart = '<a href="mailto:' + email + '" class="useremail">'
|
emailStart = '<a href="mailto:' + email + '" class="useremail">'
|
||||||
@ -72,41 +77,35 @@ Build =
|
|||||||
emailStart = ''
|
emailStart = ''
|
||||||
emailEnd = ''
|
emailEnd = ''
|
||||||
|
|
||||||
subject = "<span class=subject>#{subject or ''}</span>"
|
|
||||||
|
|
||||||
userID =
|
|
||||||
if !capcode and uniqueID
|
|
||||||
" <span class='posteruid id_#{uniqueID}'>(ID: " +
|
|
||||||
"<span class=hand title='Highlight posts by this ID'>#{uniqueID}</span>)</span> "
|
|
||||||
else
|
|
||||||
''
|
|
||||||
|
|
||||||
switch capcode
|
switch capcode
|
||||||
when 'admin', 'admin_highlight'
|
when 'admin', 'admin_highlight'
|
||||||
capcodeClass = " capcodeAdmin"
|
capcodeClass = " capcodeAdmin"
|
||||||
capcodeStart = " <strong class='capcode hand id_admin'" +
|
capcodeStart = " <strong class='capcode hand id_admin'" +
|
||||||
"title='Highlight posts by the Administrator'>## Admin</strong>"
|
"title='Highlight posts by the Administrator'>## Admin</strong>"
|
||||||
capcode = " <img src='#{staticPath}adminicon#{gifIcon}' " +
|
capcodeIcon = " <img src='#{staticPath}adminicon#{gifIcon}' " +
|
||||||
"alt='This user is the 4chan Administrator.' " +
|
|
||||||
"title='This user is the 4chan Administrator.' class=identityIcon>"
|
"title='This user is the 4chan Administrator.' class=identityIcon>"
|
||||||
when 'mod'
|
when 'mod'
|
||||||
capcodeClass = " capcodeMod"
|
capcodeClass = " capcodeMod"
|
||||||
capcodeStart = " <strong class='capcode hand id_mod' " +
|
capcodeStart = " <strong class='capcode hand id_mod' " +
|
||||||
"title='Highlight posts by Moderators'>## Mod</strong>"
|
"title='Highlight posts by Moderators'>## Mod</strong>"
|
||||||
capcode = " <img src='#{staticPath}modicon#{gifIcon}' " +
|
capcodeIcon = " <img src='#{staticPath}modicon#{gifIcon}' " +
|
||||||
"alt='This user is a 4chan Moderator.' " +
|
|
||||||
"title='This user is a 4chan Moderator.' class=identityIcon>"
|
"title='This user is a 4chan Moderator.' class=identityIcon>"
|
||||||
when 'developer'
|
when 'developer'
|
||||||
capcodeClass = " capcodeDeveloper"
|
capcodeClass = " capcodeDeveloper"
|
||||||
capcodeStart = " <strong class='capcode hand id_developer' " +
|
capcodeStart = " <strong class='capcode hand id_developer' " +
|
||||||
"title='Highlight posts by Developers'>## Developer</strong>"
|
"title='Highlight posts by Developers'>## Developer</strong>"
|
||||||
capcode = " <img src='#{staticPath}developericon#{gifIcon}' " +
|
capcodeIcon = " <img src='#{staticPath}developericon#{gifIcon}' " +
|
||||||
"alt='This user is a 4chan Developer.' " +
|
|
||||||
"title='This user is a 4chan Developer.' class=identityIcon>"
|
"title='This user is a 4chan Developer.' class=identityIcon>"
|
||||||
else
|
else
|
||||||
capcodeClass = ''
|
capcodeClass = ''
|
||||||
capcodeStart = ''
|
capcodeStart = ''
|
||||||
capcode = ''
|
capcodeIcon = ''
|
||||||
|
|
||||||
|
userID = if uniqueID and !capcode
|
||||||
|
" <span class='posteruid id_#{uniqueID}'>(ID: " +
|
||||||
|
"<span class=hand title='Highlight posts by this ID'>#{uniqueID}</span>)</span>"
|
||||||
|
else
|
||||||
|
''
|
||||||
|
|
||||||
flag = unless flagCode
|
flag = unless flagCode
|
||||||
''
|
''
|
||||||
@ -125,13 +124,7 @@ Build =
|
|||||||
"<img src='#{staticPath}filedeleted-res#{gifIcon}' alt='File deleted.' class=fileDeletedRes>" +
|
"<img src='#{staticPath}filedeleted-res#{gifIcon}' alt='File deleted.' class=fileDeletedRes>" +
|
||||||
"</span></div>"
|
"</span></div>"
|
||||||
else if file
|
else if file
|
||||||
ext = file.name[-3..]
|
fileSize = $.bytesToString file.size
|
||||||
if !file.twidth and !file.theight and ext is 'gif' # wtf ?
|
|
||||||
file.twidth = file.width
|
|
||||||
file.theight = file.height
|
|
||||||
|
|
||||||
fileSize = $.bytesToString file.size
|
|
||||||
|
|
||||||
fileThumb = file.turl
|
fileThumb = file.turl
|
||||||
if file.isSpoiler
|
if file.isSpoiler
|
||||||
fileSize = "Spoiler Image, #{fileSize}"
|
fileSize = "Spoiler Image, #{fileSize}"
|
||||||
@ -150,20 +143,17 @@ Build =
|
|||||||
"<img src='#{fileThumb}' alt='#{fileSize}' data-md5=#{file.MD5} style='height: #{file.theight}px; width: #{file.twidth}px;'>" +
|
"<img src='#{fileThumb}' alt='#{fileSize}' data-md5=#{file.MD5} style='height: #{file.theight}px; width: #{file.twidth}px;'>" +
|
||||||
"</a>"
|
"</a>"
|
||||||
|
|
||||||
# Ha ha, filenames!
|
|
||||||
# html -> text, translate WebKit's %22s into "s
|
# html -> text, translate WebKit's %22s into "s
|
||||||
a = $.el 'a', innerHTML: file.name
|
a = $.el 'a', innerHTML: file.name
|
||||||
filename = a.textContent.replace /%22/g, '"'
|
filename = a.textContent.replace /%22/g, '"'
|
||||||
|
|
||||||
# shorten filename, get html
|
# shorten filename, get html
|
||||||
a.textContent = Build.shortFilename filename
|
a.textContent = Build.shortFilename filename
|
||||||
shortFilename = a.innerHTML
|
shortFilename = a.innerHTML
|
||||||
|
|
||||||
# get html
|
# get html
|
||||||
a.textContent = filename
|
a.textContent = filename
|
||||||
filename = a.innerHTML.replace /'/g, '''
|
filename = a.innerHTML.replace /'/g, '''
|
||||||
|
|
||||||
fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
|
fileDims = if file.name[-3..] is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
|
||||||
fileInfo = "<div class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
|
fileInfo = "<div class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
|
||||||
"-(#{fileSize}, #{fileDims}#{
|
"-(#{fileSize}, #{fileDims}#{
|
||||||
if file.isSpoiler
|
if file.isSpoiler
|
||||||
@ -176,11 +166,6 @@ Build =
|
|||||||
else
|
else
|
||||||
fileHTML = ''
|
fileHTML = ''
|
||||||
|
|
||||||
tripcode = if tripcode
|
|
||||||
" <span class=postertrip>#{tripcode}</span>"
|
|
||||||
else
|
|
||||||
''
|
|
||||||
|
|
||||||
sticky = if isSticky
|
sticky = if isSticky
|
||||||
" <img src=#{staticPath}sticky#{gifIcon} alt=Sticky title=Sticky class=stickyIcon>"
|
" <img src=#{staticPath}sticky#{gifIcon} alt=Sticky title=Sticky class=stickyIcon>"
|
||||||
else
|
else
|
||||||
@ -213,11 +198,11 @@ Build =
|
|||||||
|
|
||||||
"<div class='postInfo' id=pi#{postID}>" +
|
"<div class='postInfo' id=pi#{postID}>" +
|
||||||
"<input type=checkbox name=#{postID} value=delete> " +
|
"<input type=checkbox name=#{postID} value=delete> " +
|
||||||
"#{subject} " +
|
"<span class=subject>#{subject or ''}</span> " +
|
||||||
"<span class='nameBlock#{capcodeClass}'>" +
|
"<span class='nameBlock#{capcodeClass}'>" +
|
||||||
emailStart +
|
emailStart +
|
||||||
"<span class=name>#{name or ''}</span>" + tripcode +
|
"<span class=name>#{name or ''}</span>" + tripcode +
|
||||||
capcodeStart + emailEnd + capcode + userID + flag +
|
capcodeStart + emailEnd + capcodeIcon + userID + flag +
|
||||||
' </span> ' +
|
' </span> ' +
|
||||||
"<span class=dateTime data-utc=#{dateUTC}>#{date}</span> " +
|
"<span class=dateTime data-utc=#{dateUTC}>#{date}</span> " +
|
||||||
"<span class='postNum'>" +
|
"<span class='postNum'>" +
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user