From e04e9334385dd1c68bda9e9b4f6c527179bf94f5 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 19 Sep 2014 20:13:18 -0700 Subject: [PATCH] use 4chan's new archived thread icon --- src/General/Build.coffee | 16 +++++----------- src/General/Main.coffee | 1 - src/General/lib/post.class | 6 ++++-- src/General/lib/thread.class | 26 ++++++++++++++++++-------- src/Monitoring/ThreadUpdater.coffee | 4 ++-- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 46dc5cbd1..e9c77f3a4 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -43,6 +43,7 @@ Build = # thread status isSticky: !!data.sticky isClosed: !!data.closed + isArchived: !!data.archived # file if data.filedeleted o.file = @@ -74,7 +75,6 @@ Build = { postID, threadID, boardID name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC - isSticky, isClosed comment file } = o @@ -151,15 +151,9 @@ Build = else "/#{boardID}/thread/#{threadID}\#q#{postID}" - sticky = if isSticky - <%= html(' Sticky') %> - else - <%= html('') %> - - closed = if isClosed - <%= html(' Closed') %> - else - <%= html('') %> + icons = for type in ['Sticky', 'Closed', 'Archived'] when o["is#{type}"] and !(type is 'Closed' and o.isArchived) + typeLC = type.toLowerCase() + <%= html(' ${type}') %> replyLink = if isOP and g.VIEW is 'index' <%= html('   [Reply]') %> @@ -175,7 +169,7 @@ Build = '' + 'No.' + '${postID}' + - '&{sticky}&{closed}&{replyLink}' + + '@{icons}&{replyLink}' + '' + '' ) %> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 5d1f6fe74..89942ddde 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -166,7 +166,6 @@ Main = for threadRoot in $$ '.board > .thread', 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 for postRoot in $$ '.thread > .postContainer', threadRoot try diff --git a/src/General/lib/post.class b/src/General/lib/post.class index 66bb7966d..2e9c89dec 100755 --- a/src/General/lib/post.class +++ b/src/General/lib/post.class @@ -43,8 +43,10 @@ class Post unless @isReply = $.hasClass post, 'reply' @thread.OP = @ - @thread.isSticky = !!$ '.stickyIcon', info - @thread.isClosed = !!$ '.closedIcon', info + @thread.isArchived = !!$ '.archivedIcon', info + @thread.isSticky = !!$ '.stickyIcon', info + @thread.isClosed = @thread.isArchived or !!$ '.closedIcon', info + @thread.kill() if @thread.isArchived @info = {} if subject = $ '.subject', info diff --git a/src/General/lib/thread.class b/src/General/lib/thread.class index 40b817aa2..f5c4efd71 100755 --- a/src/General/lib/thread.class +++ b/src/General/lib/thread.class @@ -3,12 +3,13 @@ class Thread toString: -> @ID constructor: (@ID, @board) -> - @fullID = "#{@board}.#{@ID}" - @posts = new SimpleDict - @isSticky = false - @isClosed = false - @postLimit = false - @fileLimit = false + @fullID = "#{@board}.#{@ID}" + @posts = new SimpleDict + @isSticky = false + @isClosed = false + @isArchived = false + @postLimit = false + @fileLimit = false g.threads.push @fullID, board.threads.push @, @ @@ -19,21 +20,30 @@ class Thread $.after $('a[title="Reply to this post"]', info), [$.tn(' '), icon] icon.title = "This thread is on page #{pageNum} in the original index." icon.textContent = "[#{pageNum}]" + setStatus: (type, status) -> name = "is#{type}" return if @[name] is status @[name] = status return unless @OP + @setIcon 'Sticky', @isSticky + @setIcon 'Closed', @isClosed and !@isArchived + @setIcon 'Archived', @isArchived + + setIcon: (type, status) -> typeLC = type.toLowerCase() + icon = $ ".#{typeLC}Icon", @OP.nodes.info + return if !!icon is status unless status - $.rm $ ".#{typeLC}Icon", @OP.nodes.info + $.rm icon.previousSibling + $.rm icon return icon = $.el 'img', src: "//s.4cdn.org/image/#{typeLC}#{if window.devicePixelRatio >= 2 then '@2x' else ''}.gif" alt: type title: type className: "#{typeLC}Icon retina" - root = if type is 'Closed' and @isSticky + root = if type isnt 'Sticky' and @isSticky $ '.stickyIcon', @OP.nodes.info else $('.page-num', @OP.nodes.info) or $('[title="Reply to this post"]', @OP.nodes.info) diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 5130262c4..4d2548d06 100755 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -132,8 +132,7 @@ ThreadUpdater = switch req.status when 200 ThreadUpdater.parse req.response.posts - if !!req.response.posts[0].archived - ThreadUpdater.thread.isArchived = true + if ThreadUpdater.thread.isArchived ThreadUpdater.set 'status', 'Archived', 'warning' ThreadUpdater.kill() else @@ -263,6 +262,7 @@ ThreadUpdater = OP = postObjects[0] Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler + ThreadUpdater.thread.setStatus 'Archived', !!OP.archived ThreadUpdater.updateThreadStatus 'Sticky', !!OP.sticky ThreadUpdater.updateThreadStatus 'Closed', !!OP.closed ThreadUpdater.thread.postLimit = !!OP.bumplimit