Spaces:
Running
Running
Commit
·
48ddfd9
1
Parent(s):
6d0f792
Update index.html
Browse files- index.html +47 -11
index.html
CHANGED
|
@@ -6,14 +6,50 @@
|
|
| 6 |
<title>My static Space</title>
|
| 7 |
<link rel="stylesheet" href="style.css" />
|
| 8 |
</head>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
<title>My static Space</title>
|
| 7 |
<link rel="stylesheet" href="style.css" />
|
| 8 |
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div id="chat-container">
|
| 11 |
+
<div id="chat-log">
|
| 12 |
+
<!-- Chat log area where messages will be displayed -->
|
| 13 |
+
</div>
|
| 14 |
+
<div id="user-input">
|
| 15 |
+
<input type="text" id="user-message" placeholder="Type your message..." />
|
| 16 |
+
<button id="send-button">Send</button>
|
| 17 |
+
</div>
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<script>
|
| 21 |
+
// JavaScript code for the chatbot functionality
|
| 22 |
+
// Add your own logic and functionality here
|
| 23 |
+
|
| 24 |
+
// Function to handle user messages and display them in the chat log
|
| 25 |
+
function handleUserMessage() {
|
| 26 |
+
var userInput = document.getElementById("user-message");
|
| 27 |
+
var userMessage = userInput.value;
|
| 28 |
+
|
| 29 |
+
// Display the user message in the chat log
|
| 30 |
+
var chatLog = document.getElementById("chat-log");
|
| 31 |
+
var userMessageElement = document.createElement("div");
|
| 32 |
+
userMessageElement.className = "user-message";
|
| 33 |
+
userMessageElement.textContent = userMessage;
|
| 34 |
+
chatLog.appendChild(userMessageElement);
|
| 35 |
+
|
| 36 |
+
// Add your logic to process the user message and generate bot response here
|
| 37 |
+
|
| 38 |
+
// Clear the user input field
|
| 39 |
+
userInput.value = "";
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Event listener for the send button
|
| 43 |
+
var sendButton = document.getElementById("send-button");
|
| 44 |
+
sendButton.addEventListener("click", handleUserMessage);
|
| 45 |
+
|
| 46 |
+
// Event listener for the enter key to submit the user message
|
| 47 |
+
var userInput = document.getElementById("user-message");
|
| 48 |
+
userInput.addEventListener("keydown", function (event) {
|
| 49 |
+
if (event.keyCode === 13) { // 13 is the Enter key code
|
| 50 |
+
handleUserMessage();
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
</script>
|
| 54 |
+
</body>
|
| 55 |
+
</html>
|