Merge from Appchan X: src/General/Build.coffee
This commit is contained in:
parent
00541ba898
commit
e38887df0d
@ -1,13 +1,12 @@
|
|||||||
Build =
|
Build =
|
||||||
staticPath: '//s.4cdn.org/image/'
|
staticPath: '//s.4cdn.org/image/'
|
||||||
gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
|
gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
|
||||||
initPixelRatio: window.devicePixelRatio
|
|
||||||
spoilerRange: {}
|
spoilerRange: {}
|
||||||
unescape: (text) ->
|
unescape: (text) ->
|
||||||
return text unless text?
|
return text unless text?
|
||||||
text.replace(/<[^>]*>/g, '').replace /&(amp|#039|quot|lt|gt);/g, (c) ->
|
text.replace(/<[^>]*>/g, '').replace /&(amp|#039|quot|lt|gt);/g, (c) ->
|
||||||
{'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[c]
|
{'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[c]
|
||||||
shortFilename: (filename, isReply) ->
|
shortFilename: (filename) ->
|
||||||
threshold = 30
|
threshold = 30
|
||||||
ext = filename.match(/\.?[^\.]*$/)[0]
|
ext = filename.match(/\.?[^\.]*$/)[0]
|
||||||
if filename.length - ext.length > threshold
|
if filename.length - ext.length > threshold
|
||||||
@ -15,8 +14,8 @@ Build =
|
|||||||
else
|
else
|
||||||
filename
|
filename
|
||||||
thumbRotate: do ->
|
thumbRotate: do ->
|
||||||
n = 0
|
t = 0
|
||||||
-> n = (n + 1) % 2
|
-> t = (if t then 0 else 1)
|
||||||
sameThread: (boardID, threadID) ->
|
sameThread: (boardID, threadID) ->
|
||||||
g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID
|
g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID
|
||||||
postURL: (boardID, threadID, postID) ->
|
postURL: (boardID, threadID, postID) ->
|
||||||
@ -83,8 +82,7 @@ Build =
|
|||||||
name or= ''
|
name or= ''
|
||||||
subject or= ''
|
subject or= ''
|
||||||
isOP = postID is threadID
|
isOP = postID is threadID
|
||||||
|
{staticPath, gifIcon} = Build
|
||||||
retina = if Build.initPixelRatio >= 2 then '@2x' else ''
|
|
||||||
|
|
||||||
### Name Block ###
|
### Name Block ###
|
||||||
|
|
||||||
@ -92,15 +90,15 @@ Build =
|
|||||||
when 'admin', 'admin_highlight'
|
when 'admin', 'admin_highlight'
|
||||||
capcodeClass = ' capcodeAdmin'
|
capcodeClass = ' capcodeAdmin'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_admin" title="Highlight posts by the Administrator">## Admin</strong>') %>
|
capcodeStart = <%= html(' <strong class="capcode hand id_admin" title="Highlight posts by the Administrator">## Admin</strong>') %>
|
||||||
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/adminicon${retina}.gif" alt="Admin Icon" title="This user is the 4chan Administrator." class="identityIcon retina">') %>
|
capcodeIcon = <%= html(' <img src="${staticPath}adminicon${gifIcon}" alt="Admin Icon" title="This user is the 4chan Administrator." class="identityIcon retina">') %>
|
||||||
when 'mod'
|
when 'mod'
|
||||||
capcodeClass = ' capcodeMod'
|
capcodeClass = ' capcodeMod'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_mod" title="Highlight posts by Moderators">## Mod</strong>') %>
|
capcodeStart = <%= html(' <strong class="capcode hand id_mod" title="Highlight posts by Moderators">## Mod</strong>') %>
|
||||||
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/modicon${retina}.gif" alt="Mod Icon" title="This user is a 4chan Moderator." class="identityIcon retina">') %>
|
capcodeIcon = <%= html(' <img src="${staticPath}modicon${gifIcon}" alt="Mod Icon" title="This user is a 4chan Moderator." class="identityIcon retina">') %>
|
||||||
when 'developer'
|
when 'developer'
|
||||||
capcodeClass = ' capcodeDeveloper'
|
capcodeClass = ' capcodeDeveloper'
|
||||||
capcodeStart = <%= html(' <strong class="capcode hand id_developer" title="Highlight posts by Developers">## Developer</strong>') %>
|
capcodeStart = <%= html(' <strong class="capcode hand id_developer" title="Highlight posts by Developers">## Developer</strong>') %>
|
||||||
capcodeIcon = <%= html(' <img src="//s.4cdn.org/image/developericon${retina}.gif" alt="Developer Icon" title="This user is a 4chan Developer." class="identityIcon retina">') %>
|
capcodeIcon = <%= html(' <img src="${staticPath}developericon${gifIcon}" alt="Developer Icon" title="This user is a 4chan Developer." class="identityIcon retina">') %>
|
||||||
else
|
else
|
||||||
capcodeClass = ''
|
capcodeClass = ''
|
||||||
capcodeStart = <%= html('') %>
|
capcodeStart = <%= html('') %>
|
||||||
@ -151,7 +149,7 @@ Build =
|
|||||||
|
|
||||||
icons = for type in ['Sticky', 'Closed', 'Archived'] when o["is#{type}"] and !(type is 'Closed' and o.isArchived)
|
icons = for type in ['Sticky', 'Closed', 'Archived'] when o["is#{type}"] and !(type is 'Closed' and o.isArchived)
|
||||||
typeLC = type.toLowerCase()
|
typeLC = type.toLowerCase()
|
||||||
<%= html(' <img src="//s.4cdn.org/image/${typeLC}${retina}.gif" alt="${type}" title="${type}" class="${typeLC}Icon retina">') %>
|
<%= html(' <img src="${staticPath}${typeLC}${gifIcon}" alt="${type}" title="${type}" class="${typeLC}Icon retina">') %>
|
||||||
|
|
||||||
replyLink = if isOP and g.VIEW is 'index'
|
replyLink = if isOP and g.VIEW is 'index'
|
||||||
<%= html(' <span>[<a href="/${boardID}/thread/${threadID}" class="replylink">Reply</a>]</span>') %>
|
<%= html(' <span>[<a href="/${boardID}/thread/${threadID}" class="replylink">Reply</a>]</span>') %>
|
||||||
@ -177,7 +175,7 @@ Build =
|
|||||||
fileCont = if file?.isDeleted
|
fileCont = if file?.isDeleted
|
||||||
<%= html(
|
<%= html(
|
||||||
'<span class="fileThumb">' +
|
'<span class="fileThumb">' +
|
||||||
'<img src="//s.4cdn.org/image/filedeleted-res${retina}.gif" alt="File deleted." class="fileDeletedRes retina">' +
|
'<img src="${staticPath}filedeleted-res${gifIcon}" alt="File deleted." class="fileDeletedRes retina">' +
|
||||||
'</span>'
|
'</span>'
|
||||||
) %>
|
) %>
|
||||||
else if file and boardID is 'f'
|
else if file and boardID is 'f'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user