mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(util) rm strCmp
This commit is contained in:
parent
1f01e77072
commit
f3e30608fa
2 changed files with 5 additions and 35 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
27
lib/util.js
27
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue