-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathindex.html
86 lines (77 loc) · 2.34 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TalkJS tutorial</title>
</head>
<!-- minified snippet to load TalkJS without delaying your page -->
<script>
(function (t, a, l, k, j, s) {
s = a.createElement("script");
s.async = 1;
s.src = "https://cdn.talkjs.com/talk.js";
a.head.appendChild(s);
k = t.Promise;
t.Talk = {
v: 3,
ready: {
then: function (f) {
if (k)
return new k(function (r, e) {
l.push([f, r, e]);
});
l.push([f]);
},
catch: function () {
return k && new k();
},
c: l,
},
};
})(window, document, []);
</script>
<script>
Talk.ready.then(function () {
var me = new Talk.User({
id: '123456',
name: 'Alice',
email: '[email protected]',
photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
welcomeMessage: 'Hey there! How are you? :-)',
role: "admin",
});
window.talkSession = new Talk.Session({
appId: 'YOUR_APP_ID',
me: me,
});
var other = new Talk.User({
id: '654321',
name: 'Sebastian',
email: '[email protected]',
photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
welcomeMessage: 'Hey, how can I help?',
});
var conversation = talkSession.getOrCreateConversation(
Talk.oneOnOneId(me, other)
);
conversation.setParticipant(me);
conversation.setParticipant(other);
var inbox = talkSession.createInbox({ selected: conversation });
inbox.mount(document.getElementById('talkjs-container'));
inbox.onCustomConversationAction('setReadOnly', (event) => {
console.log('Locked conversation with id:', event.conversation.id);
conversation = talkSession.getOrCreateConversation(event.conversation.id);
conversation.setParticipant(me, { access: 'Read' });
conversation.setParticipant(other, { access: 'Read' });
inbox.select(conversation);
});
});
</script>
<body>
<!-- container element in which TalkJS will display a chat UI -->
<div id="talkjs-container" style="width: 90%; margin: 30px; height: 500px">
<i>Loading chat...</i>
</div>
</body>
</html>