mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(util) rm rmStr
This commit is contained in:
parent
b8d146c62e
commit
a1daf8e884
5 changed files with 7 additions and 46 deletions
|
|
@ -86,7 +86,7 @@ var Util, DOM, CloudFunc, join;
|
|||
* @pParams = {name, path, func, dobefore, arg}
|
||||
*/
|
||||
function loadModule(params) {
|
||||
var name, path, func, doBefore, slash, afterSlash,
|
||||
var name, path, func, doBefore,
|
||||
funcName, isContain;
|
||||
|
||||
if (params) {
|
||||
|
|
@ -98,13 +98,7 @@ var Util, DOM, CloudFunc, join;
|
|||
|
||||
if (path && !name) {
|
||||
name = getStrBigFirst(path);
|
||||
name = Util.rmStr(name, '.js');
|
||||
|
||||
slash = name.indexOf('/');
|
||||
if (slash > 0) {
|
||||
afterSlash = name.substr(slash);
|
||||
name = Util.rmStr(name, afterSlash);
|
||||
}
|
||||
name = name.replace(/.js$/, '');
|
||||
}
|
||||
|
||||
isContain = /\.js/.test(path);
|
||||
|
|
|
|||
|
|
@ -683,13 +683,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.getParentDirPath = function(panel) {
|
||||
var path = DOM.getCurrentDirPath(panel),
|
||||
dirName = DOM.getCurrentDirName() + '/',
|
||||
ret = '/';
|
||||
dirName = DOM.getCurrentDirName() + '/';
|
||||
|
||||
if (path !== '/')
|
||||
ret = Util.rmStr(path, dirName);
|
||||
path = path.replace(dirName, '');
|
||||
|
||||
return ret;
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ var Util, DOM, CloudCmd;
|
|||
|
||||
if (isHTML) {
|
||||
if (isRoot)
|
||||
path = DIR_HTML + Util.rmStr(name, '-tmpl');
|
||||
path = DIR_HTML + name.replace('-tmpl', '');
|
||||
else
|
||||
path = DIR_HTML_FS + name;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ var CloudCmd, Util, join, DOM, CloudFunc, Github, cb;
|
|||
DOM.load.ajax({
|
||||
type : 'put',
|
||||
url : apiURL + '/auth',
|
||||
data : Util.rmStr(code, '?code='),
|
||||
data : code.replace('?code=', ''),
|
||||
success : function(data) {
|
||||
var token = Util.json.parse(data).data.token;
|
||||
|
||||
|
|
|
|||
32
lib/util.js
32
lib/util.js
|
|
@ -220,38 +220,6 @@
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* function remove substring from string
|
||||
* @param str
|
||||
* @param substr
|
||||
*/
|
||||
this.rmStr = function(str, substr, isOnce) {
|
||||
var replace,
|
||||
strArray = [],
|
||||
isString = Util.type.string(str),
|
||||
isArray = Util.type.array(substr),
|
||||
replaceStr = function(str, strItem) {
|
||||
var ret = str.replace(strItem, '');
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
replace = isOnce ? replaceStr : Util.replaceStr;
|
||||
|
||||
if (isString && substr) {
|
||||
if (isArray)
|
||||
strArray = substr;
|
||||
else
|
||||
strArray.push(substr);
|
||||
|
||||
strArray.forEach(function(strItem) {
|
||||
str = replace(str, strItem, '');
|
||||
});
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* function replase pFrom to pTo in pStr
|
||||
* @param str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue