Remembering how keybinds work is hard.

This commit is contained in:
Zixaphir 2015-01-09 20:40:02 -07:00
parent 13d5542997
commit 108129ca78
3 changed files with 285 additions and 199 deletions

View File

@ -15245,7 +15245,7 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
if (!(key = Keybinds.keyCode(e))) {
return;
}
@ -15266,9 +15266,10 @@
}
switch (key) {
case Conf['Toggle board list']:
if (Conf['Custom Board Navigation']) {
Header.toggleBoardList();
if (!Conf['Custom Board Navigation']) {
return;
}
Header.toggleBoardList();
break;
case Conf['Toggle header']:
Header.toggleBarVisibility();
@ -15277,9 +15278,10 @@
Keybinds.qr();
break;
case Conf['Open QR']:
if (threadRoot) {
Keybinds.qr(threadRoot);
if (!threadRoot) {
return;
}
Keybinds.qr(threadRoot);
break;
case Conf['Open settings']:
Settings.open();
@ -15300,35 +15302,45 @@
}
} else if (Embedding.lastEmbed) {
Embedding.closeFloat();
} else {
return;
}
return;
break;
case Conf['Spoiler tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('spoiler', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('spoiler', target);
break;
case Conf['Code tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('code', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('code', target);
break;
case Conf['Eqn tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('eqn', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('eqn', target);
break;
case Conf['Math tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('math', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('math', target);
break;
case Conf['Toggle sage']:
if (QR.nodes && !QR.nodes.el.hidden) {
Keybinds.sage();
if (!(QR.nodes && !QR.nodes.el.hidden)) {
return;
}
Keybinds.sage();
break;
case Conf['Submit QR']:
if (QR.nodes && !QR.nodes.el.hidden && !QR.status()) {
if (!(QR.nodes && !QR.nodes.el.hidden)) {
return;
}
if (!QR.status()) {
QR.submit();
}
break;
@ -15342,52 +15354,60 @@
case Conf['Update']:
switch (g.VIEW) {
case 'thread':
if (Conf['Thread Updater']) {
ThreadUpdater.update();
if (!Conf['Thread Updater']) {
return;
}
ThreadUpdater.update();
break;
case 'index':
if (Conf['JSON Navigation']) {
Index.update();
if (!Conf['JSON Navigation']) {
return;
}
Index.update();
break;
default:
return;
}
return;
break;
case Conf['Watch']:
if (!thread) {
ThreadWatcher.toggle(thread);
}
break;
case Conf['Expand image']:
if (threadRoot) {
Keybinds.img(threadRoot);
}
break;
case Conf['Expand images']:
if (threadRoot) {
Keybinds.img(threadRoot, true);
}
break;
case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) === 'index' || _ref2 === 'thread') {
Gallery.cb.toggle();
}
break;
case Conf['fappeTyme']:
if (Conf['Fappe Tyme'] && ((_ref3 = g.VIEW) === 'index' || _ref3 === 'thread') && g.BOARD !== 'f') {
FappeTyme.cb.toggle.call({
name: 'fappe'
});
}
break;
case Conf['werkTyme']:
if (g.VIEW === 'catalog') {
return;
}
if (Conf['Fappe Tyme'] && ((_ref4 = g.VIEW) === 'index' || _ref4 === 'thread') && g.BOARD !== 'f') {
FappeTyme.cb.toggle.call({
name: 'werk'
});
ThreadWatcher.toggle(thread);
break;
case Conf['Expand image']:
if (!threadRoot) {
return;
}
Keybinds.img(threadRoot);
break;
case Conf['Expand images']:
if (!threadRoot) {
return;
}
Keybinds.img(threadRoot, true);
break;
case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') {
return;
}
Gallery.cb.toggle();
break;
case Conf['fappeTyme']:
if (!Conf['Fappe Tyme'] || ((_ref3 = g.VIEW) !== 'index' && _ref3 !== 'thread') || g.BOARD === 'f') {
return;
}
FappeTyme.cb.toggle.call({
name: 'fappe'
});
break;
case Conf['werkTyme']:
if (!Conf['Fappe Tyme'] || ((_ref4 = g.VIEW) !== 'index' && _ref4 !== 'thread') || g.BOARD === 'f') {
return;
}
FappeTyme.cb.toggle.call({
name: 'werk'
});
break;
case Conf['Front page']:
if (Conf['JSON Navigation'] && g.VIEW === 'index') {
@ -15404,9 +15424,10 @@
return;
}
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.next button', Index.pagelist).click();
if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') {
return;
}
$('.next button', Index.pagelist).click();
} else {
if (form = $('.next form')) {
window.location = form.action;
@ -15418,9 +15439,10 @@
return;
}
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.prev button', Index.pagelist).click();
if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') {
return;
}
$('.prev button', Index.pagelist).click();
} else {
if (form = $('.prev form')) {
window.location = form.action;
@ -15472,63 +15494,71 @@
Index.setIndexMode('catalog');
}
break;
case Conf['Cycle sort type']:
if (Conf['JSON Navigation'] && g.VIEW === 'index' && g.BOARD !== 'f') {
Index.cycleSortType();
}
break;
case Conf['Next thread']:
if (g.VIEW === 'index' && threadRoot) {
Nav.scroll(+1);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Nav.scroll(+1);
break;
case Conf['Previous thread']:
if (g.VIEW === 'index' && threadRoot) {
Nav.scroll(-1);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Nav.scroll(-1);
break;
case Conf['Expand thread']:
if (g.VIEW === 'index' && threadRoot) {
ExpandThread.toggle(thread);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
ExpandThread.toggle(thread);
break;
case Conf['Open thread']:
if (g.VIEW === 'index' && threadRoot) {
Keybinds.open(thread);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Keybinds.open(thread);
break;
case Conf['Open thread tab']:
if (g.VIEW === 'index' && threadRoot) {
Keybinds.open(thread, true);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Keybinds.open(thread, true);
break;
case Conf['Next reply']:
if (threadRoot) {
Keybinds.hl(+1, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(+1, threadRoot);
break;
case Conf['Previous reply']:
if (threadRoot) {
Keybinds.hl(-1, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(-1, threadRoot);
break;
case Conf['Deselect reply']:
if (threadRoot) {
Keybinds.hl(0, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(0, threadRoot);
break;
case Conf['Hide']:
if (!threadRoot) {
return;
}
PostHiding.toggle(thread.OP);
break;
case Conf['Previous Post Quoting You']:
if (threadRoot) {
QuoteMarkers.cb.seek('preceding');
if (!threadRoot) {
return;
}
QuoteMarkers.cb.seek('preceding');
break;
case Conf['Next Post Quoting You']:
if (threadRoot) {
QuoteMarkers.cb.seek('following');
if (!threadRoot) {
return;
}
QuoteMarkers.cb.seek('following');
break;
default:
return;

View File

@ -15266,7 +15266,7 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
if (!(key = Keybinds.keyCode(e))) {
return;
}
@ -15287,9 +15287,10 @@
}
switch (key) {
case Conf['Toggle board list']:
if (Conf['Custom Board Navigation']) {
Header.toggleBoardList();
if (!Conf['Custom Board Navigation']) {
return;
}
Header.toggleBoardList();
break;
case Conf['Toggle header']:
Header.toggleBarVisibility();
@ -15298,9 +15299,10 @@
Keybinds.qr();
break;
case Conf['Open QR']:
if (threadRoot) {
Keybinds.qr(threadRoot);
if (!threadRoot) {
return;
}
Keybinds.qr(threadRoot);
break;
case Conf['Open settings']:
Settings.open();
@ -15321,35 +15323,45 @@
}
} else if (Embedding.lastEmbed) {
Embedding.closeFloat();
} else {
return;
}
return;
break;
case Conf['Spoiler tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('spoiler', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('spoiler', target);
break;
case Conf['Code tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('code', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('code', target);
break;
case Conf['Eqn tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('eqn', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('eqn', target);
break;
case Conf['Math tags']:
if (target.nodeName === 'TEXTAREA') {
Keybinds.tags('math', target);
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('math', target);
break;
case Conf['Toggle sage']:
if (QR.nodes && !QR.nodes.el.hidden) {
Keybinds.sage();
if (!(QR.nodes && !QR.nodes.el.hidden)) {
return;
}
Keybinds.sage();
break;
case Conf['Submit QR']:
if (QR.nodes && !QR.nodes.el.hidden && !QR.status()) {
if (!(QR.nodes && !QR.nodes.el.hidden)) {
return;
}
if (!QR.status()) {
QR.submit();
}
break;
@ -15363,52 +15375,60 @@
case Conf['Update']:
switch (g.VIEW) {
case 'thread':
if (Conf['Thread Updater']) {
ThreadUpdater.update();
if (!Conf['Thread Updater']) {
return;
}
ThreadUpdater.update();
break;
case 'index':
if (Conf['JSON Navigation']) {
Index.update();
if (!Conf['JSON Navigation']) {
return;
}
Index.update();
break;
default:
return;
}
return;
break;
case Conf['Watch']:
if (!thread) {
ThreadWatcher.toggle(thread);
}
break;
case Conf['Expand image']:
if (threadRoot) {
Keybinds.img(threadRoot);
}
break;
case Conf['Expand images']:
if (threadRoot) {
Keybinds.img(threadRoot, true);
}
break;
case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) === 'index' || _ref2 === 'thread') {
Gallery.cb.toggle();
}
break;
case Conf['fappeTyme']:
if (Conf['Fappe Tyme'] && ((_ref3 = g.VIEW) === 'index' || _ref3 === 'thread') && g.BOARD !== 'f') {
FappeTyme.cb.toggle.call({
name: 'fappe'
});
}
break;
case Conf['werkTyme']:
if (g.VIEW === 'catalog') {
return;
}
if (Conf['Fappe Tyme'] && ((_ref4 = g.VIEW) === 'index' || _ref4 === 'thread') && g.BOARD !== 'f') {
FappeTyme.cb.toggle.call({
name: 'werk'
});
ThreadWatcher.toggle(thread);
break;
case Conf['Expand image']:
if (!threadRoot) {
return;
}
Keybinds.img(threadRoot);
break;
case Conf['Expand images']:
if (!threadRoot) {
return;
}
Keybinds.img(threadRoot, true);
break;
case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') {
return;
}
Gallery.cb.toggle();
break;
case Conf['fappeTyme']:
if (!Conf['Fappe Tyme'] || ((_ref3 = g.VIEW) !== 'index' && _ref3 !== 'thread') || g.BOARD === 'f') {
return;
}
FappeTyme.cb.toggle.call({
name: 'fappe'
});
break;
case Conf['werkTyme']:
if (!Conf['Fappe Tyme'] || ((_ref4 = g.VIEW) !== 'index' && _ref4 !== 'thread') || g.BOARD === 'f') {
return;
}
FappeTyme.cb.toggle.call({
name: 'werk'
});
break;
case Conf['Front page']:
if (Conf['JSON Navigation'] && g.VIEW === 'index') {
@ -15425,9 +15445,10 @@
return;
}
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.next button', Index.pagelist).click();
if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') {
return;
}
$('.next button', Index.pagelist).click();
} else {
if (form = $('.next form')) {
window.location = form.action;
@ -15439,9 +15460,10 @@
return;
}
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.prev button', Index.pagelist).click();
if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') {
return;
}
$('.prev button', Index.pagelist).click();
} else {
if (form = $('.prev form')) {
window.location = form.action;
@ -15493,63 +15515,71 @@
Index.setIndexMode('catalog');
}
break;
case Conf['Cycle sort type']:
if (Conf['JSON Navigation'] && g.VIEW === 'index' && g.BOARD !== 'f') {
Index.cycleSortType();
}
break;
case Conf['Next thread']:
if (g.VIEW === 'index' && threadRoot) {
Nav.scroll(+1);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Nav.scroll(+1);
break;
case Conf['Previous thread']:
if (g.VIEW === 'index' && threadRoot) {
Nav.scroll(-1);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Nav.scroll(-1);
break;
case Conf['Expand thread']:
if (g.VIEW === 'index' && threadRoot) {
ExpandThread.toggle(thread);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
ExpandThread.toggle(thread);
break;
case Conf['Open thread']:
if (g.VIEW === 'index' && threadRoot) {
Keybinds.open(thread);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Keybinds.open(thread);
break;
case Conf['Open thread tab']:
if (g.VIEW === 'index' && threadRoot) {
Keybinds.open(thread, true);
if (!(g.VIEW === 'index' && threadRoot)) {
return;
}
Keybinds.open(thread, true);
break;
case Conf['Next reply']:
if (threadRoot) {
Keybinds.hl(+1, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(+1, threadRoot);
break;
case Conf['Previous reply']:
if (threadRoot) {
Keybinds.hl(-1, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(-1, threadRoot);
break;
case Conf['Deselect reply']:
if (threadRoot) {
Keybinds.hl(0, threadRoot);
if (!threadRoot) {
return;
}
Keybinds.hl(0, threadRoot);
break;
case Conf['Hide']:
if (!threadRoot) {
return;
}
PostHiding.toggle(thread.OP);
break;
case Conf['Previous Post Quoting You']:
if (threadRoot) {
QuoteMarkers.cb.seek('preceding');
if (!threadRoot) {
return;
}
QuoteMarkers.cb.seek('preceding');
break;
case Conf['Next Post Quoting You']:
if (threadRoot) {
QuoteMarkers.cb.seek('following');
if (!threadRoot) {
return;
}
QuoteMarkers.cb.seek('following');
break;
default:
return;

View File

@ -29,13 +29,15 @@ Keybinds =
switch key
# QR & Options
when Conf['Toggle board list']
Header.toggleBoardList() if Conf['Custom Board Navigation']
return unless Conf['Custom Board Navigation']
Header.toggleBoardList()
when Conf['Toggle header']
Header.toggleBarVisibility()
when Conf['Open empty QR']
Keybinds.qr()
when Conf['Open QR']
Keybinds.qr threadRoot if threadRoot
return unless threadRoot
Keybinds.qr threadRoot
when Conf['Open settings']
Settings.open()
when Conf['Close']
@ -51,19 +53,26 @@ Keybinds =
QR.close()
else if Embedding.lastEmbed
Embedding.closeFloat()
return
else
return
when Conf['Spoiler tags']
Keybinds.tags 'spoiler', target if target.nodeName is 'TEXTAREA'
return unless target.nodeName is 'TEXTAREA'
Keybinds.tags 'spoiler', target
when Conf['Code tags']
Keybinds.tags 'code', target if target.nodeName is 'TEXTAREA'
return unless target.nodeName is 'TEXTAREA'
Keybinds.tags 'code', target
when Conf['Eqn tags']
Keybinds.tags 'eqn', target if target.nodeName is 'TEXTAREA'
return unless target.nodeName is 'TEXTAREA'
Keybinds.tags 'eqn', target
when Conf['Math tags']
Keybinds.tags 'math', target if target.nodeName is 'TEXTAREA'
return unless target.nodeName is 'TEXTAREA'
Keybinds.tags 'math', target
when Conf['Toggle sage']
Keybinds.sage() if QR.nodes and !QR.nodes.el.hidden
return unless QR.nodes and !QR.nodes.el.hidden
Keybinds.sage()
when Conf['Submit QR']
QR.submit() if QR.nodes and !QR.nodes.el.hidden and !QR.status()
return unless QR.nodes and !QR.nodes.el.hidden
QR.submit() if !QR.status()
when Conf['Post Without Name']
return unless QR.nodes and !QR.status()
Keybinds.name()
@ -72,24 +81,32 @@ Keybinds =
when Conf['Update']
switch g.VIEW
when 'thread'
ThreadUpdater.update() if Conf['Thread Updater']
return unless Conf['Thread Updater']
ThreadUpdater.update()
when 'index'
Index.update() if Conf['JSON Navigation']
return
return unless Conf['JSON Navigation']
Index.update()
else
return
when Conf['Watch']
ThreadWatcher.toggle thread unless thread
return unless thread
ThreadWatcher.toggle thread
# Images
when Conf['Expand image']
Keybinds.img threadRoot if threadRoot
return unless threadRoot
Keybinds.img threadRoot
when Conf['Expand images']
Keybinds.img threadRoot, true if threadRoot
return unless threadRoot
Keybinds.img threadRoot, true
when Conf['Open Gallery']
Gallery.cb.toggle() if g.VIEW in ['index', 'thread']
return unless g.VIEW in ['index', 'thread']
Gallery.cb.toggle()
when Conf['fappeTyme']
FappeTyme.cb.toggle.call {name: 'fappe'} if Conf['Fappe Tyme'] and g.VIEW in ['index', 'thread'] and g.BOARD isnt 'f'
return if !Conf['Fappe Tyme'] or g.VIEW not in ['index', 'thread'] or g.BOARD is 'f'
FappeTyme.cb.toggle.call {name: 'fappe'}
when Conf['werkTyme']
return if g.VIEW is 'catalog'
FappeTyme.cb.toggle.call {name: 'werk'} if Conf['Fappe Tyme'] and g.VIEW in ['index', 'thread'] and g.BOARD isnt 'f'
return if !Conf['Fappe Tyme'] or g.VIEW not in ['index', 'thread'] or g.BOARD is 'f'
FappeTyme.cb.toggle.call {name: 'werk'}
# Board Navigation
when Conf['Front page']
if Conf['JSON Navigation'] and g.VIEW is 'index'
@ -101,16 +118,16 @@ Keybinds =
when Conf['Next page']
return unless g.VIEW is 'index'
if Conf['JSON Navigation']
if Conf['Index Mode'] isnt 'all pages'
$('.next button', Index.pagelist).click()
return unless Conf['Index Mode'] in ['paged', 'infinite']
$('.next button', Index.pagelist).click()
else
if form = $ '.next form'
window.location = form.action
when Conf['Previous page']
return unless g.VIEW is 'index'
if Conf['JSON Navigation']
if Conf['Index Mode'] isnt 'all pages'
$('.prev button', Index.pagelist).click()
return unless Conf['Index Mode'] in ['paged', 'infinite']
$('.prev button', Index.pagelist).click()
else
if form = $ '.prev form'
window.location = form.action
@ -138,32 +155,41 @@ Keybinds =
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'
when Conf['Cycle sort type']
Index.cycleSortType() if Conf['JSON Navigation'] and g.VIEW is 'index' and g.BOARD isnt 'f'
# Thread Navigation
when Conf['Next thread']
Nav.scroll +1 if g.VIEW is 'index' and threadRoot
return unless g.VIEW is 'index' and threadRoot
Nav.scroll +1
when Conf['Previous thread']
Nav.scroll -1 if g.VIEW is 'index' and threadRoot
return unless g.VIEW is 'index' and threadRoot
Nav.scroll -1
when Conf['Expand thread']
ExpandThread.toggle thread if g.VIEW is 'index' and threadRoot
return unless g.VIEW is 'index' and threadRoot
ExpandThread.toggle thread
when Conf['Open thread']
Keybinds.open thread if g.VIEW is 'index' and threadRoot
return unless g.VIEW is 'index' and threadRoot
Keybinds.open thread
when Conf['Open thread tab']
Keybinds.open thread, true if g.VIEW is 'index' and threadRoot
return unless g.VIEW is 'index' and threadRoot
Keybinds.open thread, true
# Reply Navigation
when Conf['Next reply']
Keybinds.hl +1, threadRoot if threadRoot
return unless threadRoot
Keybinds.hl +1, threadRoot
when Conf['Previous reply']
Keybinds.hl -1, threadRoot if threadRoot
return unless threadRoot
Keybinds.hl -1, threadRoot
when Conf['Deselect reply']
Keybinds.hl 0, threadRoot if threadRoot
return unless threadRoot
Keybinds.hl 0, threadRoot
when Conf['Hide']
return unless threadRoot
PostHiding.toggle thread.OP
when Conf['Previous Post Quoting You']
QuoteMarkers.cb.seek 'preceding' if threadRoot
return unless threadRoot
QuoteMarkers.cb.seek 'preceding'
when Conf['Next Post Quoting You']
QuoteMarkers.cb.seek 'following' if threadRoot
return unless threadRoot
QuoteMarkers.cb.seek 'following'
else
return
e.preventDefault()