This commit is contained in:
Zixaphir 2014-01-08 11:57:54 -07:00
parent fca2645787
commit 5785f9cda3
6 changed files with 94 additions and 73 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -321,9 +321,6 @@ Main =
delete posts[id] for id of posts when posts.hasOwnProperty id delete posts[id] for id of posts when posts.hasOwnProperty id
delete threads[id] for id of threads when threads.hasOwnProperty id delete threads[id] for id of threads when threads.hasOwnProperty id
g.threads = threads
g.posts = posts
disconnect: (view) -> disconnect: (view) ->
if g.VIEW is 'thread' if g.VIEW is 'thread'
features = [ features = [

View File

@ -1,20 +1,28 @@
class Callbacks class Callbacks
push: ({name, cb}) -> @[name] = cb constructor: (@type) ->
@keys = []
push: ({name, cb}) ->
@[name] = cb
@keys.push name
clean: -> clean: ->
@rm name for name of @ when @hasOwnProperty name @rm name for name in @keys
return return
rm: (name) -> delete @[name] rm: (name) ->
return unless @[name]
delete @[name]
@keys.splice @keys.indexOf(name), 1 # Didn't I make this structure to avoid this? ;__;
execute: (node) -> execute: (node) ->
for name of @ when @hasOwnProperty name for name in @keys
try try
@[name].call node @[name].call node
catch err catch err
errors = [] unless errors errors = [] unless errors
errors.push errors.push
message: ['"', name, '" crashed on node No.', node, ' (', node.board, ').'].join('') message: ['"', name, '" crashed on node ', @type, ' No.', node, ' (', node.board, ').'].join('')
error: err error: err
Main.handleErrors errors if errors Main.handleErrors errors if errors

View File

@ -1,5 +1,5 @@
class Post class Post
@callbacks = new Callbacks() @callbacks = new Callbacks 'Post'
toString: -> @ID toString: -> @ID
constructor: (root, @thread, @board, that={}) -> constructor: (root, @thread, @board, that={}) ->

View File

@ -1,5 +1,5 @@
class Thread class Thread
@callbacks = new Callbacks() @callbacks = new Callbacks 'Thread'
toString: -> @ID toString: -> @ID
constructor: (@ID, @board) -> constructor: (@ID, @board) ->