From b6e5d206f189191c6634280ae8f917fa0f10f4f2 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 12 Apr 2014 12:02:28 -0700 Subject: [PATCH 1/3] update page numbering in Index.coffee --- src/General/Index.coffee | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 1fc908b24..d5ae97147 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -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 # 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 From 1182047357e86bd5735b6a0f1d58f5a9d69144e1 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 12 Apr 2014 18:41:05 -0700 Subject: [PATCH 2/3] more indexing changes --- src/General/Build.coffee | 2 +- src/General/Config.coffee | 4 ++-- src/General/Navigate.coffee | 2 +- src/Miscellaneous/Keybinds.coffee | 2 +- src/Monitoring/ThreadStats.coffee | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index b8684853f..946ca1f3d 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -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 = " [#{pageNum}]" else pageIcon = '' diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 828ab1469..9ce66a610 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -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': [ diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 32a5f9c0e..f2a82915c 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -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 diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index b58de0e55..aaa0e8582 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -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'] diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee index ad3d869d1..185f87fb3 100755 --- a/src/Monitoring/ThreadStats.coffee +++ b/src/Monitoring/ThreadStats.coffee @@ -80,5 +80,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' - return \ No newline at end of file + (if page.page is @response.length then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning' + return From 1d29f6445146784678147340b04ea5f0e0683562 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 12 Apr 2014 18:52:37 -0700 Subject: [PATCH 3/3] indexing bugfixes --- src/General/Index.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 71d9f6649..8ff43aa63 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -195,7 +195,7 @@ Index = 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 @@ -219,7 +219,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