refactor(util) removeStr -> rmStr, removeStrOneTime -> rmStrOnce

This commit is contained in:
coderaiser 2014-04-30 04:29:49 -04:00
parent b443f324cc
commit 8867b15df1
13 changed files with 37 additions and 37 deletions

View file

@ -52,7 +52,7 @@
panel = options.panel;
if (!Config.appCache)
data = Util.removeStr(data, [
data = Util.rmStr(data, [
/* min */
' manifest=/cloudcmd.appcache',
/* normal */
@ -229,7 +229,7 @@
p.name = main.HTMLDIR + name + '.html';
main.sendFile(p);
} else if (isFS) {
name = Util.removeStrOneTime(name, CloudFunc.FS) || main.SLASH;
name = Util.rmStrOnce(name, CloudFunc.FS) || main.SLASH;
getContent(name, function(error, data, isFile) {
var json,

View file

@ -43,7 +43,7 @@ var Util, DOM, CloudFunc;
if (paramLink)
link = paramLink;
else
link = Util.removeStr(href, CloudCmd.HOST);
link = Util.rmStr(href, CloudCmd.HOST);
link += '?json';
@ -80,7 +80,7 @@ var Util, DOM, CloudFunc;
function currentToParent(dirName) {
var rootDir;
/* убираем слэш с имени каталога */
dirName = Util.removeStr(dirName, '/');
dirName = Util.rmStr(dirName, '/');
rootDir = DOM.getCurrentFileByName(dirName);
if (rootDir)
@ -106,12 +106,12 @@ var Util, DOM, CloudFunc;
if (path && !name) {
name = Util.getStrBigFirst(path);
name = Util.removeStr(name, '.js');
name = Util.rmStr(name, '.js');
slash = name.indexOf('/');
if (slash > 0) {
afterSlash = name.substr(slash);
name = Util.removeStr(name, afterSlash);
name = Util.rmStr(name, afterSlash);
}
}
@ -361,8 +361,8 @@ var Util, DOM, CloudFunc;
var SLASH = '/',
dirPath = DOM.getCurrentDirPath(),
fsPath = decodeURI(path),
noJSONPath = Util.removeStr(fsPath, '?json' ),
cleanPath = Util.removeStrOneTime(noJSONPath, CloudFunc.FS) || SLASH,
noJSONPath = Util.rmStr(fsPath, '?json' ),
cleanPath = Util.rmStrOnce(noJSONPath, CloudFunc.FS) || SLASH,
setTitle = function() {
var title;

View file

@ -785,7 +785,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
lHref = CloudFunc.rmLastSlash(lHref);
lSubstr = lHref.substr(lHref , lHref.lastIndexOf('/'));
ret = Util.removeStrOneTime(lHref, lSubstr + '/') || '/';
ret = Util.rmStrOnce(lHref, lSubstr + '/') || '/';
return ret;
};
@ -814,7 +814,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
ret = '/';
if (path !== '/')
ret = Util.removeStr(path, dirName);
ret = Util.rmStr(path, dirName);
return ret;
};
@ -877,7 +877,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
size = size.textContent;
/* если это папка - возвращаем слово dir вместо размера*/
ret = Util.removeStrOneTime(size, ['<', '>']);
ret = Util.rmStrOnce(size, ['<', '>']);
return ret;
};
@ -1331,7 +1331,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
lPath = decodeURI(lPath);
/* убираем адрес хоста*/
lPath = Util.removeStrOneTime( lPath, [CloudCmd.HOST, CloudFunc.FS] );
lPath = Util.rmStrOnce(lPath, [CloudCmd.HOST, CloudFunc.FS]);
return lPath;
};

View file

@ -96,7 +96,7 @@ var Util, DOM, CloudCmd;
n = pathLinks.length;
for (i = 0; i < n; i++) {
ai = pathLinks[i];
link = Util.removeStr(ai.href, url),
link = Util.rmStr(ai.href, url),
loadDir = CloudCmd.loadDir(link, false, panel),
Events.addClick(loadDir, ai);
OnPathLinks.push(loadDir);
@ -123,7 +123,7 @@ var Util, DOM, CloudCmd;
n = pathLinks.length;
for (i = 0; i < n; i++) {
ai = pathLinks[i];
link = Util.removeStr(ai.href, url),
link = Util.rmStr(ai.href, url),
loadDir = OnPathLinks.shift();
Events.rmClick(loadDir, ai);

View file

@ -26,7 +26,7 @@ var Util, DOM;
if (isStr) {
num = src.lastIndexOf('/') + 1,
sub = src.substr(src, num),
id = Util.removeStrOneTime(src, sub);
id = Util.rmStrOnce(src, sub);
/* убираем точки */
while (id.indexOf('.') > 0)

View file

@ -72,7 +72,7 @@ var CloudCmd, Util, DOM, CloudFunc, Github, cb;
DOM.ajax({
type : 'put',
url : config && config.apiURL + '/auth',
data : Util.removeStr(code, '?code='),
data : Util.rmStr(code, '?code='),
success : function(data) {
if (data && data.token) {
token = data.token;

View file

@ -110,7 +110,7 @@ var Util;
*/
this.rmNewLine = function(text) {
var strs = ['\n', '\r'],
str = Util.removeStr(text, strs);
str = Util.rmStr(text, strs);
return str;
};
@ -128,7 +128,7 @@ var Util;
};
this.getJoinArray = function(url) {
var str = Util.removeStrOneTime(url, JOIN),
var str = Util.rmStrOnce(url, JOIN),
names = str.split(':');
return names;
@ -168,7 +168,7 @@ var Util;
isContain = Util.isContainStrAtBegin(str, '/');
if (isContain)
ret = Util.removeStrOneTime(str, '/');
ret = Util.rmStrOnce(str, '/');
return ret;
};
@ -343,7 +343,7 @@ var Util;
var lUrl = folders[i],
lSlashIndex = lUrl.lastIndexOf('/') + 1;
lShortName = Util.removeStr(lUrl, lUrl.substr(lUrl, lSlashIndex));
lShortName = Util.rmStr(lUrl, lUrl.substr(lUrl, lSlashIndex));
if (i !== 1)
lHtmlPath += lHref + FS + lUrl +

View file

@ -244,14 +244,14 @@
function onCloudCmd(pCommand, callback) {
var lRet;
pCommand = Util.removeStr(pCommand, CLOUDCMD);
pCommand = Util.rmStr(pCommand, CLOUDCMD);
if (!equalPart(pCommand, ' ')) {
lRet = true;
Util.exec(callback, HELP);
}
else {
pCommand = Util.removeStr(pCommand, ' ');
pCommand = Util.rmStr(pCommand, ' ');
if (equalPart(pCommand, 'update') && update) {
lRet = true;
@ -272,7 +272,7 @@
function onCD(pCommand, currDir, callback) {
var dir,
getDir = WIN32 ? 'chdir' : 'pwd',
paramDir = Util.removeStr(pCommand, 'cd ');
paramDir = Util.rmStr(pCommand, 'cd ');
if (equalPart(paramDir, ['/', '~']))
dir = paramDir;

View file

@ -80,7 +80,7 @@
ret = Util.isContainStr(name, apiURL);
if (ret) {
name = Util.removeStrOneTime(name, apiURL) || '/';
name = Util.rmStrOnce(name, apiURL) || '/';
sendData({
request : request,
response : response,
@ -134,7 +134,7 @@
});
else {
if (p.name[0] === '/')
p.command = Util.removeStrOneTime(p.name, '/');
p.command = Util.rmStrOnce(p.name, '/');
switch(p.request.method) {
case 'GET':
@ -164,7 +164,7 @@
if (ret) {
p = params;
query = main.getQuery(p.request);
p.name = Util.removeStrOneTime(p.name, CloudFunc.FS) || '/';
p.name = Util.rmStrOnce(p.name, CloudFunc.FS) || '/';
switch (p.request.method) {
case 'GET':
@ -363,7 +363,7 @@
else
pipe.create({
from : files.from,
to : files.to || Util.removeStrOneTime(files.from, ['.zip', '.gzip']),
to : files.to || Util.rmStrOnce(files.from, ['.zip', '.gzip']),
gunzip : true,
callback : function(error) {
var name = path.basename(files.from);

View file

@ -16,7 +16,7 @@
switch(method) {
case 'GET':
name = Util.removeStrOneTime(name, '/markdown');
name = Util.rmStrOnce(name, '/markdown');
query = main.getQuery(request);
if (query === 'relative')

View file

@ -63,11 +63,11 @@
line = passwd.substr(passwd, passwd.indexOf('\n') + 1);
if (line) {
passwd = Util.removeStr(passwd, line);
passwd = Util.rmStr(passwd, line);
/* получаем первое слово строки */
name = line.substr(line, line.indexOf(':'));
line = Util.removeStr(line, name + ':x:');
line = Util.rmStr(line, name + ':x:');
/* получаем uid */
uid = line.substr(line, line.indexOf(':'));

View file

@ -45,7 +45,7 @@
exec('chcp ' + Charset.WIN32);
if(!error) {
volumes = Util.removeStr(stdout, removeStr)
volumes = Util.rmStr(stdout, removeStr)
.split(' ');
volumes.pop();

View file

@ -462,7 +462,7 @@
* @param str
* @param substr
*/
this.removeStr = function(str, substr) {
this.rmStr = function(str, substr) {
var n, isArray,
isString = Util.isString(str);
@ -481,12 +481,12 @@
return str;
};
/**
/**
* function remove substring from string one time
* @param pStr
* @param pSubStr
* @param str
* @param substr
*/
this.removeStrOneTime = function(str, substr) {
this.rmStrOnce = function(str, substr) {
var n, isArray,
isString = Util.isString(str);
@ -534,7 +534,7 @@
this.convertName = function(name) {
var conv = name && name.toLowerCase();
conv = Util.removeStr(conv, ['(', ')']);
conv = Util.rmStr(conv, ['(', ')']);
conv = Util.replaceStr(conv, ' ', '-');
return conv;