use 4chan's new archived thread icon
This commit is contained in:
parent
b992dffaab
commit
e04e933438
@ -43,6 +43,7 @@ Build =
|
|||||||
# thread status
|
# thread status
|
||||||
isSticky: !!data.sticky
|
isSticky: !!data.sticky
|
||||||
isClosed: !!data.closed
|
isClosed: !!data.closed
|
||||||
|
isArchived: !!data.archived
|
||||||
# file
|
# file
|
||||||
if data.filedeleted
|
if data.filedeleted
|
||||||
o.file =
|
o.file =
|
||||||
@ -74,7 +75,6 @@ Build =
|
|||||||
{
|
{
|
||||||
postID, threadID, boardID
|
postID, threadID, boardID
|
||||||
name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC
|
name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC
|
||||||
isSticky, isClosed
|
|
||||||
comment
|
comment
|
||||||
file
|
file
|
||||||
} = o
|
} = o
|
||||||
@ -151,15 +151,9 @@ Build =
|
|||||||
else
|
else
|
||||||
"/#{boardID}/thread/#{threadID}\#q#{postID}"
|
"/#{boardID}/thread/#{threadID}\#q#{postID}"
|
||||||
|
|
||||||
sticky = if isSticky
|
icons = for type in ['Sticky', 'Closed', 'Archived'] when o["is#{type}"] and !(type is 'Closed' and o.isArchived)
|
||||||
<%= html(' <img src="//s.4cdn.org/image/sticky${retina}.gif" alt="Sticky" title="Sticky" class="stickyIcon retina">') %>
|
typeLC = type.toLowerCase()
|
||||||
else
|
<%= html(' <img src="//s.4cdn.org/image/${typeLC}${retina}.gif" alt="${type}" title="${type}" class="${typeLC}Icon retina">') %>
|
||||||
<%= html('') %>
|
|
||||||
|
|
||||||
closed = if isClosed
|
|
||||||
<%= html(' <img src="//s.4cdn.org/image/closed${retina}.gif" alt="Closed" title="Closed" class="closedIcon retina">') %>
|
|
||||||
else
|
|
||||||
<%= html('') %>
|
|
||||||
|
|
||||||
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>') %>
|
||||||
@ -175,7 +169,7 @@ Build =
|
|||||||
'<span class="postNum${desktop2}">' +
|
'<span class="postNum${desktop2}">' +
|
||||||
'<a href="${postLink}" title="Link to this post">No.</a>' +
|
'<a href="${postLink}" title="Link to this post">No.</a>' +
|
||||||
'<a href="${quoteLink}" title="Reply to this post">${postID}</a>' +
|
'<a href="${quoteLink}" title="Reply to this post">${postID}</a>' +
|
||||||
'&{sticky}&{closed}&{replyLink}' +
|
'@{icons}&{replyLink}' +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</div>'
|
'</div>'
|
||||||
) %>
|
) %>
|
||||||
|
|||||||
@ -166,7 +166,6 @@ Main =
|
|||||||
|
|
||||||
for threadRoot in $$ '.board > .thread', board
|
for threadRoot in $$ '.board > .thread', board
|
||||||
thread = new Thread +threadRoot.id[1..], g.BOARD
|
thread = new Thread +threadRoot.id[1..], g.BOARD
|
||||||
thread.isDead = thread.isArchived = !!$('.closed')?.textContent.match(/Thread archived/) if g.VIEW is 'thread'
|
|
||||||
threads.push thread
|
threads.push thread
|
||||||
for postRoot in $$ '.thread > .postContainer', threadRoot
|
for postRoot in $$ '.thread > .postContainer', threadRoot
|
||||||
try
|
try
|
||||||
|
|||||||
@ -43,8 +43,10 @@ class Post
|
|||||||
|
|
||||||
unless @isReply = $.hasClass post, 'reply'
|
unless @isReply = $.hasClass post, 'reply'
|
||||||
@thread.OP = @
|
@thread.OP = @
|
||||||
@thread.isSticky = !!$ '.stickyIcon', info
|
@thread.isArchived = !!$ '.archivedIcon', info
|
||||||
@thread.isClosed = !!$ '.closedIcon', info
|
@thread.isSticky = !!$ '.stickyIcon', info
|
||||||
|
@thread.isClosed = @thread.isArchived or !!$ '.closedIcon', info
|
||||||
|
@thread.kill() if @thread.isArchived
|
||||||
|
|
||||||
@info = {}
|
@info = {}
|
||||||
if subject = $ '.subject', info
|
if subject = $ '.subject', info
|
||||||
|
|||||||
@ -3,12 +3,13 @@ class Thread
|
|||||||
toString: -> @ID
|
toString: -> @ID
|
||||||
|
|
||||||
constructor: (@ID, @board) ->
|
constructor: (@ID, @board) ->
|
||||||
@fullID = "#{@board}.#{@ID}"
|
@fullID = "#{@board}.#{@ID}"
|
||||||
@posts = new SimpleDict
|
@posts = new SimpleDict
|
||||||
@isSticky = false
|
@isSticky = false
|
||||||
@isClosed = false
|
@isClosed = false
|
||||||
@postLimit = false
|
@isArchived = false
|
||||||
@fileLimit = false
|
@postLimit = false
|
||||||
|
@fileLimit = false
|
||||||
|
|
||||||
g.threads.push @fullID, board.threads.push @, @
|
g.threads.push @fullID, board.threads.push @, @
|
||||||
|
|
||||||
@ -19,21 +20,30 @@ class Thread
|
|||||||
$.after $('a[title="Reply to this post"]', info), [$.tn(' '), icon]
|
$.after $('a[title="Reply to this post"]', info), [$.tn(' '), icon]
|
||||||
icon.title = "This thread is on page #{pageNum} in the original index."
|
icon.title = "This thread is on page #{pageNum} in the original index."
|
||||||
icon.textContent = "[#{pageNum}]"
|
icon.textContent = "[#{pageNum}]"
|
||||||
|
|
||||||
setStatus: (type, status) ->
|
setStatus: (type, status) ->
|
||||||
name = "is#{type}"
|
name = "is#{type}"
|
||||||
return if @[name] is status
|
return if @[name] is status
|
||||||
@[name] = status
|
@[name] = status
|
||||||
return unless @OP
|
return unless @OP
|
||||||
|
@setIcon 'Sticky', @isSticky
|
||||||
|
@setIcon 'Closed', @isClosed and !@isArchived
|
||||||
|
@setIcon 'Archived', @isArchived
|
||||||
|
|
||||||
|
setIcon: (type, status) ->
|
||||||
typeLC = type.toLowerCase()
|
typeLC = type.toLowerCase()
|
||||||
|
icon = $ ".#{typeLC}Icon", @OP.nodes.info
|
||||||
|
return if !!icon is status
|
||||||
unless status
|
unless status
|
||||||
$.rm $ ".#{typeLC}Icon", @OP.nodes.info
|
$.rm icon.previousSibling
|
||||||
|
$.rm icon
|
||||||
return
|
return
|
||||||
icon = $.el 'img',
|
icon = $.el 'img',
|
||||||
src: "//s.4cdn.org/image/#{typeLC}#{if window.devicePixelRatio >= 2 then '@2x' else ''}.gif"
|
src: "//s.4cdn.org/image/#{typeLC}#{if window.devicePixelRatio >= 2 then '@2x' else ''}.gif"
|
||||||
alt: type
|
alt: type
|
||||||
title: type
|
title: type
|
||||||
className: "#{typeLC}Icon retina"
|
className: "#{typeLC}Icon retina"
|
||||||
root = if type is 'Closed' and @isSticky
|
root = if type isnt 'Sticky' and @isSticky
|
||||||
$ '.stickyIcon', @OP.nodes.info
|
$ '.stickyIcon', @OP.nodes.info
|
||||||
else
|
else
|
||||||
$('.page-num', @OP.nodes.info) or $('[title="Reply to this post"]', @OP.nodes.info)
|
$('.page-num', @OP.nodes.info) or $('[title="Reply to this post"]', @OP.nodes.info)
|
||||||
|
|||||||
@ -132,8 +132,7 @@ ThreadUpdater =
|
|||||||
switch req.status
|
switch req.status
|
||||||
when 200
|
when 200
|
||||||
ThreadUpdater.parse req.response.posts
|
ThreadUpdater.parse req.response.posts
|
||||||
if !!req.response.posts[0].archived
|
if ThreadUpdater.thread.isArchived
|
||||||
ThreadUpdater.thread.isArchived = true
|
|
||||||
ThreadUpdater.set 'status', 'Archived', 'warning'
|
ThreadUpdater.set 'status', 'Archived', 'warning'
|
||||||
ThreadUpdater.kill()
|
ThreadUpdater.kill()
|
||||||
else
|
else
|
||||||
@ -263,6 +262,7 @@ ThreadUpdater =
|
|||||||
OP = postObjects[0]
|
OP = postObjects[0]
|
||||||
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler
|
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler
|
||||||
|
|
||||||
|
ThreadUpdater.thread.setStatus 'Archived', !!OP.archived
|
||||||
ThreadUpdater.updateThreadStatus 'Sticky', !!OP.sticky
|
ThreadUpdater.updateThreadStatus 'Sticky', !!OP.sticky
|
||||||
ThreadUpdater.updateThreadStatus 'Closed', !!OP.closed
|
ThreadUpdater.updateThreadStatus 'Closed', !!OP.closed
|
||||||
ThreadUpdater.thread.postLimit = !!OP.bumplimit
|
ThreadUpdater.thread.postLimit = !!OP.bumplimit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user