refactor(key) isContainStrAtBegin -> RegExp

This commit is contained in:
coderaiser 2014-01-23 04:56:03 -05:00
parent c54f7d39fb
commit 033c1308d2

View file

@ -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) {