300 lines
9.8 KiB
HTML
300 lines
9.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>FuckingChat</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: #1a1a2e;
|
|
color: #e0e0e0;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 20px;
|
|
}
|
|
.chat-container {
|
|
background: #16213e;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
|
width: 100%;
|
|
max-width: 900px;
|
|
height: 90vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
.chat-header {
|
|
background: #0f3460;
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid #1a4a7a;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.chat-header h1 {
|
|
color: #e94560;
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
letter-spacing: 1px;
|
|
}
|
|
.chat-header .status {
|
|
font-size: 12px;
|
|
background: #1a4a7a;
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
color: #a0c4ff;
|
|
}
|
|
.channel-bar {
|
|
display: flex;
|
|
background: #1a2744;
|
|
padding: 8px 12px;
|
|
gap: 6px;
|
|
border-bottom: 1px solid #0f3460;
|
|
overflow-x: auto;
|
|
}
|
|
.channel-btn {
|
|
padding: 6px 16px;
|
|
border: 1px solid #2a4a7a;
|
|
border-radius: 20px;
|
|
background: transparent;
|
|
color: #8899aa;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
white-space: nowrap;
|
|
transition: all 0.2s;
|
|
}
|
|
.channel-btn:hover {
|
|
background: #1a3a5a;
|
|
color: #c0d0e0;
|
|
}
|
|
.channel-btn.active {
|
|
background: #e94560;
|
|
color: #fff;
|
|
border-color: #e94560;
|
|
}
|
|
.chat-messages {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 16px 20px;
|
|
background: #121e38;
|
|
}
|
|
.chat-messages::-webkit-scrollbar { width: 6px; }
|
|
.chat-messages::-webkit-scrollbar-track { background: #0d1528; }
|
|
.chat-messages::-webkit-scrollbar-thumb { background: #2a4a7a; border-radius: 3px; }
|
|
.message {
|
|
background: #1a2d4a;
|
|
border-radius: 8px;
|
|
padding: 10px 14px;
|
|
margin-bottom: 8px;
|
|
border-left: 3px solid #e94560;
|
|
}
|
|
.message .msg-ip {
|
|
font-size: 11px;
|
|
color: #6a8aaa;
|
|
margin-bottom: 4px;
|
|
}
|
|
.message .msg-content {
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
word-wrap: break-word;
|
|
}
|
|
.message .msg-time {
|
|
font-size: 11px;
|
|
color: #556677;
|
|
text-align: right;
|
|
margin-top: 4px;
|
|
}
|
|
.empty-state {
|
|
text-align: center;
|
|
color: #556677;
|
|
padding: 40px;
|
|
font-size: 14px;
|
|
}
|
|
.input-area {
|
|
background: #0f3460;
|
|
padding: 12px 16px;
|
|
border-top: 1px solid #1a4a7a;
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
.input-area input {
|
|
flex: 1;
|
|
padding: 10px 14px;
|
|
border: 1px solid #1a4a7a;
|
|
border-radius: 8px;
|
|
background: #121e38;
|
|
color: #e0e0e0;
|
|
font-size: 14px;
|
|
outline: none;
|
|
transition: border 0.2s;
|
|
}
|
|
.input-area input:focus { border-color: #e94560; }
|
|
.input-area input::placeholder { color: #4a6a8a; }
|
|
.input-area button {
|
|
padding: 10px 20px;
|
|
background: #e94560;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: background 0.2s;
|
|
}
|
|
.input-area button:hover { background: #d63850; }
|
|
.input-area button:disabled {
|
|
background: #4a5a7a;
|
|
cursor: not-allowed;
|
|
}
|
|
.toast {
|
|
position: fixed;
|
|
bottom: 30px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
padding: 10px 24px;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
pointer-events: none;
|
|
z-index: 1000;
|
|
}
|
|
.toast.visible { opacity: 1; }
|
|
.toast.error { background: #c0392b; color: #fff; }
|
|
.toast.success { background: #27ae60; color: #fff; }
|
|
.toast.info { background: #2980b9; color: #fff; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="chat-container">
|
|
<div class="chat-header">
|
|
<h1>💬 FuckingChat</h1>
|
|
<span class="status" id="status-badge">Encrypted 🔒</span>
|
|
</div>
|
|
<div class="channel-bar" id="channel-bar"></div>
|
|
<div class="chat-messages" id="messages"></div>
|
|
<div class="input-area">
|
|
<input type="text" id="msg-input" placeholder="Type a message..." maxlength="2000">
|
|
<button id="send-btn">Send</button>
|
|
</div>
|
|
</div>
|
|
<div class="toast" id="toast"></div>
|
|
<script>
|
|
const CHANNELS = [
|
|
{ id: 'general', name: 'General', icon: '💬' },
|
|
{ id: 'games', name: 'Games', icon: '🎮' },
|
|
{ id: 'anime', name: 'Anime', icon: '🎌' },
|
|
{ id: 'politics', name: 'Politics', icon: '⚖️' }
|
|
];
|
|
|
|
let currentChannel = 'general';
|
|
let pollInterval = null;
|
|
|
|
const messagesEl = document.getElementById('messages');
|
|
const inputEl = document.getElementById('msg-input');
|
|
const sendBtn = document.getElementById('send-btn');
|
|
const toastEl = document.getElementById('toast');
|
|
const channelBar = document.getElementById('channel-bar');
|
|
|
|
function escapeHtml(text) {
|
|
const d = document.createElement('div');
|
|
d.textContent = text;
|
|
return d.innerHTML;
|
|
}
|
|
|
|
function showToast(msg, type = 'info') {
|
|
toastEl.textContent = msg;
|
|
toastEl.className = 'toast visible ' + type;
|
|
setTimeout(() => toastEl.classList.remove('visible'), 3000);
|
|
}
|
|
|
|
function renderChannels() {
|
|
channelBar.innerHTML = '';
|
|
CHANNELS.forEach(ch => {
|
|
const btn = document.createElement('button');
|
|
btn.className = 'channel-btn' + (ch.id === currentChannel ? ' active' : '');
|
|
btn.textContent = ch.icon + ' ' + ch.name;
|
|
btn.onclick = () => switchChannel(ch.id);
|
|
channelBar.appendChild(btn);
|
|
});
|
|
}
|
|
|
|
function switchChannel(channel) {
|
|
if (channel === currentChannel) return;
|
|
currentChannel = channel;
|
|
renderChannels();
|
|
messagesEl.innerHTML = '<div class="empty-state">Loading...</div>';
|
|
loadMessages();
|
|
}
|
|
|
|
async function loadMessages() {
|
|
try {
|
|
const r = await fetch(`/api/messages?channel=${currentChannel}&limit=50`);
|
|
const data = await r.json();
|
|
if (data.success) renderMessages(data.messages || []);
|
|
else showToast('Failed to load messages', 'error');
|
|
} catch (e) {
|
|
showToast('Network error', 'error');
|
|
}
|
|
}
|
|
|
|
function renderMessages(msgs) {
|
|
if (msgs.length === 0) {
|
|
messagesEl.innerHTML = '<div class="empty-state">💬 No messages yet. Be the first!</div>';
|
|
return;
|
|
}
|
|
let html = '';
|
|
msgs.forEach(msg => {
|
|
const time = new Date(msg.timestamp).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
|
|
html += `<div class="message">
|
|
<div class="msg-ip">🔑 ${escapeHtml(msg.ip)}</div>
|
|
<div class="msg-content">${escapeHtml(msg.content)}</div>
|
|
<div class="msg-time">${time}</div>
|
|
</div>`;
|
|
});
|
|
messagesEl.innerHTML = html;
|
|
messagesEl.scrollTop = messagesEl.scrollHeight;
|
|
}
|
|
|
|
async function sendMessage() {
|
|
const text = inputEl.value.trim();
|
|
if (!text) return;
|
|
|
|
sendBtn.disabled = true;
|
|
try {
|
|
const r = await fetch('/api/messages', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ channel: currentChannel, message: text })
|
|
});
|
|
const data = await r.json();
|
|
if (data.success) {
|
|
inputEl.value = '';
|
|
loadMessages();
|
|
} else {
|
|
showToast(data.error || 'Failed to send', 'error');
|
|
}
|
|
} catch (e) {
|
|
showToast('Network error', 'error');
|
|
}
|
|
sendBtn.disabled = false;
|
|
}
|
|
|
|
// Init
|
|
renderChannels();
|
|
loadMessages();
|
|
|
|
sendBtn.addEventListener('click', sendMessage);
|
|
inputEl.addEventListener('keydown', e => { if (e.key === 'Enter') sendMessage(); });
|
|
|
|
// Auto-poll every 3 seconds
|
|
setInterval(() => loadMessages(), 3000);
|
|
</script>
|
|
</body>
|
|
</html>
|