-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
74 lines (61 loc) · 2.75 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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QoomBot</title>
<script src="https://npmcdn.com/[email protected]/dist/js/tether.min.js"></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<link rel="stylesheet" href="style.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js'></script>
<script src="script.js"></script>
</head>
<body>
<div id="chat-circle" class="btn btn-raised">
<div id="chat-overlay"></div>
<i class="material-icons">question_answer</i>
</div>
<div class="chat-box">
<div class="chat-box-header">
ChatBot
<div class="chat-box-toggle"><i class="material-icons">close</i>
</div>
</div>
<div class="chat-box-body">
<div class="chat-box-overlay">
</div>
<div id="textarea" readonly class="chat-logs">
</div><!--chat-log -->
</div>
<div class="chat-input">
<input type="text" id="chat-input" name="question" placeholder="How can we help you?"/>
<button type="submit" class="chat-submit" id="chat-submit" value = request onclick='send()'><i class="material-icons">send</i></button>
</div>
</div>
<script>
async function send() {
const input = document.querySelector('input').value;
const resp = await fetch('/qoombot/answer', { // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
body: JSON.stringify({question: input}), // Converting data into a string to send to server cols="15" rows="5"
headers: { 'Content-Type': 'application/json'},
method: 'POST'
})
const text = await resp.text();
const inp = document.createElement("div");
const div = document.createElement("div");
//<img src = 'static/user.png'>
//<img src = '{{url_for('static', filename='qoomlogo.jpeg')}}'>
inp.innerText="You: "+ String(input) +"\n\n";
document.querySelector('#textarea').appendChild(inp);
div.innerText="QoomBot: "+text+"\n\n";
document.querySelector('#textarea').appendChild(div);
var element = document.getElementById('textarea');
element.scrollTop = element.scrollHeight;
}
</script>
</body>
</html>