diff --git a/4chan_x.user.js b/4chan_x.user.js index dae5ba873..10f697515 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -726,19 +726,19 @@ }, cb: { keydown: function(e) { - var k, o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; + var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { return; } - k = keybinds.cb.keyCode(e); + key = keybinds.cb.keyCode(e); if (e.altKey) { - k = 'alt+' + k; + key = 'alt+' + key; } if (e.ctrlKey) { - k = 'ctrl+' + k; + key = 'ctrl+' + key; } thread = nav.getThread(); - switch (k) { + switch (key) { case conf.close: if (o = $('#overlay')) { $.rm(o); @@ -834,21 +834,21 @@ return e.preventDefault(); }, keyCode: function(e, options) { - var k, kc; + var kc; kc = e.keyCode; if ((65 <= kc && kc <= 90)) { - k = String.fromCharCode(kc); + key = String.fromCharCode(kc); if (!e.shiftKey) { - k = k.toLowerCase(); + key = key.toLowerCase(); } } else if ((48 <= kc && kc <= 57)) { - k = String.fromCharCode(kc); + key = String.fromCharCode(kc); } else if (kc === 27) { - k = 'Esc'; + key = 'Esc'; } else if (options && kc === 8) { - k = ''; + key = ''; } - return k; + return key; } }, img: function(thread, all) { @@ -1122,22 +1122,21 @@ return g.hiddenReplies = {}; }, keybind: function(e) { - var k; e.preventDefault(); e.stopPropagation(); - k = keybinds.cb.keyCode(e, true); - if (k != null) { - if (k) { + key = keybinds.cb.keyCode(e, true); + if (key != null) { + if (key) { if (e.altKey) { - k = 'alt+' + k; + key = 'alt+' + key; } if (e.ctrlKey) { - k = 'ctrl+' + k; + key = 'ctrl+' + key; } } - this.value = k; - $.setValue(this.name, k); - return conf[this.name] = k; + this.value = key; + $.setValue(this.name, key); + return conf[this.name] = key; } }, time: function(e) { diff --git a/changelog b/changelog index 63e918021..b16908314 100644 --- a/changelog +++ b/changelog @@ -7,6 +7,7 @@ github - fix wrong keybind input in options - fix time preview - fix backlink inlining removing its container + - Fix options key/keybinds key variables. 2.16.1 - mayhem: diff --git a/script.coffee b/script.coffee index ab8dbce36..3392e65f0 100644 --- a/script.coffee +++ b/script.coffee @@ -520,12 +520,12 @@ keybinds = cb: keydown: (e) -> return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) - k = keybinds.cb.keyCode e - if e.altKey then k = 'alt+' + k - if e.ctrlKey then k = 'ctrl+' + k + key = keybinds.cb.keyCode e + if e.altKey then key = 'alt+' + key + if e.ctrlKey then key = 'ctrl+' + key thread = nav.getThread() - switch k + switch key when conf.close if o = $ '#overlay' $.rm o @@ -596,16 +596,16 @@ keybinds = keyCode: (e, options) -> kc = e.keyCode if 65 <= kc <= 90 #A-Z - k = String.fromCharCode kc + key = String.fromCharCode kc if !e.shiftKey - k = k.toLowerCase() + key = key.toLowerCase() else if 48 <= kc <= 57 #0-9 - k = String.fromCharCode kc + key = String.fromCharCode kc else if kc is 27 - k = 'Esc' + key = 'Esc' else if options and kc is 8 - k = '' - k + key = '' + key img: (thread, all) -> if all @@ -890,15 +890,15 @@ options = keybind: (e) -> e.preventDefault() e.stopPropagation() - k = keybinds.cb.keyCode e, true + key = keybinds.cb.keyCode e, true - if k? - if k - k = 'alt+' + k if e.altKey - k = 'ctrl+' + k if e.ctrlKey - @value = k - $.setValue @name, k - conf[@name] = k + if key? + if key + key = 'alt+' + key if e.altKey + key = 'ctrl+' + key if e.ctrlKey + @value = key + $.setValue @name, key + conf[@name] = key time: (e) -> $.setValue 'time', @value conf['time'] = @value