mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	* Initial WebUI with sample functions * Changed folder structure * Light Reset Button and Translation fixing in Links * Indentation fixed * Reorganized menu and new function for setting effects * Styling fix
		
			
				
	
	
		
			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');
 | |
|         }
 | |
|     });
 | |
| });
 |