forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jameda_config.js
71 lines (57 loc) · 1.82 KB
/
jameda_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-disable no-unused-vars, no-var */
const searchUrlParams = parseURLParams(window.location, true, 'search');
const hashUrlParams = parseURLParams(window.location, false, 'hash');
/**
* Set a global configuration object
*
* @type {{inst: {name: string | null, brandLogoPath: string | null }, peerBrowser: string}}
*/
window.jameda = {
inst: {
name: hashUrlParams['inst.name'] ? hashUrlParams['inst.name'] : null,
brandLogoPath: hashUrlParams['inst.brandLogoPath'] ? hashUrlParams['inst.brandLogoPath'] : null
},
peerBrowserName: decodeURIComponent(searchUrlParams.browserName) || ''
};
/**
* Checks for cfg user.
* @returns {?arrayList}
*/
function parseURLParams(
url,
dontParse = false,
source = 'hash') {
const paramStr = source === 'search' ? url.search : url.hash;
const params = {};
const paramParts = (paramStr && paramStr.substr(1)
.split('&')) || [];
// Detect and ignore hash params for hash routers.
if (source === 'hash' && paramParts.length === 1) {
const firstParam = paramParts[0];
if (firstParam.startsWith('/') && firstParam.split('&').length === 1) {
return params;
}
}
paramParts.forEach(part => {
const param = part.split('=');
const key = param[0];
if (!key) {
return;
}
let value;
try {
value = param[1];
if (!dontParse) {
const decoded = decodeURIComponent(value)
.replace(/\\&/, '&');
value = decoded === 'undefined' ? undefined : JSON.parse(decoded);
}
} catch (e) {
console.error(e);
return;
}
params[key] = value;
});
return params;
}
/* eslint-enable no-unused-vars, no-var */