From a0d3694b61f8ed5733ea0da406d7ef3e05711e99 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 2 Nov 2013 14:32:54 +0100 Subject: [PATCH] Fix minor bugs with keybinds/pageload + index. --- src/General/Index.coffee | 19 ++++++++++--------- src/Miscellaneous/Keybinds.coffee | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 13eb065ab..4b22276ae 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -50,7 +50,7 @@ Index = className: 'pagelist' hidden: true innerHTML: <%= importHTML('General/Index-pagelist') %> - Index.currentPage = +window.location.pathname.split('/')[2] + Index.currentPage = Index.getCurrentPage() $.on window, 'popstate', @cb.popstate $.on @pagelist, 'click', @cb.pageNav $.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), -> @@ -66,8 +66,8 @@ Index = Index.sort() Index.buildIndex() popstate: (e) -> - Index.currentPage = +window.location.pathname.split('/')[2] - Index.pageLoad() + pageNum = Index.getCurrentPage() + Index.pageLoad pageNum if Index.currentPage isnt pageNum pageNav: (e) -> return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 switch e.target.nodeName @@ -83,13 +83,14 @@ Index = scrollToIndex: -> Header.scrollTo Index.root if Index.root.getBoundingClientRect().top < 0 + getCurrentPage: -> + +window.location.pathname.split('/')[2] pageNav: (pageNum) -> return if Index.currentPage is pageNum history.pushState null, '', if pageNum is 0 then './' else pageNum + Index.pageLoad pageNum + pageLoad: (pageNum) -> Index.currentPage = pageNum - Index.pageLoad() - pageLoad: -> - return unless 'currentPage' of Index # unnecessary popstate on page load return if Conf['Index Mode'] isnt 'paged' Index.buildIndex() Index.setPage() @@ -111,7 +112,7 @@ Index = Index.setPage() Index.togglePagelist() setPage: -> - pageNum = +window.location.pathname.split('/')[2] + pageNum = Index.getCurrentPage() pagesRoot = $ '.pages', Index.pagelist # Previous/Next buttons prev = pagesRoot.previousSibling.firstChild @@ -246,9 +247,9 @@ Index = return buildIndex: -> if Conf['Index Mode'] is 'paged' - pageNum = +window.location.pathname.split('/')[2] + pageNum = Index.getCurrentPage() nodesPerPage = Index.threadsNumPerPage * 2 - nodes = Index.sortedNodes.slice nodesPerPage * pageNum, nodesPerPage * (pageNum + 1) + nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)] else nodes = Index.sortedNodes $.event 'IndexRefresh' diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 7ad88b273..d59d771e7 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -82,10 +82,10 @@ Keybinds = $.open "/#{g.BOARD}/" when Conf['Next page'] return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged' - $('.next a', Index.pagelist).click() + $('.next button', Index.pagelist).click() when Conf['Previous page'] return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged' - $('.prev a', Index.pagelist).click() + $('.prev button', Index.pagelist).click() when Conf['Search form'] $.id('search-btn').click() # Thread Navigation