Pages start at 1 now.

This commit is contained in:
Mayhem 2014-04-29 15:12:42 +02:00
parent 60a668f7da
commit ad8610b522
2 changed files with 18 additions and 18 deletions

View File

@ -173,7 +173,7 @@ Build =
'' ''
if isOP and g.VIEW is 'index' if isOP and g.VIEW is 'index'
pageNum = Index.liveThreadIDs.indexOf(postID) // Index.threadsNumPerPage pageNum = Index.liveThreadIDs.indexOf(postID) // Index.threadsNumPerPage + 1
pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>Page #{pageNum}</span>" pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>Page #{pageNum}</span>"
replyLink = " &nbsp; <span>[<a href='/#{boardID}/thread/#{threadID}' class=replylink>Reply</a>]</span>" replyLink = " &nbsp; <span>[<a href='/#{boardID}/thread/#{threadID}' class=replylink>Reply</a>]</span>"
else else
@ -263,7 +263,7 @@ Build =
postCount = data.replies + 1 postCount = data.replies + 1
fileCount = data.images + !!data.ext fileCount = data.images + !!data.ext
pageCount = Index.liveThreadIDs.indexOf(thread.ID) // Index.threadsNumPerPage pageCount = Index.liveThreadIDs.indexOf(thread.ID) // Index.threadsNumPerPage + 1
subject = if thread.OP.info.subject subject = if thread.OP.info.subject
"<div class='subject'>#{thread.OP.info.subject}</div>" "<div class='subject'>#{thread.OP.info.subject}</div>"

View File

