Merge branch 'ccd0' into v3

Conflicts:
	builds/crx.crx
	src/General/Index.coffee
	src/Miscellaneous/Keybinds.coffee
This commit is contained in:
Zixaphir 2014-04-12 18:02:25 -07:00
commit 4b3f4d1baf
13 changed files with 163 additions and 52 deletions

View File

@ -1,3 +1,10 @@
### v1.7.8
*2014-04-12*
**ccd0**
- Some keybind bugfixes.
- Begin work toward compatibility with new URLs.
### v1.7.7 ### v1.7.7
*2014-04-10* *2014-04-10*

View File

@ -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. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.7.7 // @version 1.7.8
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.7.7 // @version 1.7.8
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -24,7 +24,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.7.7 - 2014-04-10 * 4chan X - Version 1.7.8 - 2014-04-12
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -333,8 +333,8 @@
'Open Gallery': ['g', 'Opens the gallery.'], 'Open Gallery': ['g', 'Opens the gallery.'],
'fappeTyme': ['f', 'Fappe Tyme.'], 'fappeTyme': ['f', 'Fappe Tyme.'],
'werkTyme': ['Shift+w', 'Werk Tyme'], 'werkTyme': ['Shift+w', 'Werk Tyme'],
'Front page': ['0', 'Jump to page 0.'], 'Front page': ['0', 'Jump to front page.'],
'Open front page': ['Shift+0', 'Open page 0 in a new tab.'], 'Open front page': ['Shift+0', 'Open front page in a new tab.'],
'Next page': ['Shift+Right', 'Jump to the next page.'], 'Next page': ['Shift+Right', 'Jump to the next page.'],
'Previous page': ['Shift+Left', 'Jump to the previous page.'], 'Previous page': ['Shift+Left', 'Jump to the previous page.'],
'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'], 'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'],
@ -376,7 +376,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.7.7', VERSION: '1.7.8',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -3098,6 +3098,7 @@
return +window.location.pathname.split('/')[2]; return +window.location.pathname.split('/')[2];
}, },
userPageNav: function(pageNum) { userPageNav: function(pageNum) {
Navigate.pushState(pageNum === 0 ? './' : pageNum);
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') { if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') {
return Index.update(pageNum); return Index.update(pageNum);
} else { } else {
@ -3108,7 +3109,7 @@
if (Index.currentPage === pageNum && !Index.root.parentElement) { if (Index.currentPage === pageNum && !Index.root.parentElement) {
return; return;
} }
history.pushState(null, '', pageNum === 0 ? './' : pageNum); Navigate.pushState(pageNum === 0 ? './' : pageNum);
return Index.pageLoad(pageNum); return Index.pageLoad(pageNum);
}, },
pageLoad: function(pageNum) { pageLoad: function(pageNum) {
@ -11865,7 +11866,7 @@
return Conf[hotkey] = key; return Conf[hotkey] = key;
}, },
keydown: function(e) { 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))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -11953,7 +11954,9 @@
ThreadUpdater.update(); ThreadUpdater.update();
break; break;
case 'index': case 'index':
Index.update(); if (Conf['JSON Navigation']) {
Index.update();
}
} }
break; break;
case Conf['Watch']: case Conf['Watch']:
@ -11979,7 +11982,7 @@
}); });
break; break;
case Conf['Front page']: case Conf['Front page']:
if (g.VIEW === 'index') { if (Conf['JSON Navigation'] && g.VIEW === 'index') {
Index.userPageNav(0); Index.userPageNav(0);
} else { } else {
window.location = "/" + g.BOARD + "/"; window.location = "/" + g.BOARD + "/";
@ -11989,19 +11992,39 @@
$.open("/" + g.BOARD + "/"); $.open("/" + g.BOARD + "/");
break; break;
case Conf['Next page']: case Conf['Next page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { if (g.VIEW !== 'index') {
return; 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; break;
case Conf['Previous page']: case Conf['Previous page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { if (g.VIEW !== 'index') {
return; 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; break;
case Conf['Search form']: case Conf['Search form']:
Index.searchInput.focus(); if (Conf['JSON Navigation']) {
Index.searchInput.focus();
} else {
$.id('search-btn').click();
}
break; break;
case Conf['Paged mode']: case Conf['Paged mode']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) { if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) {
@ -12027,6 +12050,19 @@
} }
Index.cycleSortType(); Index.cycleSortType();
break; 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']: case Conf['Next thread']:
if (g.VIEW !== 'index') { if (g.VIEW !== 'index') {
return; return;
@ -12801,7 +12837,7 @@
if (threadID) { if (threadID) {
view = 'thread'; view = 'thread';
} else { } else {
pageNum = view; pageNum = +view;
view = 'index'; view = 'index';
} }
path = this.pathname; path = this.pathname;
@ -12810,9 +12846,8 @@
} }
Navigate.makeBreadCrumb(this.href, view, boardID, threadID); Navigate.makeBreadCrumb(this.href, view, boardID, threadID);
if (this.id !== 'popState') { if (this.id !== 'popState') {
history.pushState(null, '', path); Navigate.pushState(path);
} }
Navigate.path = this.pathname;
Navigate.setMode(this); Navigate.setMode(this);
if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) { if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) {
Navigate.disconnect(); Navigate.disconnect();
@ -12936,6 +12971,10 @@
return Main.handleErrors(errors); return Main.handleErrors(errors);
} }
}, },
pushState: function(path) {
history.pushState(null, '', path);
return Navigate.path = window.location.pathname;
},
popstate: function() { popstate: function() {
var a; var a;
a = $.el('a', { a = $.el('a', {
@ -13542,6 +13581,7 @@
g.VIEW = (function() { g.VIEW = (function() {
switch (pathname[2]) { switch (pathname[2]) {
case 'res': case 'res':
case 'thread':
return 'thread'; return 'thread';
case 'catalog': case 'catalog':
return 'catalog'; return 'catalog';

View File

@ -1,6 +1,6 @@
{ {
"name": "4chan X", "name": "4chan X",
"version": "1.7.7", "version": "1.7.8",
"manifest_version": 2, "manifest_version": 2,
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"icons": { "icons": {

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // 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. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -309,8 +309,8 @@
'Open Gallery': ['g', 'Opens the gallery.'], 'Open Gallery': ['g', 'Opens the gallery.'],
'fappeTyme': ['f', 'Fappe Tyme.'], 'fappeTyme': ['f', 'Fappe Tyme.'],
'werkTyme': ['Shift+w', 'Werk Tyme'], 'werkTyme': ['Shift+w', 'Werk Tyme'],
'Front page': ['0', 'Jump to page 0.'], 'Front page': ['0', 'Jump to front page.'],
'Open front page': ['Shift+0', 'Open page 0 in a new tab.'], 'Open front page': ['Shift+0', 'Open front page in a new tab.'],
'Next page': ['Shift+Right', 'Jump to the next page.'], 'Next page': ['Shift+Right', 'Jump to the next page.'],
'Previous page': ['Shift+Left', 'Jump to the previous page.'], 'Previous page': ['Shift+Left', 'Jump to the previous page.'],
'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'], 'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'],
@ -352,7 +352,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.7.7', VERSION: '1.7.8',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -3159,6 +3159,7 @@
return +window.location.pathname.split('/')[2]; return +window.location.pathname.split('/')[2];
}, },
userPageNav: function(pageNum) { userPageNav: function(pageNum) {
Navigate.pushState(pageNum === 0 ? './' : pageNum);
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') { if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') {
return Index.update(pageNum); return Index.update(pageNum);
} else { } else {
@ -3169,7 +3170,7 @@
if (Index.currentPage === pageNum && !Index.root.parentElement) { if (Index.currentPage === pageNum && !Index.root.parentElement) {
return; return;
} }
history.pushState(null, '', pageNum === 0 ? './' : pageNum); Navigate.pushState(pageNum === 0 ? './' : pageNum);
return Index.pageLoad(pageNum); return Index.pageLoad(pageNum);
}, },
pageLoad: function(pageNum) { pageLoad: function(pageNum) {
@ -11881,7 +11882,7 @@
return Conf[hotkey] = key; return Conf[hotkey] = key;
}, },
keydown: function(e) { 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))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -11969,7 +11970,9 @@
ThreadUpdater.update(); ThreadUpdater.update();
break; break;
case 'index': case 'index':
Index.update(); if (Conf['JSON Navigation']) {
Index.update();
}
} }
break; break;
case Conf['Watch']: case Conf['Watch']:
@ -11995,7 +11998,7 @@
}); });
break; break;
case Conf['Front page']: case Conf['Front page']:
if (g.VIEW === 'index') { if (Conf['JSON Navigation'] && g.VIEW === 'index') {
Index.userPageNav(0); Index.userPageNav(0);
} else { } else {
window.location = "/" + g.BOARD + "/"; window.location = "/" + g.BOARD + "/";
@ -12005,19 +12008,39 @@
$.open("/" + g.BOARD + "/"); $.open("/" + g.BOARD + "/");
break; break;
case Conf['Next page']: case Conf['Next page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { if (g.VIEW !== 'index') {
return; 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; break;
case Conf['Previous page']: case Conf['Previous page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) { if (g.VIEW !== 'index') {
return; 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; break;
case Conf['Search form']: case Conf['Search form']:
Index.searchInput.focus(); if (Conf['JSON Navigation']) {
Index.searchInput.focus();
} else {
$.id('search-btn').click();
}
break; break;
case Conf['Paged mode']: case Conf['Paged mode']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) { if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) {
@ -12043,6 +12066,19 @@
} }
Index.cycleSortType(); Index.cycleSortType();
break; 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']: case Conf['Next thread']:
if (g.VIEW !== 'index') { if (g.VIEW !== 'index') {
return; return;
@ -12822,7 +12858,7 @@
if (threadID) { if (threadID) {
view = 'thread'; view = 'thread';
} else { } else {
pageNum = view; pageNum = +view;
view = 'index'; view = 'index';
} }
path = this.pathname; path = this.pathname;
@ -12831,9 +12867,8 @@
} }
Navigate.makeBreadCrumb(this.href, view, boardID, threadID); Navigate.makeBreadCrumb(this.href, view, boardID, threadID);
if (this.id !== 'popState') { if (this.id !== 'popState') {
history.pushState(null, '', path); Navigate.pushState(path);
} }
Navigate.path = this.pathname;
Navigate.setMode(this); Navigate.setMode(this);
if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) { if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) {
Navigate.disconnect(); Navigate.disconnect();
@ -12957,6 +12992,10 @@
return Main.handleErrors(errors); return Main.handleErrors(errors);
} }
}, },
pushState: function(path) {
history.pushState(null, '', path);
return Navigate.path = window.location.pathname;
},
popstate: function() { popstate: function() {
var a; var a;
a = $.el('a', { a = $.el('a', {
@ -13561,6 +13600,7 @@
g.VIEW = (function() { g.VIEW = (function() {
switch (pathname[2]) { switch (pathname[2]) {
case 'res': case 'res':
case 'thread':
return 'thread'; return 'thread';
case 'catalog': case 'catalog':
return 'catalog'; return 'catalog';

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.7' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.8' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,6 +1,6 @@
{ {
"name": "4chan-X", "name": "4chan-X",
"version": "1.7.7", "version": "1.7.8",
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",

View File

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

View File

@ -404,6 +404,7 @@ Index =
+window.location.pathname.split('/')[2] +window.location.pathname.split('/')[2]
userPageNav: (pageNum) -> userPageNav: (pageNum) ->
Navigate.pushState if pageNum is 0 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
@ -411,7 +412,7 @@ Index =
pageNav: (pageNum) -> pageNav: (pageNum) ->
return if Index.currentPage is pageNum and not Index.root.parentElement 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 Index.pageLoad pageNum
pageLoad: (pageNum) -> pageLoad: (pageNum) ->

View File

@ -8,7 +8,7 @@ Main =
return if g.BOARD.ID in ['z', 'fk'] return if g.BOARD.ID in ['z', 'fk']
g.VIEW = g.VIEW =
switch pathname[2] switch pathname[2]
when 'res' when 'res', 'thread'
'thread' 'thread'
when 'catalog' when 'catalog'
'catalog' 'catalog'

View File

@ -232,7 +232,7 @@ Navigate =
if threadID if threadID
view = 'thread' view = 'thread'
else else
pageNum = view pageNum = +view
view = 'index' # path is "/boardID/". See the problem? view = 'index' # path is "/boardID/". See the problem?
path = @pathname path = @pathname
@ -240,8 +240,7 @@ Navigate =
Navigate.makeBreadCrumb @href, view, boardID, threadID Navigate.makeBreadCrumb @href, view, boardID, threadID
history.pushState null, '', path unless @id is 'popState' Navigate.pushState path unless @id is 'popState'
Navigate.path = @pathname
Navigate.setMode @ Navigate.setMode @
@ -353,6 +352,10 @@ Navigate =
Main.handleErrors errors if errors Main.handleErrors errors if errors
pushState: (path) ->
history.pushState null, '', path
Navigate.path = window.location.pathname
popstate: -> popstate: ->
a = $.el 'a', a = $.el 'a',
href: window.location href: window.location

View File

@ -70,7 +70,7 @@ Keybinds =
when 'thread' when 'thread'
ThreadUpdater.update() ThreadUpdater.update()
when 'index' when 'index'
Index.update() if Conf['JSON Navigation'] then Index.update()
when Conf['Watch'] when Conf['Watch']
ThreadWatcher.toggle thread ThreadWatcher.toggle thread
# Images # Images
@ -86,20 +86,33 @@ Keybinds =
FappeTyme.cb.toggle.call {name: 'werk'} FappeTyme.cb.toggle.call {name: 'werk'}
# Board Navigation # Board Navigation
when Conf['Front page'] when Conf['Front page']
if g.VIEW is 'index' if Conf['JSON Navigation'] and g.VIEW is 'index'
Index.userPageNav 0 Index.userPageNav 0
else else
window.location = "/#{g.BOARD}/" window.location = "/#{g.BOARD}/"
when Conf['Open front page'] when Conf['Open front page']
$.open "/#{g.BOARD}/" $.open "/#{g.BOARD}/"
when Conf['Next page'] when Conf['Next page']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages' return unless g.VIEW is 'index'
$('.next button', Index.pagelist).click() 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'] when Conf['Previous page']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages' return unless g.VIEW is 'index'
$('.prev button', Index.pagelist).click() 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'] when Conf['Search form']
Index.searchInput.focus() if Conf['JSON Navigation']
Index.searchInput.focus()
else
$.id('search-btn').click()
when Conf['Paged mode'] when Conf['Paged mode']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'paged' return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'paged'
Index.setIndexMode 'paged' Index.setIndexMode 'paged'
@ -112,6 +125,13 @@ Keybinds =
when Conf['Cycle sort type'] when Conf['Cycle sort type']
return unless g.VIEW is 'index' return unless g.VIEW is 'index'
Index.cycleSortType() 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 # Thread Navigation
when Conf['Next thread'] when Conf['Next thread']
return if g.VIEW isnt 'index' return if g.VIEW isnt 'index'