forked from scalableminds/chatroom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
74 lines (72 loc) · 1.84 KB
/
demo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="./dist/Chatroom.css">
<link rel="stylesheet" type="text/css" href="./index.css">
<title>Chatroom Demo</title>
</head>
<body>
<div class="chat-container"></div>
<div style="text-align: center;">
<button class="chat-demo-button" id="demo-button">Start Demo</button>
<button class="chat-demo-button" id="clear-button">Clear</button>
</div>
<script src="./dist/Chatroom.js"></script>
<script type="text/javascript">
window.chatroom = new window.DemoChatroom({
title: "Chat with a bot",
container: document.querySelector(".chat-container"),
});
window.demoMessages = [
{
message: { type: "text", text: "Hello how can I help you?" },
username: "bot"
},
{
message: { type: "text", text: "I need glue" },
username: "user"
},
{
message: {
type: "text",
text:
"We have many sorts of adhesives. Let me help you find the right one."
},
username: "bot"
},
{
message: {
type: "text",
text: "Are you bonding magnets?"
},
username: "bot"
},
{
message: {
type: "button",
buttons: [
{ title: "Yes", payload: "Yes" },
{ title: "No", payload: "No" }
]
},
username: "bot"
},
{
message: { type: "text", text: "No" },
username: "user"
}
];
function startDemo() {
window.chatroom.demo(window.demoMessages);
}
function clearDemo() {
window.chatroom.clear();
}
document.getElementById("demo-button").addEventListener("click", startDemo, false);
document.getElementById("clear-button").addEventListener("click", clearDemo, false);
window.addEventListener("load", startDemo, false);
</script>
</body>
</html>