4chan-x/src/General/lib/thread.class
Zixaphir 9d95bbea35 Merge branch 'mayhem' into v3 -- Still broken, do not merge (yet)
Conflicts:
	CHANGELOG.md
	Gruntfile.coffee
	css/burichan.css
	css/futaba.css
	css/photon.css
	css/style.css
	css/tomorrow.css
	css/yotsuba-b.css
	css/yotsuba.css
	html/General/Index-navlinks.html
	html/General/Settings-section-Rice.html
	html/General/Settings.html
	html/Posting/QR.html
	json/archives.json
	package.json
	src/Filtering/PostHiding.coffee
	src/Filtering/Recursive.coffee
	src/Filtering/ThreadHiding.coffee
	src/General/Build.coffee
	src/General/Config.coffee
	src/General/Get.coffee
	src/General/Header.coffee
	src/General/Index.coffee
	src/General/Main.coffee
	src/General/Settings.coffee
	src/General/UI.coffee
	src/General/lib/$.coffee
	src/General/lib/databoard.class
	src/General/lib/post.class
	src/General/lib/thread.class
	src/Images/ImageExpand.coffee
	src/Images/RevealSpoilers.coffee
	src/Linkification/Linkify.coffee
	src/Menu/Menu.coffee
	src/Miscellaneous/ExpandThread.coffee
	src/Miscellaneous/IDColor.coffee
	src/Miscellaneous/Keybinds.coffee
	src/Monitoring/ThreadUpdater.coffee
	src/Monitoring/Unread.coffee
	src/Posting/QR.captcha.coffee
	src/Posting/QR.coffee
	src/Posting/QR.cooldown.coffee
	src/Quotelinks/QuoteBacklink.coffee
	src/Quotelinks/QuoteCT.coffee
	src/Quotelinks/QuoteOP.coffee
	src/Quotelinks/QuoteStrikeThrough.coffee
	src/Quotelinks/QuoteYou.coffee
	src/Quotelinks/Quotify.coffee
2014-02-23 14:04:45 -07:00

83 lines
2.3 KiB
Plaintext
Executable File

class Thread
@callbacks = new Callbacks 'Thread'
toString: -> @ID
constructor: (@ID, @board) ->
@fullID = "#{@board}.#{@ID}"
@posts = new SimpleDict
@isDead = false
@isHidden = false
@isOnTop = false
@isPinned = false
@isSticky = false
@isClosed = false
@postLimit = false
@fileLimit = false
@OP = null
@catalogView = null
g.threads.push @fullID, board.threads.push @, @
setPage: (pageNum) ->
icon = $ '.page-num', @OP.nodes.info
for key in ['title', 'textContent']
icon[key] = icon[key].replace /\d+/, pageNum
@catalogView.nodes.pageCount.textContent = pageNum if @catalogView
setCount: (type, count, reachedLimit) ->
return unless @catalogView
el = @catalogView.nodes["#{type}Count"]
el.textContent = count
(if reachedLimit then $.addClass else $.rmClass) el, 'warning'
setStatus: (type, status) ->
name = "is#{type}"
return if @[name] is status
@[name] = status
return unless @OP
typeLC = type.toLowerCase()
unless status
$.rm $ ".#{typeLC}Icon", @OP.nodes.info
$.rm $ ".#{typeLC}Icon", @catalogView.nodes.icons if @catalogView
return
icon = $.el 'img',
src: "#{Build.staticPath}#{typeLC}#{Build.gifIcon}"
title: type
className: "#{typeLC}Icon"
root = if type is 'Closed' and @isSticky
$ '.stickyIcon', @OP.nodes.info
else if g.VIEW is 'index'
$ '.page-num', @OP.nodes.info
else
$ '[title="Quote this post"]', @OP.nodes.info
$.after root, [$.tn(' '), icon]
return unless @catalogView
(if type is 'Sticky' and @isClosed then $.prepend else $.add) @catalogView.nodes.icons, icon.cloneNode()
pin: ->
@isPinned = true
$.addClass @catalogView.nodes.root, 'pinned' if @catalogView
unpin: ->
@isPinned = false
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
hide: ->
return if @isHidden
@isHidden = true
if button = $ '.hide-post-button', @OP.nodes.root
$.replace button, PostHiding.makeButton false
show: ->
return if !@isHidden
@isHidden = false
if button = $ '.show-post-button', @OP.nodes.root
$.replace button, PostHiding.makeButton true
kill: ->
@isDead = true
collect: ->
@posts.forEach (post) -> post.collect()
g.threads.rm @fullID
@board.threads.rm @