mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-04 05:33:10 +00:00
feature(storage) change to async
This commit is contained in:
parent
059b2f054b
commit
961584ba65
4 changed files with 106 additions and 102 deletions
|
|
@ -267,9 +267,13 @@ var Util, DOM, CloudFunc;
|
|||
|
||||
dirPath = CloudFunc.rmLastSlash(dirPath) || '/';
|
||||
|
||||
if (!Storage.get(dirPath))
|
||||
Storage.set(dirPath, getJSONfromFileTable());
|
||||
Storage.get(dirPath, function(data) {
|
||||
if (!data) {
|
||||
data = getJSONfromFileTable();
|
||||
Storage.set(dirPath, data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Util.exec(CloudCmd.Key);
|
||||
Util.exec(pCallBack);
|
||||
|
|
@ -336,9 +340,7 @@ var Util, DOM, CloudFunc;
|
|||
* { refresh, nohistory } - необходимость обновить данные о каталоге
|
||||
*/
|
||||
this.ajaxLoad = function(path, options) {
|
||||
var json, str,
|
||||
ret = options && options.refresh,
|
||||
SLASH = '/',
|
||||
var SLASH = '/',
|
||||
dirPath = DOM.getCurrentDirPath(),
|
||||
fsPath = decodeURI(path),
|
||||
noJSONPath = Util.removeStr(fsPath, '?json' ),
|
||||
|
|
@ -372,37 +374,24 @@ var Util, DOM, CloudFunc;
|
|||
* если стоит поле обязательной перезагрузки -
|
||||
* перезагружаемся
|
||||
*/
|
||||
if (!ret) {
|
||||
str = Storage.get(cleanPath);
|
||||
Storage.get(cleanPath, function(json) {
|
||||
var ret = options && options.refresh;
|
||||
|
||||
if (!str)
|
||||
ret = true;
|
||||
else {
|
||||
json = Util.parseJSON(str);
|
||||
if (!ret && json) {
|
||||
json = Util.parseJSON(json);
|
||||
CloudCmd.createFileTable(json);
|
||||
setTitle();
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
DOM.getCurrentFileContent({
|
||||
url : fsPath,
|
||||
dataType : 'json',
|
||||
success : function(data) {
|
||||
var str = Util.stringifyJSON(data),
|
||||
MAX_SIZE = 50000;
|
||||
|
||||
setTitle();
|
||||
|
||||
CloudCmd.createFileTable(data);
|
||||
Util.log(str.length);
|
||||
|
||||
/* если размер данных не очень бошьой *
|
||||
* сохраняем их в кэше */
|
||||
if (str.length < MAX_SIZE)
|
||||
Storage.set(cleanPath, str);
|
||||
}
|
||||
});
|
||||
} else
|
||||
DOM.getCurrentFileContent({
|
||||
url : fsPath,
|
||||
dataType : 'json',
|
||||
success : function(json) {
|
||||
setTitle();
|
||||
CloudCmd.createFileTable(json);
|
||||
Storage.set(cleanPath, json);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue