From 78fcfd2c333c2b5caa41071a018affcceec38f40 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 24 Jul 2011 09:44:05 -0700 Subject: [PATCH] fix options keybinding --- 4chan_x.user.js | 34 ++++++++++++---------------------- script.coffee | 21 ++++++++------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 10f697515..bb6dbbf20 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -731,12 +731,6 @@ return; } key = keybinds.cb.keyCode(e); - if (e.altKey) { - key = 'alt+' + key; - } - if (e.ctrlKey) { - key = 'ctrl+' + key; - } thread = nav.getThread(); switch (key) { case conf.close: @@ -833,7 +827,7 @@ } return e.preventDefault(); }, - keyCode: function(e, options) { + keyCode: function(e) { var kc; kc = e.keyCode; if ((65 <= kc && kc <= 90)) { @@ -845,9 +839,15 @@ key = String.fromCharCode(kc); } else if (kc === 27) { key = 'Esc'; - } else if (options && kc === 8) { + } else { key = ''; } + if (e.altKey) { + key = 'alt+' + key; + } + if (e.ctrlKey) { + key = 'ctrl+' + key; + } return key; } }, @@ -1124,20 +1124,10 @@ keybind: function(e) { e.preventDefault(); e.stopPropagation(); - key = keybinds.cb.keyCode(e, true); - if (key != null) { - if (key) { - if (e.altKey) { - key = 'alt+' + key; - } - if (e.ctrlKey) { - key = 'ctrl+' + key; - } - } - this.value = key; - $.setValue(this.name, key); - return conf[this.name] = key; - } + key = keybinds.cb.keyCode(e); + this.value = key; + $.setValue(this.name, key); + return conf[this.name] = key; }, time: function(e) { $.setValue('time', this.value); diff --git a/script.coffee b/script.coffee index 3392e65f0..596382646 100644 --- a/script.coffee +++ b/script.coffee @@ -521,8 +521,6 @@ keybinds = keydown: (e) -> return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) key = keybinds.cb.keyCode e - if e.altKey then key = 'alt+' + key - if e.ctrlKey then key = 'ctrl+' + key thread = nav.getThread() switch key @@ -593,7 +591,7 @@ keybinds = return e.preventDefault() - keyCode: (e, options) -> + keyCode: (e) -> kc = e.keyCode if 65 <= kc <= 90 #A-Z key = String.fromCharCode kc @@ -603,8 +601,10 @@ keybinds = key = String.fromCharCode kc else if kc is 27 key = 'Esc' - else if options and kc is 8 + else key = '' + if e.altKey then key = 'alt+' + key + if e.ctrlKey then key = 'ctrl+' + key key img: (thread, all) -> @@ -890,15 +890,10 @@ options = keybind: (e) -> e.preventDefault() e.stopPropagation() - key = keybinds.cb.keyCode e, true - - if key? - if key - key = 'alt+' + key if e.altKey - key = 'ctrl+' + key if e.ctrlKey - @value = key - $.setValue @name, key - conf[@name] = key + key = keybinds.cb.keyCode e + @value = key + $.setValue @name, key + conf[@name] = key time: (e) -> $.setValue 'time', @value conf['time'] = @value