-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembed.html
More file actions
373 lines (345 loc) · 14.3 KB
/
Copy pathembed.html
File metadata and controls
373 lines (345 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chatlify | Live Chat</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- FontAwesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<!-- Firebase -->
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js';
import { getDatabase, ref, push, onValue } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js';
const firebaseConfig = {
apiKey: "AIzaSyD5vw97X6s1zFG4acJd5vFZ-gtW0JcMPaI",
authDomain: "chatlify-database.firebaseapp.com",
databaseURL: "https://chatlify-database-default-rtdb.firebaseio.com",
projectId: "chatlify-database",
storageBucket: "chatlify-database.appspot.com",
messagingSenderId: "176144889050",
appId: "1:176144889050:web:93290107ab4ef56b67a1e3",
measurementId: "G-5E7EZCEP3K"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
// Rank and User config
const RANK_CONFIGS = {
owner: { name: 'OWNER', color: '#ffe066', backgroundColor: '#553d00', priority: 1000 },
'co-owner': { name: 'CO-OWNER', color: '#a745f7', backgroundColor: '#632694', priority: 900 },
developer: { name: 'DEVELOPER', color: '#8305eb', backgroundColor: '#350061', priority: 850 },
'head-admin': { name: 'HEAD-ADMIN', color: '#e60000', backgroundColor: '#330000', priority: 800 },
admin: { name: 'ADMIN', color: '#ffffff', backgroundColor: '#e60000', priority: 700 },
'head-mod': { name: 'HEAD-MOD', color: '#004488', backgroundColor: '#002544', priority: 600 },
mod: { name: 'MOD', color: '#0055ff', backgroundColor: '#0044cc', priority: 500 },
member: { name: 'MEMBER', color: 'white', backgroundColor: '#009900', priority: 100 },
guest: { name: 'GUEST', color: '#888', backgroundColor: '#333', priority: 0 }
};
const USER_RANKS = {
'Dominus_Elitus': 'owner',
'meancraft': 'developer',
'mrbat8888': 'developer',
'Light slayer': 'head-admin',
'Ricplays': 'admin',
'Abyssal.': 'admin',
'VoidDestroyerXY': 'head-admin'
};
const STAFF_PASSWORDS = {
'Dominus_Elitus': 'DominumNetworkOwner2025',
'meancraft': 'DominumStaff',
'mrbat8888': 'DominumStaff',
'Light slayer': 'DominumStaff',
'Ricplays': 'DominumStaff',
'Abyssal.': 'DominumStaff',
'VoidDestroyerXY': 'DominumStaff'
};
function getUserRank(username) {
if (USER_RANKS[username]) return USER_RANKS[username];
if (username.startsWith('Guest')) return 'guest';
return 'member';
}
function getRankConfig(rank) {
return RANK_CONFIGS[rank] || RANK_CONFIGS.member;
}
let messages = [];
let currentUsername = 'Guest' + Math.floor(Math.random() * 1000);
let pendingUsername = null;
let lastSentTime = 0;
function updateUsername() {
const input = document.getElementById('usernameInput');
const newUsername = input.value.trim();
if (!newUsername) return;
const rank = getUserRank(newUsername);
const isStaff = rank !== 'member' && rank !== 'guest';
if (isStaff && STAFF_PASSWORDS[newUsername]) {
pendingUsername = newUsername;
document.getElementById('passwordModalTitle').textContent = `Enter password for ${newUsername}`;
document.getElementById('passwordInput').value = '';
document.getElementById('passwordError').style.display = 'none';
document.getElementById('passwordModal').style.display = 'block';
return;
}
applyUsername(newUsername);
}
function applyUsername(name) {
currentUsername = name;
window.username = name; // ✅ This ensures global access elsewhere
document.getElementById('currentUsername').textContent = name;
const rank = getUserRank(name);
const cfg = getRankConfig(rank);
const rd = document.getElementById('currentRank');
rd.textContent = `[${cfg.name}]`;
rd.style.color = cfg.color;
rd.style.backgroundColor = cfg.backgroundColor;
document.getElementById('usernameInput').value = name;
}
function closePasswordModal() {
document.getElementById('passwordModal').style.display = 'none';
pendingUsername = null;
}
function submitPassword() {
const pw = document.getElementById('passwordInput').value;
if (pendingUsername && pw === STAFF_PASSWORDS[pendingUsername]) {
applyUsername(pendingUsername); // ✅ Apply username
closePasswordModal(); // ✅ Close modal
} else {
document.getElementById('passwordError').style.display = 'block';
}
}
function renderMessages() {
const messagesContainer = document.getElementById('messages');
messagesContainer.innerHTML = '';
messages.forEach(message => {
const messageDiv = document.createElement('div');
messageDiv.className = 'message-bubble flex items-start space-x-3 mb-4 p-4 rounded-lg transition-all duration-200';
const rank = getUserRank(message.username);
const rankConfig = getRankConfig(rank);
const platformIcon = message.tag === 'DISCORD' ? 'fab fa-discord' : 'fas fa-user';
const platformColor = message.tag === 'DISCORD' ? 'bg-indigo-600' : 'bg-blue-600';
const platformLabel = message.tag === 'DISCORD' ? 'Discord' : 'Web';
// sanitize text
const safeText = message.message.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
messageDiv.innerHTML = `
<div class="${platformColor} w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0">
<i class="${platformIcon} text-white text-sm"></i>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center flex-wrap gap-2 mb-2">
<span class="text-xs text-gray-500 font-mono bg-gray-700 px-2 py-1 rounded">
${new Date(message.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
</span>
<span class="rank-badge inline-flex items-center px-2 py-1 rounded text-xs font-bold"
style="color: ${rankConfig.color}; background-color: ${rankConfig.backgroundColor};">
[${rankConfig.name}]
</span>
<span class="${platformColor} text-white inline-flex items-center px-2 py-1 rounded text-xs font-medium">
<i class="${platformIcon} mr-1"></i>
${platformLabel}
</span>
</div>
<div class="mb-2">
<span class="font-bold text-white text-sm">${message.username}</span>
<span class="text-gray-400 ml-1">:</span>
</div>
<p class="text-gray-200 leading-relaxed break-words">${safeText}</p>
</div>`;
messagesContainer.appendChild(messageDiv);
});
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
function sendMessage() {
const now = Date.now();
if (now - lastSentTime < 1500) return;
const input = document.getElementById('messageInput');
const msg = input.value.trim();
if (!msg || msg.length > 500) return;
push(ref(database, 'messages'), {
username: currentUsername,
message: msg,
timestamp: now,
tag: 'WEB',
});
input.value = '';
lastSentTime = now;
}
window.addEventListener('load', () => {
document.getElementById('currentUsername').textContent = currentUsername;
const cfg = getRankConfig(getUserRank(currentUsername));
const rd = document.getElementById('currentRank');
rd.textContent = `[${cfg.name}]`;
rd.style.color = cfg.color;
rd.style.backgroundColor = cfg.backgroundColor;
const messagesRef = ref(database, 'messages');
onValue(messagesRef, snapshot => {
messages = [];
const data = snapshot.val();
if (data) Object.values(data).forEach(m => messages.push(m));
messages.sort((a,b) => a.timestamp - b.timestamp);
renderMessages();
document.getElementById('messageCount').textContent = messages.length;
});
document.getElementById('sendButton').addEventListener('click', sendMessage);
document.getElementById('messageInput').addEventListener('keypress', e => { if (e.key==='Enter') sendMessage(); });
document.getElementById('updateUsernameButton').addEventListener('click', updateUsername);
document.getElementById('usernameInput').addEventListener('keypress', e => { if (e.key==='Enter') updateUsername(); });
document.getElementById('submitPasswordButton').addEventListener('click', submitPassword);
document.getElementById('cancelPasswordButton').addEventListener('click', closePasswordModal);
});
// Expose important functions to global window scope
window.sendMessage = sendMessage;
window.updateUsername = updateUsername;
window.submitPassword = submitPassword;
window.closePasswordModal = closePasswordModal;
window.applyUsername = applyUsername;
</script>
<style>
body {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.message-bubble {
background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
border: 1px solid rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
}
.rank-badge {
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
border: 1px solid rgba(0,0,0,0.2);
}
.glass-effect {
background: rgba(255,255,255,0.05);
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.1);
}
.chatlify-input {
background: rgba(255,255,255,0.1);
border: 1px solid rgba(255,255,255,0.2);
color: white;
}
.chatlify-input:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.chatlify-button {
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
transition: all 0.2s;
}
.chatlify-button:hover {
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
transform: translateY(-1px);
}
.modal {
display: none;
position: fixed;
z-index: 9999;
left: 0; top: 0;
width: 100%; height: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.modal-content {
background-color: #1e1e1e;
margin: 15% auto;
padding: 20px;
border: 2px solid #888;
border-radius: 8px;
width: 90%;
max-width: 400px;
text-align: center;
color: white;
}
.modal-content input {
padding: 10px;
margin-top: 10px;
width: 80%;
border-radius: 5px;
border: none;
outline: none;
color: #000;
}
.modal-buttons {
margin-top: 15px;
}
.modal-buttons button {
margin: 5px;
padding: 10px 20px;
background-color: #444;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.modal-buttons button:hover {
background-color: #666;
}
</style>
</head>
<body class="text-white">
<div class="min-h-screen p-4">
<div class="max-w-4xl mx-auto">
<div class="glass-effect rounded-lg p-4 mb-4">
<div class="flex items-center justify-between">
<div>
<h1 class="text-2xl font-bold flex items-center gap-2">
<i class="fas fa-comments text-blue-400"></i>
Chatlify Relay
</h1>
<p class="text-gray-400 text-sm">Unified Discord‑Web Chat System</p>
</div>
<div class="text-right">
<div class="text-lg font-bold" id="messageCount">0</div>
<div class="text-xs text-gray-400">Messages</div>
</div>
</div>
</div>
<div class="glass-effect rounded-lg p-4 mb-4">
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<span class="text-sm text-gray-400">Username:</span>
<span class="font-bold" id="currentUsername">Guest123</span>
<span class="rank-badge px-2 py-1 rounded text-xs font-bold" id="currentRank">[GUEST]</span>
</div>
<div class="flex items-center gap-2">
<input type="text" id="usernameInput" placeholder="Enter new username" class="chatlify-input px-3 py-1 rounded text-sm" />
<button id="updateUsernameButton" class="chatlify-button px-3 py-1 rounded text-sm text-white">Update</button>
</div>
</div>
</div>
<div class="glass-effect rounded-lg overflow-hidden">
<div class="h-96 overflow-y-auto p-4" id="messages">
<div class="flex items-center justify-center h-full text-gray-400">
<div class="text-center">
<i class="fas fa-comments text-4xl mb-4"></i>
<p>Loading messages...</p>
</div>
</div>
</div>
<div class="border-t border-gray-600 p-4">
<div class="flex items-center gap-3">
<input type="text" id="messageInput" placeholder="Type your message..." class="chatlify-input flex-1 px-4 py-2 rounded-lg" />
<button id="sendButton" class="chatlify-button px-6 py-2 rounded-lg text-white font-medium">
<i class="fas fa-paper-plane mr-2"></i> Send
</button>
</div>
</div>
</div>
<div class="text-center mt-4 text-gray-400 text-sm">
<p>Chatlify Relay - Real-time Discord‑Web Chat Integration</p>
</div>
</div>
</div>
<!-- Password Modal -->
<div id="passwordModal" class="modal">
<div class="modal-content">
<h3 id="passwordModalTitle">Enter Password</h3>
<input type="password" id="passwordInput" placeholder="Enter password" />
<div class="modal-buttons">
<button id="submitPasswordButton" onclick="submitPassword()">Submit</button>
<button id="cancelPasswordButton" onclick="closePasswordModal()">Cancel</button>
</div>
<p id="passwordError" style="color: red; display: none;">Incorrect password.</p>
</div>
</div>
</body>
</html>