diff --git a/CHANGELOG.md b/CHANGELOG.md index c18d1a7b1..1b3adb662 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### v1.7.8 +*2014-04-12* + +**ccd0** +- Some keybind bugfixes. +- Begin work toward compatibility with new URLs. + ### v1.7.7 *2014-04-10* diff --git a/LICENSE b/LICENSE index 7304b63a0..fbcf8ad8b 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.7.7 - 2014-04-10 +* 4chan X - Version 1.7.8 - 2014-04-12 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index 70021551c..fc3598040 100755 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.7.7 +// @version 1.7.8 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 9883832af..e6ba2cb3f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.7.7 +// @version 1.7.8 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.7.7 - 2014-04-10 +* 4chan X - Version 1.7.8 - 2014-04-12 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -333,8 +333,8 @@ 'Open Gallery': ['g', 'Opens the gallery.'], 'fappeTyme': ['f', 'Fappe Tyme.'], 'werkTyme': ['Shift+w', 'Werk Tyme'], - 'Front page': ['0', 'Jump to page 0.'], - 'Open front page': ['Shift+0', 'Open page 0 in a new tab.'], + 'Front page': ['0', 'Jump to front page.'], + 'Open front page': ['Shift+0', 'Open front page in a new tab.'], 'Next page': ['Shift+Right', 'Jump to the next page.'], 'Previous page': ['Shift+Left', 'Jump to the previous page.'], 'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'], @@ -376,7 +376,7 @@ doc = d.documentElement; g = { - VERSION: '1.7.7', + VERSION: '1.7.8', NAMESPACE: '4chan X.', boards: {} }; @@ -3098,6 +3098,7 @@ return +window.location.pathname.split('/')[2]; }, userPageNav: function(pageNum) { + Navigate.pushState(pageNum === 0 ? './' : pageNum); if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') { return Index.update(pageNum); } else { @@ -3108,7 +3109,7 @@ if (Index.currentPage === pageNum && !Index.root.parentElement) { return; } - history.pushState(null, '', pageNum === 0 ? './' : pageNum); + Navigate.pushState(pageNum === 0 ? './' : pageNum); return Index.pageLoad(pageNum); }, pageLoad: function(pageNum) { @@ -11865,7 +11866,7 @@ return Conf[hotkey] = key; }, keydown: function(e) { - var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref; + var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref; if (!(key = Keybinds.keyCode(e))) { return; } @@ -11953,7 +11954,9 @@ ThreadUpdater.update(); break; case 'index': - Index.update(); + if (Conf['JSON Navigation']) { + Index.update(); + } } break; case Conf['Watch']: @@ -11979,7 +11982,7 @@ }); break; case Conf['Front page']: - if (g.VIEW === 'index') { + if (Conf['JSON Navigation'] && g.VIEW === 'index') { Index.userPageNav(0); } else { window.location = "/" + g.BOARD + "/"; @@ -11989,19 +11992,39 @@ $.open("/" + g.BOARD + "/"); break; case Conf['Next page']: - if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { + if (g.VIEW !== 'index') { return; } - $('.next button', Index.pagelist).click(); + if (Conf['JSON Navigation']) { + if (Conf['Index Mode'] !== 'all pages') { + $('.next button', Index.pagelist).click(); + } + } else { + if (form = $('.next form')) { + window.location = form.action; + } + } break; case Conf['Previous page']: - if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { + if (g.VIEW !== 'index') { return; } - $('.prev button', Index.pagelist).click(); + if (Conf['JSON Navigation']) { + if (Conf['Index Mode'] !== 'all pages') { + $('.prev button', Index.pagelist).click(); + } + } else { + if (form = $('.prev form')) { + window.location = form.action; + } + } break; case Conf['Search form']: - Index.searchInput.focus(); + if (Conf['JSON Navigation']) { + Index.searchInput.focus(); + } else { + $.id('search-btn').click(); + } break; case Conf['Paged mode']: if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) { @@ -12027,6 +12050,19 @@ } Index.cycleSortType(); break; + case Conf['Open catalog']: + if (Conf['External Catalog']) { + window.location = CatalogLinks.external(g.BOARD.ID); + } else { + if (!Conf['JSON Navigation']) { + return window.location = "/" + g.BOARD + "/catalog"; + } + if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'catalog')) { + return; + } + Index.setIndexMode('catalog'); + } + break; case Conf['Next thread']: if (g.VIEW !== 'index') { return; @@ -12801,7 +12837,7 @@ if (threadID) { view = 'thread'; } else { - pageNum = view; + pageNum = +view; view = 'index'; } path = this.pathname; @@ -12810,9 +12846,8 @@ } Navigate.makeBreadCrumb(this.href, view, boardID, threadID); if (this.id !== 'popState') { - history.pushState(null, '', path); + Navigate.pushState(path); } - Navigate.path = this.pathname; Navigate.setMode(this); if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) { Navigate.disconnect(); @@ -12936,6 +12971,10 @@ return Main.handleErrors(errors); } }, + pushState: function(path) { + history.pushState(null, '', path); + return Navigate.path = window.location.pathname; + }, popstate: function() { var a; a = $.el('a', { @@ -13542,6 +13581,7 @@ g.VIEW = (function() { switch (pathname[2]) { case 'res': + case 'thread': return 'thread'; case 'catalog': return 'catalog'; diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json index fd129e43f..edcd12791 100755 --- a/builds/crx/manifest.json +++ b/builds/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.7.7", + "version": "1.7.8", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/crx/script.js b/builds/crx/script.js index e55c05b00..1f0cdd71c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.7.7 - 2014-04-10 +* 4chan X - Version 1.7.8 - 2014-04-12 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -309,8 +309,8 @@ 'Open Gallery': ['g', 'Opens the gallery.'], 'fappeTyme': ['f', 'Fappe Tyme.'], 'werkTyme': ['Shift+w', 'Werk Tyme'], - 'Front page': ['0', 'Jump to page 0.'], - 'Open front page': ['Shift+0', 'Open page 0 in a new tab.'], + 'Front page': ['0', 'Jump to front page.'], + 'Open front page': ['Shift+0', 'Open front page in a new tab.'], 'Next page': ['Shift+Right', 'Jump to the next page.'], 'Previous page': ['Shift+Left', 'Jump to the previous page.'], 'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'], @@ -352,7 +352,7 @@ doc = d.documentElement; g = { - VERSION: '1.7.7', + VERSION: '1.7.8', NAMESPACE: '4chan X.', boards: {} }; @@ -3159,6 +3159,7 @@ return +window.location.pathname.split('/')[2]; }, userPageNav: function(pageNum) { + Navigate.pushState(pageNum === 0 ? './' : pageNum); if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') { return Index.update(pageNum); } else { @@ -3169,7 +3170,7 @@ if (Index.currentPage === pageNum && !Index.root.parentElement) { return; } - history.pushState(null, '', pageNum === 0 ? './' : pageNum); + Navigate.pushState(pageNum === 0 ? './' : pageNum); return Index.pageLoad(pageNum); }, pageLoad: function(pageNum) { @@ -11881,7 +11882,7 @@ return Conf[hotkey] = key; }, keydown: function(e) { - var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref; + var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref; if (!(key = Keybinds.keyCode(e))) { return; } @@ -11969,7 +11970,9 @@ ThreadUpdater.update(); break; case 'index': - Index.update(); + if (Conf['JSON Navigation']) { + Index.update(); + } } break; case Conf['Watch']: @@ -11995,7 +11998,7 @@ }); break; case Conf['Front page']: - if (g.VIEW === 'index') { + if (Conf['JSON Navigation'] && g.VIEW === 'index') { Index.userPageNav(0); } else { window.location = "/" + g.BOARD + "/"; @@ -12005,19 +12008,39 @@ $.open("/" + g.BOARD + "/"); break; case Conf['Next page']: - if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { + if (g.VIEW !== 'index') { return; } - $('.next button', Index.pagelist).click(); + if (Conf['JSON Navigation']) { + if (Conf['Index Mode'] !== 'all pages') { + $('.next button', Index.pagelist).click(); + } + } else { + if (form = $('.next form')) { + window.location = form.action; + } + } break; case Conf['Previous page']: - if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { + if (g.VIEW !== 'index') { return; } - $('.prev button', Index.pagelist).click(); + if (Conf['JSON Navigation']) { + if (Conf['Index Mode'] !== 'all pages') { + $('.prev button', Index.pagelist).click(); + } + } else { + if (form = $('.prev form')) { + window.location = form.action; + } + } break; case Conf['Search form']: - Index.searchInput.focus(); + if (Conf['JSON Navigation']) { + Index.searchInput.focus(); + } else { + $.id('search-btn').click(); + } break; case Conf['Paged mode']: if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) { @@ -12043,6 +12066,19 @@ } Index.cycleSortType(); break; + case Conf['Open catalog']: + if (Conf['External Catalog']) { + window.location = CatalogLinks.external(g.BOARD.ID); + } else { + if (!Conf['JSON Navigation']) { + return window.location = "/" + g.BOARD + "/catalog"; + } + if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'catalog')) { + return; + } + Index.setIndexMode('catalog'); + } + break; case Conf['Next thread']: if (g.VIEW !== 'index') { return; @@ -12822,7 +12858,7 @@ if (threadID) { view = 'thread'; } else { - pageNum = view; + pageNum = +view; view = 'index'; } path = this.pathname; @@ -12831,9 +12867,8 @@ } Navigate.makeBreadCrumb(this.href, view, boardID, threadID); if (this.id !== 'popState') { - history.pushState(null, '', path); + Navigate.pushState(path); } - Navigate.path = this.pathname; Navigate.setMode(this); if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) { Navigate.disconnect(); @@ -12957,6 +12992,10 @@ return Main.handleErrors(errors); } }, + pushState: function(path) { + history.pushState(null, '', path); + return Navigate.path = window.location.pathname; + }, popstate: function() { var a; a = $.el('a', { @@ -13561,6 +13600,7 @@ g.VIEW = (function() { switch (pathname[2]) { case 'res': + case 'thread': return 'thread'; case 'catalog': return 'catalog'; diff --git a/builds/updates.xml b/builds/updates.xml index 5c043194a..12f1e8175 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/package.json b/package.json index deb13111f..910303c02 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "1.7.7", + "version": "1.7.8", "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X", diff --git a/src/General/Config.coffee b/src/General/Config.coffee index f50e22732..064e73af1 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -672,11 +672,11 @@ vp-replace # Board Navigation 'Front page': [ '0' - 'Jump to page 0.' + 'Jump to front page.' ] 'Open front page': [ 'Shift+0' - 'Open page 0 in a new tab.' + 'Open front page in a new tab.' ] 'Next page': [ 'Shift+Right' diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 972b3de38..a0302d4db 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -404,6 +404,7 @@ Index = +window.location.pathname.split('/')[2] userPageNav: (pageNum) -> + Navigate.pushState if pageNum is 0 then './' else pageNum if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages' Index.update pageNum else @@ -411,7 +412,7 @@ Index = pageNav: (pageNum) -> return if Index.currentPage is pageNum and not Index.root.parentElement - history.pushState null, '', if pageNum is 0 then './' else pageNum + Navigate.pushState if pageNum is 0 then './' else pageNum Index.pageLoad pageNum pageLoad: (pageNum) -> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 2b8b8dc2a..a3b716244 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -8,7 +8,7 @@ Main = return if g.BOARD.ID in ['z', 'fk'] g.VIEW = switch pathname[2] - when 'res' + when 'res', 'thread' 'thread' when 'catalog' 'catalog' diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 0e368645c..403d11287 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -232,7 +232,7 @@ Navigate = if threadID view = 'thread' else - pageNum = view + pageNum = +view view = 'index' # path is "/boardID/". See the problem? path = @pathname @@ -240,8 +240,7 @@ Navigate = Navigate.makeBreadCrumb @href, view, boardID, threadID - history.pushState null, '', path unless @id is 'popState' - Navigate.path = @pathname + Navigate.pushState path unless @id is 'popState' Navigate.setMode @ @@ -353,6 +352,10 @@ Navigate = Main.handleErrors errors if errors + pushState: (path) -> + history.pushState null, '', path + Navigate.path = window.location.pathname + popstate: -> a = $.el 'a', href: window.location diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 53df9ba90..69a19b390 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -70,7 +70,7 @@ Keybinds = when 'thread' ThreadUpdater.update() when 'index' - Index.update() + if Conf['JSON Navigation'] then Index.update() when Conf['Watch'] ThreadWatcher.toggle thread # Images @@ -86,20 +86,33 @@ Keybinds = FappeTyme.cb.toggle.call {name: 'werk'} # Board Navigation when Conf['Front page'] - if g.VIEW is 'index' + if Conf['JSON Navigation'] and g.VIEW is 'index' Index.userPageNav 0 else window.location = "/#{g.BOARD}/" when Conf['Open front page'] $.open "/#{g.BOARD}/" when Conf['Next page'] - return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages' - $('.next button', Index.pagelist).click() + return unless g.VIEW is 'index' + if Conf['JSON Navigation'] + if Conf['Index Mode'] isnt 'all pages' + $('.next button', Index.pagelist).click() + else + if form = $ '.next form' + window.location = form.action when Conf['Previous page'] - return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages' - $('.prev button', Index.pagelist).click() + return unless g.VIEW is 'index' + if Conf['JSON Navigation'] + if Conf['Index Mode'] isnt 'all pages' + $('.prev button', Index.pagelist).click() + else + if form = $ '.prev form' + window.location = form.action when Conf['Search form'] - Index.searchInput.focus() + if Conf['JSON Navigation'] + Index.searchInput.focus() + else + $.id('search-btn').click() when Conf['Paged mode'] return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'paged' Index.setIndexMode 'paged' @@ -112,6 +125,13 @@ Keybinds = when Conf['Cycle sort type'] return unless g.VIEW is 'index' Index.cycleSortType() + when Conf['Open catalog'] + if Conf['External Catalog'] + window.location = CatalogLinks.external(g.BOARD.ID) + else + return window.location = "/#{g.BOARD}/catalog" unless Conf['JSON Navigation'] + return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'catalog' + Index.setIndexMode 'catalog' # Thread Navigation when Conf['Next thread'] return if g.VIEW isnt 'index'