Make index page refreshing work.
This commit is contained in:
parent
ef38269981
commit
fecf286d26
@ -1,3 +1,5 @@
|
||||
Index navigation improvements:
|
||||
- You can now refresh the index page you are on with the same keybind for refreshing threads.
|
||||
Added a keybind to open the catalog search field on index pages.
|
||||
|
||||
### 3.11.5 - *2013-10-03*
|
||||
|
||||
@ -248,3 +248,27 @@ Build =
|
||||
quote.href = "/#{boardID}/res/#{href}" # Fix pathnames
|
||||
|
||||
container
|
||||
|
||||
thread: (board, data) ->
|
||||
root = $.el 'div',
|
||||
className: 'thread'
|
||||
id: "t#{data.no}"
|
||||
|
||||
for obj in [data].concat data.last_replies or []
|
||||
$.add root, if post = g.posts["#{board}.#{obj.no}"]
|
||||
post.nodes.root
|
||||
else
|
||||
Build.postFromObject obj, board.ID
|
||||
|
||||
# build if necessary
|
||||
if data.omitted_posts
|
||||
{omitted_posts, omitted_images} = data
|
||||
html = []
|
||||
html.push "#{omitted_posts} post#{if omitted_posts > 1 then 's' else ''}"
|
||||
html.push "and #{omitted_images} image repl#{if omitted_images > 1 then 'ies' else 'y'}" if omitted_images
|
||||
html.push "omitted. Click <a href=/#{board}/res/#{data.no} class=replylink>here</a> to view."
|
||||
$.after root.firstChild, $.el 'span',
|
||||
className: 'summary'
|
||||
innerHTML: html.join ' '
|
||||
|
||||
root
|
||||
|
||||
@ -185,7 +185,7 @@ Main =
|
||||
unless errors
|
||||
errors = []
|
||||
errors.push
|
||||
message: "Parsing of Post No.#{postRoot.id.match(/\d+/)} failed. Post will be skipped."
|
||||
message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped."
|
||||
error: err
|
||||
Main.handleErrors errors if errors
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ Index =
|
||||
return if g.VIEW isnt 'index'
|
||||
|
||||
update: ->
|
||||
# return unless navigator.onLine
|
||||
return unless navigator.onLine
|
||||
Index.req?.abort()
|
||||
Index.notice?.close()
|
||||
Index.notice = new Notice 'info', 'Refreshing index...'
|
||||
@ -23,8 +23,9 @@ Index =
|
||||
return
|
||||
|
||||
try
|
||||
Index.parse JSON.parse req.response
|
||||
catch e
|
||||
Index.parse JSON.parse req.response if req.status is 200
|
||||
catch err
|
||||
c.error err.stack
|
||||
# network error or non-JSON content for example.
|
||||
notice.setType 'error'
|
||||
notice.el.lastElementChild.textContent = 'Index refresh failed.'
|
||||
@ -38,4 +39,33 @@ Index =
|
||||
Header.scrollTo $.id 'delform'
|
||||
parse: (pages) ->
|
||||
pageNum = +window.location.pathname.split('/')[2]
|
||||
threads = pages[pageNum].threads
|
||||
dataThr = pages[pageNum].threads
|
||||
|
||||
nodes = []
|
||||
threads = []
|
||||
posts = []
|
||||
for data in dataThr
|
||||
threadRoot = Build.thread g.BOARD, data
|
||||
nodes.push threadRoot, $.el 'hr'
|
||||
unless thread = g.threads["#{g.BOARD}.#{data.no}"]
|
||||
thread = new Thread data.no, g.BOARD
|
||||
threads.push thread
|
||||
for postRoot in $$ '.thread > .postContainer', threadRoot
|
||||
continue if thread.posts[postRoot.id.match /\d+/]
|
||||
try
|
||||
posts.push new Post postRoot, thread, g.BOARD
|
||||
catch err
|
||||
# Skip posts that we failed to parse.
|
||||
unless errors
|
||||
errors = []
|
||||
errors.push
|
||||
message: "Parsing of Post No.#{postRoot.id.match /\d+/} failed. Post will be skipped."
|
||||
error: err
|
||||
Main.handleErrors errors if errors
|
||||
|
||||
Main.callbackNodes Thread, threads
|
||||
Main.callbackNodes Post, posts
|
||||
|
||||
board = $ '.board'
|
||||
$.rmAll board
|
||||
$.add board, nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user