update page numbering in Index.coffee
This commit is contained in:
parent
8a5cd7a610
commit
b6e5d206f1
@ -117,7 +117,7 @@ Index =
|
||||
Index.pageNum = Index.getCurrentPage() unless Index.pageNum? # Avoid having to pushState to keep track of the current page
|
||||
|
||||
pageNum = Index.pageNum++
|
||||
return Index.endNotice() if pageNum >= Index.pagesNum
|
||||
return Index.endNotice() if pageNum > Index.pagesNum
|
||||
|
||||
nodes = Index.buildSinglePage pageNum
|
||||
Index.buildReplies nodes if Conf['Show Replies']
|
||||
@ -161,7 +161,7 @@ Index =
|
||||
Header.scrollToIfNeeded Index.root
|
||||
|
||||
getCurrentPage: ->
|
||||
+window.location.pathname.split('/')[2]
|
||||
+window.location.pathname.split('/')[2] or 1
|
||||
userPageNav: (pageNum) ->
|
||||
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
|
||||
Index.update pageNum
|
||||
@ -169,7 +169,7 @@ Index =
|
||||
Index.pageNav pageNum
|
||||
pageNav: (pageNum) ->
|
||||
return if Index.currentPage is pageNum
|
||||
history.pushState null, '', if pageNum is 0 then './' else pageNum
|
||||
history.pushState null, '', if pageNum is 1 then './' else pageNum
|
||||
Index.pageLoad pageNum
|
||||
pageLoad: (pageNum) ->
|
||||
Index.currentPage = pageNum
|
||||
@ -184,15 +184,15 @@ Index =
|
||||
else
|
||||
Index.pagesNum
|
||||
getMaxPageNum: ->
|
||||
Math.max 0, Index.getPagesNum() - 1
|
||||
Math.max 1, Index.getPagesNum()
|
||||
togglePagelist: ->
|
||||
Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged'
|
||||
buildPagelist: ->
|
||||
pagesRoot = $ '.pages', Index.pagelist
|
||||
maxPageNum = Index.getMaxPageNum()
|
||||
if pagesRoot.childElementCount isnt maxPageNum + 1
|
||||
if pagesRoot.childElementCount isnt maxPageNum
|
||||
nodes = []
|
||||
for i in [0..maxPageNum] by 1
|
||||
for i in [1..maxPageNum] by 1
|
||||
a = $.el 'a',
|
||||
textContent: i
|
||||
href: if i then i else './'
|
||||
@ -207,11 +207,11 @@ Index =
|
||||
# Previous/Next buttons
|
||||
prev = pagesRoot.previousSibling.firstChild
|
||||
next = pagesRoot.nextSibling.firstChild
|
||||
href = Math.max pageNum - 1, 0
|
||||
prev.href = if href is 0 then './' else href
|
||||
href = Math.max pageNum - 1, 1
|
||||
prev.href = if href is 1 then './' else href
|
||||
prev.firstChild.disabled = href is pageNum
|
||||
href = Math.min pageNum + 1, maxPageNum
|
||||
next.href = if href is 0 then './' else href
|
||||
next.href = if href is 1 then './' else href
|
||||
next.firstChild.disabled = href is pageNum
|
||||
# <strong> current page
|
||||
if strong = $ 'strong', pagesRoot
|
||||
@ -442,7 +442,7 @@ Index =
|
||||
buildSinglePage: (pageNum) ->
|
||||
nodes = []
|
||||
nodesPerPage = Index.threadsNumPerPage
|
||||
offset = nodesPerPage * pageNum
|
||||
offset = nodesPerPage * (pageNum - 1)
|
||||
end = offset + nodesPerPage
|
||||
target = Index.sortedNodes.order()[offset]
|
||||
Index.sortedNodes
|
||||
@ -471,7 +471,7 @@ Index =
|
||||
unless Index.searchInput.dataset.searching
|
||||
Index.searchInput.dataset.searching = 1
|
||||
Index.pageBeforeSearch = Index.getCurrentPage()
|
||||
pageNum = 0
|
||||
pageNum = 1
|
||||
else
|
||||
pageNum = Index.getCurrentPage()
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user