mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
chore(dom) promptDeleteSelected
This commit is contained in:
parent
ef8b02375a
commit
daa8ac9e44
1 changed files with 24 additions and 26 deletions
|
|
@ -761,27 +761,27 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* @pCurrentFile
|
||||
*/
|
||||
this.promptDeleteSelected = function(pCurrentFile) {
|
||||
var lRet,
|
||||
lCurrent, lQuery, lMsg,
|
||||
lName = '',
|
||||
lMsgAsk = 'Do you really want to delete the ',
|
||||
lMsgSel = 'selected ',
|
||||
lFiles = Cmd.getSelectedFiles(),
|
||||
lSelected = Cmd.getSelectedNames(lFiles),
|
||||
i, n = lSelected && lSelected.length;
|
||||
var ret,
|
||||
lCurrent, query, msg,
|
||||
name = '',
|
||||
msgAsk = 'Do you really want to delete the ',
|
||||
msgSel = 'selected ',
|
||||
files = Cmd.getSelectedFiles(),
|
||||
selected = Cmd.getSelectedNames(files),
|
||||
i, n = selected && selected.length;
|
||||
|
||||
if (!Cmd.isCurrentFile(pCurrentFile))
|
||||
pCurrentFile = null;
|
||||
|
||||
if (n > 1) {
|
||||
for (i = 0; i < 5 && i < n; i++)
|
||||
lName += '\n' + lSelected[i];
|
||||
name += '\n' + selected[i];
|
||||
|
||||
if (n >= 5)
|
||||
lName += '\n...';
|
||||
name += '\n...';
|
||||
|
||||
lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ;
|
||||
lQuery = '?files';
|
||||
msg = msgAsk + msgSel + n + ' files/directoris?\n' + name ;
|
||||
query = '?files';
|
||||
} else {
|
||||
var lType, lIsDir;
|
||||
|
||||
|
|
@ -794,7 +794,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
lIsDir = Cmd.isCurrentIsDir(lCurrent);
|
||||
|
||||
if (lIsDir) {
|
||||
lQuery = '?dir';
|
||||
query = '?dir';
|
||||
lType ='directory';
|
||||
}
|
||||
else
|
||||
|
|
@ -802,42 +802,40 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
lType += ' ';
|
||||
|
||||
lName = Cmd.getCurrentName(lCurrent);
|
||||
lMsg = lMsgAsk + lMsgSel + lType + lName + '?';
|
||||
name = Cmd.getCurrentName(lCurrent);
|
||||
msg = msgAsk + msgSel + lType + name + '?';
|
||||
}
|
||||
|
||||
if (lName !== '..')
|
||||
lRet = Dialog.confirm(lMsg);
|
||||
if (name !== '..')
|
||||
ret = Dialog.confirm(msg);
|
||||
else
|
||||
Dialog.alert('No files selected!');
|
||||
|
||||
if (lRet) {
|
||||
if (ret) {
|
||||
var lUrl;
|
||||
|
||||
if (lCurrent)
|
||||
lUrl = Cmd.getCurrentPath(lCurrent);
|
||||
else {
|
||||
lUrl = Cmd.getCurrentDirPath();
|
||||
lCurrent = lFiles[0];
|
||||
lCurrent = files[0];
|
||||
}
|
||||
|
||||
if (lCurrent || lSelected)
|
||||
RESTful.delete(lUrl, lSelected, function() {
|
||||
if (lCurrent || selected)
|
||||
RESTful.delete(lUrl, selected, function() {
|
||||
var dirPath = CurrentInfo.dirPath,
|
||||
dir = CloudFunc.rmLastSlash(dirPath);
|
||||
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(lFiles);
|
||||
DOM.deleteSelected(files);
|
||||
else
|
||||
DOM.deleteCurrent(lCurrent);
|
||||
|
||||
Storage.remove(dir);
|
||||
}, lQuery);
|
||||
|
||||
return lCurrent;
|
||||
}, query);
|
||||
}
|
||||
|
||||
return lRet;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue