refactor(dom) promptDeleteSelected: lCurrent -> current

This commit is contained in:
coderaiser 2014-02-11 07:01:45 -05:00
parent 3d4f9a8034
commit 6aacedb656

View file

@ -762,7 +762,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*/
this.promptDeleteSelected = function(pCurrentFile) {
var ret, type, isDir, path,
lCurrent, query, msg,
current, query, msg,
name = '',
msgAsk = 'Do you really want to delete the ',
msgSel = 'selected ',
@ -771,9 +771,11 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
i, n = names && names.length;
if (!Cmd.isCurrentFile(pCurrentFile))
pCurrentFile = null;
current = DOM.getCurrentFile();
if (n > 1) {
path = Cmd.getCurrentDirPath();
for (i = 0; i < 5 && i < n; i++)
name += '\n' + names[i];
@ -783,13 +785,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
msg = msgAsk + msgSel + n + ' files/directoris?\n' + name ;
query = '?files';
} else {
/* dom element passed and it is not event */
if (pCurrentFile && !pCurrentFile.pType)
lCurrent = pCurrentFile;
else
lCurrent = Cmd.getCurrentFile();
isDir = Cmd.isCurrentIsDir(lCurrent);
path = Cmd.getCurrentPath(current);
isDir = Cmd.isCurrentIsDir(current);
if (isDir) {
query = '?dir';
@ -800,7 +797,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
type += ' ';
name = Cmd.getCurrentName(lCurrent);
name = Cmd.getCurrentName(current);
msg = msgAsk + msgSel + type + name + '?';
}
@ -810,20 +807,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
Dialog.alert('No files selected!');
if (ret) {
if (lCurrent)
path = Cmd.getCurrentPath(lCurrent);
else
path = Cmd.getCurrentDirPath();
if (lCurrent || selected)
RESTful.delete(path, selected, function() {
if (current || names)
RESTful.delete(path, names, function() {
var dirPath = CurrentInfo.dirPath,
dir = CloudFunc.rmLastSlash(dirPath);
if (n > 1)
DOM.deleteSelected(files);
else
DOM.deleteCurrent(lCurrent);
DOM.deleteCurrent(current);
Storage.remove(dir);
}, query);