Reflow Navigate.parse
This commit is contained in:
parent
b29bee8869
commit
58c68316e3
@ -76,16 +76,6 @@ Navigate =
|
|||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
return
|
return
|
||||||
|
|
||||||
ready: (name, feature, condition) ->
|
|
||||||
try
|
|
||||||
feature() if condition
|
|
||||||
catch err
|
|
||||||
error = [
|
|
||||||
message: "#{name} Failed."
|
|
||||||
error: err
|
|
||||||
]
|
|
||||||
Main.handleErrors error if error
|
|
||||||
|
|
||||||
updateContext: (view) ->
|
updateContext: (view) ->
|
||||||
g.DEAD = false
|
g.DEAD = false
|
||||||
g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread'
|
g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread'
|
||||||
@ -188,10 +178,7 @@ Navigate =
|
|||||||
pageNum = +view or 1 # string to number, '' to 1
|
pageNum = +view or 1 # string to number, '' to 1
|
||||||
view = 'index' # path is "/boardID/". See the problem?
|
view = 'index' # path is "/boardID/". See the problem?
|
||||||
|
|
||||||
if view is g.VIEW and boardID is g.BOARD.ID
|
unless view is 'index' and 'index' is g.VIEW and boardID is g.BOARD.ID
|
||||||
Navigate.updateContext view
|
|
||||||
|
|
||||||
else # We've navigated somewhere we weren't before!
|
|
||||||
Navigate.disconnect()
|
Navigate.disconnect()
|
||||||
Navigate.updateContext view
|
Navigate.updateContext view
|
||||||
Navigate.clean()
|
Navigate.clean()
|
||||||
@ -248,12 +235,11 @@ Navigate =
|
|||||||
return
|
return
|
||||||
|
|
||||||
parse: (data) ->
|
parse: (data) ->
|
||||||
board = g.BOARD
|
posts = []
|
||||||
Navigate.threadRoot = threadRoot = Build.thread board, OP = data.shift(), true
|
errors = null
|
||||||
thread = new Thread OP.no, board
|
board = g.BOARD
|
||||||
|
threadRoot = Build.thread board, OP = data[0], true
|
||||||
posts = []
|
thread = new Thread OP.no, board
|
||||||
errors = null
|
|
||||||
|
|
||||||
makePost = (postNode) ->
|
makePost = (postNode) ->
|
||||||
try
|
try
|
||||||
@ -262,34 +248,32 @@ Navigate =
|
|||||||
# Skip posts that we failed to parse.
|
# Skip posts that we failed to parse.
|
||||||
errors = [] unless errors
|
errors = [] unless errors
|
||||||
errors.push
|
errors.push
|
||||||
message: "Parsing of Post No.#{thread.ID} failed. Post will be skipped."
|
message: "Parsing of Post No.#{postNode.ID} failed. Post will be skipped."
|
||||||
error: err
|
error: err
|
||||||
|
|
||||||
makePost $('.opContainer', threadRoot)
|
makePost $('.opContainer', threadRoot)
|
||||||
|
|
||||||
for obj in data
|
i = 0
|
||||||
|
while obj = data[++i]
|
||||||
post = Build.postFromObject obj, board
|
post = Build.postFromObject obj, board
|
||||||
makePost post
|
makePost post
|
||||||
$.add threadRoot, post
|
$.add threadRoot, post
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
|
||||||
|
|
||||||
Main.callbackNodes Thread, [thread]
|
Main.callbackNodes Thread, [thread]
|
||||||
Main.callbackNodes Post, posts
|
Main.callbackNodes Post, posts
|
||||||
|
|
||||||
Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count']
|
QuoteThreading.force() if Conf['Quote Threading'] and not Conf['Unread Count']
|
||||||
|
|
||||||
|
board = $ '.board'
|
||||||
|
$.rmAll board
|
||||||
|
$.add board, [threadRoot, $.el 'hr']
|
||||||
|
|
||||||
|
Unread.ready() if Conf['Unread Count']
|
||||||
|
|
||||||
Navigate.buildThread()
|
|
||||||
QR.generatePostableThreadsList()
|
QR.generatePostableThreadsList()
|
||||||
Header.hashScroll.call window
|
Header.hashScroll.call window
|
||||||
|
|
||||||
buildThread: ->
|
Main.handleErrors errors if errors
|
||||||
board = $ '.board'
|
|
||||||
$.rmAll board
|
|
||||||
$.add board, [Navigate.threadRoot, $.el 'hr']
|
|
||||||
|
|
||||||
if Conf['Unread Count']
|
|
||||||
Navigate.ready 'Unread Count', Unread.ready, Conf['Unread Count']
|
|
||||||
|
|
||||||
pushState: (path) ->
|
pushState: (path) ->
|
||||||
history.pushState null, '', path
|
history.pushState null, '', path
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user