From 9571a52f1e674f5c820a3f5dc203783e95069d9a Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 7 Feb 2022 11:21:04 +0100 Subject: [PATCH 1/4] Re-implement action message on cowebsite trigger --- .../Phaser/Game/GameMapPropertiesListener.ts | 114 +++++++++++++++--- front/src/WebRtc/CoWebsiteManager.ts | 2 +- front/src/WebRtc/LayoutManager.ts | 1 + 3 files changed, 98 insertions(+), 19 deletions(-) diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index caa83cb0..900a00b6 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -6,7 +6,7 @@ import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore"; import { localUserStore } from "../../Connexion/LocalUserStore"; import { get } from "svelte/store"; -import { ON_ACTION_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager"; +import { ON_ACTION_TRIGGER_BUTTON, ON_ICON_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager"; import type { ITiledMapLayer } from "../Map/ITiledMap"; import { GameMapProperties } from "./GameMapProperties"; import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore"; @@ -18,12 +18,14 @@ enum OpenCoWebsiteState { } interface OpenCoWebsite { - coWebsite: CoWebsite; + actionId: string; + coWebsite?: CoWebsite; state: OpenCoWebsiteState; } export class GameMapPropertiesListener { private coWebsitesOpenByLayer = new Map(); + private coWebsitesActionTriggerByLayer = new Map(); constructor(private scene: GameScene, private gameMap: GameMap) {} @@ -95,27 +97,19 @@ export class GameMapPropertiesListener { return; } - const actionUuid = "openWebsite-" + (Math.random() + 1).toString(36).substring(7); + const actionId = "openWebsite-" + (Math.random() + 1).toString(36).substring(7); if (this.coWebsitesOpenByLayer.has(layer)) { return; } - const coWebsite = coWebsiteManager.addCoWebsite( - openWebsiteProperty, - this.scene.MapUrlFile, - allowApiProperty, - websitePolicyProperty, - websitePositionProperty, - false - ); - this.coWebsitesOpenByLayer.set(layer, { - coWebsite: coWebsite, + actionId: actionId, + coWebsite: undefined, state: OpenCoWebsiteState.ASLEEP, }); - const openWebsiteFunction = () => { + const loadCoWebsiteFunction = (coWebsite: CoWebsite) => { coWebsiteManager .loadCoWebsite(coWebsite) .then((coWebsite) => { @@ -125,8 +119,10 @@ export class GameMapPropertiesListener { console.error("Error during a co-website closing"); }); this.coWebsitesOpenByLayer.delete(layer); + this.coWebsitesActionTriggerByLayer.delete(layer); } else { this.coWebsitesOpenByLayer.set(layer, { + actionId, coWebsite, state: OpenCoWebsiteState.OPENED, }); @@ -136,14 +132,74 @@ export class GameMapPropertiesListener { console.error("Error during loading a co-website: " + coWebsite.url); }); - layoutManagerActionStore.removeAction(actionUuid); + layoutManagerActionStore.removeAction(actionId); + }; + + const openCoWebsiteFunction = ( + url: string | undefined, + allowApi: boolean | undefined, + policy: string | undefined, + position: number | undefined + ) => { + const coWebsite = coWebsiteManager.addCoWebsite( + url ?? "", + this.scene.MapUrlFile, + allowApiProperty, + websitePolicyProperty, + websitePositionProperty, + false + ); + + loadCoWebsiteFunction(coWebsite); }; if ( - !localUserStore.getForceCowebsiteTrigger() && - websiteTriggerProperty !== ON_ACTION_TRIGGER_BUTTON + localUserStore.getForceCowebsiteTrigger() || + websiteTriggerProperty === ON_ACTION_TRIGGER_BUTTON ) { - openWebsiteFunction(); + if (!websiteTriggerMessageProperty) { + websiteTriggerMessageProperty = "Press SPACE or touch here to open web site"; + } + + this.coWebsitesActionTriggerByLayer.set(layer, actionId); + + layoutManagerActionStore.addAction({ + uuid: actionId, + type: "message", + message: websiteTriggerMessageProperty, + callback: () => + openCoWebsiteFunction( + openWebsiteProperty, + allowApiProperty, + websitePolicyProperty, + websitePositionProperty + ), + userInputManager: this.scene.userInputManager, + }); + } else if (!websiteTriggerProperty || websiteTriggerProperty === ON_ICON_TRIGGER_BUTTON) { + const coWebsite = coWebsiteManager.addCoWebsite( + openWebsiteProperty, + this.scene.MapUrlFile, + allowApiProperty, + websitePolicyProperty, + websitePositionProperty, + false + ); + + const ObjectByLayer = this.coWebsitesOpenByLayer.get(layer); + + if (ObjectByLayer) { + ObjectByLayer.coWebsite = coWebsite; + } + } + + if (!websiteTriggerProperty) { + openCoWebsiteFunction( + openWebsiteProperty, + allowApiProperty, + websitePolicyProperty, + websitePositionProperty + ); } }); }; @@ -192,6 +248,28 @@ export class GameMapPropertiesListener { } this.coWebsitesOpenByLayer.delete(layer); + + if (!websiteTriggerProperty) { + return; + } + + const actionStore = get(layoutManagerActionStore); + const actionTriggerUuid = this.coWebsitesActionTriggerByLayer.get(layer); + + if (!actionTriggerUuid) { + return; + } + + const action = + actionStore && actionStore.length > 0 + ? actionStore.find((action) => action.uuid === actionTriggerUuid) + : undefined; + + if (action) { + layoutManagerActionStore.removeAction(actionTriggerUuid); + } + + this.coWebsitesActionTriggerByLayer.delete(layer); }); }; diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index 8e646d9d..9f4f0c36 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -21,7 +21,7 @@ const gameOverlayDomId = "game-overlay"; const cowebsiteBufferDomId = "cowebsite-buffer"; // the id of the container who contains cowebsite iframes. const cowebsiteAsideHolderDomId = "cowebsite-aside-holder"; const cowebsiteLoaderDomId = "cowebsite-loader"; -export const cowebsiteCloseButtonId = "cowebsite-close"; +const cowebsiteCloseButtonId = "cowebsite-close"; const cowebsiteFullScreenButtonId = "cowebsite-fullscreen"; const cowebsiteOpenFullScreenImageId = "cowebsite-fullscreen-open"; const cowebsiteCloseFullScreenImageId = "cowebsite-fullscreen-close"; diff --git a/front/src/WebRtc/LayoutManager.ts b/front/src/WebRtc/LayoutManager.ts index de79047f..a926cb41 100644 --- a/front/src/WebRtc/LayoutManager.ts +++ b/front/src/WebRtc/LayoutManager.ts @@ -13,5 +13,6 @@ export enum DivImportance { } export const ON_ACTION_TRIGGER_BUTTON = "onaction"; +export const ON_ICON_TRIGGER_BUTTON = "onicon"; export type Box = { xStart: number; yStart: number; xEnd: number; yEnd: number }; From 60c17ecea271732deb78d56d145c4aa8300b49d0 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 7 Feb 2022 14:55:51 +0100 Subject: [PATCH 2/4] Re-implement set width of main cowebsite --- front/src/Api/Events/OpenCoWebsiteEvent.ts | 1 + front/src/Api/iframe/nav.ts | 2 + front/src/Phaser/Game/GameMapProperties.ts | 1 + .../Phaser/Game/GameMapPropertiesListener.ts | 31 +++----- front/src/Phaser/Game/GameScene.ts | 1 + front/src/WebRtc/CoWebsiteManager.ts | 73 +++++++++++++------ front/src/WebRtc/JitsiFactory.ts | 10 ++- .../CoWebsite/cowebsite_property_trigger.json | 5 ++ 8 files changed, 81 insertions(+), 43 deletions(-) diff --git a/front/src/Api/Events/OpenCoWebsiteEvent.ts b/front/src/Api/Events/OpenCoWebsiteEvent.ts index 51a17763..b991d3f7 100644 --- a/front/src/Api/Events/OpenCoWebsiteEvent.ts +++ b/front/src/Api/Events/OpenCoWebsiteEvent.ts @@ -5,6 +5,7 @@ export const isOpenCoWebsiteEvent = new tg.IsInterface() url: tg.isString, allowApi: tg.isOptional(tg.isBoolean), allowPolicy: tg.isOptional(tg.isString), + widthPercent: tg.isOptional(tg.isNumber), position: tg.isOptional(tg.isNumber), closable: tg.isOptional(tg.isBoolean), lazy: tg.isOptional(tg.isBoolean), diff --git a/front/src/Api/iframe/nav.ts b/front/src/Api/iframe/nav.ts index d5362b4b..b57f2456 100644 --- a/front/src/Api/iframe/nav.ts +++ b/front/src/Api/iframe/nav.ts @@ -45,6 +45,7 @@ export class WorkadventureNavigationCommands extends IframeApiContribution { + const openCoWebsiteFunction = () => { const coWebsite = coWebsiteManager.addCoWebsite( - url ?? "", + openWebsiteProperty ?? "", this.scene.MapUrlFile, allowApiProperty, websitePolicyProperty, + websiteWidthProperty, websitePositionProperty, false ); @@ -167,13 +166,7 @@ export class GameMapPropertiesListener { uuid: actionId, type: "message", message: websiteTriggerMessageProperty, - callback: () => - openCoWebsiteFunction( - openWebsiteProperty, - allowApiProperty, - websitePolicyProperty, - websitePositionProperty - ), + callback: () => openCoWebsiteFunction(), userInputManager: this.scene.userInputManager, }); } else if (!websiteTriggerProperty || websiteTriggerProperty === ON_ICON_TRIGGER_BUTTON) { @@ -182,6 +175,7 @@ export class GameMapPropertiesListener { this.scene.MapUrlFile, allowApiProperty, websitePolicyProperty, + websiteWidthProperty, websitePositionProperty, false ); @@ -194,12 +188,7 @@ export class GameMapPropertiesListener { } if (!websiteTriggerProperty) { - openCoWebsiteFunction( - openWebsiteProperty, - allowApiProperty, - websitePolicyProperty, - websitePositionProperty - ); + openCoWebsiteFunction(); } }); }; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 242d97c8..8b62a435 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1265,6 +1265,7 @@ ${escapedMessage} iframeListener.getBaseUrlFromSource(source), openCoWebsite.allowApi, openCoWebsite.allowPolicy, + openCoWebsite.widthPercent, openCoWebsite.position, openCoWebsite.closable ?? true ); diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index 9f4f0c36..7b7147b3 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -43,6 +43,7 @@ export type CoWebsite = { closable: boolean; allowPolicy: string | undefined; allowApi: boolean | undefined; + widthPercent?: number | undefined; jitsi?: boolean; altMessage?: string; }; @@ -82,8 +83,13 @@ class CoWebsiteManager { this.cowebsiteDom.style.width = width + "px"; } - set widthPercent(width: number) { - this.cowebsiteDom.style.width = width + "%"; + get maxWidth(): number { + let maxWidth = 75 * window.innerWidth; + if (maxWidth !== 0) { + maxWidth = Math.round(maxWidth / 100); + } + + return maxWidth; } get height(): number { @@ -94,6 +100,15 @@ class CoWebsiteManager { this.cowebsiteDom.style.height = height + "px"; } + get maxHeight(): number { + let maxHeight = 60 * window.innerHeight; + if (maxHeight !== 0) { + maxHeight = Math.round(maxHeight / 100); + } + + return maxHeight; + } + get verticalMode(): boolean { return window.innerWidth < window.innerHeight; } @@ -191,29 +206,21 @@ class CoWebsiteManager { if (this.verticalMode) { const tempValue = this.height + y; - let maxHeight = 60 * window.innerHeight; - if (maxHeight !== 0) { - maxHeight = Math.round(maxHeight / 100); - } if (tempValue < this.cowebsiteAsideHolderDom.offsetHeight) { this.height = this.cowebsiteAsideHolderDom.offsetHeight; - } else if (tempValue > maxHeight) { - this.height = maxHeight; + } else if (tempValue > this.maxHeight) { + this.height = this.maxHeight; } else { this.height = tempValue; } } else { const tempValue = this.width - x; - let maxWidth = 75 * window.innerWidth; - if (maxWidth !== 0) { - maxWidth = Math.round(maxWidth / 100); - } if (tempValue < this.cowebsiteAsideHolderDom.offsetWidth) { this.width = this.cowebsiteAsideHolderDom.offsetWidth; - } else if (tempValue > maxWidth) { - this.width = maxWidth; + } else if (tempValue > this.maxWidth) { + this.width = this.maxWidth; } else { this.width = tempValue; } @@ -308,7 +315,7 @@ class CoWebsiteManager { this.fire(); } - private loadMain(): void { + private loadMain(openingWidth?: number): void { this.loaderAnimationInterval.interval = setInterval(() => { if (!this.loaderAnimationInterval.trails) { this.loaderAnimationInterval.trails = [0, 1, 2]; @@ -337,6 +344,25 @@ class CoWebsiteManager { trail === 3 ? 0 : trail + 1 ); }, 200); + + if (!this.verticalMode && openingWidth) { + let newWidth = 50; + + if (openingWidth > 100) { + newWidth = 100; + } else if (openingWidth > 1) { + newWidth = openingWidth; + } + + newWidth = Math.round((newWidth * this.maxWidth) / 100); + + if (newWidth < this.cowebsiteAsideHolderDom.offsetWidth) { + newWidth = this.cowebsiteAsideHolderDom.offsetWidth; + } + + this.width = newWidth; + } + this.cowebsiteDom.classList.add("opened"); this.openedMain = iframeStates.loading; } @@ -346,7 +372,6 @@ class CoWebsiteManager { this.resizeAllIframes(); }); this.openedMain = iframeStates.opened; - this.resetStyleMain(); } public resetStyleMain() { @@ -533,6 +558,7 @@ class CoWebsiteManager { base: string, allowApi?: boolean, allowPolicy?: string, + widthPercent?: number, position?: number, closable?: boolean, altMessage?: string @@ -549,6 +575,7 @@ class CoWebsiteManager { closable: closable ?? false, allowPolicy, allowApi, + widthPercent, altMessage, }; @@ -561,14 +588,11 @@ class CoWebsiteManager { iframe: HTMLIFrameElement, allowApi?: boolean, allowPolicy?: string, + widthPercent?: number, position?: number, closable?: boolean, jitsi?: boolean ): CoWebsite { - if (get(coWebsitesNotAsleep).length < 1) { - this.loadMain(); - } - iframe.id = this.generateUniqueId(); const newCoWebsite: CoWebsite = { @@ -578,9 +602,16 @@ class CoWebsiteManager { closable: closable ?? false, allowPolicy, allowApi, + widthPercent, jitsi, }; + if (get(coWebsitesNotAsleep).length < 1) { + coWebsites.remove(newCoWebsite); + coWebsites.add(newCoWebsite, 0); + this.loadMain(widthPercent); + } + if (position === 0) { this.openMain(); setTimeout(() => { @@ -597,7 +628,7 @@ class CoWebsiteManager { if (get(coWebsitesNotAsleep).length < 1) { coWebsites.remove(coWebsite); coWebsites.add(coWebsite, 0); - this.loadMain(); + this.loadMain(coWebsite.widthPercent); } coWebsite.state.set("loading"); diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index b273a64c..8f7ed952 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -179,7 +179,15 @@ class JitsiFactory { const doResolve = (): void => { const iframe = coWebsiteManager.getCoWebsiteBuffer().querySelector('[id*="jitsi" i]'); if (iframe && this.jitsiApi) { - const coWebsite = coWebsiteManager.addCoWebsiteFromIframe(iframe, false, undefined, 0, false, true); + const coWebsite = coWebsiteManager.addCoWebsiteFromIframe( + iframe, + false, + undefined, + undefined, + 0, + false, + true + ); this.jitsiApi.addListener("videoConferenceLeft", () => { this.closeOrUnload(coWebsite); diff --git a/maps/tests/CoWebsite/cowebsite_property_trigger.json b/maps/tests/CoWebsite/cowebsite_property_trigger.json index 183fad3a..116f399c 100644 --- a/maps/tests/CoWebsite/cowebsite_property_trigger.json +++ b/maps/tests/CoWebsite/cowebsite_property_trigger.json @@ -47,6 +47,11 @@ "name":"openWebsiteTrigger", "type":"string", "value":"onaction" + }, + { + "name":"openWebsiteWidth", + "type":"int", + "value":100 }], "type":"tilelayer", "visible":true, From 75d42209f48d33dc92c955736b5cea4594a4453f Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 7 Feb 2022 17:09:52 +0100 Subject: [PATCH 3/4] Hide main cowebsite --- .../CoWebsiteThumbnailSlot.svelte | 7 +++- front/src/WebRtc/CoWebsiteManager.ts | 32 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte b/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte index 809d1985..b71a35c0 100644 --- a/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte +++ b/front/src/Components/EmbedScreens/CoWebsiteThumbnailSlot.svelte @@ -5,6 +5,7 @@ import { coWebsitesNotAsleep, mainCoWebsite } from "../../Stores/CoWebsiteStore"; import { highlightedEmbedScreen } from "../../Stores/EmbedScreensStore"; import type { CoWebsite } from "../../WebRtc/CoWebsiteManager"; + import { iframeStates } from "../../WebRtc/CoWebsiteManager"; import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; export let index: number; @@ -35,8 +36,12 @@ if ($mainCoWebsite.iframe.id === coWebsite.iframe.id) { const coWebsites = $coWebsitesNotAsleep; const newMain = $highlightedEmbedScreen ?? coWebsites.length > 1 ? coWebsites[1] : undefined; - if (newMain) { + if (newMain && newMain.iframe.id !== $mainCoWebsite.iframe.id) { coWebsiteManager.goToMain(newMain); + } else if (coWebsiteManager.getMainState() === iframeStates.closed) { + coWebsiteManager.displayMain(); + } else { + coWebsiteManager.hideMain(); } } else { highlightedEmbedScreen.toggleHighlight({ diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index 7b7147b3..4d6f482c 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -10,7 +10,7 @@ import { jitsiFactory } from "./JitsiFactory"; import { gameManager } from "../Phaser/Game/GameManager"; import { LayoutMode } from "./LayoutManager"; -enum iframeStates { +export enum iframeStates { closed = 1, loading, // loading an iframe can be slow, so we show some placeholder until it is ready opened, @@ -75,6 +75,10 @@ class CoWebsiteManager { this.resizeAllIframes(); }); + public getMainState() { + return this.openedMain; + } + get width(): number { return this.cowebsiteDom.clientWidth; } @@ -306,6 +310,27 @@ class CoWebsiteManager { }); } + public displayMain() { + const coWebsite = this.getMainCoWebsite(); + if (coWebsite) { + coWebsite.iframe.style.display = "block"; + } + this.loadMain(); + this.openMain(); + this.fire(); + } + + public hideMain() { + const coWebsite = this.getMainCoWebsite(); + if (coWebsite) { + coWebsite.iframe.style.display = "none"; + } + this.cowebsiteDom.classList.add("closing"); + this.cowebsiteDom.classList.remove("opened"); + this.openedMain = iframeStates.closed; + this.fire(); + } + private closeMain(): void { this.toggleFullScreenIcon(true); this.cowebsiteDom.classList.add("closing"); @@ -631,6 +656,11 @@ class CoWebsiteManager { this.loadMain(coWebsite.widthPercent); } + // Check if the main is hide + if (this.getMainCoWebsite() && this.openedMain === iframeStates.closed) { + this.displayMain(); + } + coWebsite.state.set("loading"); const mainCoWebsite = this.getMainCoWebsite(); From e51300e850f75e869d96d25262a8c2bedfd80715 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 7 Feb 2022 17:53:36 +0100 Subject: [PATCH 4/4] Add cowebsite percentWidth property to the documention --- docs/maps/api-nav.md | 27 ++++++++++++------------- docs/maps/images/icon_open_website.png | Bin 0 -> 7971 bytes docs/maps/opening-a-website.md | 7 +++++++ 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 docs/maps/images/icon_open_website.png diff --git a/docs/maps/api-nav.md b/docs/maps/api-nav.md index 2743d1ad..8d9fe595 100644 --- a/docs/maps/api-nav.md +++ b/docs/maps/api-nav.md @@ -3,7 +3,7 @@ ### Opening a web page in a new tab -``` +```ts WA.nav.openTab(url: string): void ``` @@ -11,13 +11,13 @@ Opens the webpage at "url" in your browser, in a new tab. Example: -```javascript +```ts WA.nav.openTab('https://www.wikipedia.org/'); ``` ### Opening a web page in the current tab -``` +```ts WA.nav.goToPage(url: string): void ``` @@ -25,14 +25,13 @@ Opens the webpage at "url" in your browser in place of WorkAdventure. WorkAdvent Example: -```javascript +```ts WA.nav.goToPage('https://www.wikipedia.org/'); ``` ### Going to a different map from the script -``` - +```ts WA.nav.goToRoom(url: string): void ``` @@ -43,7 +42,7 @@ global urls: "/_/global/domain/path/map.json[#start-layer-name]" Example: -```javascript +```ts WA.nav.goToRoom("/@/tcm/workadventure/floor0") // workadventure urls WA.nav.goToRoom('../otherMap/map.json'); WA.nav.goToRoom("/_/global/.json#start-layer-2") @@ -51,25 +50,25 @@ WA.nav.goToRoom("/_/global/.json#start-layer-2") ### Opening/closing web page in Co-Websites -``` -WA.nav.openCoWebSite(url: string, allowApi: boolean = false, allowPolicy: string = "", position: number, closable: boolean, lazy: boolean): Promise +```ts +WA.nav.openCoWebSite(url: string, allowApi?: boolean = false, allowPolicy?: string = "", percentWidth?: number, position?: number, closable?: boolean, lazy?: boolean): Promise ``` -Opens the webpage at "url" in an iFrame (on the right side of the screen) or close that iFrame. `allowApi` allows the webpage to use the "IFrame API" and execute script (it is equivalent to putting the `openWebsiteAllowApi` property in the map). `allowPolicy` grants additional access rights to the iFrame. The `allowPolicy` parameter is turned into an [`allow` feature policy in the iFrame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allow), position in whitch slot the web page will be open, closable allow to close the webpage also you need to close it by the api and lazy +Opens the webpage at "url" in an iFrame (on the right side of the screen) or close that iFrame. `allowApi` allows the webpage to use the "IFrame API" and execute script (it is equivalent to putting the `openWebsiteAllowApi` property in the map). `allowPolicy` grants additional access rights to the iFrame. The `allowPolicy` parameter is turned into an [`allow` feature policy in the iFrame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allow),widthPercent define the width of the main cowebsite beetween the min size and the max size (70% of the viewport), position in whitch slot the web page will be open, closable allow to close the webpage also you need to close it by the api and lazy it's to add the cowebsite but don't load it. Example: -```javascript +```ts const coWebsite = await WA.nav.openCoWebSite('https://www.wikipedia.org/'); -const coWebsiteWorkAdventure = await WA.nav.openCoWebSite('https://workadventu.re/', true, "", 1, true, true); +const coWebsiteWorkAdventure = await WA.nav.openCoWebSite('https://workadventu.re/', true, "", 70, 1, true, true); // ... coWebsite.close(); ``` ### Get all Co-Websites -``` +```ts WA.nav.getCoWebSites(): Promise ``` @@ -77,6 +76,6 @@ Get all opened co-websites with their ids and positions. Example: -```javascript +```ts const coWebsites = await WA.nav.getCowebSites(); ``` diff --git a/docs/maps/images/icon_open_website.png b/docs/maps/images/icon_open_website.png new file mode 100644 index 0000000000000000000000000000000000000000..f3a505bd357feb3b4ea23b124bef0ed9977f6fe4 GIT binary patch literal 7971 zcmbtZX;@R|w%&*p2T;)pDgr82tRSdN%2-iAMZk$chCrnZ1!OP~<^+o(GFz+2T%d@6 z5D*zd2o4MuLYP7bkRSxZ7(#+c2qENt=yT8MbI!SKIhQ{?@a(<5wchovcdc*j2bV3) zq&Dx}3_+08h4bgGLeM%k1c@zg+yMSl8ET#jeyxWaU%0*z{6uX0Ar}0-C(y($@S2}{ zVDR_1-5?KNzgup{;I6mb+=P*(nlG)ZO%J%2qbm4I45iHa5W#gRJ?NLTfZ+m#6`-NlE$q$X$I1I&^4U4BCI- zz%~flv?&yV&Yy1+hrTm5R)C-#J60dP3=brQ5WS%ldvD)H&(0Z{fzA0!O4jOPc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eKu<-UC7Rn2m5rhJ?(&Ifaty{68| zll8gIyn3O!Y6hmvr;O}V=5czW&fWP&vSm&>V)ZN8$u)e)@k*N8iJVUPRV3|ccNq}o-t(0)%{jW-?3kY5Xp$V2baUN zjG*QL7w2x0=empp8o0}vq$3fX!wcQpWblb!8_HfpAu-ycwN>3X42$(r3kIfD6Sy3< nvHJ~4;Fih=_*(!?ip0xds;_ySF(*L7gD#j@o+~qU`RRWE>8~i4 literal 0 HcmV?d00001 diff --git a/docs/maps/opening-a-website.md b/docs/maps/opening-a-website.md index 64b19f1c..a84bde30 100644 --- a/docs/maps/opening-a-website.md +++ b/docs/maps/opening-a-website.md @@ -52,6 +52,13 @@ If you set `openWebsiteTrigger: onaction`, when the user walks on the layer, an If you set `openWebsiteTriggerMessage: your message action` you can edit alert message displayed. If is not defined, the default message displayed is 'Press on SPACE to open the web site'. +If you set `openWebsiteTrigger: onicon`, when the user walks on the layer, an icon will be displayed at the bottom of the screen: + +
+ +
The iFrame will only open if the user clicks on icon
+
+ ### Setting the iFrame "allow" attribute By default, iFrames have limited rights in browsers. For instance, they cannot put their content in fullscreen, they cannot start your webcam, etc...