Add 3 files
Browse files- index.html +1 -19
- main.js +23 -0
- style.css +28 -24
index.html
CHANGED
|
@@ -1,19 +1 @@
|
|
| 1 |
-
<
|
| 2 |
-
<html>
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width" />
|
| 6 |
-
<title>My static Space</title>
|
| 7 |
-
<link rel="stylesheet" href="style.css" />
|
| 8 |
-
</head>
|
| 9 |
-
<body>
|
| 10 |
-
<div class="card">
|
| 11 |
-
<h1>Welcome to your static Space!</h1>
|
| 12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
| 13 |
-
<p>
|
| 14 |
-
Also don't forget to check the
|
| 15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
| 16 |
-
</p>
|
| 17 |
-
</div>
|
| 18 |
-
</body>
|
| 19 |
-
</html>
|
|
|
|
| 1 |
+
<html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Chatbot in HTML</title></head><body><h1>Chatbot in HTML</h1><div class="w-full lg:w-1/2"><div x-data="{ message: '', messages: [] }" class="chatapp-chat"></div><div class="chatapp-messages"><div x-data="{ messages: [] }"><template x-for="message in messages"><div class="chatapp-message"><span x-text="message"></span></div></template></div></div></div></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { receiveMessage } = require('./script.js');
|
| 2 |
+
|
| 3 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 4 |
+
const chatApp = document.querySelector('.chatapp-chat');
|
| 5 |
+
const messagesContainer = document.querySelector('.chatapp-messages');
|
| 6 |
+
|
| 7 |
+
chatApp.addEventListener('chat-submit', function(event) {
|
| 8 |
+
event.preventDefault();
|
| 9 |
+
const message = event.detail.Message;
|
| 10 |
+
messagesContainer.innerHTML += message;
|
| 11 |
+
receiveMessage(message);
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
receiveMessage('Welcome to the chat! How can I help you?');
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
function receiveMessage(message) {
|
| 18 |
+
const delay = 1000;
|
| 19 |
+
const response = 'I\'m just an AI, I don\'t have the ability to respond to your message.';
|
| 20 |
+
setTimeout(function() {
|
| 21 |
+
messagesContainer.innerHTML += response;
|
| 22 |
+
}, delay);
|
| 23 |
+
}
|
style.css
CHANGED
|
@@ -1,28 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
.card p:last-child {
|
| 27 |
-
margin-bottom: 0;
|
| 28 |
-
}
|
|
|
|
| 1 |
+
.chatapp-chat {
|
| 2 |
+
border-radius: 6px;
|
| 3 |
+
padding: 20px;
|
| 4 |
+
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15);
|
| 5 |
+
border: 1px solid #dbe2ef;
|
| 6 |
+
background-color: #dae1ee;
|
| 7 |
+
display: flex;
|
| 8 |
+
flex-direction: column;
|
| 9 |
+
justify-content: center;
|
| 10 |
+
align-items: center;
|
| 11 |
}
|
| 12 |
|
| 13 |
+
.chatapp-messages {
|
| 14 |
+
padding: 20px;
|
| 15 |
+
border-radius: 6px;
|
| 16 |
+
background-color: #dae1ee;
|
| 17 |
+
display: flex;
|
| 18 |
+
flex-direction: column;
|
| 19 |
+
justify-content: center;
|
| 20 |
+
align-items: center;
|
| 21 |
}
|
| 22 |
|
| 23 |
+
.chatapp-message {
|
| 24 |
+
margin-bottom: 10px;
|
| 25 |
+
padding: 10px;
|
| 26 |
+
border-radius: 6px;
|
| 27 |
+
background-color: #dbe2ef;
|
| 28 |
+
display: flex;
|
| 29 |
+
flex-direction: column;
|
| 30 |
+
justify-content: center;
|
| 31 |
+
align-items: center;
|
| 32 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|