forked from goku44SSJ/J.U.R.I.M.I.N.D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot.html
76 lines (66 loc) · 2.24 KB
/
chatbot.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 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>AI ChatBot</title>
<link rel="stylesheet" type="text/css" href="static/style.css">
</head>
<body>
<header>
<a href="{{ url_for('main_page') }}" class="logo">J.U.R.I.M.I.N.D</a>
<nav class="navigation">
<a href="{{ url_for('landing_page') }}">Home</a>
<a href="{{ url_for('about_page') }}">About</a>
<a href="{{ url_for('main_page') }}">Services</a>
<a href="{{ url_for('pricing_page') }}">Pricing</a>
</nav>
</header>
<div class="chat-container">
<div class="chat" id="chat-box">
<!-- Chat messages will be dynamically added here -->
</div>
<div class="input-container">
<input type="text" id="user-input" placeholder="Type your message...">
<button id="send-button">Send</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$("#send-button").click(function () {
sendMessage();
});
$("#user-input").keypress(function (e) {
if (e.which === 13) {
sendMessage();
}
});
function sendMessage() {
var userMessage = $("#user-input").val();
if (userMessage.trim() === "") {
return;
}
$("#chat-box").append('<div class="user-message">' + userMessage + '</div>');
$("#user-input").val("");
$.ajax({
type: "POST",
url: "/api/chat",
data: { userMessage: userMessage },
success: function (data) {
var chatbotResponse = data.response;
$("#chat-box").append('<div class="chatbot-message">' + chatbotResponse + '</div>');
scrollChatToBottom();
},
error: function (error) {
console.error(error);
},
});
}
function scrollChatToBottom() {
var chatBox = document.getElementById("chat-box");
chatBox.scrollTop = chatBox.scrollHeight;
}
});
</script>