From b4fc8c6d275e8297f6ce0e6d0aca10e365dfde8b Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Sun, 16 May 2021 10:22:05 +0200 Subject: [PATCH] Added discussion scripting --- front/src/Api/IframeListener.ts | 3 +++ front/src/Api/ScriptUtils.ts | 10 ++++++++-- front/src/WebRtc/DiscussionManager.ts | 2 +- front/src/iframe_api.ts | 6 ++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 56ed81db..bed65f2f 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -95,6 +95,9 @@ class IframeListener { else if(payload.type === 'closeCoWebSite') { scriptUtils.closeCoWebSite(); } + else if(payload.type === 'closeChatMessage') { + scriptUtils.closeChatMessage(); + } else if (payload.type === 'disablePlayerControl'){ this._disablePlayerControlStream.next(); } diff --git a/front/src/Api/ScriptUtils.ts b/front/src/Api/ScriptUtils.ts index 1a7fed0f..49ce14cf 100644 --- a/front/src/Api/ScriptUtils.ts +++ b/front/src/Api/ScriptUtils.ts @@ -1,4 +1,6 @@ import {coWebsiteManager} from "../WebRtc/CoWebsiteManager"; +import {discussionManager} from "../WebRtc/DiscussionManager"; + class ScriptUtils { @@ -11,12 +13,16 @@ class ScriptUtils { } + public closeCoWebSite(){ + coWebsiteManager.closeCoWebsite(); + } + public openCoWebsite(url : string){ coWebsiteManager.loadCoWebsite(url,url); } - public closeCoWebSite(){ - coWebsiteManager.closeCoWebsite(); + public closeChatMessage(){ + discussionManager.hideDiscussion(); } } diff --git a/front/src/WebRtc/DiscussionManager.ts b/front/src/WebRtc/DiscussionManager.ts index 0041a5c0..efe0f3a6 100644 --- a/front/src/WebRtc/DiscussionManager.ts +++ b/front/src/WebRtc/DiscussionManager.ts @@ -223,7 +223,7 @@ export class DiscussionManager { this.divDiscuss?.classList.add('active'); } - private hideDiscussion(){ + public hideDiscussion(){ this.activeDiscussion = false; this.divDiscuss?.classList.remove('active'); } diff --git a/front/src/iframe_api.ts b/front/src/iframe_api.ts index 18d8d172..06127dcd 100644 --- a/front/src/iframe_api.ts +++ b/front/src/iframe_api.ts @@ -13,6 +13,7 @@ import {OpenCoWebSiteEvent} from "./Api/Events/OpenCoWebSiteEvent"; interface WorkAdventureApi { sendChatMessage(message: string, author: string): void; onChatMessage(callback: (message: string) => void): void; + closeChatMessage() : void; onEnterZone(name: string, callback: () => void): void; onLeaveZone(name: string, callback: () => void): void; openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup; @@ -88,6 +89,11 @@ window.WA = { } as ChatEvent }, '*'); }, + closeChatMessage() : void{ + window.parent.postMessage({ + "type" : 'closeChatMessage' + },'*'); + }, disablePlayerControl() : void { window.parent.postMessage({'type' : 'disablePlayerControl'},'*'); },