mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(dom) add getDataFromCache, saveDataInCache
This commit is contained in:
parent
ac6d4d6c91
commit
2332b147e5
1 changed files with 67 additions and 2 deletions
|
|
@ -1485,6 +1485,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
lName += lExt;
|
||||
}
|
||||
|
||||
DOM.saveDataInCache(lName, pData);
|
||||
|
||||
Util.exec(pCallBack, {
|
||||
data: pData,
|
||||
name: lName
|
||||
|
|
@ -1498,9 +1500,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
success : lFunc,
|
||||
error : pCallBack.error
|
||||
};
|
||||
|
||||
|
||||
return this.getCurrentFileContent(lParams, lCurrentFile);
|
||||
var lName = DOM.getCurrentName(lCurrentFile);
|
||||
|
||||
DOM.getDataFromCache(lName, function(data) {
|
||||
if (data)
|
||||
lFunc(data);
|
||||
else
|
||||
DOM.getCurrentFileContent(lParams, lCurrentFile);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1731,6 +1739,63 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
return lLink;
|
||||
};
|
||||
|
||||
/**
|
||||
* save data to storage
|
||||
*
|
||||
* @param name
|
||||
* @param data
|
||||
* @param callback
|
||||
*/
|
||||
this.saveDataInCache = function(name, data, callback) {
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var allowed = config.localStorage;
|
||||
|
||||
if (!allowed)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
Cache.set(name + '-data', data);
|
||||
DOM.loadCurrentHash(function(hash) {
|
||||
var isContain = Util.isContainStr(hash, 'error');
|
||||
|
||||
if (!isContain)
|
||||
Cache.set(name + '-hash', hash);
|
||||
|
||||
Util.exec(callback, hash);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* save data to storage
|
||||
*
|
||||
* @param name
|
||||
* @param data
|
||||
* @param callback
|
||||
*/
|
||||
this.getDataFromCache = function(name, callback) {
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var hash, allowed = config.localStorage,
|
||||
isDir = DOM.isCurrentIsDir();
|
||||
|
||||
if (!allowed || isDir)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
hash = Cache.get(name + '-hash');
|
||||
|
||||
DOM.loadCurrentHash(function(pHash) {
|
||||
var data,
|
||||
isContain = Util.isContainStr(hash, 'error');
|
||||
|
||||
if (!isContain && hash === pHash)
|
||||
data = Cache.get(name + '-data');
|
||||
|
||||
Util.exec(callback, data);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** function getting FM
|
||||
* @param pPanel_o = {active: true}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue