mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
7dfb9f1967
* initial commit of webconfig * update example config with webconfig and fix format of file update debian postinst script for install example config
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/*global define */
|
|
define(['lib/stapes'], function (Stapes) {
|
|
'use strict';
|
|
return Stapes.subclass(/** @lends LocalStorage.prototype */{
|
|
|
|
/**
|
|
* @class LocalStorage
|
|
* @classdesc LocalStorage handler using HTML5 localStorage
|
|
* @constructs
|
|
*
|
|
* @fires got
|
|
* @fires error
|
|
* @fires set
|
|
*/
|
|
constructor: function () {
|
|
},
|
|
|
|
/**
|
|
* Gets stored data
|
|
*/
|
|
get: function () {
|
|
var data;
|
|
|
|
if (!window.localStorage) {
|
|
this.emit('error', 'Local Storage not supported');
|
|
return;
|
|
}
|
|
|
|
if (localStorage.data) {
|
|
data = JSON.parse(localStorage.data);
|
|
this.emit('got', data);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Stores settings
|
|
* @param {object} data - Data object to store
|
|
*/
|
|
set: function (data) {
|
|
if (!window.localStorage) {
|
|
this.emit('error', 'Local Storage not supported');
|
|
return;
|
|
}
|
|
|
|
localStorage.data = JSON.stringify(data);
|
|
this.emit('set');
|
|
}
|
|
});
|
|
});
|