feature(cloudfunc) rm rmLastSlash

This commit is contained in:
coderaiser 2015-07-21 11:06:57 -04:00
parent afeb59b1ca
commit a4a18fe920
6 changed files with 15 additions and 66 deletions

View file

@ -49,22 +49,18 @@ var Util, DOM, CloudFunc, join;
* @param callback
*/
this.loadDir = function(params, callback) {
var link, imgPosition, panelChanged, pathParams,
var imgPosition, panelChanged,
noCurrent,
isRefresh, panel, history,
p = params;
if (params) {
pathParams = p.path;
isRefresh = p.isRefresh;
panel = p.panel;
history = p.history;
noCurrent = p.noCurrent;
}
if (pathParams)
link = pathParams;
if (!noCurrent)
if (panel && panel !== Info.panel) {
DOM.changePanel();
@ -77,7 +73,7 @@ var Util, DOM, CloudFunc, join;
Images.show.load(imgPosition, panel);
/* загружаем содержимое каталога */
ajaxLoad(link, {
ajaxLoad(p.path, {
refresh : isRefresh,
history : history,
noCurrent : noCurrent
@ -296,9 +292,6 @@ var Util, DOM, CloudFunc, join;
Listeners.initKeysPanel();
/* Устанавливаем кэш корневого каталога */
dirPath = CloudFunc.rmLastSlash(dirPath);
Storage.get(dirPath, function(error, data) {
if (!data) {
data = getJSONfromFileTable();
@ -330,8 +323,7 @@ var Util, DOM, CloudFunc, join;
var panel = panelParam || Info.panel,
noCurrent,
NEEDREFRESH = true,
path = DOM.getCurrentDirPath(panel),
notSlashlLink = CloudFunc.rmLastSlash(path);
path = DOM.getCurrentDirPath(panel);
if (options)
noCurrent = options.noCurrent;
@ -342,7 +334,7 @@ var Util, DOM, CloudFunc, join;
}
CloudCmd.loadDir({
path : notSlashlLink,
path : path,
isRefresh : NEEDREFRESH,
history : false,
panel : panel,
@ -511,7 +503,6 @@ var Util, DOM, CloudFunc, join;
if (path !== parentPath) {
path = parentPath;
path = CloudFunc.rmLastSlash(path);
CloudCmd.loadDir({
path: path

View file

@ -500,13 +500,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*/
this.getCurrentDirName = function() {
var ret,
lSubstr,
substr,
/* получаем имя каталога в котором находимся */
lHref = this.getCurrentDirPath();
href = this.getCurrentDirPath();
lHref = CloudFunc.rmLastSlash(lHref);
lSubstr = lHref.substr(lHref, lHref.lastIndexOf('/'));
ret = lHref.replace(lSubstr + '/', '') || '/';
href = href.replace(/\/$/, '');
substr = href.substr(href, href.lastIndexOf('/'));
ret = href.replace(substr + '/', '') || '/';
return ret;
};
@ -1418,13 +1418,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
};
RESTful.mv(files, function(error) {
var Storage = DOM.Storage,
path = CloudFunc.rmLastSlash(dirPath);
var Storage = DOM.Storage;
if (!error) {
DOM.setCurrentName(to, current);
Cmd.updateCurrentInfo();
Storage.remove(path);
Storage.remove(dirPath);
if (isExist)
CloudCmd.refresh();

View file

@ -50,8 +50,6 @@
'P': function() {
var command = Console.getPromptText(),
path = DOM.getCurrentDirPath();
path = rmLastSlash(path);
command += path;
Console.setPromptText(command);
@ -59,10 +57,6 @@
});
}
function rmLastSlash(str) {
return str.replace(/\/$/, '');
}
this.show = function(callback) {
if (Loaded)
CloudCmd.View.show(Element, {

View file

@ -167,8 +167,6 @@ var Util, DOM, CloudFunc, CloudCmd;
isDir = DOM.isCurrentIsDir(current),
path = DOM.getCurrentPath(current);
path = CloudFunc.rmLastSlash(path);
if (isDir) {
CloudCmd.loadDir({
path: path

View file

@ -31,10 +31,6 @@
Operation = this;
function rmLastSlash(str) {
return str.replace(/\/$/, '');
}
function init() {
showLoad();
@ -295,8 +291,7 @@
deleteFn(path + query, names, function(error) {
var Storage = DOM.Storage,
dirPath = Info.dirPath,
dir = rmLastSlash(dirPath);
dirPath = Info.dirPath;
if (!error) {
if (n > 1)
@ -304,7 +299,7 @@
else
DOM.deleteCurrent(current);
Storage.removeMatch(dir);
Storage.removeMatch(dirPath);
}
});
}
@ -372,9 +367,7 @@
};
operation(files, function(error) {
var path = rmLastSlash(from);
!error && DOM.Storage.remove(path, function() {
!error && DOM.Storage.remove(from, function() {
var panel = Info.panel,
panelPassive = Info.panelPassive,
setCurrent = function() {

View file

@ -69,30 +69,10 @@ var Util;
else
name = '';
msg = msg + ': ' + status + name;
return msg;
};
/**
* Функция убирает последний слеш,
* если он - последний символ строки
*/
this.rmLastSlash = function(path) {
var length, lastSlash, isEqual;
if (typeof path !== 'string')
throw(Error('path should be a string!'));
length = path.length - 1;
lastSlash = path.lastIndexOf('/');
isEqual = lastSlash === length;
if (length && isEqual)
path = path.substr(path, length);
return path;
};
/** Функция возвращает заголовок веб страницы
* @pPath
@ -173,14 +153,8 @@ var Util;
*/
htmlPath = getPathLink(path, template.pathLink),
/* Убираем последний слэш
* с пути для кнопки обновить страницу
* если он есть
*/
refreshPath = CloudFunc.rmLastSlash(path),
fileTable = rendy(template.path, {
link : FS + refreshPath,
link : FS + path,
fullPath : path,
path : htmlPath
}),