diff --git a/html/index.html b/html/index.html
index 9455e5d7..2f920f3f 100644
--- a/html/index.html
+++ b/html/index.html
@@ -42,6 +42,7 @@
client + 'dom.js',
client + 'loader.js',
client + 'notify.js',
+ client + 'storage.js',
lib + 'client.js',
client + 'listeners.js',
client + 'key.js'
diff --git a/lib/client/dom.js b/lib/client/dom.js
index f7bd61dd..21c87160 100644
--- a/lib/client/dom.js
+++ b/lib/client/dom.js
@@ -585,78 +585,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
}
}
},
- StorageProto = function() {
- /* приватный переключатель возможности работы с кэшем */
- var StorageAllowed;
-
- /* функция проверяет возможно ли работать с кэшем каким-либо образом */
- this.isAllowed = function() {
- var lRet = StorageAllowed && !!window.localStorage;
- return lRet;
- };
-
- /**
- * allow Storage usage
- */
- this.setAllowed = function(pAllowd) {
- StorageAllowed = pAllowd;
-
- return pAllowd;
- };
-
- /** remove element */
- this.remove = function(pItem) {
- var lRet = this;
-
- if (StorageAllowed)
- localStorage.removeItem(pItem);
-
- return lRet;
- };
-
- /** если доступен localStorage и
- * в нём есть нужная нам директория -
- * записываем данные в него
- */
- this.set = function(pName, pData) {
- var lRet = this;
-
- if (StorageAllowed && pName)
- localStorage.setItem(pName, pData);
-
- return lRet;
- },
-
- /** Если доступен Storage принимаем из него данные*/
- this.get = function(pName) {
- var lRet;
-
- if (StorageAllowed)
- lRet = localStorage.getItem(pName);
-
- return lRet;
- },
-
- /* get all Storage from local storage */
- this.getAll = function() {
- var lRet = null;
-
- if (StorageAllowed)
- lRet = localStorage;
-
- return lRet;
- };
-
- /** функция чистит весь кэш для всех каталогов*/
- this.clear = function() {
- var lRet = this;
-
- if (StorageAllowed)
- localStorage.clear();
-
- return lRet;
- };
- },
CmdProto = function() {
var Cmd = this,
@@ -805,15 +733,16 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
if (ret)
RESTful.delete(path, names, function() {
- var dirPath = CurrentInfo.dirPath,
- dir = CloudFunc.rmLastSlash(dirPath);
+ var storagee = DOM.Storage,
+ dirPath = CurrentInfo.dirPath,
+ dir = CloudFunc.rmLastSlash(dirPath);
if (n > 1)
DOM.deleteSelected(files);
else
DOM.deleteCurrent(current);
- Storage.remove(dir);
+ DOM.Storage.remove(dir);
}, query);
return ret;
@@ -1413,7 +1342,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
DOM.loadCurrentHash(function(loadHash) {
var equal, error,
nameHash = name + '-hash',
- storeHash = Storage.get(name + '-hash'),
+ storeHash = DOM.Storage.get(name + '-hash'),
isContain = Util.isContainStr(loadHash, 'error');
if (isContain)
@@ -1443,8 +1372,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
Util.exec(callback);
else
Util.ifExec(hash, function() {
- Storage.set(nameHash, hash);
- Storage.set(nameData, data);
+ var storage = DOM.Storage;
+
+ storage.set(nameHash, hash);
+ storage.set(nameData, data);
Util.exec(callback, hash);
}, function(callback) {
@@ -1466,6 +1397,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
this.getDataFromStorage = function(name, callback) {
CloudCmd.getConfig(function(config) {
var data, hash,
+ storage = DOM.Storage,
nameHash = name + '-hash',
nameData = name + '-data',
allowed = config.localStorage,
@@ -1474,8 +1406,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
if (!allowed || isDir)
Util.exec(callback);
else {
- data = Storage.get(nameData);
- hash = Storage.get(nameHash);
+ data = storage.get(nameData);
+ hash = storage.get(nameHash);
Util.exec(callback, data, hash);
}
@@ -1817,8 +1749,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
DOMTree = Util.extendProto(DOMTreeProto),
Events = Util.extendProto(EventsProto),
Images = Util.extendProto(ImagesProto),
- RESTful = Util.extendProto(RESTfulProto),
- Storage = Util.extendProto(StorageProto);
+ RESTful = Util.extendProto(RESTfulProto);
DOMProto = DOMFunc.prototype = new CmdProto();
@@ -1829,7 +1760,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
Events : Events,
RESTful : RESTful,
Images : Images,
- Storage : Storage,
Dialog : Dialog
}
]);