-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
90 lines (75 loc) · 2.96 KB
/
scripts.js
File metadata and controls
90 lines (75 loc) · 2.96 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import uitoolkit from './@zoom/videosdk-ui-toolkit/index.js'
const urlParams = new URLSearchParams(window.location.search);
const preSetSession = urlParams.get('session');
const preSetpasscode = urlParams.get('passcode');
const sessionContainer = document.getElementById('sessionContainer')
if(preSetSession) {
// set session in inputs
document.getElementById('sessionName').value = preSetSession
}
if(preSetpasscode) {
// set passcode in inputs
if(preSetpasscode.length > 10) {
document.getElementById('passcodeLength').style.display = 'block'
} else {
document.getElementById('sessionPasscode').value = preSetpasscode
}
}
var authEndpoint = 'https://4c8no4s7ie.execute-api.us-west-1.amazonaws.com/default/videosdkdev'
var config = {
videoSDKJWT: '',
sessionName: '',
userName: '',
sessionPasscode: '',
features: ['video', 'audio', 'settings', 'users', 'chat', 'share'],
webEndpoint: 'zoomdev.us',
advancedTelemetry: true
};
window.getVideoSDKJWT = getVideoSDKJWT
function getVideoSDKJWT() {
document.getElementById('nameRequired').style.display = 'none'
document.getElementById('sessionNameRequired').style.display = 'none'
document.getElementById('passcodeLength').style.display = 'none'
document.getElementById('rating').style.display = 'none'
config.userName = document.getElementById('yourName').value
config.sessionName = document.getElementById('sessionName').value
config.sessionPasscode = document.getElementById('sessionPasscode').value
if(config.userName && config.sessionName) {
fetch(authEndpoint, {
method: 'POST',
body: JSON.stringify({
sessionName: config.sessionName,
role: parseInt(document.getElementById('role').value),
telemetryTrackingId: `tommy-ui-toolkit-${config.sessionName}-${config.userName}-${Date.now()}`
})
}).then((response) => {
return response.json()
}).then((data) => {
console.log(data)
config.videoSDKJWT = data.signature
joinSession()
}).catch((error) => {
console.log(error)
})
} else {
if(!config.userName) {
document.getElementById('nameRequired').style.display = 'block'
}
if(!config.sessionName) {
document.getElementById('sessionNameRequired').style.display = 'block'
}
}
}
function joinSession() {
uitoolkit.joinSession(sessionContainer, config)
document.getElementById('header').style.display = 'none'
document.getElementById('join-flow').style.display = 'none'
uitoolkit.onSessionClosed(sessionClosed)
}
var sessionClosed = (() => {
console.log('session closed')
uitoolkit.closeSession(sessionContainer)
document.getElementById('header').style.display = 'block'
document.getElementById('join-flow').style.display = 'block'
document.getElementById('rating').style.display = 'block'
})