Rename cowebsite API functions

This commit is contained in:
Alexis Faizeau 2021-10-25 18:50:40 +02:00
parent fbff7491df
commit fb7fe0dc0a
2 changed files with 8 additions and 40 deletions

View file

@ -52,9 +52,7 @@ WA.nav.goToRoom("/_/global/<path to global map>.json#start-layer-2")
### Opening/closing web page in Co-Websites
```
WA.nav.openCoWebsite(url: string, allowApi: boolean = false, allowPolicy: string = "", position: number = 0): Promise
WA.nav.closeCoWebsite(coWebsiteId: string): Promise
WA.nav.closeCoWebsites(): Promise
WA.nav.openCoWebSite(url: string, allowApi: boolean = false, allowPolicy: string = "", position: number = 0): Promise<CoWebsite>
```
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.
@ -62,17 +60,16 @@ Opens the webpage at "url" in an iFrame (on the right side of the screen) or clo
Example:
```javascript
const coWebsite = await WA.nav.openCoWebsite('https://www.wikipedia.org/');
const coWebsiteWorkAdventure = await WA.nav.openCoWebsite('https://workadventu.re/', true, "", 1);
const coWebsite = await WA.nav.openCoWebSite('https://www.wikipedia.org/');
const coWebsiteWorkAdventure = await WA.nav.openCoWebSite('https://workadventu.re/', true, "", 1);
// ...
WA.nav.closeCoWebsite(coWebsite.id);
WA.nav.closeCoWebsites();
coWebsite.close();
```
### Opening/closing web page in Co-Websites
```
WA.nav.getCoWebsites(): Promise
WA.nav.getCoWebSites(): Promise<CoWebsite[]>
```
Get all opened co-websites withe their ids and positions.
@ -80,5 +77,5 @@ Get all opened co-websites withe their ids and positions.
Example:
```javascript
const coWebsites = await WA.nav.getCowebsites();
const coWebsites = await WA.nav.getCowebSites();
```

View file

@ -41,22 +41,7 @@ export class WorkadventureNavigationCommands extends IframeApiContribution<Worka
});
}
/**
* @deprecated Use openCoWebsite instead
*/
openCoWebSite(url: string, allowApi?: boolean, allowPolicy?: string) {
return queryWorkadventure({
type: "openCoWebsite",
data: {
url,
allowApi,
allowPolicy,
position: undefined,
},
});
}
async openCoWebsite(url: string, allowApi?: boolean, allowPolicy?: string, position?: number): Promise<CoWebsite> {
async openCoWebSite(url: string, allowApi?: boolean, allowPolicy?: string, position?: number): Promise<CoWebsite> {
const result = await queryWorkadventure({
type: "openCoWebsite",
data: {
@ -69,7 +54,7 @@ export class WorkadventureNavigationCommands extends IframeApiContribution<Worka
return new CoWebsite(result.id, result.position);
}
async getCoWebsites(): Promise<CoWebsite[]> {
async getCoWebSites(): Promise<CoWebsite[]> {
const result = await queryWorkadventure({
type: "getCoWebsites",
data: undefined
@ -86,20 +71,6 @@ export class WorkadventureNavigationCommands extends IframeApiContribution<Worka
data: undefined,
});
}
closeCoWebsite(coWebsiteId: string) {
return queryWorkadventure({
type: "closeCoWebsite",
data: coWebsiteId,
});
}
closeCoWebsites() {
return queryWorkadventure({
type: "closeCoWebsites",
data: undefined,
});
}
}
export default new WorkadventureNavigationCommands();