Merge pull request #1446 from jitsi/iframe_api_params

fix(iframe_api): Passing config params is not working
This commit is contained in:
Saúl Ibarra Corretgé 2017-03-31 17:47:14 +01:00 committed by GitHub
commit e8de8735e2
1 changed files with 29 additions and 16 deletions

View File

@ -80,6 +80,27 @@ function changeParticipantNumber(APIInstance, number) {
APIInstance.numberOfParticipants += number;
}
/**
* Generates array with URL params based on the passed config object that will
* be used for the Jitsi Meet URL generation.
*
* @param config {object} the config object.
* @returns {Array<string>} the array with URL param strings.
*/
function configToURLParamsArray(config) {
const params = [];
for (const key in config) {
try {
params.push(key + '='
+ encodeURIComponent(JSON.stringify(config[key])));
} catch (e) {
console.warn(`Error encoding ${key}: ${e}`);
}
}
return params;
}
/**
* Constructs new API instance. Creates iframe element that loads
* Jitsi Meet.
@ -130,24 +151,16 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
this.url += "#jitsi_meet_external_api_id=" + id;
var key;
if (configOverwrite) {
for (key in configOverwrite) {
if (!configOverwrite.hasOwnProperty(key) ||
typeof key !== 'string')
continue;
this.url += "&config." + key + "=" + configOverwrite[key];
}
const configURLParams = configToURLParamsArray(configOverwrite);
if (configURLParams.length) {
this.url += '&config.' + configURLParams.join('&config.');
}
if (interfaceConfigOverwrite) {
for (key in interfaceConfigOverwrite) {
if (!interfaceConfigOverwrite.hasOwnProperty(key) ||
typeof key !== 'string')
continue;
this.url += "&interfaceConfig." + key + "=" +
interfaceConfigOverwrite[key];
}
const interfaceConfigURLParams
= configToURLParamsArray(interfaceConfigOverwrite);
if (interfaceConfigURLParams.length) {
this.url += '&interfaceConfig.'
+ interfaceConfigURLParams.join('&interfaceConfig.');
}
this.frame = document.createElement("iframe");