Index.buildSinglePage returning nodes -> Index.threadsOnPage returning threads
This commit is contained in:
parent
cfaa2a86b3
commit
696d3c37c3
@ -145,9 +145,9 @@ Index =
|
|||||||
pageNum = ++Index.pageNum
|
pageNum = ++Index.pageNum
|
||||||
return Index.endNotice() if pageNum > Index.pagesNum
|
return Index.endNotice() if pageNum > Index.pagesNum
|
||||||
|
|
||||||
nodes = Index.buildSinglePage pageNum
|
threads = Index.threadsOnPage pageNum
|
||||||
Index.buildReplies nodes if Conf['Show Replies']
|
Index.buildReplies threads if Conf['Show Replies']
|
||||||
Index.buildStructure nodes
|
Index.buildStructure threads
|
||||||
|
|
||||||
endNotice: do ->
|
endNotice: do ->
|
||||||
notify = false
|
notify = false
|
||||||
@ -602,10 +602,9 @@ Index =
|
|||||||
Index.updateHideLabel()
|
Index.updateHideLabel()
|
||||||
$.event 'IndexRefresh'
|
$.event 'IndexRefresh'
|
||||||
|
|
||||||
buildReplies: (threadRoots) ->
|
buildReplies: (threads) ->
|
||||||
posts = []
|
posts = []
|
||||||
for threadRoot in threadRoots
|
for thread in threads
|
||||||
thread = Get.threadFromRoot threadRoot
|
|
||||||
i = Index.liveThreadIDs.indexOf thread.ID
|
i = Index.liveThreadIDs.indexOf thread.ID
|
||||||
continue unless lastReplies = Index.liveThreadData[i].last_replies
|
continue unless lastReplies = Index.liveThreadData[i].last_replies
|
||||||
nodes = []
|
nodes = []
|
||||||
@ -622,7 +621,7 @@ Index =
|
|||||||
errors.push
|
errors.push
|
||||||
message: "Parsing of Post No.#{data.no} failed. Post will be skipped."
|
message: "Parsing of Post No.#{data.no} failed. Post will be skipped."
|
||||||
error: err
|
error: err
|
||||||
$.add threadRoot, nodes
|
$.add Index.nodes[thread.ID], nodes
|
||||||
|
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
Main.callbackNodes 'Post', posts
|
Main.callbackNodes 'Post', posts
|
||||||
@ -689,11 +688,8 @@ Index =
|
|||||||
buildIndex: ->
|
buildIndex: ->
|
||||||
return unless Index.liveThreadData
|
return unless Index.liveThreadData
|
||||||
switch Conf['Index Mode']
|
switch Conf['Index Mode']
|
||||||
when 'all pages'
|
when 'all pages', 'catalog'
|
||||||
nodes = Index.sortedThreads.map (thread) -> Index.nodes[thread.ID]
|
threads = Index.sortedThreads
|
||||||
when 'catalog'
|
|
||||||
nodes = Index.buildCatalogViews()
|
|
||||||
Index.sizeCatalogViews nodes
|
|
||||||
else
|
else
|
||||||
if Index.followedThreadID?
|
if Index.followedThreadID?
|
||||||
i = 0
|
i = 0
|
||||||
@ -703,24 +699,27 @@ Index =
|
|||||||
Index.currentPage = page
|
Index.currentPage = page
|
||||||
Index.pushState {page}
|
Index.pushState {page}
|
||||||
Index.setPage()
|
Index.setPage()
|
||||||
nodes = Index.buildSinglePage Index.currentPage
|
threads = Index.threadsOnPage Index.currentPage
|
||||||
delete Index.pageNum
|
delete Index.pageNum
|
||||||
$.rmAll Index.root
|
$.rmAll Index.root
|
||||||
$.rmAll Header.hover
|
$.rmAll Header.hover
|
||||||
if Conf['Index Mode'] is 'catalog'
|
if Conf['Index Mode'] is 'catalog'
|
||||||
|
nodes = Index.buildCatalogViews()
|
||||||
|
Index.sizeCatalogViews nodes
|
||||||
$.add Index.root, nodes
|
$.add Index.root, nodes
|
||||||
else
|
else
|
||||||
Index.buildReplies nodes if Conf['Show Replies']
|
Index.buildReplies threads if Conf['Show Replies']
|
||||||
Index.buildStructure nodes
|
Index.buildStructure threads
|
||||||
if Index.followedThreadID? and (post = g.posts["#{g.BOARD}.#{Index.followedThreadID}"])
|
if Index.followedThreadID? and (post = g.posts["#{g.BOARD}.#{Index.followedThreadID}"])
|
||||||
Header.scrollTo post.nodes.root
|
Header.scrollTo post.nodes.root
|
||||||
|
|
||||||
buildSinglePage: (pageNum) ->
|
threadsOnPage: (pageNum) ->
|
||||||
nodesPerPage = Index.threadsNumPerPage
|
nodesPerPage = Index.threadsNumPerPage
|
||||||
offset = nodesPerPage * (pageNum - 1)
|
offset = nodesPerPage * (pageNum - 1)
|
||||||
Index.sortedThreads[offset ... offset + nodesPerPage].map (thread) -> Index.nodes[thread.ID]
|
Index.sortedThreads[offset ... offset + nodesPerPage]
|
||||||
|
|
||||||
buildStructure: (nodes) ->
|
buildStructure: (threads) ->
|
||||||
|
nodes = threads.map (thread) -> Index.nodes[thread.ID]
|
||||||
for node in nodes
|
for node in nodes
|
||||||
if thumb = $ 'img[data-src]', node
|
if thumb = $ 'img[data-src]', node
|
||||||
thumb.src = thumb.dataset.src
|
thumb.src = thumb.dataset.src
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user