mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(dom) processFiles: operation, data -> data, operation
This commit is contained in:
parent
8ddec5f792
commit
d38f2e2f0e
1 changed files with 6 additions and 15 deletions
|
|
@ -1578,31 +1578,22 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
/*
|
||||
* process files (copy or move)
|
||||
* @param data
|
||||
* @param operation
|
||||
*/
|
||||
function processFiles(operation, data) {
|
||||
var name, files, opFunc,
|
||||
function processFiles(data, operation) {
|
||||
var name, files,
|
||||
panel,
|
||||
shouldAsk,
|
||||
sameName,
|
||||
ok,
|
||||
tmpl = '"{{ name }}" already exist. Overwrite?',
|
||||
RESTful = DOM.RESTful,
|
||||
|
||||
from = '',
|
||||
to = '',
|
||||
|
||||
names = [];
|
||||
|
||||
switch(operation) {
|
||||
case 'copy':
|
||||
opFunc = RESTful.cp;
|
||||
break;
|
||||
case 'move':
|
||||
opFunc = RESTful.mv;
|
||||
break;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
from = data.from;
|
||||
to = data.to;
|
||||
|
|
@ -1646,7 +1637,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
names : names
|
||||
};
|
||||
|
||||
opFunc(files, function() {
|
||||
operation(files, function() {
|
||||
var path = CloudFunc.rmLastSlash(from);
|
||||
|
||||
DOM.Storage.remove(path, function() {
|
||||
|
|
@ -1701,11 +1692,11 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
}
|
||||
|
||||
this.copyFiles = function(data) {
|
||||
processFiles('copy', data);
|
||||
processFiles(data, DOM.RESTful.cp);
|
||||
};
|
||||
|
||||
this.moveFiles = function(data) {
|
||||
processFiles('move', data);
|
||||
processFiles(data, DOM.RESTful.mv);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue