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'] 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>" pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>[#{pageNum}]</span>"
else else
pageIcon = '' pageIcon = ''

View File

@ -671,11 +671,11 @@ vp-replace
] ]
# Board Navigation # Board Navigation
'Front page': [ 'Front page': [
'0' '1'
'Jump to front page.' 'Jump to front page.'
] ]
'Open front page': [ 'Open front page': [
'Shift+0' 'Shift+1'
'Open front page in a new tab.' 'Open front page in a new tab.'
] ]
'Next page': [ '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 Index.pageNum = Index.getCurrentPage() unless Index.pageNum? # Avoid having to pushState to keep track of the current page
pageNum = Index.pageNum++ pageNum = Index.pageNum++
return Index.endNotice() if pageNum >= Index.pagesNum return Index.endNotice() if pageNum > Index.pagesNum
nodes = Index.buildSinglePage pageNum nodes = Index.buildSinglePage pageNum
Index.buildReplies nodes if Conf['Show Replies'] Index.buildReplies nodes if Conf['Show Replies']
@ -162,9 +162,9 @@ Index =
Header.scrollToIfNeeded Index.root Header.scrollToIfNeeded Index.root
getCurrentPage: -> getCurrentPage: ->
+window.location.pathname.split('/')[2] +window.location.pathname.split('/')[2] or 1
userPageNav: (pageNum) -> 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' if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
Index.update pageNum Index.update pageNum
else else
@ -183,18 +183,18 @@ Index =
else else
Index.pagesNum Index.pagesNum
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
@ -206,11 +206,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
@ -218,7 +218,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
@ -441,7 +441,7 @@ Index =
buildSinglePage: (pageNum) -> buildSinglePage: (pageNum) ->
nodes = [] nodes = []
nodesPerPage = Index.threadsNumPerPage nodesPerPage = Index.threadsNumPerPage
offset = nodesPerPage * pageNum offset = nodesPerPage * (pageNum - 1)
end = offset + nodesPerPage end = offset + nodesPerPage
target = Index.sortedNodes.order()[offset] target = Index.sortedNodes.order()[offset]
Index.sortedNodes Index.sortedNodes
@ -470,7 +470,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
@ -491,7 +491,7 @@ Index =
Index.buildIndex() Index.buildIndex()
Index.setPage() Index.setPage()
else else
Navigate.pushState if pageNum is 0 then './' else pageNum Navigate.pushState if pageNum is 1 then './' else pageNum
Index.pageLoad pageNum Index.pageLoad pageNum
querySearch: (query) -> querySearch: (query) ->

View File

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

View File

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

View File

@ -81,5 +81,5 @@ ThreadStats =
for page in @response for page in @response
for thread in page.threads when thread.no is ThreadStats.thread.ID for thread in page.threads when thread.no is ThreadStats.thread.ID
ThreadStats.pageCountEl.textContent = page.page 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 return