| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | import {UIEventSource} from "./Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2020-09-02 11:37:34 +02:00
										 |  |  | import {GenerateEmpty} from "./UI/CustomGenerator/GenerateEmpty"; | 
					
						
							| 
									
										
										
										
											2020-09-03 00:00:37 +02:00
										 |  |  | import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson"; | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  | import {OsmConnection} from "./Logic/Osm/OsmConnection"; | 
					
						
							|  |  |  | import CustomGeneratorPanel from "./UI/CustomGenerator/CustomGeneratorPanel"; | 
					
						
							|  |  |  | import {LocalStorageSource} from "./Logic/Web/LocalStorageSource"; | 
					
						
							| 
									
										
										
										
											2021-04-11 23:43:23 +02:00
										 |  |  | import {Utils} from "./Utils"; | 
					
						
							|  |  |  | import LZString from "lz-string"; | 
					
						
							| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 02:05:09 +02:00
										 |  |  | let layout = GenerateEmpty.createEmptyLayout(); | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  | if (window.location.hash.length > 10) { | 
					
						
							| 
									
										
										
										
											2021-04-11 23:43:23 +02:00
										 |  |  |     const hash = window.location.hash.substr(1) | 
					
						
							| 
									
										
										
										
											2021-04-11 22:32:36 +02:00
										 |  |  |     try{ | 
					
						
							| 
									
										
										
										
											2021-04-11 23:43:23 +02:00
										 |  |  |         layout = JSON.parse(atob(hash)) as LayoutConfigJson; | 
					
						
							| 
									
										
										
										
											2021-04-11 22:32:36 +02:00
										 |  |  |     }catch(e){ | 
					
						
							|  |  |  |         console.log("Initial load of theme failed, attempt nr 2 with decompression", e) | 
					
						
							| 
									
										
										
										
											2021-04-11 23:43:23 +02:00
										 |  |  |         layout =  JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(hash))) | 
					
						
							| 
									
										
										
										
											2021-04-11 22:32:36 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  | } else { | 
					
						
							|  |  |  |     const hash = LocalStorageSource.Get("last-custom-theme").data | 
					
						
							|  |  |  |     if (hash !== undefined) { | 
					
						
							| 
									
										
										
										
											2020-09-03 19:05:18 +02:00
										 |  |  |         console.log("Using theme from local storage") | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |         layout = JSON.parse(atob(hash)) as LayoutConfigJson; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-03 00:00:37 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  | const connection = new OsmConnection(false, new UIEventSource<string>(undefined), "customGenerator", false); | 
					
						
							| 
									
										
										
										
											2020-09-02 11:37:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  | new CustomGeneratorPanel(connection, layout) | 
					
						
							| 
									
										
										
										
											2020-09-02 11:37:34 +02:00
										 |  |  |     .AttachTo("maindiv"); | 
					
						
							| 
									
										
										
										
											2020-08-08 21:17:17 +02:00
										 |  |  | 
 |