Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +513 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: blue
|
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: private-xlma
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: yellow
|
5 |
colorTo: blue
|
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,513 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>SMS Messenger | Secure Numbers</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.message-item:hover {
|
11 |
+
transform: translateY(-2px);
|
12 |
+
transition: transform 0.2s ease;
|
13 |
+
}
|
14 |
+
|
15 |
+
.fade-in {
|
16 |
+
animation: fadeIn 0.3s ease-in;
|
17 |
+
}
|
18 |
+
|
19 |
+
@keyframes fadeIn {
|
20 |
+
from { opacity: 0; transform: translateY(10px); }
|
21 |
+
to { opacity: 1; transform: translateY(0); }
|
22 |
+
}
|
23 |
+
|
24 |
+
.custom-scrollbar::-webkit-scrollbar {
|
25 |
+
width: 6px;
|
26 |
+
}
|
27 |
+
|
28 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
29 |
+
background: #f1f1f1;
|
30 |
+
border-radius: 10px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
34 |
+
background: #888;
|
35 |
+
border-radius: 10px;
|
36 |
+
}
|
37 |
+
|
38 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
39 |
+
background: #555;
|
40 |
+
}
|
41 |
+
|
42 |
+
.outgoing-bubble {
|
43 |
+
background-color: #3b82f6;
|
44 |
+
color: white;
|
45 |
+
border-radius: 18px 18px 0 18px;
|
46 |
+
}
|
47 |
+
|
48 |
+
.incoming-bubble {
|
49 |
+
background-color: #e2e8f0;
|
50 |
+
color: #1e293b;
|
51 |
+
border-radius: 18px 18px 18px 0;
|
52 |
+
}
|
53 |
+
|
54 |
+
.contact-code {
|
55 |
+
background-color: #e2e8f0;
|
56 |
+
color: #3b82f6;
|
57 |
+
padding: 0.25rem 0.5rem;
|
58 |
+
border-radius: 0.375rem;
|
59 |
+
font-size: 0.75rem;
|
60 |
+
font-weight: 600;
|
61 |
+
margin-left: 0.5rem;
|
62 |
+
}
|
63 |
+
</style>
|
64 |
+
</head>
|
65 |
+
<body class="bg-gray-100">
|
66 |
+
<div class="max-w-md mx-auto min-h-screen flex flex-col">
|
67 |
+
<!-- Header -->
|
68 |
+
<header class="bg-blue-600 text-white p-4 shadow-md">
|
69 |
+
<div class="flex items-center justify-between">
|
70 |
+
<button id="backBtn" class="text-white hover:text-blue-200">
|
71 |
+
<i class="fas fa-arrow-left text-xl"></i>
|
72 |
+
</button>
|
73 |
+
<h1 class="text-xl font-bold">Secure SMS</h1>
|
74 |
+
<button id="newMsgBtn" class="text-white hover:text-blue-200">
|
75 |
+
<i class="fas fa-plus text-xl"></i>
|
76 |
+
</button>
|
77 |
+
</div>
|
78 |
+
</header>
|
79 |
+
|
80 |
+
<!-- Main Content -->
|
81 |
+
<main class="flex-1 p-4 flex flex-col" id="contentArea">
|
82 |
+
<!-- Contacts List (Default View) -->
|
83 |
+
<div id="contactsView" class="flex-1">
|
84 |
+
<div class="mb-4 flex items-center">
|
85 |
+
<div class="relative flex-1">
|
86 |
+
<input type="text" placeholder="Search contacts..." class="w-full pl-10 pr-4 py-2 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
87 |
+
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
|
91 |
+
<div class="bg-white rounded-xl shadow-sm overflow-hidden">
|
92 |
+
<ul id="contactsList" class="divide-y divide-gray-100 custom-scrollbar" style="max-height: 70vh; overflow-y: auto;">
|
93 |
+
<!-- Contacts will be added here dynamically -->
|
94 |
+
</ul>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
<!-- Conversation View (Hidden by default) -->
|
99 |
+
<div id="conversationView" class="hidden flex-1 flex flex-col">
|
100 |
+
<div class="bg-white rounded-t-xl p-4 shadow-sm flex items-center">
|
101 |
+
<img id="contactAvatar" src="https://ui-avatars.com/api/?name=J+D&background=3b82f6&color=fff&rounded=true" alt="Contact" class="w-10 h-10 rounded-full mr-3">
|
102 |
+
<div>
|
103 |
+
<h2 id="contactName" class="font-semibold">John Doe</h2>
|
104 |
+
<p id="contactCode" class="text-xs text-gray-500">Code: #123456789</p>
|
105 |
+
</div>
|
106 |
+
<button id="contactOptions" class="ml-auto text-gray-500 hover:text-blue-600">
|
107 |
+
<i class="fas fa-ellipsis-v"></i>
|
108 |
+
</button>
|
109 |
+
</div>
|
110 |
+
|
111 |
+
<div id="messagesArea" class="flex-1 p-4 bg-gray-50 custom-scrollbar" style="overflow-y: auto;">
|
112 |
+
<div class="flex flex-col space-y-2">
|
113 |
+
<!-- Messages will be added here dynamically -->
|
114 |
+
<div class="text-center text-xs text-gray-400 my-4">
|
115 |
+
Start of conversation
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="bg-white p-3 border-t border-gray-200 rounded-b-xl shadow-sm">
|
121 |
+
<div class="flex items-center">
|
122 |
+
<button class="text-blue-600 hover:text-blue-800 mr-2">
|
123 |
+
<i class="fas fa-paperclip text-xl"></i>
|
124 |
+
</button>
|
125 |
+
<input type="text" id="messageInput" placeholder="Type a message" class="flex-1 py-2 px-3 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
126 |
+
<button id="sendBtn" class="ml-2 bg-blue-600 text-white p-2 rounded-full hover:bg-blue-700 transition-colors">
|
127 |
+
<i class="fas fa-paper-plane"></i>
|
128 |
+
</button>
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
</div>
|
132 |
+
|
133 |
+
<!-- New Message View (Hidden by default) -->
|
134 |
+
<div id="newMessageView" class="hidden flex-1">
|
135 |
+
<div class="mb-4">
|
136 |
+
<h2 class="text-lg font-bold text-gray-800 mb-2">New Message</h2>
|
137 |
+
<div class="relative">
|
138 |
+
<label for="recipientInput" class="block text-sm font-medium text-gray-700 mb-1">To:</label>
|
139 |
+
<input type="text" id="recipientInput" placeholder="Contact name or code (e.g. #123456789)" class="w-full pl-3 pr-10 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
140 |
+
<button id="addRecipientBtn" class="absolute right-3 top-8 text-blue-600">
|
141 |
+
<i class="fas fa-plus-circle"></i>
|
142 |
+
</button>
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
|
146 |
+
<div class="mb-4">
|
147 |
+
<label for="newMessageText" class="block text-sm font-medium text-gray-700 mb-1">Message:</label>
|
148 |
+
<textarea id="newMessageText" rows="5" class="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Type your message here..."></textarea>
|
149 |
+
</div>
|
150 |
+
|
151 |
+
<div class="flex justify-between">
|
152 |
+
<span id="charCount" class="text-sm text-gray-500">160 characters left</span>
|
153 |
+
<button id="sendNewMessageBtn" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors">
|
154 |
+
Send Message
|
155 |
+
</button>
|
156 |
+
</div>
|
157 |
+
</div>
|
158 |
+
</main>
|
159 |
+
</div>
|
160 |
+
|
161 |
+
<script>
|
162 |
+
document.addEventListener('DOMContentLoaded', function() {
|
163 |
+
// UI Elements
|
164 |
+
const contactsView = document.getElementById('contactsView');
|
165 |
+
const conversationView = document.getElementById('conversationView');
|
166 |
+
const newMessageView = document.getElementById('newMessageView');
|
167 |
+
const backBtn = document.getElementById('backBtn');
|
168 |
+
const newMsgBtn = document.getElementById('newMsgBtn');
|
169 |
+
const sendBtn = document.getElementById('sendBtn');
|
170 |
+
const sendNewMessageBtn = document.getElementById('sendNewMessageBtn');
|
171 |
+
const messageInput = document.getElementById('messageInput');
|
172 |
+
const recipientInput = document.getElementById('recipientInput');
|
173 |
+
const newMessageText = document.getElementById('newMessageText');
|
174 |
+
const charCount = document.getElementById('charCount');
|
175 |
+
const messagesArea = document.getElementById('messagesArea');
|
176 |
+
const contactsList = document.getElementById('contactsList');
|
177 |
+
|
178 |
+
// Number coding system
|
179 |
+
const numberToCodeMap = new Map();
|
180 |
+
const codeToNumberMap = new Map();
|
181 |
+
|
182 |
+
// Generate a 9-digit code from a phone number
|
183 |
+
function generateContactCode(phoneNumber) {
|
184 |
+
// Simple hash function to generate consistent codes for demo
|
185 |
+
let hash = 0;
|
186 |
+
for (let i = 0; i < phoneNumber.length; i++) {
|
187 |
+
hash = ((hash << 5) - hash) + phoneNumber.charCodeAt(i);
|
188 |
+
hash = hash & hash; // Convert to 32bit integer
|
189 |
+
}
|
190 |
+
const code = String(Math.abs(hash)).padStart(9, '0').substring(0, 9);
|
191 |
+
|
192 |
+
// Store the mappings
|
193 |
+
numberToCodeMap.set(phoneNumber, code);
|
194 |
+
codeToNumberMap.set(code, phoneNumber);
|
195 |
+
|
196 |
+
return code;
|
197 |
+
}
|
198 |
+
|
199 |
+
// Get a contact's code (generates if doesn't exist)
|
200 |
+
function getContactCode(phoneNumber) {
|
201 |
+
if (numberToCodeMap.has(phoneNumber)) {
|
202 |
+
return numberToCodeMap.get(phoneNumber);
|
203 |
+
}
|
204 |
+
return generateContactCode(phoneNumber);
|
205 |
+
}
|
206 |
+
|
207 |
+
// Find a contact by name or code
|
208 |
+
function findContact(identifier) {
|
209 |
+
// Check if it's a code (starts with # and 9 digits)
|
210 |
+
if (identifier.startsWith('#') && identifier.length === 10) {
|
211 |
+
const code = identifier.substring(1);
|
212 |
+
if (codeToNumberMap.has(code)) {
|
213 |
+
const phoneNumber = codeToNumberMap.get(code);
|
214 |
+
return contacts.find(c => c.number === phoneNumber);
|
215 |
+
}
|
216 |
+
return null;
|
217 |
+
}
|
218 |
+
|
219 |
+
// Search by name
|
220 |
+
const lowerIdentifier = identifier.toLowerCase();
|
221 |
+
return contacts.find(c =>
|
222 |
+
c.name.toLowerCase().includes(lowerIdentifier) ||
|
223 |
+
c.number.includes(identifier)
|
224 |
+
);
|
225 |
+
}
|
226 |
+
|
227 |
+
// Sample contacts data
|
228 |
+
const contacts = [
|
229 |
+
{ id: 1, name: "John Doe", number: "+15551234567", lastMessage: "See you tomorrow!", time: "10:30 AM" },
|
230 |
+
{ id: 2, name: "Jane Smith", number: "+15559876543", lastMessage: "Thanks for the info", time: "Yesterday" },
|
231 |
+
{ id: 3, name: "Mike Johnson", number: "+15554567890", lastMessage: "Call me when you can", time: "Monday" },
|
232 |
+
{ id: 4, name: "Sarah Williams", number: "+15553334444", lastMessage: "Let's meet at 5pm", time: "Last week" },
|
233 |
+
{ id: 5, name: "David Brown", number: "+15557778888", lastMessage: "Did you see the news?", time: "5/20/23" }
|
234 |
+
];
|
235 |
+
|
236 |
+
// Pre-generate codes for all contacts
|
237 |
+
contacts.forEach(contact => {
|
238 |
+
getContactCode(contact.number);
|
239 |
+
});
|
240 |
+
|
241 |
+
// Sample messages data with timestamps
|
242 |
+
const sampleMessages = {
|
243 |
+
"John Doe": [
|
244 |
+
{ text: "Hey, how are you doing?", sent: false, time: "10:25 AM" },
|
245 |
+
{ text: "I'm good, thanks! How about you?", sent: true, time: "10:27 AM" },
|
246 |
+
{ text: "Pretty good. Want to grab lunch tomorrow?", sent: false, time: "10:29 AM" },
|
247 |
+
{ text: "Sure, sounds great! See you tomorrow.", sent: true, time: "10:30 AM" }
|
248 |
+
],
|
249 |
+
"Jane Smith": [
|
250 |
+
{ text: "Did you get the report I sent?", sent: false, time: "Yesterday 2:45 PM" },
|
251 |
+
{ text: "Yes, I received it. Thanks for sending it over.", sent: true, time: "Yesterday 2:50 PM" },
|
252 |
+
{ text: "Great! Let me know if you need anything else.", sent: false, time: "Yesterday 2:51 PM" },
|
253 |
+
{ text: "Will do. The info was very helpful.", sent: true, time: "Yesterday 3:00 PM" }
|
254 |
+
]
|
255 |
+
};
|
256 |
+
|
257 |
+
// Current conversation
|
258 |
+
let currentConversation = null;
|
259 |
+
|
260 |
+
// Initialize the app
|
261 |
+
function init() {
|
262 |
+
renderContacts();
|
263 |
+
setupEventListeners();
|
264 |
+
updateCharCount();
|
265 |
+
}
|
266 |
+
|
267 |
+
// Render contacts list
|
268 |
+
function renderContacts() {
|
269 |
+
contactsList.innerHTML = '';
|
270 |
+
|
271 |
+
contacts.forEach(contact => {
|
272 |
+
const code = getContactCode(contact.number);
|
273 |
+
const li = document.createElement('li');
|
274 |
+
li.className = 'message-item p-3 hover:bg-gray-50 cursor-pointer transition-colors';
|
275 |
+
li.innerHTML = `
|
276 |
+
<div class="flex items-center">
|
277 |
+
<img src="https://ui-avatars.com/api/?name=${contact.name.split(' ').join('+')}&background=3b82f6&color=fff&rounded=true" alt="${contact.name}" class="w-12 h-12 rounded-full mr-3">
|
278 |
+
<div class="flex-1">
|
279 |
+
<div class="flex justify-between items-start">
|
280 |
+
<h3 class="font-medium text-gray-800">${contact.name}</h3>
|
281 |
+
<span class="text-xs text-gray-500">${contact.time}</span>
|
282 |
+
</div>
|
283 |
+
<div class="flex items-center justify-between">
|
284 |
+
<p class="text-sm text-gray-500 truncate">${contact.lastMessage}</p>
|
285 |
+
<span class="contact-code">#${code}</span>
|
286 |
+
</div>
|
287 |
+
</div>
|
288 |
+
</div>
|
289 |
+
`;
|
290 |
+
li.addEventListener('click', () => openConversation(contact));
|
291 |
+
contactsList.appendChild(li);
|
292 |
+
});
|
293 |
+
}
|
294 |
+
|
295 |
+
// Open conversation with a contact
|
296 |
+
function openConversation(contact) {
|
297 |
+
currentConversation = contact;
|
298 |
+
|
299 |
+
// Update contact info in conversation view
|
300 |
+
document.getElementById('contactName').textContent = contact.name;
|
301 |
+
const code = numberToCodeMap.get(contact.number);
|
302 |
+
document.getElementById('contactCode').textContent = `Code: #${code}`;
|
303 |
+
document.getElementById('contactAvatar').src = `https://ui-avatars.com/api/?name=${contact.name.split(' ').join('+')}&background=3b82f6&color=fff&rounded=true`;
|
304 |
+
|
305 |
+
// Switch views
|
306 |
+
contactsView.classList.add('hidden');
|
307 |
+
newMessageView.classList.add('hidden');
|
308 |
+
conversationView.classList.remove('hidden');
|
309 |
+
|
310 |
+
// Load messages
|
311 |
+
loadMessages(contact.name);
|
312 |
+
|
313 |
+
// Scroll to bottom of messages
|
314 |
+
setTimeout(() => {
|
315 |
+
messagesArea.scrollTop = messagesArea.scrollHeight;
|
316 |
+
}, 100);
|
317 |
+
}
|
318 |
+
|
319 |
+
// Load messages for a contact
|
320 |
+
function loadMessages(contactName) {
|
321 |
+
messagesArea.querySelector('div').innerHTML = '<div class="text-center text-xs text-gray-400 my-4">Start of conversation</div>';
|
322 |
+
|
323 |
+
const messages = sampleMessages[contactName] || [];
|
324 |
+
|
325 |
+
messages.forEach(msg => {
|
326 |
+
addMessageToView(msg.text, msg.sent, msg.time);
|
327 |
+
});
|
328 |
+
}
|
329 |
+
|
330 |
+
// Add message to the conversation view
|
331 |
+
function addMessageToView(text, isOutgoing, timestamp) {
|
332 |
+
const messageDiv = document.createElement('div');
|
333 |
+
messageDiv.className = `flex ${isOutgoing ? 'justify-end' : 'justify-start'} fade-in`;
|
334 |
+
|
335 |
+
const bubbleClass = isOutgoing ? 'outgoing-bubble' : 'incoming-bubble';
|
336 |
+
|
337 |
+
messageDiv.innerHTML = `
|
338 |
+
<div class="max-w-xs md:max-w-md">
|
339 |
+
<div class="${bubbleClass} px-4 py-2 shadow-sm">
|
340 |
+
<p class="text-sm">${text}</p>
|
341 |
+
</div>
|
342 |
+
<div class="text-xs text-gray-500 mt-1 ${isOutgoing ? 'text-right' : 'text-left'}">${timestamp || getCurrentTime()}</div>
|
343 |
+
</div>
|
344 |
+
`;
|
345 |
+
|
346 |
+
messagesArea.querySelector('div').appendChild(messageDiv);
|
347 |
+
messagesArea.scrollTop = messagesArea.scrollHeight;
|
348 |
+
}
|
349 |
+
|
350 |
+
// Open new message view
|
351 |
+
function openNewMessageView() {
|
352 |
+
contactsView.classList.add('hidden');
|
353 |
+
conversationView.classList.add('hidden');
|
354 |
+
newMessageView.classList.remove('hidden');
|
355 |
+
recipientInput.focus();
|
356 |
+
}
|
357 |
+
|
358 |
+
// Go back to previous view
|
359 |
+
function goBack() {
|
360 |
+
if (!contactsView.classList.contains('hidden')) {
|
361 |
+
// Already in contacts view, maybe minimize app in a real scenario
|
362 |
+
return;
|
363 |
+
}
|
364 |
+
|
365 |
+
if (!conversationView.classList.contains('hidden')) {
|
366 |
+
// Returning from conversation to contacts
|
367 |
+
conversationView.classList.add('hidden');
|
368 |
+
contactsView.classList.remove('hidden');
|
369 |
+
} else if (!newMessageView.classList.contains('hidden')) {
|
370 |
+
// Returning from new message view
|
371 |
+
newMessageView.classList.add('hidden');
|
372 |
+
contactsView.classList.remove('hidden');
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
// Send a new message
|
377 |
+
function sendMessage() {
|
378 |
+
const messageText = messageInput.value.trim();
|
379 |
+
if (messageText === '') return;
|
380 |
+
|
381 |
+
// In a real app, this would send via SMS API (using actual number)
|
382 |
+
console.log(`Sending message to ${currentConversation.number}: ${messageText}`);
|
383 |
+
|
384 |
+
// Add to conversation view
|
385 |
+
addMessageToView(messageText, true);
|
386 |
+
|
387 |
+
// Add auto-reply for demo purposes
|
388 |
+
setTimeout(() => {
|
389 |
+
const replies = [
|
390 |
+
"Got it, thanks!",
|
391 |
+
"Sure, I'll be there!",
|
392 |
+
"Can we talk later?",
|
393 |
+
"I'll get back to you soon.",
|
394 |
+
"Thanks for letting me know."
|
395 |
+
];
|
396 |
+
const randomReply = replies[Math.floor(Math.random() * replies.length)];
|
397 |
+
addMessageToView(randomReply, false);
|
398 |
+
}, 1000 + Math.random() * 2000);
|
399 |
+
|
400 |
+
// Clear input
|
401 |
+
messageInput.value = '';
|
402 |
+
}
|
403 |
+
|
404 |
+
// Send a new message from new message view
|
405 |
+
function sendNewMessage() {
|
406 |
+
const recipientIdentifier = recipientInput.value.trim();
|
407 |
+
const message = newMessageText.value.trim();
|
408 |
+
|
409 |
+
if (recipientIdentifier === '' || message === '') {
|
410 |
+
alert('Please enter a recipient and message');
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
|
414 |
+
// Find contact by name or code
|
415 |
+
const contact = findContact(recipientIdentifier);
|
416 |
+
|
417 |
+
if (!contact) {
|
418 |
+
alert('Contact not found. Please enter a valid name or code (e.g. #123456789)');
|
419 |
+
return;
|
420 |
+
}
|
421 |
+
|
422 |
+
// In a real app, this would send via SMS API (using contact.number)
|
423 |
+
console.log(`Sending message to ${contact.number}: ${message}`);
|
424 |
+
|
425 |
+
// Show success message
|
426 |
+
alert(`Message sent to ${contact.name} (Code: #${numberToCodeMap.get(contact.number)})`);
|
427 |
+
|
428 |
+
// Clear form
|
429 |
+
recipientInput.value = '';
|
430 |
+
newMessageText.value = '';
|
431 |
+
|
432 |
+
// Go back to contacts view
|
433 |
+
goBack();
|
434 |
+
}
|
435 |
+
|
436 |
+
// Update character count
|
437 |
+
function updateCharCount() {
|
438 |
+
const maxLength = 160;
|
439 |
+
const currentLength = newMessageText.value.length;
|
440 |
+
const remaining = maxLength - currentLength;
|
441 |
+
|
442 |
+
charCount.textContent = `${remaining} characters left`;
|
443 |
+
|
444 |
+
if (remaining < 0) {
|
445 |
+
charCount.classList.add('text-red-500');
|
446 |
+
charCount.classList.remove('text-gray-500');
|
447 |
+
} else {
|
448 |
+
charCount.classList.add('text-gray-500');
|
449 |
+
charCount.classList.remove('text-red-500');
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
// Get current time in HH:MM AM/PM format
|
454 |
+
function getCurrentTime() {
|
455 |
+
const now = new Date();
|
456 |
+
let hours = now.getHours();
|
457 |
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
458 |
+
hours = hours % 12;
|
459 |
+
hours = hours ? hours : 12; // the hour '0' should be '12'
|
460 |
+
const minutes = now.getMinutes().toString().padStart(2, '0');
|
461 |
+
return `${hours}:${minutes} ${ampm}`;
|
462 |
+
}
|
463 |
+
|
464 |
+
// Set up event listeners
|
465 |
+
function setupEventListeners() {
|
466 |
+
backBtn.addEventListener('click', goBack);
|
467 |
+
newMsgBtn.addEventListener('click', openNewMessageView);
|
468 |
+
sendBtn.addEventListener('click', sendMessage);
|
469 |
+
sendNewMessageBtn.addEventListener('click', sendNewMessage);
|
470 |
+
|
471 |
+
// Send message on Enter key
|
472 |
+
messageInput.addEventListener('keypress', (e) => {
|
473 |
+
if (e.key === 'Enter') {
|
474 |
+
sendMessage();
|
475 |
+
}
|
476 |
+
});
|
477 |
+
|
478 |
+
// Update character count as user types
|
479 |
+
newMessageText.addEventListener('input', updateCharCount);
|
480 |
+
|
481 |
+
// Prevent Enter key from creating new line when Shift is not pressed
|
482 |
+
newMessageText.addEventListener('keydown', (e) => {
|
483 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
484 |
+
e.preventDefault();
|
485 |
+
sendNewMessage();
|
486 |
+
}
|
487 |
+
});
|
488 |
+
|
489 |
+
// Tab completion for contact codes
|
490 |
+
recipientInput.addEventListener('input', function(e) {
|
491 |
+
if (e.target.value.startsWith('#') && e.target.value.length > 1) {
|
492 |
+
const codeInput = e.target.value.substring(1);
|
493 |
+
const matchingCode = Array.from(codeToNumberMap.keys()).find(k => k.startsWith(codeInput));
|
494 |
+
|
495 |
+
if (matchingCode && matchingCode !== codeInput && document.activeElement === recipientInput) {
|
496 |
+
const currentPos = e.target.selectionStart;
|
497 |
+
|
498 |
+
// Set timeout to allow the current input to be processed
|
499 |
+
setTimeout(() => {
|
500 |
+
e.target.value = `#${matchingCode}`;
|
501 |
+
e.target.setSelectionRange(currentPos, currentPos);
|
502 |
+
}, 0);
|
503 |
+
}
|
504 |
+
}
|
505 |
+
});
|
506 |
+
}
|
507 |
+
|
508 |
+
// Initialize the app
|
509 |
+
init();
|
510 |
+
});
|
511 |
+
</script>
|
512 |
+
<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=privateuserh/private-xlma" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
513 |
+
</html>
|