Allow a website opened by script to use iframe_api
This commit is contained in:
parent
d7ff8e4be6
commit
feab5da2ad
9 changed files with 126 additions and 8 deletions
|
@ -5,6 +5,8 @@ import * as tg from "generic-type-guard";
|
|||
export const isOpenCoWebsite =
|
||||
new tg.IsInterface().withProperties({
|
||||
url: tg.isString,
|
||||
allowApi: tg.isBoolean,
|
||||
allowPolicy: tg.isString,
|
||||
}).get();
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,7 @@ class IframeListener {
|
|||
this._loadSoundStream.next(payload.data);
|
||||
}
|
||||
else if (payload.type === 'openCoWebSite' && isOpenCoWebsite(payload.data)) {
|
||||
scriptUtils.openCoWebsite(payload.data.url, foundSrc);
|
||||
scriptUtils.openCoWebsite(payload.data.url, foundSrc, payload.data.allowApi, payload.data.allowPolicy);
|
||||
}
|
||||
|
||||
else if (payload.type === 'closeCoWebSite') {
|
||||
|
|
|
@ -11,8 +11,8 @@ class ScriptUtils {
|
|||
|
||||
}
|
||||
|
||||
public openCoWebsite(url: string, base: string) {
|
||||
coWebsiteManager.loadCoWebsite(url, base);
|
||||
public openCoWebsite(url: string, base: string, allowApi: boolean, allowPolicy: string) {
|
||||
coWebsiteManager.loadCoWebsite(url, base, allowApi, allowPolicy);
|
||||
}
|
||||
|
||||
public closeCoWebSite(){
|
||||
|
|
|
@ -22,7 +22,7 @@ interface WorkAdventureApi {
|
|||
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
||||
openTab(url : string): void;
|
||||
goToPage(url : string): void;
|
||||
openCoWebSite(url : string): void;
|
||||
openCoWebSite(url : string, allowApi: boolean, allowPolicy: string): void;
|
||||
closeCoWebSite(): void;
|
||||
disablePlayerControls(): void;
|
||||
restorePlayerControls(): void;
|
||||
|
@ -166,11 +166,13 @@ window.WA = {
|
|||
}, '*');
|
||||
},
|
||||
|
||||
openCoWebSite(url : string) : void{
|
||||
openCoWebSite(url : string, allowApi: boolean = false, allowPolicy: string = "") : void{
|
||||
window.parent.postMessage({
|
||||
"type" : 'openCoWebSite',
|
||||
"data" : {
|
||||
url
|
||||
url,
|
||||
allowApi,
|
||||
allowPolicy,
|
||||
} as OpenCoWebSiteEvent
|
||||
}, '*');
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue