From ccffa3a61f184908669ace49918c549f628e146d Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 15:35:39 -0700 Subject: [PATCH] refactor --- 4chan_x.user.js | 8 ++++---- script.coffee | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3a8f6a9d3..f678f8853 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -867,7 +867,7 @@ return e.preventDefault(); }, keyCode: function(e) { - var kc; + var c, kc; key = (function() { switch (kc = e.keyCode) { case 8: @@ -892,6 +892,7 @@ case 55: case 56: case 57: + return String.fromCharCode(kc); case 65: case 66: case 67: @@ -918,10 +919,9 @@ case 88: case 89: case 90: + c = String.fromCharCode(kc); if (e.shiftKey) { - return String.fromCharCode(kc); - } else { - return String.fromCharCode(kc).toLowerCase(); + return c.toLowerCase(); } break; default: diff --git a/script.coffee b/script.coffee index 220d27bdc..c129103a7 100644 --- a/script.coffee +++ b/script.coffee @@ -632,11 +632,11 @@ keybinds = 'Right' when 40 'Down' - when 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 #0-9 and A-Z - if e.shiftKey - String.fromCharCode kc - else - String.fromCharCode(kc).toLowerCase() + when 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 #0-9 + String.fromCharCode kc + when 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 #A-Z + c = String.fromCharCode kc + c.toLowerCase() if e.shiftKey else null if key