mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(dom) getCurrentFileContent
This commit is contained in:
parent
f81a84d575
commit
996686fd27
1 changed files with 9 additions and 24 deletions
|
|
@ -971,33 +971,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* @callback - callback function or data struct {sucess, error}
|
||||
* @currentFile
|
||||
*/
|
||||
this.getCurrentFileContent = function(pParams, currentFile) {
|
||||
var ret,
|
||||
current = currentFile || this.getCurrentFile(),
|
||||
lParams = pParams ? pParams : {},
|
||||
lPath = this.getCurrentPath(current),
|
||||
lErrorWas = pParams.error,
|
||||
lError = function(jqXHR) {
|
||||
Util.exec(lErrorWas);
|
||||
Images.showError(jqXHR);
|
||||
};
|
||||
this.getCurrentFileContent = function(callback, currentFile) {
|
||||
var RESTful = DOM.RESTful,
|
||||
current = currentFile || this.getCurrentFile(),
|
||||
isDir = this.isCurrentIsDir(currentFile),
|
||||
path = this.getCurrentPath(current);
|
||||
|
||||
if (Util.isFunction(lParams))
|
||||
lParams.success = Util.retExec(pParams);
|
||||
if (isDir)
|
||||
path += '?json';
|
||||
|
||||
lParams.error = lError;
|
||||
RESTful.read(path, callback);
|
||||
|
||||
if (this.isCurrentIsDir(currentFile))
|
||||
lPath += '?json';
|
||||
else if (!lParams.dataType)
|
||||
lParams.dataType = 'text';
|
||||
|
||||
if (!lParams.url)
|
||||
lParams.url = CloudFunc.FS + lPath;
|
||||
|
||||
ret = this.ajax(lParams);
|
||||
|
||||
return ret;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue