| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import { UIEventSource } from "../Logic/UIEventSource" | 
					
						
							|  |  |  | import { QueryParameters } from "../Logic/Web/QueryParameters" | 
					
						
							|  |  |  | import Hash from "../Logic/Web/Hash" | 
					
						
							| 
									
										
										
										
											2021-11-03 00:44:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export class DefaultGuiState { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     static state: DefaultGuiState | 
					
						
							| 
									
										
										
										
											2023-01-06 03:46:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public readonly welcomeMessageIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>( | 
					
						
							|  |  |  |         false | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     public readonly downloadControlIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>( | 
					
						
							|  |  |  |         false | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     public readonly filterViewIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>(false) | 
					
						
							|  |  |  |     public readonly copyrightViewIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>( | 
					
						
							|  |  |  |         false | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     public readonly currentViewControlIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>( | 
					
						
							|  |  |  |         false | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     public readonly userInfoIsOpened: UIEventSource<boolean> = new UIEventSource<boolean>(false) | 
					
						
							| 
									
										
										
										
											2023-01-13 02:48:48 +01:00
										 |  |  |     public readonly userInfoFocusedQuestion: UIEventSource<string> = new UIEventSource<string>( | 
					
						
							|  |  |  |         undefined | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-11-03 00:44:53 +01:00
										 |  |  |     public readonly welcomeMessageOpenedTab: UIEventSource<number> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor() { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.welcomeMessageOpenedTab = UIEventSource.asFloat( | 
					
						
							|  |  |  |             QueryParameters.GetQueryParameter( | 
					
						
							|  |  |  |                 "tab", | 
					
						
							|  |  |  |                 "0", | 
					
						
							|  |  |  |                 `The tab that is shown in the welcome-message.` | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2023-01-06 03:46:49 +01:00
										 |  |  |         const sources = { | 
					
						
							|  |  |  |             welcome: this.welcomeMessageIsOpened, | 
					
						
							| 
									
										
										
										
											2022-01-08 04:22:50 +01:00
										 |  |  |             download: this.downloadControlIsOpened, | 
					
						
							|  |  |  |             filters: this.filterViewIsOpened, | 
					
						
							|  |  |  |             copyright: this.copyrightViewIsOpened, | 
					
						
							|  |  |  |             currentview: this.currentViewControlIsOpened, | 
					
						
							| 
									
										
										
										
											2023-01-06 03:46:49 +01:00
										 |  |  |             userinfo: this.userInfoIsOpened, | 
					
						
							| 
									
										
										
										
											2021-11-03 00:44:53 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-01-06 03:46:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-13 02:48:48 +01:00
										 |  |  |         const self = this | 
					
						
							|  |  |  |         this.userInfoIsOpened.addCallback((isOpen) => { | 
					
						
							|  |  |  |             if (!isOpen) { | 
					
						
							|  |  |  |                 console.log("Resetting focused question") | 
					
						
							|  |  |  |                 self.userInfoFocusedQuestion.setData(undefined) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 03:46:49 +01:00
										 |  |  |         sources[Hash.hash.data?.toLowerCase()]?.setData(true) | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-08 04:22:50 +01:00
										 |  |  |         if (Hash.hash.data === "" || Hash.hash.data === undefined) { | 
					
						
							| 
									
										
										
										
											2021-11-03 00:44:53 +01:00
										 |  |  |             this.welcomeMessageIsOpened.setData(true) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |