| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  | import {OsmObject} from "./Logic/Osm/OsmObject"; | 
					
						
							| 
									
										
										
										
											2021-07-01 02:26:45 +02:00
										 |  |  | import DeleteButton from "./UI/Popup/DeleteWizard"; | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  | import Combine from "./UI/Base/Combine"; | 
					
						
							|  |  |  | import State from "./State"; | 
					
						
							| 
									
										
										
										
											2021-07-01 02:26:45 +02:00
										 |  |  | import DeleteWizard from "./UI/Popup/DeleteWizard"; | 
					
						
							|  |  |  | import {UIEventSource} from "./Logic/UIEventSource"; | 
					
						
							|  |  |  | import {Tag} from "./Logic/Tags/Tag"; | 
					
						
							|  |  |  | import {QueryParameters} from "./Logic/Web/QueryParameters"; | 
					
						
							|  |  |  | import {Translation} from "./UI/i18n/Translation"; | 
					
						
							| 
									
										
										
										
											2021-07-14 00:17:15 +02:00
										 |  |  | import LocationInput from "./UI/Input/LocationInput"; | 
					
						
							|  |  |  | import Loc from "./Models/Loc"; | 
					
						
							|  |  |  | import {VariableUiElement} from "./UI/Base/VariableUIElement"; | 
					
						
							| 
									
										
										
										
											2021-07-14 16:06:34 +02:00
										 |  |  | import LengthInput from "./UI/Input/LengthInput"; | 
					
						
							| 
									
										
										
										
											2021-07-20 01:33:58 +02:00
										 |  |  | import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers"; | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  | /*import ValidatedTextField from "./UI/Input/ValidatedTextField"; | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  | import Combine from "./UI/Base/Combine"; | 
					
						
							| 
									
										
										
										
											2021-06-16 14:23:53 +02:00
										 |  |  | import {VariableUiElement} from "./UI/Base/VariableUIElement"; | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  | import {UIEventSource} from "./Logic/UIEventSource"; | 
					
						
							|  |  |  | import TagRenderingConfig from "./Customizations/JSON/TagRenderingConfig"; | 
					
						
							|  |  |  | import State from "./State"; | 
					
						
							|  |  |  | import TagRenderingQuestion from "./UI/Popup/TagRenderingQuestion"; | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  | import {SlideShow} from "./UI/Image/SlideShow"; | 
					
						
							|  |  |  | import {FixedUiElement} from "./UI/Base/FixedUiElement"; | 
					
						
							|  |  |  | import Img from "./UI/Base/Img"; | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  | import {AttributedImage} from "./UI/Image/AttributedImage"; | 
					
						
							| 
									
										
										
										
											2021-06-22 14:21:32 +02:00
										 |  |  | import {Imgur} from "./Logic/ImageProviders/Imgur"; | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | import Minimap from "./UI/Base/Minimap"; | 
					
						
							|  |  |  | import Loc from "./Models/Loc"; | 
					
						
							|  |  |  | import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers"; | 
					
						
							|  |  |  | import ShowDataLayer from "./UI/ShowDataLayer"; | 
					
						
							|  |  |  | import LayoutConfig from "./Customizations/JSON/LayoutConfig"; | 
					
						
							|  |  |  | import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; | 
					
						
							| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 17:28:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | function TestSlideshow() { | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  |     const elems = new UIEventSource([ | 
					
						
							|  |  |  |         new FixedUiElement("A"), | 
					
						
							|  |  |  |         new FixedUiElement("qmsldkfjqmlsdkjfmqlskdjfmqlksdf").SetClass("text-xl"), | 
					
						
							|  |  |  |         new Img("https://i.imgur.com/8lIQ5Hv.jpg"), | 
					
						
							| 
									
										
										
										
											2021-06-21 03:14:03 +02:00
										 |  |  |         new AttributedImage("https://i.imgur.com/y5XudzW.jpg", Imgur.singleton), | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  |         new Img("https://www.grunge.com/img/gallery/the-real-reason-your-cat-sleeps-so-much/intro-1601496900.webp") | 
					
						
							|  |  |  |     ]) | 
					
						
							|  |  |  |     new SlideShow(elems).AttachTo("maindiv") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | function TestTagRendering() { | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  |     State.state = new State(undefined) | 
					
						
							|  |  |  |     const tagsSource = new UIEventSource({ | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  |         id: "node/1" | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  |     }) | 
					
						
							|  |  |  |     new TagRenderingQuestion( | 
					
						
							|  |  |  |         tagsSource, | 
					
						
							|  |  |  |         new TagRenderingConfig({ | 
					
						
							|  |  |  |             multiAnswer: false, | 
					
						
							|  |  |  |             freeform: { | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  |                 key: "valve" | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  |             }, | 
					
						
							|  |  |  |             question: "What valves are supported?", | 
					
						
							|  |  |  |             render: "This pump supports {valve}", | 
					
						
							|  |  |  |             mappings: [ | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     if: "valve=dunlop", | 
					
						
							|  |  |  |                     then: "This pump supports dunlop" | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  |                     if: "valve=shrader", | 
					
						
							|  |  |  |                     then: "shrader is supported", | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |              | 
					
						
							| 
									
										
										
										
											2021-06-22 03:16:45 +02:00
										 |  |  |         }, undefined, "test"), | 
					
						
							|  |  |  |         [] | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  |     ).AttachTo("maindiv") | 
					
						
							|  |  |  |     new VariableUiElement(tagsSource.map(tags => tags["valves"])).SetClass("alert").AttachTo("extradiv") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | function TestAllInputMethods() { | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     new Combine(ValidatedTextField.tpList.map(tp => { | 
					
						
							|  |  |  |         const tf = ValidatedTextField.InputForType(tp.name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return new Combine([tf, new VariableUiElement(tf.GetValue()).SetClass("alert")]); | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  |     })).AttachTo("maindiv") | 
					
						
							| 
									
										
										
										
											2021-06-16 21:23:03 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  | function TestMiniMap() { | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     const location = new UIEventSource<Loc>({ | 
					
						
							|  |  |  |         lon: 4.84771728515625, | 
					
						
							|  |  |  |         lat: 51.17920846421931, | 
					
						
							|  |  |  |         zoom: 14 | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     const map0 = new Minimap({ | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  |         location: location, | 
					
						
							|  |  |  |         allowMoving: true, | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |         background: new AvailableBaseLayers(location).availableEditorLayers.map(layers => layers[2]) | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     map0.SetStyle("width: 500px; height: 250px; overflow: hidden; border: 2px solid red") | 
					
						
							|  |  |  |         .AttachTo("maindiv") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const layout = AllKnownLayouts.layoutsList[1] | 
					
						
							|  |  |  |     State.state = new State(layout) | 
					
						
							|  |  |  |     console.log("LAYOUT is", layout.id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const feature = { | 
					
						
							|  |  |  |             "type": "Feature", | 
					
						
							|  |  |  |             _matching_layer_id: "bike_repair_station", | 
					
						
							|  |  |  |             "properties": { | 
					
						
							|  |  |  |                 id: "node/-1", | 
					
						
							|  |  |  |                 "amenity": "bicycle_repair_station" | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             "geometry": { | 
					
						
							|  |  |  |                 "type": "Point", | 
					
						
							|  |  |  |                 "coordinates": [ | 
					
						
							|  |  |  |                     4.84771728515625, | 
					
						
							|  |  |  |                     51.17920846421931 | 
					
						
							|  |  |  |                 ] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ; | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     State.state.allElements.addOrGetElement(feature) | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     const featureSource = new UIEventSource([{ | 
					
						
							|  |  |  |         freshness: new Date(), | 
					
						
							|  |  |  |         feature: feature | 
					
						
							|  |  |  |     }]) | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     new ShowDataLayer( | 
					
						
							|  |  |  |         featureSource, | 
					
						
							|  |  |  |         map0.leafletMap, | 
					
						
							|  |  |  |         new UIEventSource<LayoutConfig>(layout) | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     const map1 = new Minimap({ | 
					
						
							|  |  |  |             location: location, | 
					
						
							|  |  |  |             allowMoving: true, | 
					
						
							|  |  |  |             background: new AvailableBaseLayers(location).availableEditorLayers.map(layers => layers[5]) | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     map1.SetStyle("width: 500px; height: 250px; overflow: hidden; border : 2px solid black") | 
					
						
							|  |  |  |         .AttachTo("extradiv") | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     new ShowDataLayer( | 
					
						
							|  |  |  |         featureSource, | 
					
						
							|  |  |  |         map1.leafletMap, | 
					
						
							|  |  |  |         new UIEventSource<LayoutConfig>(layout) | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-06-23 02:15:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 18:06:54 +02:00
										 |  |  |     featureSource.ping() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | //*/
 | 
					
						
							| 
									
										
										
										
											2021-07-14 00:17:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-20 01:33:58 +02:00
										 |  |  | const loc = new UIEventSource<Loc>({ | 
					
						
							|  |  |  |     zoom: 24, | 
					
						
							|  |  |  |     lat: 51.21043, | 
					
						
							|  |  |  |     lon: 3.21389 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | const li = new LengthInput( | 
					
						
							|  |  |  |     AvailableBaseLayers.SelectBestLayerAccordingTo(loc, new UIEventSource<string | string[]>("map","photo")), | 
					
						
							|  |  |  |     loc | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  |     li.SetStyle("height: 30rem; background: aliceblue;") | 
					
						
							| 
									
										
										
										
											2021-07-14 00:17:15 +02:00
										 |  |  |         .AttachTo("maindiv") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | new VariableUiElement(li.GetValue().map(v => JSON.stringify(v, null, "  "))).AttachTo("extradiv") |