Add 3 files
Browse files- README.md +6 -4
- index.html +463 -19
- prompts.txt +6 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: green
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: chat-app
|
| 3 |
+
emoji: 🐳
|
| 4 |
colorFrom: green
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,463 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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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 |
+
<title>Real-Time Chat App</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
|
| 9 |
+
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js"></script>
|
| 10 |
+
<style>
|
| 11 |
+
.message-container {
|
| 12 |
+
scrollbar-width: thin;
|
| 13 |
+
scrollbar-color: #4B5563 #1F2937;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.message-container::-webkit-scrollbar {
|
| 17 |
+
width: 8px;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.message-container::-webkit-scrollbar-track {
|
| 21 |
+
background: #1F2937;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.message-container::-webkit-scrollbar-thumb {
|
| 25 |
+
background-color: #4B5563;
|
| 26 |
+
border-radius: 4px;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.typing-indicator::after {
|
| 30 |
+
content: "...";
|
| 31 |
+
animation: typing 1.5s infinite;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
@keyframes typing {
|
| 35 |
+
0% { content: "."; }
|
| 36 |
+
33% { content: ".."; }
|
| 37 |
+
66% { content: "..."; }
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.fade-in {
|
| 41 |
+
animation: fadeIn 0.3s ease-in;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
@keyframes fadeIn {
|
| 45 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 46 |
+
to { opacity: 1; transform: translateY(0); }
|
| 47 |
+
}
|
| 48 |
+
</style>
|
| 49 |
+
</head>
|
| 50 |
+
<body class="bg-gray-900 text-gray-100 min-h-screen flex flex-col">
|
| 51 |
+
<!-- Firebase Configuration -->
|
| 52 |
+
<script>
|
| 53 |
+
// Your Firebase configuration
|
| 54 |
+
const firebaseConfig = {
|
| 55 |
+
apiKey: "AIzaSyB5XQ7j5X5X5X5X5X5X5X5X5X5X5X5X5X5",
|
| 56 |
+
authDomain: "realtime-chat-app-12345.firebaseapp.com",
|
| 57 |
+
databaseURL: "https://realtime-chat-app-12345.firebaseio.com",
|
| 58 |
+
projectId: "realtime-chat-app-12345",
|
| 59 |
+
storageBucket: "realtime-chat-app-12345.appspot.com",
|
| 60 |
+
messagingSenderId: "123456789012",
|
| 61 |
+
appId: "1:123456789012:web:5X5X5X5X5X5X5X5X5X5X5X"
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
// Initialize Firebase
|
| 65 |
+
firebase.initializeApp(firebaseConfig);
|
| 66 |
+
const database = firebase.database();
|
| 67 |
+
</script>
|
| 68 |
+
|
| 69 |
+
<header class="bg-gray-800 py-4 px-6 shadow-lg">
|
| 70 |
+
<div class="container mx-auto flex justify-between items-center">
|
| 71 |
+
<h1 class="text-2xl font-bold text-blue-400">Real-Time Chat</h1>
|
| 72 |
+
<div id="connection-status" class="flex items-center">
|
| 73 |
+
<span class="h-3 w-3 rounded-full bg-red-500 mr-2"></span>
|
| 74 |
+
<span>Disconnected</span>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
</header>
|
| 78 |
+
|
| 79 |
+
<main class="flex-1 container mx-auto p-4 flex flex-col md:flex-row gap-6">
|
| 80 |
+
<!-- Connection Panel -->
|
| 81 |
+
<div class="bg-gray-800 rounded-lg p-6 w-full md:w-1/3 lg:w-1/4 shadow-lg">
|
| 82 |
+
<div class="mb-6">
|
| 83 |
+
<h2 class="text-xl font-semibold mb-4">Your Profile</h2>
|
| 84 |
+
<div class="space-y-4">
|
| 85 |
+
<div>
|
| 86 |
+
<label for="user-id" class="block text-sm font-medium mb-1">Your Unique ID</label>
|
| 87 |
+
<div class="flex">
|
| 88 |
+
<input type="text" id="user-id" readonly class="bg-gray-700 text-gray-200 rounded-l-md px-3 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 89 |
+
<button onclick="copyUserId()" class="bg-blue-600 hover:bg-blue-700 px-3 rounded-r-md flex items-center">
|
| 90 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 91 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
|
| 92 |
+
</svg>
|
| 93 |
+
</button>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
<div>
|
| 97 |
+
<label for="display-name" class="block text-sm font-medium mb-1">Display Name</label>
|
| 98 |
+
<input type="text" id="display-name" placeholder="Enter your name" class="bg-gray-700 text-gray-200 rounded-md px-3 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 99 |
+
</div>
|
| 100 |
+
<button onclick="generateUserId()" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md transition duration-200">
|
| 101 |
+
Generate New ID
|
| 102 |
+
</button>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<div>
|
| 107 |
+
<h2 class="text-xl font-semibold mb-4">Connect to Friend</h2>
|
| 108 |
+
<div class="space-y-4">
|
| 109 |
+
<div>
|
| 110 |
+
<label for="friend-id" class="block text-sm font-medium mb-1">Friend's ID</label>
|
| 111 |
+
<input type="text" id="friend-id" placeholder="Enter friend's ID" class="bg-gray-700 text-gray-200 rounded-md px-3 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 112 |
+
</div>
|
| 113 |
+
<button onclick="connectToFriend()" id="connect-button" class="w-full bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-md transition duration-200">
|
| 114 |
+
Connect
|
| 115 |
+
</button>
|
| 116 |
+
<button onclick="disconnectFromFriend()" id="disconnect-button" class="w-full bg-red-600 hover:bg-red-700 text-white py-2 px-4 rounded-md transition duration-200 hidden">
|
| 117 |
+
Disconnect
|
| 118 |
+
</button>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
|
| 123 |
+
<!-- Chat Panel -->
|
| 124 |
+
<div class="bg-gray-800 rounded-lg p-6 flex-1 shadow-lg flex flex-col">
|
| 125 |
+
<div class="flex justify-between items-center mb-4">
|
| 126 |
+
<h2 class="text-xl font-semibold">Chat</h2>
|
| 127 |
+
<div id="chat-status" class="text-sm text-gray-400">
|
| 128 |
+
Not connected to anyone
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<div id="message-container" class="message-container flex-1 overflow-y-auto mb-4 space-y-3 p-2 bg-gray-700 rounded-lg">
|
| 133 |
+
<div class="text-center text-gray-400 py-10">
|
| 134 |
+
Connect with a friend to start chatting
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<div id="typing-indicator" class="typing-indicator text-sm text-gray-400 mb-2 h-5 hidden">
|
| 139 |
+
Friend is typing
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<div class="flex gap-2">
|
| 143 |
+
<input type="text" id="message-input" placeholder="Type a message..." disabled class="flex-1 bg-gray-700 text-gray-200 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 144 |
+
<button onclick="sendMessage()" id="send-button" disabled class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md transition duration-200 disabled:opacity-50">
|
| 145 |
+
Send
|
| 146 |
+
</button>
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
</main>
|
| 150 |
+
|
| 151 |
+
<script>
|
| 152 |
+
// Global variables
|
| 153 |
+
let userId = '';
|
| 154 |
+
let friendId = '';
|
| 155 |
+
let displayName = 'Anonymous';
|
| 156 |
+
let isConnected = false;
|
| 157 |
+
let typingTimeout;
|
| 158 |
+
let chatRef;
|
| 159 |
+
let typingRef;
|
| 160 |
+
let userRef;
|
| 161 |
+
|
| 162 |
+
// Initialize the app
|
| 163 |
+
function init() {
|
| 164 |
+
// Check if user ID exists in localStorage
|
| 165 |
+
if (localStorage.getItem('chatUserId')) {
|
| 166 |
+
userId = localStorage.getItem('chatUserId');
|
| 167 |
+
document.getElementById('user-id').value = userId;
|
| 168 |
+
} else {
|
| 169 |
+
generateUserId();
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Check if display name exists
|
| 173 |
+
if (localStorage.getItem('chatDisplayName')) {
|
| 174 |
+
displayName = localStorage.getItem('chatDisplayName');
|
| 175 |
+
document.getElementById('display-name').value = displayName;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Set up event listeners
|
| 179 |
+
document.getElementById('display-name').addEventListener('input', function() {
|
| 180 |
+
displayName = this.value || 'Anonymous';
|
| 181 |
+
localStorage.setItem('chatDisplayName', displayName);
|
| 182 |
+
|
| 183 |
+
if (isConnected) {
|
| 184 |
+
// Update display name in the database
|
| 185 |
+
userRef.update({
|
| 186 |
+
name: displayName
|
| 187 |
+
});
|
| 188 |
+
}
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
document.getElementById('message-input').addEventListener('input', function() {
|
| 192 |
+
if (isConnected) {
|
| 193 |
+
// User is typing
|
| 194 |
+
typingRef.set(true);
|
| 195 |
+
|
| 196 |
+
// Clear previous timeout if it exists
|
| 197 |
+
if (typingTimeout) clearTimeout(typingTimeout);
|
| 198 |
+
|
| 199 |
+
// Set timeout to indicate typing stopped
|
| 200 |
+
typingTimeout = setTimeout(() => {
|
| 201 |
+
typingRef.set(false);
|
| 202 |
+
}, 1000);
|
| 203 |
+
}
|
| 204 |
+
});
|
| 205 |
+
|
| 206 |
+
document.getElementById('message-input').addEventListener('keypress', function(e) {
|
| 207 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
| 208 |
+
e.preventDefault();
|
| 209 |
+
sendMessage();
|
| 210 |
+
}
|
| 211 |
+
});
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
// Generate a new user ID
|
| 215 |
+
function generateUserId() {
|
| 216 |
+
userId = 'user-' + Math.random().toString(36).substr(2, 9);
|
| 217 |
+
document.getElementById('user-id').value = userId;
|
| 218 |
+
localStorage.setItem('chatUserId', userId);
|
| 219 |
+
|
| 220 |
+
// Disconnect if currently connected
|
| 221 |
+
if (isConnected) {
|
| 222 |
+
disconnectFromFriend();
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
// Copy user ID to clipboard
|
| 227 |
+
function copyUserId() {
|
| 228 |
+
const userIdInput = document.getElementById('user-id');
|
| 229 |
+
userIdInput.select();
|
| 230 |
+
document.execCommand('copy');
|
| 231 |
+
|
| 232 |
+
// Show feedback
|
| 233 |
+
const copyButton = userIdInput.nextElementSibling;
|
| 234 |
+
copyButton.innerHTML = `
|
| 235 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 236 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
| 237 |
+
</svg>
|
| 238 |
+
`;
|
| 239 |
+
|
| 240 |
+
setTimeout(() => {
|
| 241 |
+
copyButton.innerHTML = `
|
| 242 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 243 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
|
| 244 |
+
</svg>
|
| 245 |
+
`;
|
| 246 |
+
}, 2000);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
// Connect to a friend
|
| 250 |
+
function connectToFriend() {
|
| 251 |
+
friendId = document.getElementById('friend-id').value.trim();
|
| 252 |
+
|
| 253 |
+
if (!friendId) {
|
| 254 |
+
alert('Please enter your friend\'s ID');
|
| 255 |
+
return;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
if (friendId === userId) {
|
| 259 |
+
alert('You cannot connect to yourself');
|
| 260 |
+
return;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// Check if friend exists
|
| 264 |
+
const friendRef = database.ref('users/' + friendId);
|
| 265 |
+
|
| 266 |
+
friendRef.once('value').then((snapshot) => {
|
| 267 |
+
if (snapshot.exists()) {
|
| 268 |
+
// Friend exists, establish connection
|
| 269 |
+
isConnected = true;
|
| 270 |
+
|
| 271 |
+
// Update UI
|
| 272 |
+
document.getElementById('connect-button').classList.add('hidden');
|
| 273 |
+
document.getElementById('disconnect-button').classList.remove('hidden');
|
| 274 |
+
document.getElementById('message-input').disabled = false;
|
| 275 |
+
document.getElementById('send-button').disabled = false;
|
| 276 |
+
document.getElementById('friend-id').disabled = true;
|
| 277 |
+
|
| 278 |
+
// Update status
|
| 279 |
+
document.getElementById('connection-status').innerHTML = `
|
| 280 |
+
<span class="h-3 w-3 rounded-full bg-green-500 mr-2"></span>
|
| 281 |
+
<span>Connected to ${snapshot.val().name || 'Friend'}</span>
|
| 282 |
+
`;
|
| 283 |
+
|
| 284 |
+
document.getElementById('chat-status').textContent = `Chatting with ${snapshot.val().name || 'Friend'}`;
|
| 285 |
+
|
| 286 |
+
// Clear message container
|
| 287 |
+
document.getElementById('message-container').innerHTML = '';
|
| 288 |
+
|
| 289 |
+
// Create chat reference
|
| 290 |
+
const chatId = [userId, friendId].sort().join('-');
|
| 291 |
+
chatRef = database.ref('chats/' + chatId);
|
| 292 |
+
|
| 293 |
+
// Create typing reference
|
| 294 |
+
typingRef = database.ref('typing/' + chatId + '/' + userId);
|
| 295 |
+
|
| 296 |
+
// Create user reference
|
| 297 |
+
userRef = database.ref('users/' + userId);
|
| 298 |
+
|
| 299 |
+
// Set user data
|
| 300 |
+
userRef.set({
|
| 301 |
+
name: displayName,
|
| 302 |
+
connectedTo: friendId,
|
| 303 |
+
lastSeen: firebase.database.ServerValue.TIMESTAMP
|
| 304 |
+
});
|
| 305 |
+
|
| 306 |
+
// Listen for messages
|
| 307 |
+
chatRef.limitToLast(100).on('child_added', (snapshot) => {
|
| 308 |
+
const message = snapshot.val();
|
| 309 |
+
addMessageToChat(message);
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
// Listen for typing indicators from friend
|
| 313 |
+
database.ref('typing/' + chatId + '/' + friendId).on('value', (snapshot) => {
|
| 314 |
+
const isTyping = snapshot.val();
|
| 315 |
+
const typingIndicator = document.getElementById('typing-indicator');
|
| 316 |
+
|
| 317 |
+
if (isTyping) {
|
| 318 |
+
typingIndicator.classList.remove('hidden');
|
| 319 |
+
} else {
|
| 320 |
+
typingIndicator.classList.add('hidden');
|
| 321 |
+
}
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
// Listen for friend disconnection
|
| 325 |
+
database.ref('users/' + friendId + '/connectedTo').on('value', (snapshot) => {
|
| 326 |
+
if (snapshot.val() !== userId) {
|
| 327 |
+
// Friend disconnected
|
| 328 |
+
disconnectFromFriend();
|
| 329 |
+
alert('Your friend has disconnected');
|
| 330 |
+
}
|
| 331 |
+
});
|
| 332 |
+
} else {
|
| 333 |
+
alert('Friend not found. Please check the ID and try again.');
|
| 334 |
+
}
|
| 335 |
+
}).catch((error) => {
|
| 336 |
+
console.error('Error connecting to friend:', error);
|
| 337 |
+
alert('Error connecting to friend. Please try again.');
|
| 338 |
+
});
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// Disconnect from friend
|
| 342 |
+
function disconnectFromFriend() {
|
| 343 |
+
if (!isConnected) return;
|
| 344 |
+
|
| 345 |
+
isConnected = false;
|
| 346 |
+
|
| 347 |
+
// Update UI
|
| 348 |
+
document.getElementById('connect-button').classList.remove('hidden');
|
| 349 |
+
document.getElementById('disconnect-button').classList.add('hidden');
|
| 350 |
+
document.getElementById('message-input').disabled = true;
|
| 351 |
+
document.getElementById('send-button').disabled = true;
|
| 352 |
+
document.getElementById('friend-id').disabled = false;
|
| 353 |
+
|
| 354 |
+
// Update status
|
| 355 |
+
document.getElementById('connection-status').innerHTML = `
|
| 356 |
+
<span class="h-3 w-3 rounded-full bg-red-500 mr-2"></span>
|
| 357 |
+
<span>Disconnected</span>
|
| 358 |
+
`;
|
| 359 |
+
|
| 360 |
+
document.getElementById('chat-status').textContent = 'Not connected to anyone';
|
| 361 |
+
document.getElementById('typing-indicator').classList.add('hidden');
|
| 362 |
+
|
| 363 |
+
// Add disconnect message to chat
|
| 364 |
+
addSystemMessage('Disconnected from chat');
|
| 365 |
+
|
| 366 |
+
// Clean up Firebase references
|
| 367 |
+
if (chatRef) chatRef.off();
|
| 368 |
+
if (typingRef) typingRef.off();
|
| 369 |
+
if (userRef) {
|
| 370 |
+
userRef.update({
|
| 371 |
+
connectedTo: null,
|
| 372 |
+
lastSeen: firebase.database.ServerValue.TIMESTAMP
|
| 373 |
+
});
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
// Clear typing status
|
| 377 |
+
if (typingRef) typingRef.set(false);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
// Send a message
|
| 381 |
+
function sendMessage() {
|
| 382 |
+
const messageInput = document.getElementById('message-input');
|
| 383 |
+
const messageText = messageInput.value.trim();
|
| 384 |
+
|
| 385 |
+
if (!messageText || !isConnected) return;
|
| 386 |
+
|
| 387 |
+
// Create message object
|
| 388 |
+
const message = {
|
| 389 |
+
sender: userId,
|
| 390 |
+
senderName: displayName,
|
| 391 |
+
text: messageText,
|
| 392 |
+
timestamp: firebase.database.ServerValue.TIMESTAMP
|
| 393 |
+
};
|
| 394 |
+
|
| 395 |
+
// Push message to database
|
| 396 |
+
chatRef.push(message);
|
| 397 |
+
|
| 398 |
+
// Clear input
|
| 399 |
+
messageInput.value = '';
|
| 400 |
+
|
| 401 |
+
// Stop typing indicator
|
| 402 |
+
typingRef.set(false);
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
// Add message to chat UI
|
| 406 |
+
function addMessageToChat(message) {
|
| 407 |
+
const messageContainer = document.getElementById('message-container');
|
| 408 |
+
|
| 409 |
+
// Remove "not connected" message if it exists
|
| 410 |
+
if (messageContainer.children.length === 1 && messageContainer.children[0].classList.contains('text-center')) {
|
| 411 |
+
messageContainer.innerHTML = '';
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
const messageElement = document.createElement('div');
|
| 415 |
+
messageElement.classList.add('fade-in');
|
| 416 |
+
|
| 417 |
+
if (message.sender === userId) {
|
| 418 |
+
// Your message
|
| 419 |
+
messageElement.innerHTML = `
|
| 420 |
+
<div class="flex justify-end">
|
| 421 |
+
<div class="bg-blue-600 text-white rounded-l-lg rounded-br-lg px-4 py-2 max-w-xs md:max-w-md lg:max-w-lg">
|
| 422 |
+
<div class="text-xs text-blue-200 mb-1">You</div>
|
| 423 |
+
<div>${message.text}</div>
|
| 424 |
+
</div>
|
| 425 |
+
</div>
|
| 426 |
+
`;
|
| 427 |
+
} else if (message.sender === 'system') {
|
| 428 |
+
// System message
|
| 429 |
+
messageElement.innerHTML = `
|
| 430 |
+
<div class="text-center text-gray-400 text-sm py-2">
|
| 431 |
+
${message.text}
|
| 432 |
+
</div>
|
| 433 |
+
`;
|
| 434 |
+
} else {
|
| 435 |
+
// Friend's message
|
| 436 |
+
messageElement.innerHTML = `
|
| 437 |
+
<div class="flex justify-start">
|
| 438 |
+
<div class="bg-gray-700 text-white rounded-r-lg rounded-bl-lg px-4 py-2 max-w-xs md:max-w-md lg:max-w-lg">
|
| 439 |
+
<div class="text-xs text-gray-300 mb-1">${message.senderName || 'Friend'}</div>
|
| 440 |
+
<div>${message.text}</div>
|
| 441 |
+
</div>
|
| 442 |
+
</div>
|
| 443 |
+
`;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
messageContainer.appendChild(messageElement);
|
| 447 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
// Add system message
|
| 451 |
+
function addSystemMessage(text) {
|
| 452 |
+
addMessageToChat({
|
| 453 |
+
sender: 'system',
|
| 454 |
+
text: text,
|
| 455 |
+
timestamp: firebase.database.ServerValue.TIMESTAMP
|
| 456 |
+
});
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
// Initialize the app when the page loads
|
| 460 |
+
window.onload = init;
|
| 461 |
+
</script>
|
| 462 |
+
<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=Fdgg55/chat-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 463 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Prompt: Create an open-world game set in a fictional South Asian town where the player starts as a broke mechanic. The game should include a mix of urban, rural, and hidden areas like jungles and abandoned forts. The core gameplay revolves around building and customizing vehicles, completing odd jobs (like deliveries, races, or shady tasks), and interacting with dynamic NPCs that speak in local dialects. Add a day/night cycle, weather effects, street mini-games (like cricket and ludo), and a dramatic storyline involving underground racing, betrayal, and a lost family member. Include multiplayer elements where other players can appear in your world as ghostly challengers or allies. Style: gritty, funny, and emotional. Think GTA meets Need for Speed, but desi.
|
| 2 |
+
rustyroadsdesidriftmechanicopenworldsouthasiantownracingbetrayalcustomcarsminigamesnpcweather
|
| 3 |
+
Create a game Ghostline Urban Haunt Detective Openworld Spirits Quests Puzzles Secrets Ghostcam Dialogue Mystery
|
| 4 |
+
Create a open world game where a player create a world and live in it
|
| 5 |
+
Create a 3d shooting game with smooth fps guns and named Talha shooting
|
| 6 |
+
Real time chatting app that works rally 2 people can contact by their ids
|