darknight123
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,46 @@
|
|
1 |
-
---
|
2 |
-
license: artistic-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: artistic-2.0
|
3 |
+
---
|
4 |
+
<!DOCTYPE html>
|
5 |
+
<html lang="en">
|
6 |
+
<head>
|
7 |
+
<meta charset="UTF-8">
|
8 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
9 |
+
<title>ChatBot</title>
|
10 |
+
<link href="https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.css" rel="stylesheet" type="text/css" />
|
11 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
12 |
+
</head>
|
13 |
+
<body class="bg-gray-100 h-screen flex items-center justify-center">
|
14 |
+
<div class="bg-white p-8 rounded-lg shadow-lg w-full max-w-md">
|
15 |
+
<h1 class="text-2xl font-bold mb-4 text-center">Your Friendly ChatBot</h1>
|
16 |
+
<div id="chatbox" class="chat chat-start h-96 overflow-y-auto mb-4"></div>
|
17 |
+
<div class="flex">
|
18 |
+
<input type="text" id="inputMessage" placeholder="Type your message here..." class="input input-bordered flex-grow">
|
19 |
+
<button id="sendMessage" class="btn btn-primary ml-2">Send</button>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
|
23 |
+
<script>
|
24 |
+
var inputMessage = document.getElementById("inputMessage");
|
25 |
+
var sendMessage = document.getElementById("sendMessage");
|
26 |
+
var chatbox = document.getElementById("chatbox");
|
27 |
+
|
28 |
+
sendMessage.addEventListener("click", function() {
|
29 |
+
var message = inputMessage.value;
|
30 |
+
if (message.trim() !== "") {
|
31 |
+
sendMessageToChat(message, "user");
|
32 |
+
inputMessage.value = "";
|
33 |
+
sendMessageToChat("Sorry, the chatbot is unavailable at the moment. Please try again later.", "assistant");
|
34 |
+
}
|
35 |
+
});
|
36 |
+
|
37 |
+
function sendMessageToChat(message, role) {
|
38 |
+
var messageElement = document.createElement("div");
|
39 |
+
messageElement.classList.add("chat-bubble", role === "user" ? "chat-bubble-primary" : "chat-bubble-secondary");
|
40 |
+
messageElement.innerHTML = "<p><strong>" + role + ":</strong> " + message + "</p>";
|
41 |
+
chatbox.appendChild(messageElement);
|
42 |
+
chatbox.scrollTop = chatbox.scrollHeight;
|
43 |
+
}
|
44 |
+
</script>
|
45 |
+
</body>
|
46 |
+
</html>
|