2016-01-13 13:58:12 -07:00
|
|
|
|
(function (globalScope) {
|
2014-10-23 21:54:35 -07:00
|
|
|
|
|
|
|
|
|
function myStore(defaultObject) {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
self.localData = {};
|
|
|
|
|
|
|
|
|
|
var isDefaultAvailable;
|
|
|
|
|
|
|
|
|
|
if (defaultObject) {
|
|
|
|
|
try {
|
|
|
|
|
defaultObject.setItem('_test', '0');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
defaultObject.removeItem('_test');
|
2014-10-23 21:54:35 -07:00
|
|
|
|
isDefaultAvailable = true;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.setItem = function (name, value) {
|
|
|
|
|
|
|
|
|
|
if (isDefaultAvailable) {
|
|
|
|
|
defaultObject.setItem(name, value);
|
|
|
|
|
} else {
|
|
|
|
|
self.localData[name] = value;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.getItem = function (name) {
|
|
|
|
|
|
|
|
|
|
if (isDefaultAvailable) {
|
|
|
|
|
return defaultObject.getItem(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self.localData[name];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.removeItem = function (name) {
|
|
|
|
|
|
|
|
|
|
if (isDefaultAvailable) {
|
|
|
|
|
defaultObject.removeItem(name);
|
|
|
|
|
} else {
|
|
|
|
|
self.localData[name] = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 13:58:12 -07:00
|
|
|
|
globalScope.appStorage = new myStore(globalScope.localStorage);
|
|
|
|
|
globalScope.sessionStore = new myStore(globalScope.sessionStorage);
|
2014-10-23 21:54:35 -07:00
|
|
|
|
|
2016-01-13 13:58:12 -07:00
|
|
|
|
})(this);
|