4chan-x/src/Filtering/Recursive.coffee
Zixaphir 91233b8d61 remove [].contains. It was a bad idea.
I shouldn't be messing with stuff like this without a really good
reason for doing so, and the longer I thought about it, the more
it occurred to me that I didn't have one.
2013-12-24 14:41:21 -07:00

39 lines
897 B
CoffeeScript
Executable File

Recursive =
recursives: {}
init: ->
return if g.VIEW is 'catalog'
Post.callbacks.push
name: 'Recursive'
cb: @node
node: ->
return if @isClone
for quote in @quotes
if obj = Recursive.recursives[quote]
for recursive, i in obj.recursives
recursive @, obj.args[i]...
return
add: (recursive, post, args...) ->
obj = Recursive.recursives[post.fullID] or=
recursives: []
args: []
obj.recursives.push recursive
obj.args.push args
rm: (recursive, post) ->
return unless obj = Recursive.recursives[post.fullID]
for rec, i in obj.recursives
if rec is recursive
obj.recursives.splice i, 1
obj.args.splice i, 1
return
apply: (recursive, post, args...) ->
{fullID} = post
for ID, post of g.posts
if fullID in post.quotes
recursive post, args...
return