From 033c1308d2e59423d21064adb2e5a06c36e4562a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 23 Jan 2014 04:56:03 -0500 Subject: [PATCH] refactor(key) isContainStrAtBegin -> RegExp --- lib/client/key.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/client/key.js b/lib/client/key.js index 3ce0d401..78b149cd 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -110,16 +110,15 @@ var CloudCmd, Util, DOM; } function setCurrentByLetter(pKeyCode) { - var i, n, name, isCurrent, isContain, byName, firstByName, + var i, n, name, isCurrent, isMatch, byName, firstByName, skipCount = 0, skipN = 0, setted = false, current = Info.element, panel = Info.panel, files = Info.files, - SMALL = 32, char = String.fromCharCode(pKeyCode), - charSmall = String.fromCharCode(pKeyCode + SMALL); + regExp = new RegExp('^' + char + '.*$', 'i'); n = Chars.length; for (i = 0; i < n; i++) @@ -134,11 +133,11 @@ var CloudCmd, Util, DOM; n = files.length; for (i = 0; i < n; i++) { - current = files[i]; + current = files[i]; name = DOM.getCurrentName(current); - isContain = Util.isContainStrAtBegin(name, [char, charSmall]); + isMatch = name.match(regExp); - if (isContain) { + if (isMatch) { byName = DOM.getCurrentFileByName(name); if (!skipCount) {