@ -227,8 +227,8 @@ Index =
else else
'Show' 'Show'
Index.sort() Index.sort()
if Conf['Index Mode'] is 'paged' and Index.getCurrentPage() > 0 if Conf['Index Mode'] is 'paged' and Index.getCurrentPage() > 1
Index.pageNav 0 Index.pageNav 1
else else
Index.buildIndex() Index.buildIndex()
mode: (e) -> mode: (e) ->
@ -287,7 +287,7 @@ Index =
return return
e.preventDefault() e.preventDefault()
return if Index.cb.indexNav a, true return if Index.cb.indexNav a, true
Index.userPageNav +a.pathname.split('/')[2] Index.userPageNav +a.pathname.split('/')[2] or 1
headerNav: (e) -> headerNav: (e) ->
a = e.target a = e.target
return if e.button isnt 0 or a.nodeName isnt 'A' or a.hostname isnt 'boards.4chan.org' return if e.button isnt 0 or a.nodeName isnt 'A' or a.hostname isnt 'boards.4chan.org'
@ -323,7 +323,7 @@ Index =
Header.scrollToIfNeeded Index.navLinks Header.scrollToIfNeeded Index.navLinks
getCurrentPage: -> getCurrentPage: ->
+window.location.pathname.split('/')[2] +window.location.pathname.split('/')[2] or 1
userPageNav: (pageNum) -> userPageNav: (pageNum) ->
if Conf['Refreshed Navigation'] and Conf['Index Mode'] is 'paged' if Conf['Refreshed Navigation'] and Conf['Index Mode'] is 'paged'
Index.update pageNum Index.update pageNum
@ -331,7 +331,7 @@ Index =
Index.pageNav pageNum Index.pageNav pageNum
pageNav: (pageNum) -> pageNav: (pageNum) ->
return if Index.currentPage is 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 Index.pageLoad pageNum
pageLoad: (pageNum) -> pageLoad: (pageNum) ->
Index.currentPage = pageNum Index.currentPage = pageNum
@ -347,18 +347,18 @@ Index =
getPagesNum: -> getPagesNum: ->
Math.ceil Index.sortedThreads.length / Index.getThreadsNumPerPage() Math.ceil Index.sortedThreads.length / Index.getThreadsNumPerPage()
getMaxPageNum: -> getMaxPageNum: ->
Math.max 0, Index.getPagesNum() - 1 Math.max 1, Index.getPagesNum()
togglePagelist: -> togglePagelist: ->
Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged' Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged'
buildPagelist: -> buildPagelist: ->
pagesRoot = $ '.pages', Index.pagelist pagesRoot = $ '.pages', Index.pagelist
maxPageNum = Index.getMaxPageNum() maxPageNum = Index.getMaxPageNum()
if pagesRoot.childElementCount isnt maxPageNum + 1 if pagesRoot.childElementCount isnt maxPageNum
nodes = [] nodes = []
for i in [0..maxPageNum] by 1 for i in [1..maxPageNum] by 1
a = $.el 'a', a = $.el 'a',
textContent: i textContent: i
href: if i then i else './' href: if i is 1 then './' else i
nodes.push $.tn('['), a, $.tn '] ' nodes.push $.tn('['), a, $.tn '] '
$.rmAll pagesRoot $.rmAll pagesRoot
$.add pagesRoot, nodes $.add pagesRoot, nodes
@ -370,11 +370,11 @@ Index =
# Previous/Next buttons # Previous/Next buttons
prev = pagesRoot.previousSibling.firstChild prev = pagesRoot.previousSibling.firstChild
next = pagesRoot.nextSibling.firstChild next = pagesRoot.nextSibling.firstChild
href = Math.max pageNum - 1, 0 href = Math.max pageNum - 1, 1
prev.href = if href is 0 then './' else href prev.href = if href is 1 then './' else href
prev.firstChild.disabled = href is pageNum prev.firstChild.disabled = href is pageNum
href = Math.min pageNum + 1, maxPageNum 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 next.firstChild.disabled = href is pageNum
# <strong> current page # <strong> current page
if strong = $ 'strong', pagesRoot if strong = $ 'strong', pagesRoot
@ -382,7 +382,7 @@ Index =
$.replace strong, strong.firstChild $.replace strong, strong.firstChild
else else
strong = $.el 'strong' strong = $.el 'strong'
a = pagesRoot.children[pageNum] a = pagesRoot.children[pageNum - 1]
$.before a, strong $.before a, strong
$.add strong, a $.add strong, a
@ -493,7 +493,7 @@ Index =
for threadData, i in Index.liveThreadData for threadData, i in Index.liveThreadData
threadRoot = Build.thread g.BOARD, threadData threadRoot = Build.thread g.BOARD, threadData
if thread = g.BOARD.threads[threadData.no] if thread = g.BOARD.threads[threadData.no]
thread.setPage i // Index.threadsNumPerPage thread.setPage i // Index.threadsNumPerPage + 1
thread.setCount 'post', threadData.replies + 1, threadData.bumplimit thread.setCount 'post', threadData.replies + 1, threadData.bumplimit
thread.setCount 'file', threadData.images + !!threadData.ext, threadData.imagelimit thread.setCount 'file', threadData.images + !!threadData.ext, threadData.imagelimit
thread.setStatus 'Sticky', !!threadData.sticky thread.setStatus 'Sticky', !!threadData.sticky
@ -600,7 +600,7 @@ Index =
Index.pageNav Index.getMaxPageNum() Index.pageNav Index.getMaxPageNum()
return return
threadsPerPage = Index.getThreadsNumPerPage() threadsPerPage = Index.getThreadsNumPerPage()
threads = Index.sortedThreads[threadsPerPage * pageNum ... threadsPerPage * (pageNum + 1)] threads = Index.sortedThreads[threadsPerPage * (pageNum - 1) ... threadsPerPage * pageNum]
nodes = threads.map (thread) -> thread.OP.nodes.root.parentNode nodes = threads.map (thread) -> thread.OP.nodes.root.parentNode
Index.buildReplies threads Index.buildReplies threads
Index.buildHRs nodes Index.buildHRs nodes
@ -627,7 +627,7 @@ Index =
unless Index.searchInput.dataset.searching unless Index.searchInput.dataset.searching
Index.searchInput.dataset.searching = 1 Index.searchInput.dataset.searching = 1
Index.pageBeforeSearch = Index.getCurrentPage() Index.pageBeforeSearch = Index.getCurrentPage()
pageNum = 0 pageNum = 1
else else
pageNum = Index.getCurrentPage() pageNum = Index.getCurrentPage()
else else