forked from MapComplete/MapComplete
		
	Add binoculars theme, auto reformat everything
This commit is contained in:
		
							parent
							
								
									38dea806c5
								
							
						
					
					
						commit
						78d6482c88
					
				
					 586 changed files with 115573 additions and 111842 deletions
				
			
		|  | @ -4,19 +4,19 @@ import {UIEventSource} from "../UIEventSource"; | |||
|  * UIEventsource-wrapper around localStorage | ||||
|  */ | ||||
| export class LocalStorageSource { | ||||
|      | ||||
|     static GetParsed<T>(key: string, defaultValue : T) : UIEventSource<T>{ | ||||
| 
 | ||||
|     static GetParsed<T>(key: string, defaultValue: T): UIEventSource<T> { | ||||
|         return LocalStorageSource.Get(key).map( | ||||
|             str => { | ||||
|                 if(str === undefined){ | ||||
|                 if (str === undefined) { | ||||
|                     return defaultValue | ||||
|                 } | ||||
|                 try{ | ||||
|                 try { | ||||
|                     return JSON.parse(str) | ||||
|                 }catch{ | ||||
|                 } catch { | ||||
|                     return defaultValue | ||||
|                 } | ||||
|             }, [],  | ||||
|             }, [], | ||||
|             value => JSON.stringify(value) | ||||
|         ) | ||||
|     } | ||||
|  | @ -24,17 +24,17 @@ export class LocalStorageSource { | |||
|     static Get(key: string, defaultValue: string = undefined): UIEventSource<string> { | ||||
|         try { | ||||
|             const saved = localStorage.getItem(key); | ||||
|             const source = new UIEventSource<string>(saved ?? defaultValue, "localstorage:"+key); | ||||
|             const source = new UIEventSource<string>(saved ?? defaultValue, "localstorage:" + key); | ||||
| 
 | ||||
|             source.addCallback((data) => { | ||||
|                 try{ | ||||
|                 try { | ||||
|                     localStorage.setItem(key, data); | ||||
|                 }catch(e){ | ||||
|                 } catch (e) { | ||||
|                     // Probably exceeded the quota with this item!
 | ||||
|                     // Lets nuke everything
 | ||||
|                     localStorage.clear() | ||||
|                 } | ||||
|                  | ||||
| 
 | ||||
|             }); | ||||
|             return source; | ||||
|         } catch (e) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue