From 7971daa27fa0a7d188f5a2a6f3e3a611a2ba3054 Mon Sep 17 00:00:00 2001
From: jonny <ga86lad@mytum.de>
Date: Wed, 1 Sep 2021 14:50:48 +0200
Subject: [PATCH 1/3] openTabPropertyKey (create new props in own file)

---
 .../src/Phaser/Game/GameMapPropertyChange.ts  | 56 +++++++++++++++++++
 front/src/Phaser/Game/GameScene.ts            | 34 +----------
 2 files changed, 58 insertions(+), 32 deletions(-)
 create mode 100644 front/src/Phaser/Game/GameMapPropertyChange.ts

diff --git a/front/src/Phaser/Game/GameMapPropertyChange.ts b/front/src/Phaser/Game/GameMapPropertyChange.ts
new file mode 100644
index 00000000..929b94c8
--- /dev/null
+++ b/front/src/Phaser/Game/GameMapPropertyChange.ts
@@ -0,0 +1,56 @@
+import type { GameScene } from "./GameScene";
+import type { GameMap } from "./GameMap";
+import { scriptUtils } from "../../Api/ScriptUtils";
+import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
+import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
+import {
+    ON_ACTION_TRIGGER_BUTTON,
+    TRIGGER_WEBSITE_PROPERTIES,
+    WEBSITE_MESSAGE_PROPERTIES,
+} from "../../WebRtc/LayoutManager";
+
+export class GameMapPropertyChange {
+    constructor(private scene: GameScene, private gameMap: GameMap) {}
+
+    register() {
+        this.gameMap.onPropertyChange("openTab", (newValue) => {
+            if (typeof newValue == "string" && newValue.length) {
+                scriptUtils.openTab(newValue);
+            }
+        });
+
+        this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {
+            if (newValue === undefined) {
+                layoutManagerActionStore.removeAction("openWebsite");
+                coWebsiteManager.closeCoWebsite();
+            } else {
+                const openWebsiteFunction = () => {
+                    coWebsiteManager.loadCoWebsite(
+                        newValue as string,
+                        this.scene.MapUrlFile,
+                        allProps.get("openWebsiteAllowApi") as boolean | undefined,
+                        allProps.get("openWebsitePolicy") as string | undefined
+                    );
+                    layoutManagerActionStore.removeAction("openWebsite");
+                };
+
+                const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES);
+                if (openWebsiteTriggerValue && openWebsiteTriggerValue === ON_ACTION_TRIGGER_BUTTON) {
+                    let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES);
+                    if (message === undefined) {
+                        message = "Press SPACE or touch here to open web site";
+                    }
+                    layoutManagerActionStore.addAction({
+                        uuid: "openWebsite",
+                        type: "message",
+                        message: message,
+                        callback: () => openWebsiteFunction(),
+                        userInputManager: this.scene.userInputManager,
+                    });
+                } else {
+                    openWebsiteFunction();
+                }
+            }
+        });
+    }
+}
diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts
index 7ba97175..9ab097c5 100644
--- a/front/src/Phaser/Game/GameScene.ts
+++ b/front/src/Phaser/Game/GameScene.ts
@@ -92,6 +92,7 @@ import Tileset = Phaser.Tilemaps.Tileset;
 import { userIsAdminStore } from "../../Stores/GameStore";
 import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
 import { EmbeddedWebsiteManager } from "./EmbeddedWebsiteManager";
+import { GameMapPropertyChange } from "./GameMapPropertyChange";
 
 export interface GameSceneInitInterface {
     initPosition: PointInterface | null;
@@ -580,6 +581,7 @@ export class GameScene extends DirtyScene {
             this.updateCameraOffset(box)
         );
 
+        new GameMapPropertyChange(this, this.gameMap).register();
         this.triggerOnMapLayerPropertyChange();
 
         if (!this.room.isDisconnected()) {
@@ -825,39 +827,7 @@ export class GameScene extends DirtyScene {
                 }, 2000);
             }
         });
