Spaces:
Running

youassistant / index.html
Yghubpush's picture
Add 3 files
b484f6b verified
Raw History Blame Contribute Delete
10.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Powerful Chatbox</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message-animation {
animation: fadeIn 0.3s ease-out forwards;
}
.typing-indicator span {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #4f46e5;
margin: 0 2px;
}
.typing-indicator span:nth-child(1) {
animation: bounce 1.3s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) {
animation: bounce 1.3s infinite ease-in-out 0.2s;
}
.typing-indicator span:nth-child(3) {
animation: bounce 1.3s infinite ease-in-out 0.4s;
}
@keyframes bounce {
0%, 60%, 100% { transform: translateY(0); }
30% { transform: translateY(-5px); }
}
.chat-container {
height: 500px;
transition: all 0.3s ease;
}
.message-input:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
.scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>
</head>
<body class="bg-gray-100 flex items-center justify-center min-h-screen p-4">
<div class="w-full max-w-md bg-white rounded-2xl shadow-xl overflow-hidden">
<!-- Chat header -->
<div class="bg-indigo-600 text-white p-4 flex items-center justify-between">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-indigo-500 flex items-center justify-center">
<i class="fas fa-robot text-xl"></i>
</div>
<div>
<h3 class="font-semibold">AI Assistant</h3>
<p class="text-xs text-indigo-200">Online</p>
</div>
</div>
<div class="flex space-x-2">
<button class="w-8 h-8 rounded-full bg-indigo-500 hover:bg-indigo-700 flex items-center justify-center transition">
<i class="fas fa-phone-alt text-sm"></i>
</button>
<button class="w-8 h-8 rounded-full bg-indigo-500 hover:bg-indigo-700 flex items-center justify-center transition">
<i class="fas fa-video text-sm"></i>
</button>
<button class="w-8 h-8 rounded-full bg-indigo-500 hover:bg-indigo-700 flex items-center justify-center transition">
<i class="fas fa-ellipsis-v text-sm"></i>
</button>
</div>
</div>
<!-- Chat messages -->
<div class="chat-container flex flex-col">
<div class="flex-1 p-4 overflow-y-auto scrollbar-hide" id="chat-messages">
<!-- Messages will be inserted here by JavaScript -->
</div>
<!-- Typing indicator -->
<div id="typing-indicator" class="px-4 pb-2 hidden">
<div class="flex items-center space-x-2">
<div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center">
<i class="fas fa-robot text-indigo-600"></i>
</div>
<div class="typing-indicator bg-gray-100 rounded-full px-4 py-2">
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
<!-- Message input -->
<div class="border-t border-gray-200 p-4">
<div class="flex items-center space-x-2">
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-gray-200 flex items-center justify-center transition">
<i class="fas fa-paperclip text-gray-500"></i>
</button>
<div class="flex-1 relative">
<input
type="text"
id="message-input"
placeholder="Type your message..."
class="message-input w-full bg-gray-100 rounded-full py-3 px-4 pr-12 focus:ring-2 focus:ring-indigo-200 transition"
autocomplete="off"
>
<button class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 hover:text-indigo-600 transition">
<i class="far fa-smile"></i>
</button>
</div>
<button
id="send-button"
class="w-10 h-10 rounded-full bg-indigo-600 hover:bg-indigo-700 flex items-center justify-center transition text-white"
>
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const chatMessages = document.getElementById('chat-messages');
const messageInput = document.getElementById('message-input');
const sendButton = document.getElementById('send-button');
const typingIndicator = document.getElementById('typing-indicator');
// Sample bot responses
const botResponses = [
"Hello! How can I assist you today?",
"That's an interesting question. Let me think about that...",
"I'm an AI assistant here to help with your queries.",
"I don't have information about that, but I can look it up for you.",
"Thanks for chatting with me! Is there anything else you'd like to know?"
];
// Add initial bot message
setTimeout(() => {
addMessage('bot', "Hello there! 👋 I'm your AI assistant. How can I help you today?");
}, 500);
// Send message when button is clicked
sendButton.addEventListener('click', sendMessage);
// Send message when Enter is pressed
messageInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
sendMessage();
}
});
function sendMessage() {
const message = messageInput.value.trim();
if (message) {
addMessage('user', message);
messageInput.value = '';
// Show typing indicator
typingIndicator.classList.remove('hidden');
// Simulate bot thinking and responding
setTimeout(() => {
typingIndicator.classList.add('hidden');
const randomResponse = botResponses[Math.floor(Math.random() * botResponses.length)];
addMessage('bot', randomResponse);
// Scroll to bottom
chatMessages.scrollTop = chatMessages.scrollHeight;
}, 1500 + Math.random() * 2000);
}
}
function addMessage(sender, text) {
const messageDiv = document.createElement('div');
messageDiv.classList.add('mb-4', 'message-animation');
const timestamp = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
if (sender === 'user') {
messageDiv.innerHTML = `
<div class="flex justify-end">
<div class="max-w-xs md:max-w-md lg:max-w-lg bg-indigo-600 text-white rounded-t-2xl rounded-l-2xl px-4 py-2">
<p>${text}</p>
<p class="text-xs text-indigo-200 text-right mt-1">${timestamp}</p>
</div>
</div>
`;
} else {
messageDiv.innerHTML = `
<div class="flex items-start space-x-2">
<div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center">
<i class="fas fa-robot text-indigo-600"></i>
</div>
<div class="max-w-xs md:max-w-md lg:max-w-lg bg-gray-100 rounded-t-2xl rounded-r-2xl px-4 py-2">
<p>${text}</p>
<p class="text-xs text-gray-500 mt-1">${timestamp}</p>
</div>
</div>
`;
}
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Yghubpush/youassistant" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>