mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
(function (globalScope) {
|
|
|
|
function myStore(defaultObject) {
|
|
|
|
var self = this;
|
|
self.localData = {};
|
|
|
|
var isDefaultAvailable;
|
|
|
|
if (defaultObject) {
|
|
try {
|
|
defaultObject.setItem('_test', '0');
|
|
defaultObject.removeItem('_test');
|
|
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;
|
|
}
|
|
};
|
|
}
|
|
|
|
globalScope.appStorage = new myStore(globalScope.localStorage);
|
|
globalScope.sessionStore = new myStore(globalScope.sessionStorage);
|
|
|
|
})(this); |