mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
feature(dom) rm getCurrentFileContent
This commit is contained in:
parent
996686fd27
commit
3b82890b47
1 changed files with 8 additions and 27 deletions
|
|
@ -965,37 +965,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* unified way to get current file content
|
||||
*
|
||||
* @callback - callback function or data struct {sucess, error}
|
||||
* @currentFile
|
||||
*/
|
||||
this.getCurrentFileContent = function(callback, currentFile) {
|
||||
var RESTful = DOM.RESTful,
|
||||
current = currentFile || this.getCurrentFile(),
|
||||
isDir = this.isCurrentIsDir(currentFile),
|
||||
path = this.getCurrentPath(current);
|
||||
|
||||
if (isDir)
|
||||
path += '?json';
|
||||
|
||||
RESTful.read(path, callback);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* unified way to get current file content
|
||||
*
|
||||
* @callback - function({data, name}) {}
|
||||
* @currentFile
|
||||
* @param callback
|
||||
* @param currentFile
|
||||
*/
|
||||
this.getCurrentData = function(callback, currentFile) {
|
||||
var hash,
|
||||
currentFile = currentFile ? currentFile : Cmd.getCurrentFile(),
|
||||
path = DOM.getCurrentPath(currentFile),
|
||||
isDir = DOM.isCurrentIsDir(currentFile),
|
||||
RESTful = DOM.RESTful,
|
||||
current = currentFile || DOM.getCurrentFile(),
|
||||
path = DOM.getCurrentPath(current),
|
||||
isDir = DOM.isCurrentIsDir(current),
|
||||
|
||||
func = function(data) {
|
||||
var length,
|
||||
|
|
@ -1012,14 +993,14 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
};
|
||||
|
||||
if (isDir)
|
||||
DOM.getCurrentFileContent(func, currentFile);
|
||||
RESTful.read(path + '?json', func);
|
||||
else
|
||||
DOM.checkStorageHash(path, function(error, equal, hashNew) {
|
||||
Util.ifExec(!error && equal, function() {
|
||||
DOM.getDataFromStorage(path, callback);
|
||||
}, function() {
|
||||
hash = hashNew;
|
||||
DOM.getCurrentFileContent(func, currentFile);
|
||||
RESTful.read(path, func);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue