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

@ -252,7 +252,7 @@ Main =
<%= grunt.file.read('src/General/css/tomorrow.css').replace(/\s+/g, ' ').trim() %>
<%= grunt.file.read('src/General/css/photon.css').replace(/\s+/g, ' ').trim() %>
"""
features: [
['Polyfill', Polyfill]
['Redirect', Redirect]
@ -315,14 +315,11 @@ Main =
['Show Dice Roll', Dice]
['Banner', Banner]
]
clean: ->
{posts, threads} = g
delete posts[id] for id of posts when posts.hasOwnProperty id
delete threads[id] for id of threads when threads.hasOwnProperty id
g.threads = threads
g.posts = posts
disconnect: (view) ->
if g.VIEW is 'thread'
@ -349,7 +346,7 @@ Main =
# Clean the board, as we'll be dumping shit here
# $.rmAll $ '.board'
g.VIEW = view
navigate: (e) ->
@ -360,7 +357,7 @@ Main =
[boardID, view, threadID] = path
return if view is 'catalog'
e.preventDefault()
history.pushState null, '', @pathname
@ -377,7 +374,7 @@ Main =
Main.updateBoard boardID
Index.update()
else
Main.refresh {boardID, view, threadID}
@ -390,7 +387,7 @@ Main =
else
Main.refresh {boardID, view, threadID}
Header.setBoardList()
updateBoard: (boardID) ->

View File

@ -1,20 +1,28 @@
class Callbacks
push: ({name, cb}) -> @[name] = cb
constructor: (@type) ->
@keys = []
clean: ->
@rm name for name of @ when @hasOwnProperty name
push: ({name, cb}) ->
@[name] = cb
@keys.push name
clean: ->
@rm name for name in @keys
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) ->
for name of @ when @hasOwnProperty name
for name in @keys
try
@[name].call node
catch err
errors = [] unless errors
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
Main.handleErrors errors if errors

View File

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

View File

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