Spaces:
Running
Running
Download script.js from daxkhal/virtual-romance-oasis: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/spaces/daxkhal/virtual-romance-oasis/resolve/main/script.js
- Command line
-
hf download hf://spaces/daxkhal/virtual-romance-oasis/script.js
-
curl -L -o script.js https://huggingface.co/spaces/daxkhal/virtual-romance-oasis/resolve/main/script.js
2.46 kB
| // Initialize real-time features (simulated for demo) | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Simulate online status updates | |
| setInterval(() => { | |
| const statusIndicators = document.querySelectorAll('.status-indicator'); | |
| statusIndicators.forEach(indicator => { | |
| // Randomly change some statuses for demo purposes | |
| if (Math.random() > 0.8) { | |
| indicator.classList.toggle('bg-green-500'); | |
| indicator.classList.toggle('bg-gray-500'); | |
| } | |
| }); | |
| }, 5000); | |
| // Handle chat functionality | |
| const chatForm = document.querySelector('.chat-form'); | |
| if (chatForm) { | |
| chatForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const input = chatForm.querySelector('input'); | |
| if (input.value.trim()) { | |
| // In a real app, this would send to a server | |
| addMessageToChat('You', input.value, true); | |
| input.value = ''; | |
| // Simulate reply after 1-3 seconds | |
| setTimeout(() => { | |
| const replies = [ | |
| "That's interesting! Tell me more.", | |
| "I feel the same way!", | |
| "What are you up to today?", | |
| "Would you like to meet in the virtual world?", | |
| "😊" | |
| ]; | |
| const randomReply = replies[Math.floor(Math.random() * replies.length)]; | |
| addMessageToChat('Virtual Friend', randomReply, false); | |
| }, 1000 + Math.random() * 2000); | |
| } | |
| }); | |
| } | |
| }); | |
| function addMessageToChat(sender, message, isUser) { | |
| const chatMessages = document.querySelector('.chat-messages'); | |
| if (chatMessages) { | |
| const messageDiv = document.createElement('div'); | |
| messageDiv.className = `flex ${isUser ? 'justify-end' : 'justify-start'} mb-3`; | |
| messageDiv.innerHTML = ` | |
| <div class="${isUser ? 'bg-pink-600' : 'bg-indigo-700'} rounded-lg px-4 py-2 max-w-xs lg:max-w-md"> | |
| <div class="text-xs font-semibold ${isUser ? 'text-pink-200' : 'text-indigo-200'}">${sender}</div> | |
| <div class="mt-1">${message}</div> | |
| </div> | |
| `; | |
| chatMessages.appendChild(messageDiv); | |
| chatMessages.scrollTop = chatMessages.scrollHeight; | |
| } | |
| } |