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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<meta name="description" content="A simple chatbot application built with HTML, CSS, and vanilla JavaScript.">
|
| 7 |
+
<meta name="keywords" content="chatbot, AI, simple bot">
|
| 8 |
+
<title>Simple Chatbot</title>
|
| 9 |
+
<link rel="stylesheet" href="assets/css/styles.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<header>
|
| 13 |
+
<h1>Simple Chatbot</h1>
|
| 14 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
|
| 15 |
+
</header>
|
| 16 |
+
<main>
|
| 17 |
+
<div id="chat-container">
|
| 18 |
+
<div id="chat-messages">
|
| 19 |
+
<div class="message bot">Bot: Hello! How can I help you today?</div>
|
| 20 |
+
</div>
|
| 21 |
+
<div id="input-area">
|
| 22 |
+
<input type="text" id="user-input" placeholder="Type your message...">
|
| 23 |
+
<button id="send-button">Send</button>
|
| 24 |
+
</div>
|
| 25 |
+
</div>
|
| 26 |
+
</main>
|
| 27 |
+
<footer>
|
| 28 |
+
<p>© 2023 Simple Chatbot. All rights reserved.</p>
|
| 29 |
+
</footer>
|
| 30 |
+
<script src="assets/js/chatbot.js"></script>
|
| 31 |
+
</body>
|
| 32 |
</html>
|
| 33 |
+
|
| 34 |
+
=== assets/css/styles.css ===
|
| 35 |
+
/* Mobile-first responsive design */
|
| 36 |
+
body {
|
| 37 |
+
font-family: Arial, sans-serif;
|
| 38 |
+
margin: 0;
|
| 39 |
+
padding: 0;
|
| 40 |
+
display: flex;
|
| 41 |
+
flex-direction: column;
|
| 42 |
+
min-height: 100vh;
|
| 43 |
+
background-color: #f4f4f4;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
header {
|
| 47 |
+
background-color: #333;
|
| 48 |
+
color: white;
|
| 49 |
+
text-align: center;
|
| 50 |
+
padding: 1rem;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
header h1 {
|
| 54 |
+
margin: 0;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
header a {
|
| 58 |
+
color: #4CAF50;
|
| 59 |
+
text-decoration: none;
|
| 60 |
+
font-size: 0.9rem;
|
| 61 |
+
margin-top: 0.5rem;
|
| 62 |
+
display: block;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
header a:hover {
|
| 66 |
+
text-decoration: underline;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
main {
|
| 70 |
+
flex: 1;
|
| 71 |
+
display: flex;
|
| 72 |
+
justify-content: center;
|
| 73 |
+
padding: 1rem;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
#chat-container {
|
| 77 |
+
width: 100%;
|
| 78 |
+
max-width: 600px;
|
| 79 |
+
background-color: white;
|
| 80 |
+
border-radius: 8px;
|
| 81 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 82 |
+
display: flex;
|
| 83 |
+
flex-direction: column;
|
| 84 |
+
height: 80vh;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
#chat-messages {
|
| 88 |
+
flex: 1;
|
| 89 |
+
overflow-y: auto;
|
| 90 |
+
padding: 1rem;
|
| 91 |
+
border-bottom: 1px solid #ddd;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.message {
|
| 95 |
+
margin-bottom: 1rem;
|
| 96 |
+
padding: 0.5rem;
|
| 97 |
+
border-radius: 4px;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.message.user {
|
| 101 |
+
background-color: #4CAF50;
|
| 102 |
+
color: white;
|
| 103 |
+
text-align: right;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.message.bot {
|
| 107 |
+
background-color: #e0e0e0;
|
| 108 |
+
color: #333;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
#input-area {
|
| 112 |
+
display: flex;
|
| 113 |
+
padding: 1rem;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
#user-input {
|
| 117 |
+
flex: 1;
|
| 118 |
+
padding: 0.5rem;
|
| 119 |
+
border: 1px solid #ddd;
|
| 120 |
+
border-radius: 4px 0 0 4px;
|
| 121 |
+
outline: none;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
#send-button {
|
| 125 |
+
padding: 0.5rem 1rem;
|
| 126 |
+
background-color: #4CAF50;
|
| 127 |
+
color: white;
|
| 128 |
+
border: none;
|
| 129 |
+
border-radius: 0 4px 4px 0;
|
| 130 |
+
cursor: pointer;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
#send-button:hover {
|
| 134 |
+
background-color: #45a049;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
footer {
|
| 138 |
+
background-color: #333;
|
| 139 |
+
color: white;
|
| 140 |
+
text-align: center;
|
| 141 |
+
padding: 1rem;
|
| 142 |
+
margin-top: auto;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
/* Responsive adjustments */
|
| 146 |
+
@media (min-width: 768px) {
|
| 147 |
+
#chat-container {
|
| 148 |
+
height: 70vh;
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
=== assets/js/chatbot.js ===
|
| 153 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 154 |
+
const chatMessages = document.getElementById('chat-messages');
|
| 155 |
+
const userInput = document.getElementById('user-input');
|
| 156 |
+
const sendButton = document.getElementById('send-button');
|
| 157 |
+
|
| 158 |
+
// Simple response logic
|
| 159 |
+
function getBotResponse(message) {
|
| 160 |
+
message = message.toLowerCase();
|
| 161 |
+
if (message.includes('hello') || message.includes('hi')) {
|
| 162 |
+
return 'Bot: Hi there! How can I assist you?';
|
| 163 |
+
} else if (message.includes('how are you')) {
|
| 164 |
+
return 'Bot: I\'m doing well, thank you! What about you?';
|
| 165 |
+
} else if (message.includes('bye') || message.includes('goodbye')) {
|
| 166 |
+
return 'Bot: Goodbye! Have a great day!';
|
| 167 |
+
} else {
|
| 168 |
+
return 'Bot: Sorry, I didn\'t understand that. Can you try rephrasing?';
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Function to add message to chat
|
| 173 |
+
function addMessage(text, className) {
|
| 174 |
+
const messageDiv = document.createElement('div');
|
| 175 |
+
messageDiv.className = `message ${className}`;
|
| 176 |
+
messageDiv.textContent = text;
|
| 177 |
+
chatMessages.appendChild(messageDiv);
|
| 178 |
+
chatMessages.scrollTop = chatMessages.scrollHeight; // Auto-scroll to bottom
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
// Send message function
|
| 182 |
+
function sendMessage() {
|
| 183 |
+
const message = userInput.value.trim();
|
| 184 |
+
if (message) {
|
| 185 |
+
addMessage(`You: ${message}`, 'user');
|
| 186 |
+
userInput.value = '';
|
| 187 |
+
// Simulate bot response after a short delay
|
| 188 |
+
setTimeout(() => {
|
| 189 |
+
const response = getBotResponse(message);
|
| 190 |
+
addMessage(response, 'bot');
|
| 191 |
+
}, 500);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
// Event listeners
|
| 196 |
+
sendButton.addEventListener('click', sendMessage);
|
| 197 |
+
userInput.addEventListener('keypress', function(e) {
|
| 198 |
+
if (e.key === 'Enter') {
|
| 199 |
+
sendMessage();
|
| 200 |
+
}
|
| 201 |
+
});
|
| 202 |
+
});
|