-        this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {
-            if (newValue === undefined) {
-                layoutManagerActionStore.removeAction("openWebsite");
-                coWebsiteManager.closeCoWebsite();
-            } else {
-                const openWebsiteFunction = () => {
-                    coWebsiteManager.loadCoWebsite(
-                        newValue as string,
-                        this.MapUrlFile,
-                        allProps.get("openWebsiteAllowApi") as boolean | undefined,
-                        allProps.get("openWebsitePolicy") as string | undefined
-                    );
-                    layoutManagerActionStore.removeAction("openWebsite");
-                };
 
-                const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES);
-                if (openWebsiteTriggerValue && openWebsiteTriggerValue === ON_ACTION_TRIGGER_BUTTON) {
-                    let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES);
-                    if (message === undefined) {
-                        message = "Press SPACE or touch here to open web site";
-                    }
-                    layoutManagerActionStore.addAction({
-                        uuid: "openWebsite",
-                        type: "message",
-                        message: message,
-                        callback: () => openWebsiteFunction(),
-                        userInputManager: this.userInputManager,
-                    });
-                } else {
-                    openWebsiteFunction();
-                }
-            }
-        });
         this.gameMap.onPropertyChange("jitsiRoom", (newValue, oldValue, allProps) => {
             if (newValue === undefined) {
                 layoutManagerActionStore.removeAction("jitsi");

From 181232c1e678527b06d53f6a0373055660b460f4 Mon Sep 17 00:00:00 2001
From: jonny <ga86lad@mytum.de>
Date: Wed, 1 Sep 2021 17:55:23 +0200
Subject: [PATCH 2/3] added jitsiTypes

---
 front/src/WebRtc/JitsiFactory.ts | 33 +++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts
index 7a3264f1..8e3a37c7 100644
--- a/front/src/WebRtc/JitsiFactory.ts
+++ b/front/src/WebRtc/JitsiFactory.ts
@@ -1,9 +1,7 @@
 import { JITSI_URL } from "../Enum/EnvironmentVariable";
-import { mediaManager } from "./MediaManager";
 import { coWebsiteManager } from "./CoWebsiteManager";
 import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
 import { get } from "svelte/store";
-declare const window: any; // eslint-disable-line @typescript-eslint/no-explicit-any
 
 interface jitsiConfigInterface {
     startWithAudioMuted: boolean;
@@ -11,6 +9,32 @@ interface jitsiConfigInterface {
     prejoinPageEnabled: boolean;
 }
 
+interface JitsiOptions {
+    jwt?: string;
+    roomName: string;
+    width: string;
+    height: string;
+    parentNode: HTMLElement;
+    configOverwrite: jitsiConfigInterface;
+    interfaceConfigOverwrite: typeof defaultInterfaceConfig;
+    onload?: Function;
+}
+
+interface JitsiApi {
+    executeCommand: (command: string, ...args: Array<unknown>) => void;
+
+    addListener: (type: string, callback: Function) => void;
+    removeListener: (type: string, callback: Function) => void;
+
+    dispose: () => void;
+}
+
+declare global {
+    interface Window {
+        JitsiMeetExternalAPI: new (domain: string, options: JitsiOptions) => JitsiApi;
+    }
+}
+
 const getDefaultConfig = (): jitsiConfigInterface => {
     return {
         startWithAudioMuted: !get(requestedMicrophoneState),
@@ -96,7 +120,7 @@ const slugify = (...args: (string | number)[]): string => {
 };
 
 class JitsiFactory {
-    private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any
+    private jitsiApi?: JitsiApi;
     private audioCallback = this.onAudioChange.bind(this);
     private videoCallback = this.onVideoChange.bind(this);
     private jitsiScriptLoaded: boolean = false;
@@ -132,8 +156,7 @@ class JitsiFactory {
             }
             await this.loadJitsiScript(domain);
 
-            const options: any = {
-                // eslint-disable-line @typescript-eslint/no-explicit-any
+            const options: JitsiOptions = {
                 roomName: roomName,
                 jwt: jwt,
                 width: "100%",

From 606e9093e15a78b29b4249b0afd9fdc5ea6d2df4 Mon Sep 17 00:00:00 2001
From: jonny <ga86lad@mytum.de>
Date: Wed, 1 Sep 2021 18:16:31 +0200
Subject: [PATCH 3/3] renamed

---
 ...{GameMapPropertyChange.ts => GameMapPropertiesListener.ts} | 2 +-
 front/src/Phaser/Game/GameScene.ts                            | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename front/src/Phaser/Game/{GameMapPropertyChange.ts => GameMapPropertiesListener.ts} (98%)

diff --git a/front/src/Phaser/Game/GameMapPropertyChange.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts
similarity index 98%
rename from front/src/Phaser/Game/GameMapPropertyChange.ts
rename to front/src/Phaser/Game/GameMapPropertiesListener.ts
index 76a7a3d4..db100935 100644
--- a/front/src/Phaser/Game/GameMapPropertyChange.ts
+++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts
@@ -9,7 +9,7 @@ import {
     WEBSITE_MESSAGE_PROPERTIES,
 } from "../../WebRtc/LayoutManager";
 
-export class GameMapPropertyChange {
+export class GameMapPropertiesListener {
     constructor(private scene: GameScene, private gameMap: GameMap) {}
 
     register() {
diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts
index d29c5e3c..12063e6c 100644
--- a/front/src/Phaser/Game/GameScene.ts
+++ b/front/src/Phaser/Game/GameScene.ts
@@ -92,7 +92,7 @@ import Tileset = Phaser.Tilemaps.Tileset;
 import { userIsAdminStore } from "../../Stores/GameStore";
 import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
 import { EmbeddedWebsiteManager } from "./EmbeddedWebsiteManager";
-import { GameMapPropertyChange } from "./GameMapPropertyChange";
+import { GameMapPropertiesListener } from "./GameMapPropertiesListener";
 
 export interface GameSceneInitInterface {
     initPosition: PointInterface | null;
@@ -581,7 +581,7 @@ export class GameScene extends DirtyScene {
             this.updateCameraOffset(box)
         );
 
-        new GameMapPropertyChange(this, this.gameMap).register();
+        new GameMapPropertiesListener(this, this.gameMap).register();
         this.triggerOnMapLayerPropertyChange();
 
         if (!this.room.isDisconnected()) {