import { UIEventSource } from "../Logic/UIEventSource" import { QueryParameters } from "../Logic/Web/QueryParameters" import Hash from "../Logic/Web/Hash" export class DefaultGuiState { static state: DefaultGuiState public readonly welcomeMessageIsOpened: UIEventSource = new UIEventSource( false ) public readonly downloadControlIsOpened: UIEventSource = new UIEventSource( false ) public readonly filterViewIsOpened: UIEventSource = new UIEventSource(false) public readonly copyrightViewIsOpened: UIEventSource = new UIEventSource( false ) public readonly currentViewControlIsOpened: UIEventSource = new UIEventSource( false ) public readonly userInfoIsOpened: UIEventSource = new UIEventSource(false) public readonly userInfoFocusedQuestion: UIEventSource = new UIEventSource( undefined ) public readonly welcomeMessageOpenedTab: UIEventSource constructor() { this.welcomeMessageOpenedTab = UIEventSource.asFloat( QueryParameters.GetQueryParameter( "tab", "0", `The tab that is shown in the welcome-message.` ) ) const sources = { welcome: this.welcomeMessageIsOpened, download: this.downloadControlIsOpened, filters: this.filterViewIsOpened, copyright: this.copyrightViewIsOpened, currentview: this.currentViewControlIsOpened, userinfo: this.userInfoIsOpened, } const self = this this.userInfoIsOpened.addCallback((isOpen) => { if (!isOpen) { console.log("Resetting focused question") self.userInfoFocusedQuestion.setData(undefined) } }) sources[Hash.hash.data?.toLowerCase()]?.setData(true) if (Hash.hash.data === "" || Hash.hash.data === undefined) { this.welcomeMessageIsOpened.setData(true) } } }