diff --git a/4chan_x.user.js b/4chan_x.user.js index a8ee0848f..b07ae8628 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -750,14 +750,13 @@ var range, selEnd, selStart, ta, valEnd, valMid, valStart, value; switch (keybinds.key) { case keybinds.close: - e.preventDefault(); - return $.rm($('#qr')); + $.rm($('#qr')); + break; case keybinds.spoiler: ta = d.activeElement; if (ta.nodeName !== 'TEXTAREA') { return; } - e.preventDefault(); value = ta.value; selStart = ta.selectionStart; selEnd = ta.selectionEnd; @@ -766,50 +765,71 @@ valEnd = '[/spoiler]' + value.slice(selEnd); ta.value = valStart + valMid + valEnd; range = valStart.length + valMid.length; - return ta.setSelectionRange(range, range); + ta.setSelectionRange(range, range); + break; + default: + return; } + return e.preventDefault(); }, normal: function(e) { var o, thread; thread = nav.getThread(); switch (keybinds.key) { case keybinds.close: - e.preventDefault(); if (o = $('#overlay')) { - return $.rm(o); + $.rm(o); } break; case keybinds.zero: - return window.location = "/" + g.BOARD + "/0#0"; + window.location = "/" + g.BOARD + "/0#0"; + break; case keybinds.openEmptyQR: - return keybinds.qr(thread); + keybinds.qr(thread); + break; case keybinds.nextReply: - return keybinds.hl.next(thread); + keybinds.hl.next(thread); + break; case keybinds.previousReply: - return keybinds.hl.prev(thread); + keybinds.hl.prev(thread); + break; case keybinds.expandAllImages: - return keybinds.img(thread, true); + keybinds.img(thread, true); + break; case keybinds.openThread: - return keybinds.open(thread); + keybinds.open(thread); + break; case keybinds.expandThread: - return expandThread.toggle(thread); + expandThread.toggle(thread); + break; case keybinds.openQR: - return keybinds.qr(thread, true); + keybinds.qr(thread, true); + break; case keybinds.expandImages: - return keybinds.img(thread); + keybinds.img(thread); + break; case keybinds.nextThread: - return nav.next(); + nav.next(); + break; case keybinds.openThreadTab: - return keybinds.open(thread, true); + keybinds.open(thread, true); + break; case keybinds.previousThread: - return nav.prev(); + nav.prev(); + break; case keybinds.update: - return updater.update(); + updater.update(); + break; case keybinds.watch: - return watcher.toggle(thread); + watcher.toggle(thread); + break; case keybinds.hide: - return threadHiding.toggle(thread); + threadHiding.toggle(thread); + break; + default: + return; } + return e.preventDefault(); }, img: function(thread, all) { var root, thumb; diff --git a/script.coffee b/script.coffee index fba549989..9c9142055 100644 --- a/script.coffee +++ b/script.coffee @@ -537,14 +537,11 @@ keybinds = insert: (e) -> switch keybinds.key when keybinds.close - e.preventDefault() $.rm $ '#qr' when keybinds.spoiler ta = d.activeElement return unless ta.nodeName is 'TEXTAREA' - e.preventDefault() - value = ta.value selStart = ta.selectionStart selEnd = ta.selectionEnd @@ -556,12 +553,14 @@ keybinds = ta.value = valStart + valMid + valEnd range = valStart.length + valMid.length ta.setSelectionRange range, range + else + return + e.preventDefault() normal: (e) -> thread = nav.getThread() switch keybinds.key when keybinds.close - e.preventDefault() $.rm o if o = $ '#overlay' when keybinds.zero window.location = "/#{g.BOARD}/0#0" @@ -593,6 +592,9 @@ keybinds = watcher.toggle thread when keybinds.hide threadHiding.toggle thread + else + return + e.preventDefault() img: (thread, all) -> if all