Merge branch 'page1'

This commit is contained in:
ccd0 2014-04-19 15:28:56 -07:00
commit ec03ab524d
6 changed files with 20 additions and 20 deletions

View File

@ -182,7 +182,7 @@ Build =
''
if isOP and g.VIEW is 'index' and Conf['JSON Navigation']
pageNum = Math.floor Index.liveThreadIDs.indexOf(postID) / Index.threadsNumPerPage
pageNum = Math.floor Index.liveThreadIDs.indexOf(postID) / Index.threadsNumPerPage + 1
pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>[#{pageNum}]</span>"
else
pageIcon = ''

View File

@ -671,11 +671,11 @@ vp-replace
]
# Board Navigation
'Front page': [
'0'
'1'
'Jump to front page.'
]
'Open front page': [
'Shift+0'
'Shift+1'
'Open front page in a new tab.'
]
'Next page': [

View File

@ -118,7 +118,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']
@ -162,9 +162,9 @@ Index =
Header.scrollToIfNeeded Index.root
getCurrentPage: ->
+window.location.pathname.split('/')[2]
+window.location.pathname.split('/')[2] or 1
userPageNav: (pageNum) ->
Navigate.pushState if pageNum is 0 then './' else pageNum
Navigate.pushState if pageNum is 1 then './' else pageNum
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
Index.update pageNum
else
@ -183,18 +183,18 @@ 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 './'
href: if i is 1 then './' else i
nodes.push $.tn('['), a, $.tn '] '
$.rmAll pagesRoot
$.add pagesRoot, nodes
@ -206,11 +206,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
@ -218,7 +218,7 @@ Index =
$.replace strong, strong.firstChild
else
strong = $.el 'strong'
a = pagesRoot.children[pageNum]
a = pagesRoot.children[pageNum - 1]
$.before a, strong
$.add strong, a
@ -441,7 +441,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
@ -470,7 +470,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
@ -491,7 +491,7 @@ Index =
Index.buildIndex()
Index.setPage()
else
Navigate.pushState if pageNum is 0 then './' else pageNum
Navigate.pushState if pageNum is 1 then './' else pageNum
Index.pageLoad pageNum
querySearch: (query) ->

View File

@ -198,7 +198,7 @@ Navigate =
if threadID
view = 'thread'
else
pageNum = +view
pageNum = +view or 1 # string to number, '' to 1
view = 'index' # path is "/boardID/". See the problem?
if view is g.VIEW and boardID is g.BOARD.ID

View File

@ -87,7 +87,7 @@ Keybinds =
# Board Navigation
when Conf['Front page']
if Conf['JSON Navigation'] and g.VIEW is 'index'
Index.userPageNav 0
Index.userPageNav 1
else
window.location = "/#{g.BOARD}/"
when Conf['Open front page']

View File

@ -81,5 +81,5 @@ ThreadStats =
for page in @response
for thread in page.threads when thread.no is ThreadStats.thread.ID
ThreadStats.pageCountEl.textContent = page.page
(if page.page is @response.length - 1 then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning'
(if page.page is @response.length then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning'
return