From f3e30608fa69f9ca63483a2ccbe0c1870d74f617 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 8 Jan 2015 14:43:41 -0500 Subject: [PATCH] feature(util) rm strCmp --- lib/client/dom.js | 13 +++++-------- lib/util.js | 27 --------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index a72282f6..a44cc962 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -989,7 +989,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; element = document.elementFromPoint(x, y), tag = element.tagName; - isChild = Util.strCmp(tag, ['A', 'SPAN', 'LI']); + isChild = /A|SPAN|LI/.test(tag); if (!isChild) { element = null; @@ -1527,7 +1527,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @currentFile */ this.renameCurrent = function(current) { - var from, to, dirPath, cmp, files, + var from, to, dirPath, files, RESTful = DOM.RESTful; if (!Cmd.isCurrentFile(current)) @@ -1540,9 +1540,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } else { to = Dialog.prompt('Rename', from) || from; dirPath = Cmd.getCurrentDirPath(); - cmp = Util.strCmp(from, to); - if (!cmp) { + if (from !== to) { files = { from : dirPath + from, to : dirPath + to @@ -1565,7 +1564,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param operation */ function processFiles(operation, data) { - var n, name, files, cmp, msg, opFunc, + var n, name, files, msg, opFunc, RESTful = DOM.RESTful, from = '', @@ -1615,9 +1614,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!data) to = Dialog.prompt(msg, to); - cmp = Util.strCmp(from, to); - - if (!cmp && to) { + if (from !== to && to) { Images.show.load('top'); files = { diff --git a/lib/util.js b/lib/util.js index 3db3be04..99a4de53 100644 --- a/lib/util.js +++ b/lib/util.js @@ -219,33 +219,6 @@ return str; }; } - /** - * function check is strings are equal - * @param {String} str1 - * @param {String, Array} str2 - */ - this.strCmp = function(str1, str2) { - var isEqual, - type = Util.type(str2); - - switch(type) { - case 'array': - str2.some(function(str) { - isEqual = Util.strCmp(str1, str); - - return isEqual; - }); - break; - - case 'string': - isEqual = str1 === str2; - - break; - } - - return isEqual; - - }; /** * function log pArg if it's not empty