fix(iframe_api): Change the format of the arguments in the constructor
This commit is contained in:
parent
3736d6ca78
commit
70122789e7
52
doc/api.md
52
doc/api.md
|
@ -9,54 +9,56 @@ To embed Jitsi Meet in your application you need to add the Jitsi Meet API libra
|
||||||
```javascript
|
```javascript
|
||||||
<script src="https://meet.jit.si/external_api.js"></script>
|
<script src="https://meet.jit.si/external_api.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### `api = new JitsiMeetExternalAPI(domain, room, [width], [height], [htmlElement], [configOverwite], [interfaceConfigOverwrite], [noSsl], [jwt])`
|
### `api = new JitsiMeetExternalAPI(domain, options)`
|
||||||
|
|
||||||
The next step for embedding Jitsi Meet is to create the Jitsi Meet API object.
|
The next step for embedding Jitsi Meet is to create the Jitsi Meet API object.
|
||||||
Its constructor gets a number of options:
|
Its constructor gets a number of options:
|
||||||
|
|
||||||
* **domain**: domain used to build the conference URL, "meet.jit.si" for
|
* **domain**: domain used to build the conference URL, "meet.jit.si" for
|
||||||
example.
|
example.
|
||||||
* **room**: name of the room to join.
|
* **options**: object with properties - the optional arguments:
|
||||||
* **width**: (optional) width for the iframe which will be created.
|
* **room**: (optional) name of the room to join.
|
||||||
* **height**: (optional) height for the iframe which will be created.
|
* **width**: (optional) width for the iframe which will be created.
|
||||||
* **htmlElement**: (optional) HTL DOM Element where the iframe will be added as
|
* **height**: (optional) height for the iframe which will be created.
|
||||||
a child.
|
* **htmlElement**: (optional) HTL DOM Element where the iframe will be added as a child.
|
||||||
* **configOverwite**: (optional) JS object with overrides for options defined in
|
* **configOverwite**: (optional) JS object with overrides for options defined in [config.js].
|
||||||
[config.js].
|
* **interfaceConfigOverwrite**: (optional) JS object with overrides for options defined in [interface_config.js].
|
||||||
* **interfaceConfigOverwrite**: (optional) JS object with overrides for options
|
* **noSsl**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
|
||||||
defined in [interface_config.js].
|
* **jwt**: (optional) [JWT](https://jwt.io/) token.
|
||||||
* **noSsl**: (optional, defaults to true) Boolean indicating if the server
|
|
||||||
should be contacted using HTTP or HTTPS.
|
|
||||||
* **jwt**: (optional) [JWT](https://jwt.io/) token.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var domain = "meet.jit.si";
|
var options = {
|
||||||
var room = "JitsiMeetAPIExample";
|
domain: "meet.jit.si",
|
||||||
var width = 700;
|
room: "JitsiMeetAPIExample",
|
||||||
var height = 700;
|
width: 700,
|
||||||
var htmlElement = document.querySelector('#meet');
|
height: 700,
|
||||||
var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement);
|
htmlElement: document.querySelector('#meet')
|
||||||
|
}
|
||||||
|
var api = new JitsiMeetExternalAPI(domain, options);
|
||||||
```
|
```
|
||||||
|
|
||||||
You can overwrite options set in [config.js] and [interface_config.js].
|
You can overwrite options set in [config.js] and [interface_config.js].
|
||||||
For example, to enable the filmstrip-only interface mode, you can use:
|
For example, to enable the filmstrip-only interface mode, you can use:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var interfaceConfigOverwrite = {filmStripOnly: true};
|
var options = {
|
||||||
var api = new JitsiMeetExternalAPI(domain, room, width, height, undefined, undefined, interfaceConfigOverwrite);
|
interfaceConfigOverwrite: {filmStripOnly: true}
|
||||||
|
};
|
||||||
|
var api = new JitsiMeetExternalAPI(domain, options);
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also pass a jwt token to Jitsi Meet:
|
You can also pass a jwt token to Jitsi Meet:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var jwt = "<jwt_token>";
|
var options = {
|
||||||
var noSsl = false;
|
jwt: "<jwt_token>",
|
||||||
var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement, configOverwrite, interfaceConfigOverwrite, noSsl, jwt);
|
noSsl: false
|
||||||
|
};
|
||||||
|
var api = new JitsiMeetExternalAPI(domain, options);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Controlling the embedded Jitsi Meet Conference
|
### Controlling the embedded Jitsi Meet Conference
|
||||||
|
|
|
@ -142,6 +142,54 @@ function generateURL(domain, options = {}) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the arguments passed to the constructor. If the old format is used
|
||||||
|
* the function translates the arguments to the new format.
|
||||||
|
*
|
||||||
|
* @param {Array} args - The arguments to be parsed.
|
||||||
|
* @returns {Object} JS object with properties.
|
||||||
|
*/
|
||||||
|
function parseArguments(args) {
|
||||||
|
if (!args.length) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstArg = args[0];
|
||||||
|
|
||||||
|
switch (typeof firstArg) {
|
||||||
|
case 'string': // old arguments format
|
||||||
|
case undefined: // eslint-disable-line no-case-declarations
|
||||||
|
// not sure which format but we are trying to parse the old
|
||||||
|
// format because if the new format is used everything will be undefined
|
||||||
|
// anyway.
|
||||||
|
const [
|
||||||
|
roomName,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
parentNode,
|
||||||
|
configOverwrite,
|
||||||
|
interfaceConfigOverwrite,
|
||||||
|
noSSL,
|
||||||
|
jwt
|
||||||
|
] = args;
|
||||||
|
|
||||||
|
return {
|
||||||
|
roomName,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
parentNode,
|
||||||
|
configOverwrite,
|
||||||
|
interfaceConfigOverwrite,
|
||||||
|
noSSL,
|
||||||
|
jwt
|
||||||
|
};
|
||||||
|
case 'object': // new arguments format
|
||||||
|
return args[0];
|
||||||
|
default:
|
||||||
|
throw new Error('Can\'t parse the arguments!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IFrame API interface class.
|
* The IFrame API interface class.
|
||||||
*/
|
*/
|
||||||
|
@ -151,29 +199,34 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
*
|
*
|
||||||
* @param {string} domain - The domain name of the server that hosts the
|
* @param {string} domain - The domain name of the server that hosts the
|
||||||
* conference.
|
* conference.
|
||||||
* @param {string} [roomName] - The name of the room to join.
|
* @param {Object} [options] - Optional arguments.
|
||||||
* @param {number} [width] - Width of the iframe.
|
* @param {string} [options.roomName] - The name of the room to join.
|
||||||
* @param {number} [height] - Height of the iframe.
|
* @param {number} [options.width] - Width of the iframe.
|
||||||
* @param {DOMElement} [parentNode] - The node that will contain the
|
* @param {number} [options.height] - Height of the iframe.
|
||||||
|
* @param {DOMElement} [options.parentNode] - The node that will contain the
|
||||||
* iframe.
|
* iframe.
|
||||||
* @param {Object} [configOverwrite] - Object containing configuration
|
* @param {Object} [options.configOverwrite] - Object containing
|
||||||
* options defined in config.js to be overridden.
|
* configuration options defined in config.js to be overridden.
|
||||||
* @param {Object} [interfaceConfigOverwrite] - Object containing
|
* @param {Object} [options.interfaceConfigOverwrite] - Object containing
|
||||||
* configuration options defined in interface_config.js to be overridden.
|
* configuration options defined in interface_config.js to be overridden.
|
||||||
* @param {boolean} [noSSL] - If the value is true https won't be used.
|
* @param {boolean} [options.noSSL] - If the value is true https won't be
|
||||||
* @param {string} [jwt] - The JWT token if needed by jitsi-meet for
|
* used.
|
||||||
|
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
|
||||||
* authentication.
|
* authentication.
|
||||||
*/
|
*/
|
||||||
constructor(domain, // eslint-disable-line max-params
|
constructor(domain, ...args) {
|
||||||
roomName = '',
|
|
||||||
width = MIN_WIDTH,
|
|
||||||
height = MIN_HEIGHT,
|
|
||||||
parentNode = document.body,
|
|
||||||
configOverwrite = {},
|
|
||||||
interfaceConfigOverwrite = {},
|
|
||||||
noSSL = false,
|
|
||||||
jwt = undefined) {
|
|
||||||
super();
|
super();
|
||||||
|
const {
|
||||||
|
roomName = '',
|
||||||
|
width = MIN_WIDTH,
|
||||||
|
height = MIN_HEIGHT,
|
||||||
|
parentNode = document.body,
|
||||||
|
configOverwrite = {},
|
||||||
|
interfaceConfigOverwrite = {},
|
||||||
|
noSSL = false,
|
||||||
|
jwt = undefined
|
||||||
|
} = parseArguments(args);
|
||||||
|
|
||||||
this._parentNode = parentNode;
|
this._parentNode = parentNode;
|
||||||
this._url = generateURL(domain, {
|
this._url = generateURL(domain, {
|
||||||
configOverwrite,
|
configOverwrite,
|
||||||
|
|
Loading…
Reference in New Issue