-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchat.html
77 lines (69 loc) · 1.96 KB
/
chat.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>Chat with BOTNAME</title>
<style type="text/css">
#transcript {
background-color:#ffc;
height:200px;
overflow-y:scroll;
padding: 0 .5em;
width:400px;
}
#transcript div {
margin-top:4px;
text-align:right;
}
#transcript div.bot {
text-align:left;
}
#transcript span {
background-color: #cdf;
}
#transcript span.bot {
background-color: #ddd;
font-family: monospace;
}
@media (max-width: 600px) {
#transcript {
font-size: larger;
}
.button,
.input {
font-size: large;
}
.input {
width:400px;
}
}
</style>
</head>
<body>
<h1>Chat with Eliza</h1>
<div id="transcript">
<span class="bot">> Hello, what would you like to discuss today?</span><br>
</div>
<form id="chatform" action="#" method="GET">
<label><input type="text" name="text" id="text" size="50" class="input"></label>
<input type="submit" value="Send" class="button">
</form>
<hr>
<p id="credit"></p>
<p>Want to make your own bot? Read the <a href="/chatbots/bots/nltk/2019/02/23/diy-gist-chatbot.html">bot-making instructions</a>.</p>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("#chatform").submit(function() {
$('#transcript').append('<div><span>' + this.text.value + '</span></div>');
jQuery.get('/chat-api?text=' + this.text.value,
function(data) {
$('#transcript').append('<span class="bot">> ' + data + '<br></span>');
$('#transcript').scrollTop($('#transcript').prop('scrollHeight'));
});
this.text.value = '';
return false;
});
</script>
</body>
</html>