/
usr
/
local
/
jetapps
/
frontend
/
jetbackup
/
app
/
services
/
File Upload :
llllll
Current File: //usr/local/jetapps/frontend/jetbackup/app/services/storage.js
'use strict'; define([ 'app' ], function (app) { app.factory('storage', [function() { var STORAGE = function(pool_name) { if(pool_name === undefined) throw Error("You must provide pool name"); this._storage_name = 'JetBackupStorage_' + pool_name; this._data = {}; var storageData = localStorage.getItem(this._storage_name); if(storageData === undefined) this.save(); else this.setData(JSON.parse(storageData)); }; STORAGE.prototype = { _storage_name: undefined, _data: null, set: function (key, value) { this._data[key] = value; }, get: function (key, defaultValue) { return this._data[key] !== undefined ? this._data[key] : defaultValue; }, isSet: function(key) { return this._data[key] !== undefined; }, remove: function(key) { delete this._data[key]; }, save: function() { localStorage.setItem(this._storage_name, JSON.stringify(this._data)); }, setData: function (data) { if(data) this._data = data; }, getData: function () { return this._data; }, destroy: function () { localStorage.removeItem(this._storage_name); this._data={}; } }; return { create: function(pool_name) { return new STORAGE(pool_name); }, delete: function (pool_name) { if(pool_name === undefined) throw Error("You must provide pool name"); localStorage.removeItem('JetBackupStorage_' + pool_name); }, deleteAll: function () { localStorage.clear(); }, exists: function (pool_name) { return !!localStorage.getItem('JetBackupStorage_' + pool_name); } }; }]); });
Copyright ©2k19 -
Hexid
|
Tex7ure