4chan-x/src/General/lib/thread.class
Zixaphir b38f63e313 Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3
Conflicts:
	Gruntfile.coffee
	src/Filtering/PostHiding.coffee
	src/General/Build.coffee
	src/General/lib/$.coffee
	src/Menu/Menu.coffee
	src/Posting/QuickReply.coffee
2013-12-25 10:54:21 -07:00

51 lines
1.3 KiB
Plaintext
Executable File

class Thread
@callbacks = []
toString: -> @ID
constructor: (@ID, @board) ->
@fullID = "#{@board}.#{@ID}"
@posts = {}
@isSticky = false
@isClosed = false
@postLimit = false
@fileLimit = false
g.threads[@fullID] = board.threads[@] = @
setPage: (pageNum) ->
icon = $ '.page-num', @OP.nodes.post
for key in ['title', 'textContent']
icon[key] = icon[key].replace /\d+/, pageNum
return
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
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"
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]
kill: ->
@isDead = true
@timeOfDeath = Date.now()
collect: ->
for postID, post in @posts
post.collect()
delete g.threads[@fullID]
delete @board.threads[@]