Upload 4 files
Browse files
SETUP.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🔥 NoahsChat v3 – Firebase Setup
|
| 2 |
+
|
| 3 |
+
## Warum Firebase?
|
| 4 |
+
Das Chat-System nutzt jetzt **Firebase Realtime Database** damit Nachrichten,
|
| 5 |
+
DMs, Tickets und Voice-Presence für ALLE User sichtbar sind – nicht nur lokal.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Schritt 1: Firebase-Projekt erstellen (kostenlos)
|
| 10 |
+
|
| 11 |
+
1. Gehe zu → https://console.firebase.google.com
|
| 12 |
+
2. Klicke **"Projekt erstellen"**
|
| 13 |
+
3. Gib einen Namen ein (z.B. `noahschat`) → Weiter → Projekt erstellen
|
| 14 |
+
4. Im Dashboard: Klicke **"Realtime Database"** (links im Menü)
|
| 15 |
+
5. Klicke **"Datenbank erstellen"**
|
| 16 |
+
6. Wähle **Europe-West1** als Standort
|
| 17 |
+
7. Starte im **Testmodus** (Regeln = offen für 30 Tage)
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Schritt 2: App-Konfiguration holen
|
| 22 |
+
|
| 23 |
+
1. Klicke auf das Zahnrad ⚙️ neben "Projektübersicht" → Projekteinstellungen
|
| 24 |
+
2. Scrolle runter zu **"Deine Apps"**
|
| 25 |
+
3. Klicke auf `</>` (Web-App hinzufügen)
|
| 26 |
+
4. App-Namen eingeben → App registrieren
|
| 27 |
+
5. Du siehst jetzt ein `firebaseConfig`-Objekt mit allen Werten
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## Schritt 3: app.js anpassen
|
| 32 |
+
|
| 33 |
+
Öffne `app.js` und ersetze oben den `FIREBASE_CONFIG` Block:
|
| 34 |
+
|
| 35 |
+
```javascript
|
| 36 |
+
const FIREBASE_CONFIG = {
|
| 37 |
+
apiKey: "AIzaSy...", // ← dein Wert
|
| 38 |
+
authDomain: "noahschat.firebaseapp.com",
|
| 39 |
+
databaseURL: "https://noahschat-default-rtdb.europe-west1.firebasedatabase.app",
|
| 40 |
+
projectId: "noahschat",
|
| 41 |
+
storageBucket: "noahschat.appspot.com",
|
| 42 |
+
messagingSenderId: "123456789",
|
| 43 |
+
appId: "1:123456789:web:..."
|
| 44 |
+
};
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Schritt 4: Datenbank-Regeln (nach dem Testen sichern!)
|
| 50 |
+
|
| 51 |
+
Im Firebase Console → Realtime Database → **Regeln**:
|
| 52 |
+
|
| 53 |
+
```json
|
| 54 |
+
{
|
| 55 |
+
"rules": {
|
| 56 |
+
".read": true,
|
| 57 |
+
".write": true
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Für Produktion später:
|
| 63 |
+
```json
|
| 64 |
+
{
|
| 65 |
+
"rules": {
|
| 66 |
+
"users": {
|
| 67 |
+
".read": true,
|
| 68 |
+
".write": true
|
| 69 |
+
},
|
| 70 |
+
"msgs": {
|
| 71 |
+
".read": true,
|
| 72 |
+
".write": true
|
| 73 |
+
},
|
| 74 |
+
"dms": {
|
| 75 |
+
".read": true,
|
| 76 |
+
".write": true
|
| 77 |
+
},
|
| 78 |
+
"online": {
|
| 79 |
+
".read": true,
|
| 80 |
+
".write": true
|
| 81 |
+
},
|
| 82 |
+
"voice_participants": {
|
| 83 |
+
".read": true,
|
| 84 |
+
".write": true
|
| 85 |
+
},
|
| 86 |
+
"tickets": {
|
| 87 |
+
".read": true,
|
| 88 |
+
".write": true
|
| 89 |
+
},
|
| 90 |
+
"pins": {
|
| 91 |
+
".read": true,
|
| 92 |
+
".write": true
|
| 93 |
+
},
|
| 94 |
+
"moderation": {
|
| 95 |
+
".read": true,
|
| 96 |
+
".write": true
|
| 97 |
+
},
|
| 98 |
+
"config": {
|
| 99 |
+
".read": true,
|
| 100 |
+
".write": true
|
| 101 |
+
},
|
| 102 |
+
"user_fps": {
|
| 103 |
+
".read": true,
|
| 104 |
+
".write": true
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## Was jetzt funktioniert ✅
|
| 113 |
+
|
| 114 |
+
| Feature | Status |
|
| 115 |
+
|---------|--------|
|
| 116 |
+
| Nachrichten (geteilt) | ✅ Realtime via Firebase |
|
| 117 |
+
| DMs | ✅ Funktioniert für alle User |
|
| 118 |
+
| Voice Presence | ✅ Sichtbar für alle |
|
| 119 |
+
| Tickets | ✅ Für Admins sichtbar |
|
| 120 |
+
| Online-Status | ✅ Live-Update |
|
| 121 |
+
| Ban/Kick/Timeout | ✅ Server-übergreifend |
|
| 122 |
+
| AutoMod | ✅ |
|
| 123 |
+
| Pins | ✅ |
|
| 124 |
+
| Suche | ✅ |
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
## Fallback (ohne Firebase)
|
| 129 |
+
|
| 130 |
+
Ohne Firebase-Konfiguration läuft alles in **localStorage** – funktioniert
|
| 131 |
+
nur lokal in deinem Browser, aber zum Testen reicht es.
|
| 132 |
+
|
| 133 |
+
Der gelbe Hinweis `⚠ LOKAL – Firebase fehlt!` verschwindet wenn Firebase konfiguriert ist.
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## Owner-Account
|
| 138 |
+
- **Username:** Noah
|
| 139 |
+
- **Passwort:** Noah100419!
|
app.js
ADDED
|
@@ -0,0 +1,1333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ═══════════════════════════════════════════════════════════════
|
| 2 |
+
// NOAHSCHAT — app.js v3.0 (Firebase Backend)
|
| 3 |
+
// ═══════════════════════════════════════════════════════════════
|
| 4 |
+
|
| 5 |
+
// ─── FIREBASE CONFIG ──────────────────────────────────────────
|
| 6 |
+
// !! Ersetze mit deinen eigenen Firebase-Projektdaten !!
|
| 7 |
+
// Erstelle ein kostenloses Projekt auf https://console.firebase.google.com
|
| 8 |
+
// → Realtime Database aktivieren → Regeln auf Testmodus setzen
|
| 9 |
+
const FIREBASE_CONFIG = {
|
| 10 |
+
apiKey: "DEINE_API_KEY",
|
| 11 |
+
authDomain: "DEIN_PROJEKT.firebaseapp.com",
|
| 12 |
+
databaseURL: "https://DEIN_PROJEKT-default-rtdb.europe-west1.firebasedatabase.app",
|
| 13 |
+
projectId: "DEIN_PROJEKT",
|
| 14 |
+
storageBucket: "DEIN_PROJEKT.appspot.com",
|
| 15 |
+
messagingSenderId: "DEINE_SENDER_ID",
|
| 16 |
+
appId: "DEINE_APP_ID"
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
// ─── CONFIG ───────────────────────────────────────────────────
|
| 20 |
+
const OWNER_NAME = 'Noah';
|
| 21 |
+
const OWNER_PASS = 'Noah100419!';
|
| 22 |
+
|
| 23 |
+
// ─── STATE ────────────────────────────────────────────────────
|
| 24 |
+
let currentUser = null;
|
| 25 |
+
let currentChannel = 'allgemein';
|
| 26 |
+
let currentDM = null;
|
| 27 |
+
let pollTimer = null;
|
| 28 |
+
let lastMsgCount = {};
|
| 29 |
+
let unreadCounts = {};
|
| 30 |
+
let spamTs = [];
|
| 31 |
+
let captchaData = {};
|
| 32 |
+
let pendingSpamMsg = null;
|
| 33 |
+
let appConfig = {};
|
| 34 |
+
let voiceActive = false;
|
| 35 |
+
let voiceChannel = null;
|
| 36 |
+
let micMuted = false;
|
| 37 |
+
let deafened = false;
|
| 38 |
+
let voiceParticipants = {};
|
| 39 |
+
let translationEnabled = false;
|
| 40 |
+
let userLanguage = 'de';
|
| 41 |
+
let firebaseReady = false;
|
| 42 |
+
let db = null;
|
| 43 |
+
let listeners = {};
|
| 44 |
+
|
| 45 |
+
// ─── FINGERPRINT ──────────────────────────────────────────────
|
| 46 |
+
function getFingerprint() {
|
| 47 |
+
const str = navigator.userAgent + screen.width + 'x' + screen.height + screen.colorDepth
|
| 48 |
+
+ (Intl.DateTimeFormat().resolvedOptions().timeZone || '') + navigator.language;
|
| 49 |
+
let h = 0;
|
| 50 |
+
for (let i = 0; i < str.length; i++) { h = ((h << 5) - h) + str.charCodeAt(i); h = h & h; }
|
| 51 |
+
return Math.abs(h).toString(36);
|
| 52 |
+
}
|
| 53 |
+
const MY_FP = getFingerprint();
|
| 54 |
+
|
| 55 |
+
// ─── DB WRAPPER ───────────────────────────────────────────────
|
| 56 |
+
const DB = {
|
| 57 |
+
async get(path) {
|
| 58 |
+
try {
|
| 59 |
+
if (firebaseReady && db) {
|
| 60 |
+
const snap = await db.ref(path).once('value');
|
| 61 |
+
return snap.val();
|
| 62 |
+
}
|
| 63 |
+
const v = localStorage.getItem('nc3_' + path);
|
| 64 |
+
return v ? JSON.parse(v) : null;
|
| 65 |
+
} catch(e) { return null; }
|
| 66 |
+
},
|
| 67 |
+
|
| 68 |
+
async set(path, val) {
|
| 69 |
+
try {
|
| 70 |
+
if (firebaseReady && db) { await db.ref(path).set(val); return; }
|
| 71 |
+
localStorage.setItem('nc3_' + path, JSON.stringify(val));
|
| 72 |
+
} catch(e) { console.error('DB.set', e); }
|
| 73 |
+
},
|
| 74 |
+
|
| 75 |
+
async push(path, val) {
|
| 76 |
+
try {
|
| 77 |
+
if (firebaseReady && db) {
|
| 78 |
+
const ref = await db.ref(path).push(val);
|
| 79 |
+
return ref.key;
|
| 80 |
+
}
|
| 81 |
+
const arr = JSON.parse(localStorage.getItem('nc3_' + path) || '{}');
|
| 82 |
+
const key = Date.now().toString(36);
|
| 83 |
+
arr[key] = val;
|
| 84 |
+
localStorage.setItem('nc3_' + path, JSON.stringify(arr));
|
| 85 |
+
return key;
|
| 86 |
+
} catch(e) { return null; }
|
| 87 |
+
},
|
| 88 |
+
|
| 89 |
+
async delete(path) {
|
| 90 |
+
try {
|
| 91 |
+
if (firebaseReady && db) { await db.ref(path).remove(); return; }
|
| 92 |
+
// For localStorage, just remove the item if it's a leaf
|
| 93 |
+
localStorage.removeItem('nc3_' + path);
|
| 94 |
+
} catch(e) {}
|
| 95 |
+
},
|
| 96 |
+
|
| 97 |
+
on(path, cb) {
|
| 98 |
+
if (firebaseReady && db) {
|
| 99 |
+
const ref = db.ref(path);
|
| 100 |
+
ref.on('value', snap => cb(snap.val()));
|
| 101 |
+
return () => ref.off('value');
|
| 102 |
+
}
|
| 103 |
+
return null;
|
| 104 |
+
}
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
// ─── FIREBASE INIT ────────────────────────────────────────────
|
| 108 |
+
async function initFirebase() {
|
| 109 |
+
return new Promise((resolve) => {
|
| 110 |
+
if (typeof firebase === 'undefined') {
|
| 111 |
+
console.warn('Firebase SDK nicht geladen – localStorage Modus');
|
| 112 |
+
resolve(false); return;
|
| 113 |
+
}
|
| 114 |
+
try {
|
| 115 |
+
if (!firebase.apps.length) firebase.initializeApp(FIREBASE_CONFIG);
|
| 116 |
+
db = firebase.database();
|
| 117 |
+
const timeout = setTimeout(() => { resolve(false); }, 5000);
|
| 118 |
+
db.ref('.info/connected').once('value', snap => {
|
| 119 |
+
clearTimeout(timeout);
|
| 120 |
+
firebaseReady = !!snap.val();
|
| 121 |
+
console.log(firebaseReady ? '✅ Firebase verbunden' : '⚠️ Firebase offline');
|
| 122 |
+
resolve(firebaseReady);
|
| 123 |
+
});
|
| 124 |
+
} catch(e) { console.error('Firebase Fehler:', e); resolve(false); }
|
| 125 |
+
});
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// ─── ROLE HELPERS ─────────────────────────────────────────────
|
| 129 |
+
const ROLE_PRIORITY = { owner:5, admin:4, mod:3, vip:2, member:1 };
|
| 130 |
+
const ROLE_BADGE = { owner:'👑', admin:'🔰', mod:'⭐', vip:'💎', member:'' };
|
| 131 |
+
const ROLE_LABELS = { owner:'Owner', admin:'Admin', mod:'Moderator', vip:'VIP', member:'Mitglied' };
|
| 132 |
+
const ROLE_COLORS = { owner:'name-color-1', admin:'name-color-0', mod:'name-color-2', vip:'name-color-4', member:'' };
|
| 133 |
+
|
| 134 |
+
function hasRole(role) {
|
| 135 |
+
return currentUser && ROLE_PRIORITY[currentUser.role] >= ROLE_PRIORITY[role];
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// ─── CAPTCHA ──────────────────────────────────────────────────
|
| 139 |
+
function genCaptcha() {
|
| 140 |
+
const a = Math.floor(Math.random()*18)+2, b = Math.floor(Math.random()*18)+2;
|
| 141 |
+
if (Math.random()>0.4) return { q:`${a} + ${b} = ?`, ans:a+b };
|
| 142 |
+
const big=Math.max(a,b), sm=Math.min(a,b);
|
| 143 |
+
return { q:`${big} − ${sm} = ?`, ans:big-sm };
|
| 144 |
+
}
|
| 145 |
+
function refreshCaptcha(id) {
|
| 146 |
+
const d=genCaptcha(); captchaData[id]=d;
|
| 147 |
+
const qEl=document.getElementById(id+'-q'); if(qEl) qEl.textContent=d.q;
|
| 148 |
+
const aEl=document.getElementById(id+'-a'); if(aEl) aEl.value='';
|
| 149 |
+
}
|
| 150 |
+
function verifyCaptcha(id) {
|
| 151 |
+
const a=parseInt(document.getElementById(id+'-a')?.value);
|
| 152 |
+
return captchaData[id] && a===captchaData[id].ans;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
// ─── AUTH TABS ────────────────────────────────────────────────
|
| 156 |
+
function switchTab(tab) {
|
| 157 |
+
['login','register'].forEach((t,i)=>{
|
| 158 |
+
document.getElementById('tab-'+t).style.display=t===tab?'':'none';
|
| 159 |
+
document.querySelectorAll('.auth-tab')[i].classList.toggle('active',t===tab);
|
| 160 |
+
});
|
| 161 |
+
document.getElementById('auth-error').textContent='';
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
// ─── REGISTER ─────────────────────────────────────────────────
|
| 165 |
+
async function doRegister() {
|
| 166 |
+
const u=document.getElementById('reg-user').value.trim();
|
| 167 |
+
const p=document.getElementById('reg-pass').value;
|
| 168 |
+
const p2=document.getElementById('reg-pass2').value;
|
| 169 |
+
const err=t=>document.getElementById('auth-error').textContent=t;
|
| 170 |
+
if(u.length<2) return err('Username mind. 2 Zeichen');
|
| 171 |
+
if(u.length>20) return err('Username max. 20 Zeichen');
|
| 172 |
+
if(!/^[a-zA-Z0-9_]+$/.test(u)) return err('Nur Buchstaben, Zahlen, _');
|
| 173 |
+
if(p.length<4) return err('Passwort mind. 4 Zeichen');
|
| 174 |
+
if(p!==p2) return err('Passwörter stimmen nicht überein');
|
| 175 |
+
if(!verifyCaptcha('reg')) { refreshCaptcha('reg'); return err('❌ Falsches Captcha!'); }
|
| 176 |
+
const mod=(await DB.get('moderation'))||{};
|
| 177 |
+
if(mod.bans?.[u.toLowerCase()]) return err('Dieser Account ist gesperrt.');
|
| 178 |
+
if(mod.banned_fps?.[MY_FP]) return showBanned();
|
| 179 |
+
const existing=await DB.get(`users/${u.toLowerCase()}`);
|
| 180 |
+
if(existing) return err('Username bereits vergeben');
|
| 181 |
+
await DB.set(`users/${u.toLowerCase()}`,{
|
| 182 |
+
username:u, password:encode(p),
|
| 183 |
+
color:Math.floor(Math.random()*5), role:'member', joined:Date.now(),
|
| 184 |
+
settings:{lang:'de',translate:false,notif:true}
|
| 185 |
+
});
|
| 186 |
+
refreshCaptcha('reg');
|
| 187 |
+
showAuthSuccess('✓ Account erstellt! Du kannst dich jetzt einloggen.');
|
| 188 |
+
setTimeout(()=>{ switchTab('login'); document.getElementById('login-user').value=u; },1300);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
// ─── LOGIN ────────────────────────────────────────────────────
|
| 192 |
+
async function doLogin() {
|
| 193 |
+
const u=document.getElementById('login-user').value.trim();
|
| 194 |
+
const p=document.getElementById('login-pass').value;
|
| 195 |
+
const err=t=>document.getElementById('auth-error').textContent=t;
|
| 196 |
+
if(!verifyCaptcha('login')) { refreshCaptcha('login'); return err('❌ Falsches Captcha!'); }
|
| 197 |
+
const mod=(await DB.get('moderation'))||{};
|
| 198 |
+
if(mod.banned_fps?.[MY_FP]) return showBanned();
|
| 199 |
+
const entry=await DB.get(`users/${u.toLowerCase()}`);
|
| 200 |
+
if(!entry) return err('Falscher Username oder Passwort');
|
| 201 |
+
if(decode(entry.password)!==p) return err('Falscher Username oder Passwort');
|
| 202 |
+
if(mod.bans?.[u.toLowerCase()]) return err('🚫 Du bist von NoahsChat gebannt.');
|
| 203 |
+
currentUser={...entry};
|
| 204 |
+
refreshCaptcha('login');
|
| 205 |
+
await DB.set(`user_fps/${entry.username.toLowerCase()}`,MY_FP);
|
| 206 |
+
await DB.set(`online/${entry.username}`,Date.now());
|
| 207 |
+
userLanguage=entry.settings?.lang||'de';
|
| 208 |
+
translationEnabled=entry.settings?.translate||false;
|
| 209 |
+
launchApp();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// ─── LOGOUT ───────────────────────────────────────────────────
|
| 213 |
+
async function doLogout() {
|
| 214 |
+
if(!currentUser) return;
|
| 215 |
+
await DB.delete(`online/${currentUser.username}`);
|
| 216 |
+
if(voiceActive) await leaveVoice();
|
| 217 |
+
Object.values(listeners).forEach(off=>{ if(typeof off==='function') off(); });
|
| 218 |
+
listeners={};
|
| 219 |
+
currentUser=null;
|
| 220 |
+
clearInterval(pollTimer);
|
| 221 |
+
document.getElementById('app').classList.remove('visible');
|
| 222 |
+
document.getElementById('auth-screen').style.display='flex';
|
| 223 |
+
document.getElementById('login-pass').value='';
|
| 224 |
+
refreshCaptcha('login');
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
// ─── LAUNCH APP ───────────────────────────────────────────────
|
| 228 |
+
async function launchApp() {
|
| 229 |
+
document.getElementById('auth-screen').style.display='none';
|
| 230 |
+
document.getElementById('app').classList.add('visible');
|
| 231 |
+
appConfig=(await DB.get('config'))||{};
|
| 232 |
+
if(!appConfig.channels) {
|
| 233 |
+
appConfig.channels=window.DEFAULT_CHANNELS||[];
|
| 234 |
+
appConfig.automod=window.DEFAULT_AUTOMOD||{};
|
| 235 |
+
await DB.set('config',appConfig);
|
| 236 |
+
}
|
| 237 |
+
updateTopbar();
|
| 238 |
+
buildChannelList();
|
| 239 |
+
await openChannel('allgemein');
|
| 240 |
+
startPolling();
|
| 241 |
+
setupRealtimeListeners();
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
// ─── REALTIME LISTENERS ───────────────────────────────────────
|
| 245 |
+
function setupRealtimeListeners() {
|
| 246 |
+
// Online users
|
| 247 |
+
const offOnline=DB.on('online',(data)=>{
|
| 248 |
+
if(!currentUser) return;
|
| 249 |
+
const now=Date.now();
|
| 250 |
+
const onlineNames=data?Object.entries(data).filter(([,ts])=>now-ts<15000).map(([u])=>u):[];
|
| 251 |
+
document.getElementById('online-count').textContent=onlineNames.length;
|
| 252 |
+
renderUserListFromOnline(onlineNames);
|
| 253 |
+
});
|
| 254 |
+
if(offOnline) listeners.online=offOnline;
|
| 255 |
+
|
| 256 |
+
// Voice participants
|
| 257 |
+
const offVoice=DB.on('voice_participants',(data)=>{
|
| 258 |
+
voiceParticipants=data||{};
|
| 259 |
+
buildChannelList();
|
| 260 |
+
});
|
| 261 |
+
if(offVoice) listeners.voice=offVoice;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
function listenToChannel(chId) {
|
| 265 |
+
if(listeners.channel) { listeners.channel(); listeners.channel=null; }
|
| 266 |
+
if(!firebaseReady) return;
|
| 267 |
+
const off=DB.on(`msgs/${chId}`,async(data)=>{
|
| 268 |
+
if(!currentUser||currentDM||currentChannel!==chId) return;
|
| 269 |
+
const msgs=data?Object.values(data).sort((a,b)=>a.ts-b.ts):[];
|
| 270 |
+
await renderMessages(msgs);
|
| 271 |
+
const c=document.getElementById('messages');
|
| 272 |
+
if(c.scrollHeight-c.scrollTop<=c.clientHeight+120) c.scrollTop=c.scrollHeight;
|
| 273 |
+
lastMsgCount[`ch_${chId}`]=msgs.length;
|
| 274 |
+
});
|
| 275 |
+
listeners.channel=off;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
function listenToDM(username) {
|
| 279 |
+
if(listeners.dm) { listeners.dm(); listeners.dm=null; }
|
| 280 |
+
if(!firebaseReady) return;
|
| 281 |
+
const dmKey=getDMKey(currentUser.username,username);
|
| 282 |
+
const off=DB.on(`dms/${dmKey}`,async(data)=>{
|
| 283 |
+
if(!currentUser||currentDM!==username) return;
|
| 284 |
+
const msgs=data?Object.values(data).sort((a,b)=>a.ts-b.ts):[];
|
| 285 |
+
await renderMessages(msgs,true);
|
| 286 |
+
const c=document.getElementById('messages');
|
| 287 |
+
if(c.scrollHeight-c.scrollTop<=c.clientHeight+120) c.scrollTop=c.scrollHeight;
|
| 288 |
+
});
|
| 289 |
+
listeners.dm=off;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
// ─── POLLING (heartbeat + fallback) ──────────────────────────
|
| 293 |
+
function startPolling() {
|
| 294 |
+
pollTimer=setInterval(pollTick,3000);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
async function pollTick() {
|
| 298 |
+
if(!currentUser) return;
|
| 299 |
+
await DB.set(`online/${currentUser.username}`,Date.now());
|
| 300 |
+
const me=await DB.get(`users/${currentUser.username.toLowerCase()}`);
|
| 301 |
+
if(me) {
|
| 302 |
+
currentUser={...me};
|
| 303 |
+
updateTopbar();
|
| 304 |
+
userLanguage=me.settings?.lang||'de';
|
| 305 |
+
translationEnabled=me.settings?.translate||false;
|
| 306 |
+
}
|
| 307 |
+
const mod=(await DB.get('moderation'))||{};
|
| 308 |
+
if(mod.bans?.[currentUser.username.toLowerCase()]||mod.banned_fps?.[MY_FP]) {
|
| 309 |
+
clearInterval(pollTimer); showBanned(); return;
|
| 310 |
+
}
|
| 311 |
+
const kick=mod.kicked?.[currentUser.username.toLowerCase()];
|
| 312 |
+
if(kick&&Date.now()-kick.ts<60000) { clearInterval(pollTimer); showKickedModal(); return; }
|
| 313 |
+
updateTimeoutBar(mod);
|
| 314 |
+
if(!firebaseReady) {
|
| 315 |
+
if(currentDM) await loadDMMessages(currentDM);
|
| 316 |
+
else await loadMessages(currentChannel);
|
| 317 |
+
await checkUnreadDMs();
|
| 318 |
+
await updateDMList();
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
async function checkUnreadDMs() {
|
| 323 |
+
const users=await DB.get('users');
|
| 324 |
+
if(!users) return;
|
| 325 |
+
for(const [ukey,udata] of Object.entries(users)) {
|
| 326 |
+
if(ukey===currentUser.username.toLowerCase()) continue;
|
| 327 |
+
if(currentDM&¤tDM.toLowerCase()===ukey) continue;
|
| 328 |
+
const dmKey=getDMKey(currentUser.username,udata.username);
|
| 329 |
+
const data=await DB.get(`dms/${dmKey}`);
|
| 330 |
+
const msgs=data?Object.values(data):[];
|
| 331 |
+
const key=`dm_${ukey}`;
|
| 332 |
+
const prev=lastMsgCount[key]||0;
|
| 333 |
+
if(msgs.length>prev) {
|
| 334 |
+
unreadCounts[key]=(unreadCounts[key]||0)+(msgs.length-prev);
|
| 335 |
+
lastMsgCount[key]=msgs.length;
|
| 336 |
+
await updateDMList();
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// ─── TOPBAR ───────────────────────────────────────────────────
|
| 342 |
+
function updateTopbar() {
|
| 343 |
+
const av=document.getElementById('topbar-avatar');
|
| 344 |
+
av.textContent=currentUser.username[0].toUpperCase();
|
| 345 |
+
av.className=`user-avatar-sm av-color-${currentUser.color}`;
|
| 346 |
+
document.getElementById('topbar-username').textContent=currentUser.username;
|
| 347 |
+
document.getElementById('topbar-role-badge').textContent=ROLE_BADGE[currentUser.role]||'';
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
// ─── SIDEBAR ──────────────────────────────────────────────────
|
| 351 |
+
function buildChannelList() {
|
| 352 |
+
const channels=appConfig.channels||window.DEFAULT_CHANNELS||[];
|
| 353 |
+
const list=document.getElementById('channel-list');
|
| 354 |
+
list.innerHTML='';
|
| 355 |
+
|
| 356 |
+
const categories={info:'Info',chat:'Text-Channels',fun:'Community',staff:'Staff'};
|
| 357 |
+
const grouped={};
|
| 358 |
+
for(const ch of channels) {
|
| 359 |
+
const cat=ch.category||'chat';
|
| 360 |
+
if(!grouped[cat]) grouped[cat]=[];
|
| 361 |
+
grouped[cat].push(ch);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
for(const[catId,label] of Object.entries(categories)) {
|
| 365 |
+
const chs=grouped[catId];
|
| 366 |
+
if(!chs) continue;
|
| 367 |
+
if(catId==='staff'&&!hasRole('mod')) continue;
|
| 368 |
+
const catEl=document.createElement('div');
|
| 369 |
+
catEl.className='channel-category';
|
| 370 |
+
catEl.textContent='— '+label;
|
| 371 |
+
list.appendChild(catEl);
|
| 372 |
+
for(const ch of chs) {
|
| 373 |
+
if(ch.adminOnly&&!hasRole('admin')) {
|
| 374 |
+
if(catId==='staff') continue;
|
| 375 |
+
const div=document.createElement('div');
|
| 376 |
+
div.className='channel-item ch-locked';
|
| 377 |
+
div.innerHTML=`<span class="channel-icon">${ch.icon}</span><span class="channel-name">${ch.name}</span><span style="font-size:.65rem;color:var(--muted)">🔒</span>`;
|
| 378 |
+
list.appendChild(div); continue;
|
| 379 |
+
}
|
| 380 |
+
if(ch.modOnly&&!hasRole('mod')) continue;
|
| 381 |
+
const div=document.createElement('div');
|
| 382 |
+
div.className='channel-item'+(ch.id===currentChannel&&!currentDM?' active':'');
|
| 383 |
+
div.dataset.channel=ch.id;
|
| 384 |
+
div.innerHTML=`<span class="channel-icon">${ch.icon}</span><span class="channel-name">${ch.name}</span><span class="unread-badge" id="badge-${ch.id}" style="display:none"></span>`;
|
| 385 |
+
div.onclick=()=>openChannel(ch.id);
|
| 386 |
+
list.appendChild(div);
|
| 387 |
+
}
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
// Voice channels
|
| 391 |
+
const vcCat=document.createElement('div');
|
| 392 |
+
vcCat.className='channel-category';
|
| 393 |
+
vcCat.textContent='— Voice Channels';
|
| 394 |
+
list.appendChild(vcCat);
|
| 395 |
+
|
| 396 |
+
const voiceChannels=[
|
| 397 |
+
{id:'voice-allgemein',name:'Allgemein',icon:'🔊'},
|
| 398 |
+
{id:'voice-gaming',name:'Gaming',icon:'🎮'},
|
| 399 |
+
{id:'voice-musik',name:'Musik',icon:'🎵'},
|
| 400 |
+
];
|
| 401 |
+
|
| 402 |
+
for(const vc of voiceChannels) {
|
| 403 |
+
const isActive=voiceActive&&voiceChannel===vc.id;
|
| 404 |
+
const div=document.createElement('div');
|
| 405 |
+
div.className='channel-item'+(isActive?' active':'');
|
| 406 |
+
div.dataset.vc=vc.id;
|
| 407 |
+
div.innerHTML=`<span class="channel-icon">${vc.icon}</span><span class="channel-name">${vc.name}</span>`;
|
| 408 |
+
div.onclick=()=>joinVoice(vc.id,vc.name);
|
| 409 |
+
list.appendChild(div);
|
| 410 |
+
const parts=voiceParticipants[vc.id];
|
| 411 |
+
if(parts) {
|
| 412 |
+
const partList=typeof parts==='object'?Object.values(parts):[];
|
| 413 |
+
for(const p of partList) {
|
| 414 |
+
const pe=document.createElement('div');
|
| 415 |
+
pe.style.cssText='padding:3px 14px 3px 32px;font-size:.78rem;color:var(--green);display:flex;gap:6px;align-items:center';
|
| 416 |
+
pe.innerHTML=`<span>🎙</span><span>${escHtml(p.name||p)}</span>${p.muted?'<span style="color:var(--muted)">🔇</span>':''}`;
|
| 417 |
+
list.appendChild(pe);
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
// ─── CHANNELS ─────────────────────────────────────────────────
|
| 424 |
+
async function openChannel(chId) {
|
| 425 |
+
currentChannel=chId; currentDM=null;
|
| 426 |
+
if(listeners.dm) { listeners.dm(); listeners.dm=null; }
|
| 427 |
+
document.querySelectorAll('.channel-item').forEach(el=>el.classList.remove('active'));
|
| 428 |
+
document.querySelector(`[data-channel="${chId}"]`)?.classList.add('active');
|
| 429 |
+
document.querySelectorAll('.dm-item').forEach(el=>el.classList.remove('active'));
|
| 430 |
+
const channels=appConfig.channels||window.DEFAULT_CHANNELS||[];
|
| 431 |
+
const ch=channels.find(c=>c.id===chId)||{name:chId,icon:'💬',sub:''};
|
| 432 |
+
document.getElementById('chat-title').textContent=ch.icon+' '+ch.name;
|
| 433 |
+
document.getElementById('chat-sub').textContent=ch.sub||'';
|
| 434 |
+
document.getElementById('topbar-channel-name').textContent='# '+ch.name;
|
| 435 |
+
unreadCounts[`ch_${chId}`]=0;
|
| 436 |
+
updateBadge(`badge-${chId}`,0);
|
| 437 |
+
const locked=(ch.adminOnly&&!hasRole('admin'))||(ch.readOnly&&!hasRole('admin'))||(ch.modOnly&&!hasRole('mod'));
|
| 438 |
+
document.getElementById('msg-input').disabled=locked;
|
| 439 |
+
document.getElementById('send-btn').disabled=locked;
|
| 440 |
+
document.getElementById('msg-input').placeholder=locked?'🔒 Du kannst hier nicht schreiben':'Nachricht schreiben...';
|
| 441 |
+
await loadMessages(chId);
|
| 442 |
+
listenToChannel(chId);
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
async function loadMessages(chId) {
|
| 446 |
+
const data=await DB.get(`msgs/${chId}`);
|
| 447 |
+
const msgs=data?Object.values(data).sort((a,b)=>a.ts-b.ts):[];
|
| 448 |
+
lastMsgCount[`ch_${chId}`]=msgs.length;
|
| 449 |
+
await renderMessages(msgs);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
// ─── DMs ──────────────────────────────────────────────────────
|
| 453 |
+
function getDMKey(a,b) { return [a.toLowerCase(),b.toLowerCase()].sort().join('__'); }
|
| 454 |
+
|
| 455 |
+
async function openDM(username) {
|
| 456 |
+
currentDM=username; currentChannel=null;
|
| 457 |
+
if(listeners.channel) { listeners.channel(); listeners.channel=null; }
|
| 458 |
+
document.querySelectorAll('.channel-item').forEach(el=>el.classList.remove('active'));
|
| 459 |
+
document.querySelectorAll('.dm-item').forEach(el=>{
|
| 460 |
+
el.classList.toggle('active',el.dataset.user===username.toLowerCase());
|
| 461 |
+
});
|
| 462 |
+
document.getElementById('chat-title').textContent='@ '+username;
|
| 463 |
+
document.getElementById('chat-sub').textContent='Direktnachricht – privat';
|
| 464 |
+
document.getElementById('topbar-channel-name').textContent='@ '+username;
|
| 465 |
+
document.getElementById('msg-input').disabled=false;
|
| 466 |
+
document.getElementById('send-btn').disabled=false;
|
| 467 |
+
document.getElementById('msg-input').placeholder=`Nachricht an @${username}...`;
|
| 468 |
+
unreadCounts[`dm_${username.toLowerCase()}`]=0;
|
| 469 |
+
await updateDMList();
|
| 470 |
+
await loadDMMessages(username);
|
| 471 |
+
listenToDM(username);
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
async function loadDMMessages(username) {
|
| 475 |
+
const dmKey=getDMKey(currentUser.username,username);
|
| 476 |
+
const data=await DB.get(`dms/${dmKey}`);
|
| 477 |
+
const msgs=data?Object.values(data).sort((a,b)=>a.ts-b.ts):[];
|
| 478 |
+
lastMsgCount[`dm_${username.toLowerCase()}`]=msgs.length;
|
| 479 |
+
await renderMessages(msgs,true);
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
// ─── RENDER ───────────────────────────────────────────────────
|
| 483 |
+
async function renderMessages(msgs,isDM=false) {
|
| 484 |
+
const container=document.getElementById('messages');
|
| 485 |
+
const atBottom=container.scrollHeight-container.scrollTop<=container.clientHeight+80;
|
| 486 |
+
if(!msgs.length) {
|
| 487 |
+
container.innerHTML=`<div class="empty-chat"><div class="empty-chat-icon">💬</div><p>Noch keine Nachrichten. Schreib was!</p></div>`;
|
| 488 |
+
return;
|
| 489 |
+
}
|
| 490 |
+
let html='', lastDay='', lastAuthor='', lastTime=0;
|
| 491 |
+
for(let i=0;i<msgs.length;i++) {
|
| 492 |
+
const m=msgs[i];
|
| 493 |
+
if(m.system) { html+=`<div class="msg-system">⚙ ${escHtml(m.text)}</div>`; lastAuthor=''; continue; }
|
| 494 |
+
if(m.automod) { html+=`<div class="msg-automod">🤖 AutoMod: ${escHtml(m.text)}</div>`; lastAuthor=''; continue; }
|
| 495 |
+
const date=new Date(m.ts);
|
| 496 |
+
const day=date.toLocaleDateString('de-DE',{day:'2-digit',month:'2-digit',year:'numeric'});
|
| 497 |
+
const time=date.toLocaleTimeString('de-DE',{hour:'2-digit',minute:'2-digit'});
|
| 498 |
+
if(day!==lastDay) { html+=`<div class="day-divider">${day}</div>`; lastDay=day; lastAuthor=''; }
|
| 499 |
+
const color=m.color??0;
|
| 500 |
+
const consecutive=m.author===lastAuthor&&(m.ts-lastTime)<5*60000;
|
| 501 |
+
lastAuthor=m.author; lastTime=m.ts;
|
| 502 |
+
const initials=(m.author||'?')[0].toUpperCase();
|
| 503 |
+
const role=m.role||'member';
|
| 504 |
+
const badge=ROLE_BADGE[role]||'';
|
| 505 |
+
const nameClass=ROLE_COLORS[role]||`name-color-${color}`;
|
| 506 |
+
const canDelete=hasRole('mod')||m.author===currentUser?.username;
|
| 507 |
+
const canPin=hasRole('mod')&&!isDM;
|
| 508 |
+
const safeText=(m.text||'').substring(0,50).replace(/'/g,"\\'");
|
| 509 |
+
const actionsHtml=`<div class="msg-actions">
|
| 510 |
+
${translationEnabled?`<button class="msg-action-btn" onclick="translateMsg(this,'${escHtml(m.text).replace(/'/g,"'")}')">🌐</button>`:''}
|
| 511 |
+
${canPin?`<button class="msg-action-btn" onclick="pinMessage('${escHtml(m.author)}','${escHtml(safeText)}')">📌</button>`:''}
|
| 512 |
+
${canDelete?`<button class="msg-action-btn danger" onclick="deleteMsg(${i},${isDM})">🗑</button>`:''}
|
| 513 |
+
</div>`;
|
| 514 |
+
html+=`<div class="msg ${consecutive?'consecutive':''}" data-idx="${i}">
|
| 515 |
+
<div class="msg-avatar av-color-${color}" onclick="onAvatarClick(event,'${escHtml(m.author)}')">${initials}</div>
|
| 516 |
+
<div class="msg-content">
|
| 517 |
+
<div class="msg-header">
|
| 518 |
+
<span class="msg-name ${nameClass}" onclick="onAvatarClick(event,'${escHtml(m.author)}')">${escHtml(m.author)}${badge?` <span class="msg-role-badge">${badge}</span>`:''}</span>
|
| 519 |
+
<span class="msg-time">${time}</span>
|
| 520 |
+
${actionsHtml}
|
| 521 |
+
</div>
|
| 522 |
+
<div class="msg-text" id="mt-${i}">${formatMsg(m.text)}</div>
|
| 523 |
+
</div>
|
| 524 |
+
</div>`;
|
| 525 |
+
}
|
| 526 |
+
container.innerHTML=html;
|
| 527 |
+
if(atBottom) container.scrollTop=container.scrollHeight;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
function formatMsg(text) {
|
| 531 |
+
return escHtml(text)
|
| 532 |
+
.replace(/\*\*(.*?)\*\*/g,'<strong>$1</strong>')
|
| 533 |
+
.replace(/\*(.*?)\*/g,'<em>$1</em>')
|
| 534 |
+
.replace(/`(.*?)`/g,'<code style="background:rgba(0,212,255,0.08);padding:1px 5px;border-radius:2px;font-family:monospace">$1</code>')
|
| 535 |
+
.replace(/(https?:\/\/[^\s]+)/g,'<a href="$1" target="_blank" rel="noopener">$1</a>');
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
async function translateMsg(btn,text) {
|
| 539 |
+
const target=userLanguage==='de'?'en':'de';
|
| 540 |
+
btn.textContent='⏳';
|
| 541 |
+
try {
|
| 542 |
+
const res=await fetch('https://libretranslate.de/translate',{
|
| 543 |
+
method:'POST',headers:{'Content-Type':'application/json'},
|
| 544 |
+
body:JSON.stringify({q:text,source:'auto',target}),
|
| 545 |
+
signal:AbortSignal.timeout(4000)
|
| 546 |
+
});
|
| 547 |
+
if(res.ok) {
|
| 548 |
+
const data=await res.json();
|
| 549 |
+
btn.textContent='🌐';
|
| 550 |
+
if(data.translatedText) {
|
| 551 |
+
const msgEl=btn.closest('.msg-content');
|
| 552 |
+
const existing=msgEl.querySelector('.msg-translated');
|
| 553 |
+
if(existing) existing.remove();
|
| 554 |
+
else msgEl.insertAdjacentHTML('beforeend',`<div class="msg-translated">🌐 ${escHtml(data.translatedText)}</div>`);
|
| 555 |
+
return;
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
} catch {}
|
| 559 |
+
btn.textContent='🌐';
|
| 560 |
+
showToast('Übersetzung nicht verfügbar','var(--warn)');
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
// ─── SEND ─────────────────────────────────────────────────────
|
| 564 |
+
async function sendMessage() {
|
| 565 |
+
const input=document.getElementById('msg-input');
|
| 566 |
+
const text=input.value.trim();
|
| 567 |
+
if(!text||!currentUser) return;
|
| 568 |
+
const mod=(await DB.get('moderation'))||{};
|
| 569 |
+
const to=mod.timeouts?.[currentUser.username.toLowerCase()];
|
| 570 |
+
if(to&&to.until>Date.now()) { showToast('Du bist stummgeschaltet!','var(--warn)'); return; }
|
| 571 |
+
const channels=appConfig.channels||window.DEFAULT_CHANNELS||[];
|
| 572 |
+
const ch=channels.find(c=>c.id===currentChannel);
|
| 573 |
+
if(!currentDM) {
|
| 574 |
+
if(ch?.adminOnly&&!hasRole('admin')) return;
|
| 575 |
+
if(ch?.readOnly&&!hasRole('admin')) return;
|
| 576 |
+
if(ch?.modOnly&&!hasRole('mod')) return;
|
| 577 |
+
}
|
| 578 |
+
if(!currentDM) {
|
| 579 |
+
const amResult=autoModCheck(text);
|
| 580 |
+
if(amResult.blocked) { showToast('🤖 AutoMod: '+amResult.reason,'var(--warn)'); input.value=''; input.style.height=''; return; }
|
| 581 |
+
}
|
| 582 |
+
const now=Date.now();
|
| 583 |
+
spamTs=spamTs.filter(t=>now-t<(appConfig.automod?.spamWindow||10000));
|
| 584 |
+
spamTs.push(now);
|
| 585 |
+
if(spamTs.length>(appConfig.automod?.spamThreshold||5)) {
|
| 586 |
+
pendingSpamMsg=text; input.value=''; input.style.height='';
|
| 587 |
+
showSpamCaptchaModal(); return;
|
| 588 |
+
}
|
| 589 |
+
input.value=''; input.style.height='';
|
| 590 |
+
await _sendMsg(text);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
function autoModCheck(text) {
|
| 594 |
+
const am=appConfig.automod||{};
|
| 595 |
+
if(!am.enabled) return {blocked:false};
|
| 596 |
+
if(am.maxMsgLength&&text.length>am.maxMsgLength) return {blocked:true,reason:`Zu lang (max. ${am.maxMsgLength})`};
|
| 597 |
+
const lower=text.toLowerCase();
|
| 598 |
+
for(const w of(am.bannedWords||[])) { if(lower.includes(w.toLowerCase())) return {blocked:true,reason:'Verbotenes Wort'}; }
|
| 599 |
+
if(am.capsFilter&&text.length>10) {
|
| 600 |
+
const caps=(text.match(/[A-ZÄÖÜ]/g)||[]).length;
|
| 601 |
+
if(caps/text.length>(am.capsThreshold||0.7)) return {blocked:true,reason:'Zu viele Großbuchstaben'};
|
| 602 |
+
}
|
| 603 |
+
return {blocked:false};
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
async function _sendMsg(text) {
|
| 607 |
+
const msg={author:currentUser.username,color:currentUser.color,role:currentUser.role,text,ts:Date.now()};
|
| 608 |
+
if(currentDM) {
|
| 609 |
+
const dmKey=getDMKey(currentUser.username,currentDM);
|
| 610 |
+
await DB.push(`dms/${dmKey}`,msg);
|
| 611 |
+
if(!firebaseReady) await loadDMMessages(currentDM);
|
| 612 |
+
} else {
|
| 613 |
+
await DB.push(`msgs/${currentChannel}`,msg);
|
| 614 |
+
if(!firebaseReady) {
|
| 615 |
+
await loadMessages(currentChannel);
|
| 616 |
+
const c=document.getElementById('messages');
|
| 617 |
+
c.scrollTop=c.scrollHeight;
|
| 618 |
+
}
|
| 619 |
+
}
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
async function deleteMsg(idx,isDM=false) {
|
| 623 |
+
if(isDM&¤tDM) {
|
| 624 |
+
const dmKey=getDMKey(currentUser.username,currentDM);
|
| 625 |
+
const data=await DB.get(`dms/${dmKey}`);
|
| 626 |
+
if(!data) return;
|
| 627 |
+
const entries=Object.entries(data).sort(([,a],[,b])=>a.ts-b.ts);
|
| 628 |
+
if(!entries[idx]) return;
|
| 629 |
+
const[key,msg]=entries[idx];
|
| 630 |
+
if(msg.author!==currentUser.username&&!hasRole('mod')) return;
|
| 631 |
+
await DB.delete(`dms/${dmKey}/${key}`);
|
| 632 |
+
if(!firebaseReady) await loadDMMessages(currentDM);
|
| 633 |
+
} else {
|
| 634 |
+
const data=await DB.get(`msgs/${currentChannel}`);
|
| 635 |
+
if(!data) return;
|
| 636 |
+
const entries=Object.entries(data).sort(([,a],[,b])=>a.ts-b.ts);
|
| 637 |
+
if(!entries[idx]) return;
|
| 638 |
+
const[key,msg]=entries[idx];
|
| 639 |
+
if(msg.author!==currentUser.username&&!hasRole('mod')) return;
|
| 640 |
+
await DB.delete(`msgs/${currentChannel}/${key}`);
|
| 641 |
+
if(!firebaseReady) await loadMessages(currentChannel);
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
async function pinMessage(author,text) {
|
| 646 |
+
await DB.push('pins',{author,text,by:currentUser.username,ts:Date.now(),channel:currentChannel});
|
| 647 |
+
showToast('📌 Nachricht angepinnt','var(--green)');
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
function handleKey(e) { if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMessage();} }
|
| 651 |
+
function autoResize(el) { el.style.height='auto'; el.style.height=Math.min(el.scrollHeight,120)+'px'; }
|
| 652 |
+
|
| 653 |
+
function updateTimeoutBar(mod) {
|
| 654 |
+
const t=mod?.timeouts?.[currentUser.username.toLowerCase()];
|
| 655 |
+
const bar=document.getElementById('timeout-bar');
|
| 656 |
+
if(t&&t.until>Date.now()) {
|
| 657 |
+
bar.style.display='';
|
| 658 |
+
document.getElementById('timeout-until').textContent=new Date(t.until).toLocaleTimeString('de-DE',{hour:'2-digit',minute:'2-digit',second:'2-digit'});
|
| 659 |
+
document.getElementById('msg-input').disabled=true;
|
| 660 |
+
document.getElementById('send-btn').disabled=true;
|
| 661 |
+
} else {
|
| 662 |
+
bar.style.display='none';
|
| 663 |
+
const ch=(appConfig.channels||window.DEFAULT_CHANNELS||[]).find(c=>c.id===currentChannel);
|
| 664 |
+
const locked=!currentDM&&((ch?.adminOnly&&!hasRole('admin'))||(ch?.readOnly&&!hasRole('admin')));
|
| 665 |
+
document.getElementById('msg-input').disabled=!!locked;
|
| 666 |
+
document.getElementById('send-btn').disabled=!!locked;
|
| 667 |
+
}
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
function updateBadge(id,count) {
|
| 671 |
+
const el=document.getElementById(id);
|
| 672 |
+
if(!el) return;
|
| 673 |
+
if(count>0) { el.style.display=''; el.textContent=count>99?'99+':count; } else el.style.display='none';
|
| 674 |
+
}
|
| 675 |
+
|
| 676 |
+
// ─── VOICE ────────────────────────────────────────────────────
|
| 677 |
+
async function joinVoice(vcId,vcName) {
|
| 678 |
+
if(voiceActive&&voiceChannel===vcId) { await leaveVoice(); return; }
|
| 679 |
+
if(voiceActive) await leaveVoice();
|
| 680 |
+
voiceActive=true; voiceChannel=vcId; micMuted=false; deafened=false;
|
| 681 |
+
await DB.set(`voice_participants/${vcId}/${currentUser.username}`,{name:currentUser.username,muted:false,ts:Date.now()});
|
| 682 |
+
const vPanel=document.getElementById('voice-panel');
|
| 683 |
+
vPanel.classList.add('active');
|
| 684 |
+
document.getElementById('voice-channel-name').textContent='🔊 '+vcName;
|
| 685 |
+
document.getElementById('voice-mute-btn').classList.remove('active');
|
| 686 |
+
document.getElementById('voice-deaf-btn').classList.remove('active');
|
| 687 |
+
document.getElementById('voice-mute-btn').textContent='🎙 Stumm';
|
| 688 |
+
document.getElementById('voice-deaf-btn').textContent='🔔 Taub';
|
| 689 |
+
buildChannelList();
|
| 690 |
+
showToast(`🔊 Beigetreten: ${vcName}`,'var(--green)');
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
async function leaveVoice() {
|
| 694 |
+
if(!voiceActive) return;
|
| 695 |
+
await DB.delete(`voice_participants/${voiceChannel}/${currentUser.username}`);
|
| 696 |
+
voiceActive=false; voiceChannel=null;
|
| 697 |
+
document.getElementById('voice-panel').classList.remove('active');
|
| 698 |
+
buildChannelList();
|
| 699 |
+
showToast('Voice verlassen','var(--muted)');
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
async function toggleMute() {
|
| 703 |
+
micMuted=!micMuted;
|
| 704 |
+
const btn=document.getElementById('voice-mute-btn');
|
| 705 |
+
btn.textContent=micMuted?'🔇 Stumm':'🎙 Stumm';
|
| 706 |
+
btn.classList.toggle('active',micMuted);
|
| 707 |
+
if(voiceActive&&voiceChannel) await DB.set(`voice_participants/${voiceChannel}/${currentUser.username}/muted`,micMuted);
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
async function toggleDeafen() {
|
| 711 |
+
deafened=!deafened;
|
| 712 |
+
const btn=document.getElementById('voice-deaf-btn');
|
| 713 |
+
btn.textContent=deafened?'🔕 Taub':'🔔 Taub';
|
| 714 |
+
btn.classList.toggle('active',deafened);
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
// ─── USER LIST ────────────────────────────────────────────────
|
| 718 |
+
async function renderUserListFromOnline(onlineNames) {
|
| 719 |
+
const users=await DB.get('users');
|
| 720 |
+
if(!users) return;
|
| 721 |
+
document.getElementById('online-count').textContent=onlineNames.length;
|
| 722 |
+
const listEl=document.getElementById('user-list');
|
| 723 |
+
listEl.innerHTML='';
|
| 724 |
+
const groups={owner:[],admin:[],mod:[],vip:[],member:[]};
|
| 725 |
+
for(const udata of Object.values(users)) {
|
| 726 |
+
const role=udata.role||'member';
|
| 727 |
+
if(groups[role]) groups[role].push(udata); else groups.member.push(udata);
|
| 728 |
+
}
|
| 729 |
+
for(const[roleId,roleUsers] of Object.entries(groups)) {
|
| 730 |
+
if(!roleUsers.length) continue;
|
| 731 |
+
appendRoleGroup(listEl,ROLE_LABELS[roleId]||roleId,roleUsers,onlineNames);
|
| 732 |
+
}
|
| 733 |
+
await updateDMList();
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
function appendRoleGroup(container,label,users,onlineNames) {
|
| 737 |
+
if(!users.length) return;
|
| 738 |
+
const header=document.createElement('div');
|
| 739 |
+
header.className='role-group-header';
|
| 740 |
+
header.innerHTML=`<span>${label}</span><span style="color:var(--muted);font-size:.7rem">${users.length}</span>`;
|
| 741 |
+
container.appendChild(header);
|
| 742 |
+
for(const udata of users) {
|
| 743 |
+
const isMe=udata.username===currentUser?.username;
|
| 744 |
+
const isOnline=onlineNames.includes(udata.username);
|
| 745 |
+
const badge=ROLE_BADGE[udata.role]||'';
|
| 746 |
+
const color=udata.color??0;
|
| 747 |
+
const div=document.createElement('div');
|
| 748 |
+
div.className='user-item'+(isMe?' me':'')+(!isOnline?' offline':'');
|
| 749 |
+
div.innerHTML=`
|
| 750 |
+
<div class="${isOnline?'online-dot':'offline-dot'}"></div>
|
| 751 |
+
<div class="user-avatar-sm av-color-${color}">${udata.username[0].toUpperCase()}</div>
|
| 752 |
+
<span>${escHtml(udata.username)}${badge?' '+badge:''}</span>`;
|
| 753 |
+
if(!isMe) div.onclick=e=>{e.stopPropagation();showUserCtx(e,udata.username);};
|
| 754 |
+
container.appendChild(div);
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
async function updateDMList() {
|
| 759 |
+
const users=await DB.get('users');
|
| 760 |
+
if(!users) return;
|
| 761 |
+
const dmListEl=document.getElementById('dm-list');
|
| 762 |
+
dmListEl.innerHTML='';
|
| 763 |
+
for(const entry of Object.values(users)) {
|
| 764 |
+
if(entry.username===currentUser?.username) continue;
|
| 765 |
+
const unread=unreadCounts[`dm_${entry.username.toLowerCase()}`]||0;
|
| 766 |
+
const div=document.createElement('div');
|
| 767 |
+
div.className=`channel-item dm-item ${currentDM===entry.username?'active':''}`;
|
| 768 |
+
div.dataset.user=entry.username.toLowerCase();
|
| 769 |
+
div.innerHTML=`
|
| 770 |
+
<span class="channel-icon">@</span>
|
| 771 |
+
<span class="channel-name">${escHtml(entry.username)}</span>
|
| 772 |
+
${unread>0?`<span class="unread-badge">${unread}</span>`:''}`;
|
| 773 |
+
div.onclick=()=>openDM(entry.username);
|
| 774 |
+
dmListEl.appendChild(div);
|
| 775 |
+
}
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
// ─── CONTEXT MENU ─────────────────────────────────────────────
|
| 779 |
+
function onAvatarClick(e,username) {
|
| 780 |
+
e.preventDefault(); e.stopPropagation();
|
| 781 |
+
hideCtx();
|
| 782 |
+
if(username===currentUser?.username) return;
|
| 783 |
+
showUserCtx(e,username);
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
function showUserCtx(e,username) {
|
| 787 |
+
e.preventDefault(); e.stopPropagation();
|
| 788 |
+
hideCtx();
|
| 789 |
+
const menu=document.getElementById('context-menu');
|
| 790 |
+
menu.innerHTML='';
|
| 791 |
+
const h=document.createElement('div');
|
| 792 |
+
h.className='ctx-header'; h.textContent=username;
|
| 793 |
+
menu.appendChild(h);
|
| 794 |
+
addCtxItem(menu,'💬 Direktnachricht','',()=>{hideCtx();openDM(username);});
|
| 795 |
+
addCtxItem(menu,'👤 Profil','',()=>{hideCtx();showProfileModal(username);});
|
| 796 |
+
if(hasRole('mod')) {
|
| 797 |
+
addCtxDivider(menu);
|
| 798 |
+
addCtxItem(menu,'👢 Kicken','warn',()=>{hideCtx();openKickModal(username);});
|
| 799 |
+
addCtxItem(menu,'⏱ Timeout','warn',()=>{hideCtx();openTimeoutModal(username);});
|
| 800 |
+
addCtxItem(menu,'🗑 Nachrichten löschen','warn',()=>{hideCtx();clearUserMsgs(username);});
|
| 801 |
+
}
|
| 802 |
+
if(hasRole('admin')) {
|
| 803 |
+
addCtxItem(menu,'🚫 Bannen','danger',()=>{hideCtx();openBanModal(username);});
|
| 804 |
+
addCtxDivider(menu);
|
| 805 |
+
addCtxItem(menu,'🎖 Rolle ändern','',()=>{hideCtx();openRoleModal(username);});
|
| 806 |
+
}
|
| 807 |
+
const x=Math.min(e.clientX,window.innerWidth-210);
|
| 808 |
+
const y=Math.min(e.clientY,window.innerHeight-200);
|
| 809 |
+
menu.style.left=x+'px'; menu.style.top=y+'px'; menu.style.display='';
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
function addCtxItem(menu,label,cls,fn) {
|
| 813 |
+
const item=document.createElement('div');
|
| 814 |
+
item.className='ctx-item'+(cls?' '+cls:'');
|
| 815 |
+
item.textContent=label; item.onclick=fn;
|
| 816 |
+
menu.appendChild(item);
|
| 817 |
+
}
|
| 818 |
+
function addCtxDivider(menu) {
|
| 819 |
+
const d=document.createElement('div'); d.className='ctx-divider'; menu.appendChild(d);
|
| 820 |
+
}
|
| 821 |
+
function hideCtx() { document.getElementById('context-menu').style.display='none'; }
|
| 822 |
+
document.addEventListener('click',hideCtx);
|
| 823 |
+
|
| 824 |
+
// ─── MODERATION ───────────────────────────────────────────────
|
| 825 |
+
function openKickModal(username) {
|
| 826 |
+
showModal(`<div class="modal-title">👢 Kick: ${escHtml(username)}</div>
|
| 827 |
+
<div class="modal-sub">Der User wird aus dem Chat geworfen.</div>
|
| 828 |
+
<div class="modal-field"><label>Grund (optional)</label><input type="text" id="m-reason" placeholder="z.B. Regelverstoß"></div>
|
| 829 |
+
<div class="modal-btns">
|
| 830 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 831 |
+
<button class="modal-btn warn-btn" onclick="doKick('${escHtml(username)}')">Kicken</button>
|
| 832 |
+
</div>`);
|
| 833 |
+
}
|
| 834 |
+
async function doKick(username) {
|
| 835 |
+
const reason=document.getElementById('m-reason')?.value||'';
|
| 836 |
+
const mod=(await DB.get('moderation'))||{};
|
| 837 |
+
if(!mod.kicked) mod.kicked={};
|
| 838 |
+
mod.kicked[username.toLowerCase()]={by:currentUser.username,ts:Date.now(),reason};
|
| 839 |
+
await DB.set('moderation',mod);
|
| 840 |
+
await sysMsg(`${username} wurde von ${currentUser.username} gekickt.${reason?' Grund: '+reason:''}`);
|
| 841 |
+
clearModal(); showToast(`${username} gekickt`,'var(--warn)');
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
function openTimeoutModal(username) {
|
| 845 |
+
showModal(`<div class="modal-title">⏱ Timeout: ${escHtml(username)}</div>
|
| 846 |
+
<div class="modal-sub">Stummschalten für eine bestimmte Zeit.</div>
|
| 847 |
+
<div class="modal-field"><label>Dauer</label>
|
| 848 |
+
<select id="m-dur">
|
| 849 |
+
<option value="60000">1 Minute</option>
|
| 850 |
+
<option value="300000">5 Minuten</option>
|
| 851 |
+
<option value="600000">10 Minuten</option>
|
| 852 |
+
<option value="1800000">30 Minuten</option>
|
| 853 |
+
<option value="3600000">1 Stunde</option>
|
| 854 |
+
<option value="86400000">24 Stunden</option>
|
| 855 |
+
</select></div>
|
| 856 |
+
<div class="modal-field"><label>Grund</label><input type="text" id="m-reason" placeholder="z.B. Spam"></div>
|
| 857 |
+
<div class="modal-btns">
|
| 858 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 859 |
+
<button class="modal-btn warn-btn" onclick="doTimeout('${escHtml(username)}')">Timeout</button>
|
| 860 |
+
</div>`);
|
| 861 |
+
}
|
| 862 |
+
async function doTimeout(username) {
|
| 863 |
+
const dur=parseInt(document.getElementById('m-dur').value);
|
| 864 |
+
const reason=document.getElementById('m-reason')?.value||'';
|
| 865 |
+
const mod=(await DB.get('moderation'))||{};
|
| 866 |
+
if(!mod.timeouts) mod.timeouts={};
|
| 867 |
+
mod.timeouts[username.toLowerCase()]={until:Date.now()+dur,by:currentUser.username,reason};
|
| 868 |
+
await DB.set('moderation',mod);
|
| 869 |
+
await sysMsg(`${username} stummgeschaltet für ${Math.round(dur/60000)} Min. von ${currentUser.username}.${reason?' Grund: '+reason:''}`);
|
| 870 |
+
clearModal(); showToast(`${username} stummgeschaltet`,'var(--warn)');
|
| 871 |
+
}
|
| 872 |
+
|
| 873 |
+
function openBanModal(username) {
|
| 874 |
+
showModal(`<div class="modal-title" style="color:var(--danger)">🚫 Ban: ${escHtml(username)}</div>
|
| 875 |
+
<div class="modal-sub">Permanenter Bann – Username + Browser-ID.</div>
|
| 876 |
+
<div class="modal-field"><label>Grund</label><input type="text" id="m-reason" placeholder="Banngrund (Pflicht)"></div>
|
| 877 |
+
<div class="modal-btns">
|
| 878 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 879 |
+
<button class="modal-btn danger-btn" onclick="doBan('${escHtml(username)}')">BANNEN</button>
|
| 880 |
+
</div>`);
|
| 881 |
+
}
|
| 882 |
+
async function doBan(username) {
|
| 883 |
+
const reason=document.getElementById('m-reason')?.value||'';
|
| 884 |
+
if(!reason) { showToast('Bitte einen Grund angeben!','var(--danger)'); return; }
|
| 885 |
+
const mod=(await DB.get('moderation'))||{};
|
| 886 |
+
if(!mod.bans) mod.bans={};
|
| 887 |
+
mod.bans[username.toLowerCase()]={by:currentUser.username,ts:Date.now(),reason};
|
| 888 |
+
const targetFP=await DB.get(`user_fps/${username.toLowerCase()}`);
|
| 889 |
+
if(targetFP) { if(!mod.banned_fps) mod.banned_fps={}; mod.banned_fps[targetFP]=true; }
|
| 890 |
+
await DB.set('moderation',mod);
|
| 891 |
+
await sysMsg(`${username} wurde von ${currentUser.username} gebannt. Grund: ${reason}`);
|
| 892 |
+
clearModal(); showToast(`${username} gebannt`,'var(--danger)');
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
function openRoleModal(username) {
|
| 896 |
+
showModal(`<div class="modal-title">🎖 Rolle: ${escHtml(username)}</div>
|
| 897 |
+
<div class="modal-sub">Rolle des Users ändern.</div>
|
| 898 |
+
<div class="modal-field"><label>Neue Rolle</label>
|
| 899 |
+
<select id="m-role">
|
| 900 |
+
<option value="member">Mitglied</option>
|
| 901 |
+
<option value="vip">💎 VIP</option>
|
| 902 |
+
<option value="mod">⭐ Moderator</option>
|
| 903 |
+
${currentUser.role==='owner'?'<option value="admin">🔰 Admin</option>':''}
|
| 904 |
+
</select></div>
|
| 905 |
+
<div class="modal-btns">
|
| 906 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 907 |
+
<button class="modal-btn primary" onclick="doSetRole('${escHtml(username)}')">Speichern</button>
|
| 908 |
+
</div>`);
|
| 909 |
+
}
|
| 910 |
+
async function doSetRole(username) {
|
| 911 |
+
const newRole=document.getElementById('m-role').value;
|
| 912 |
+
const target=await DB.get(`users/${username.toLowerCase()}`);
|
| 913 |
+
if(!target) return clearModal();
|
| 914 |
+
if(target.role==='owner') { showToast('Owner-Rolle kann nicht geändert werden','var(--danger)'); return clearModal(); }
|
| 915 |
+
if(currentUser.role!=='owner'&&ROLE_PRIORITY[target.role]>=ROLE_PRIORITY[currentUser.role]) {
|
| 916 |
+
showToast('Keine Berechtigung','var(--danger)'); return clearModal();
|
| 917 |
+
}
|
| 918 |
+
target.role=newRole;
|
| 919 |
+
await DB.set(`users/${username.toLowerCase()}`,target);
|
| 920 |
+
await sysMsg(`${username} → Rolle "${ROLE_LABELS[newRole]}" (von ${currentUser.username})`);
|
| 921 |
+
clearModal(); showToast(`${username} → ${ROLE_LABELS[newRole]}`,'var(--green)');
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
async function clearUserMsgs(username) {
|
| 925 |
+
if(!hasRole('mod')) return;
|
| 926 |
+
const data=await DB.get(`msgs/${currentChannel}`);
|
| 927 |
+
if(!data) return;
|
| 928 |
+
for(const[key,msg] of Object.entries(data)) {
|
| 929 |
+
if(msg.author===username) await DB.delete(`msgs/${currentChannel}/${key}`);
|
| 930 |
+
}
|
| 931 |
+
if(!firebaseReady) await loadMessages(currentChannel);
|
| 932 |
+
showToast(`Nachrichten von ${username} gelöscht`,'var(--warn)');
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
async function sysMsg(text) {
|
| 936 |
+
if(!currentChannel) return;
|
| 937 |
+
await DB.push(`msgs/${currentChannel}`,{system:true,text,ts:Date.now()});
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
// ─── PROFILE ──────────────────────────────────────────────────
|
| 941 |
+
async function showProfileModal(username) {
|
| 942 |
+
const u=await DB.get(`users/${username.toLowerCase()}`);
|
| 943 |
+
if(!u) return;
|
| 944 |
+
const joined=new Date(u.joined||Date.now()).toLocaleDateString('de-DE');
|
| 945 |
+
showModal(`<div class="modal-title">👤 ${escHtml(u.username)} ${ROLE_BADGE[u.role]||''}</div>
|
| 946 |
+
<div class="modal-sub">Rolle: ${ROLE_LABELS[u.role]||'Mitglied'} · Beigetreten: ${joined}</div>
|
| 947 |
+
<div style="text-align:center;margin:14px 0">
|
| 948 |
+
<div class="user-avatar-sm av-color-${u.color}" style="width:60px;height:60px;font-size:1.5rem;margin:0 auto 12px">${u.username[0].toUpperCase()}</div>
|
| 949 |
+
</div>
|
| 950 |
+
<div class="modal-btns">
|
| 951 |
+
<button class="modal-btn secondary" onclick="clearModal()">Schließen</button>
|
| 952 |
+
<button class="modal-btn primary" onclick="clearModal();openDM('${escHtml(u.username)}')">💬 DM senden</button>
|
| 953 |
+
</div>`);
|
| 954 |
+
}
|
| 955 |
+
|
| 956 |
+
// ─── SETTINGS ─────────────────────────────────────────────────
|
| 957 |
+
const _settingsToggles={};
|
| 958 |
+
|
| 959 |
+
function openSettings() {
|
| 960 |
+
const s=currentUser.settings||{};
|
| 961 |
+
showModal(`<div class="modal-title">⚙️ Einstellungen</div>
|
| 962 |
+
<div class="modal-tabs">
|
| 963 |
+
<button class="modal-tab active" onclick="switchSettingsTab('konto',this)">Konto</button>
|
| 964 |
+
<button class="modal-tab" onclick="switchSettingsTab('darstellung',this)">Darstellung</button>
|
| 965 |
+
${hasRole('mod')?'<button class="modal-tab" onclick="switchSettingsTab(\'automod\',this)">AutoMod</button>':''}
|
| 966 |
+
${hasRole('admin')?'<button class="modal-tab" onclick="switchSettingsTab(\'tickets\',this)">Tickets</button>':''}
|
| 967 |
+
</div>
|
| 968 |
+
<div id="settings-tab-konto">
|
| 969 |
+
<div class="settings-section"><h4>Konto</h4>
|
| 970 |
+
<div class="modal-field"><label>Neuer Username</label><input type="text" id="s-username" placeholder="${escHtml(currentUser.username)}"></div>
|
| 971 |
+
<div class="modal-field"><label>Neues Passwort</label><input type="password" id="s-pass" placeholder="Leer lassen = keine Änderung"></div>
|
| 972 |
+
<div class="modal-field"><label>Passwort bestätigen</label><input type="password" id="s-pass2" placeholder="Passwort bestätigen"></div>
|
| 973 |
+
</div>
|
| 974 |
+
<div class="settings-section"><h4>Sprache & Übersetzung</h4>
|
| 975 |
+
<div class="modal-field"><label>Sprache</label>
|
| 976 |
+
<select id="s-lang">
|
| 977 |
+
<option value="de" ${(s.lang||'de')==='de'?'selected':''}>🇩🇪 Deutsch</option>
|
| 978 |
+
<option value="en" ${s.lang==='en'?'selected':''}>🇬🇧 English</option>
|
| 979 |
+
</select></div>
|
| 980 |
+
<div class="toggle-row"><label>Auto-Übersetzung</label><div class="toggle ${s.translate?'on':''}" id="toggle-translate" onclick="toggleSettingsToggle('translate')"></div></div>
|
| 981 |
+
</div>
|
| 982 |
+
<div class="settings-section"><h4>Benachrichtigungen</h4>
|
| 983 |
+
<div class="toggle-row"><label>DM-Benachrichtigungen</label><div class="toggle ${s.notif!==false?'on':''}" id="toggle-notif" onclick="toggleSettingsToggle('notif')"></div></div>
|
| 984 |
+
</div>
|
| 985 |
+
</div>
|
| 986 |
+
<div id="settings-tab-darstellung" style="display:none">
|
| 987 |
+
<div class="settings-section"><h4>Avatar-Farbe</h4>
|
| 988 |
+
<div style="display:flex;gap:10px;margin-bottom:14px">
|
| 989 |
+
${[0,1,2,3,4].map(i=>`<div class="user-avatar-sm av-color-${i}" style="width:36px;height:36px;cursor:pointer" onclick="setAvatarColor(${i})">${currentUser.username[0].toUpperCase()}</div>`).join('')}
|
| 990 |
+
</div>
|
| 991 |
+
</div>
|
| 992 |
+
</div>
|
| 993 |
+
${hasRole('mod')?`<div id="settings-tab-automod" style="display:none">
|
| 994 |
+
<div class="settings-section"><h4>AutoMod</h4>
|
| 995 |
+
<div class="toggle-row"><label>AutoMod aktiv</label><div class="toggle ${appConfig.automod?.enabled?'on':''}" id="toggle-am-enabled" onclick="toggleSettingsToggle('am-enabled')"></div></div>
|
| 996 |
+
<div class="modal-field"><label>Max. Nachrichtenlänge</label><input type="number" id="s-maxlen" value="${appConfig.automod?.maxMsgLength||800}"></div>
|
| 997 |
+
<div class="modal-field"><label>Spam-Grenze (Nachrichten/10s)</label><input type="number" id="s-spam" value="${appConfig.automod?.spamThreshold||5}"></div>
|
| 998 |
+
<div class="modal-field"><label>Verbotene Wörter</label>
|
| 999 |
+
<div id="banned-words-tags">${(appConfig.automod?.bannedWords||[]).map(w=>`<span class="tag">${escHtml(w)}<button class="tag-remove" onclick="removeTag('${escHtml(w)}')">×</button></span>`).join('')}</div>
|
| 1000 |
+
<div style="display:flex;gap:6px;margin-top:6px">
|
| 1001 |
+
<input class="tag-input" type="text" id="new-bw" placeholder="Wort hinzufügen" style="flex:1">
|
| 1002 |
+
<button class="modal-btn primary" style="flex:none;width:auto;padding:5px 12px;font-size:.7rem" onclick="addBannedWord()">+</button>
|
| 1003 |
+
</div>
|
| 1004 |
+
</div>
|
| 1005 |
+
<div class="toggle-row"><label>Caps-Filter</label><div class="toggle ${appConfig.automod?.capsFilter?'on':''}" id="toggle-caps" onclick="toggleSettingsToggle('caps')"></div></div>
|
| 1006 |
+
<div class="toggle-row"><label>Link-Filter</label><div class="toggle ${appConfig.automod?.linkFilter?'on':''}" id="toggle-links" onclick="toggleSettingsToggle('links')"></div></div>
|
| 1007 |
+
</div>
|
| 1008 |
+
</div>`:''}
|
| 1009 |
+
${hasRole('admin')?`<div id="settings-tab-tickets" style="display:none">
|
| 1010 |
+
<div class="settings-section"><h4>Ticket-System</h4>
|
| 1011 |
+
<div id="admin-tickets-list">Wird geladen...</div>
|
| 1012 |
+
</div>
|
| 1013 |
+
</div>`:''}
|
| 1014 |
+
<div class="modal-btns">
|
| 1015 |
+
<button class="modal-btn secondary" onclick="clearModal()">Schließen</button>
|
| 1016 |
+
<button class="modal-btn primary" onclick="saveSettings()">Speichern</button>
|
| 1017 |
+
</div>`,true);
|
| 1018 |
+
if(hasRole('admin')) setTimeout(()=>loadAdminTickets(),100);
|
| 1019 |
+
}
|
| 1020 |
+
|
| 1021 |
+
function toggleSettingsToggle(id) {
|
| 1022 |
+
const el=document.getElementById('toggle-'+id);
|
| 1023 |
+
if(!el) return;
|
| 1024 |
+
const on=!el.classList.contains('on');
|
| 1025 |
+
el.classList.toggle('on',on); _settingsToggles[id]=on;
|
| 1026 |
+
}
|
| 1027 |
+
|
| 1028 |
+
function switchSettingsTab(tab,btn) {
|
| 1029 |
+
document.querySelectorAll('[id^="settings-tab-"]').forEach(el=>el.style.display='none');
|
| 1030 |
+
document.querySelectorAll('.modal-tab').forEach(el=>el.classList.remove('active'));
|
| 1031 |
+
const tabEl=document.getElementById('settings-tab-'+tab);
|
| 1032 |
+
if(tabEl) tabEl.style.display='';
|
| 1033 |
+
if(btn) btn.classList.add('active');
|
| 1034 |
+
if(tab==='tickets') loadAdminTickets();
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
function addBannedWord() {
|
| 1038 |
+
const input=document.getElementById('new-bw');
|
| 1039 |
+
const word=input.value.trim().toLowerCase();
|
| 1040 |
+
if(!word) return;
|
| 1041 |
+
if(!appConfig.automod) appConfig.automod={};
|
| 1042 |
+
if(!appConfig.automod.bannedWords) appConfig.automod.bannedWords=[];
|
| 1043 |
+
if(!appConfig.automod.bannedWords.includes(word)) {
|
| 1044 |
+
appConfig.automod.bannedWords.push(word);
|
| 1045 |
+
const tags=document.getElementById('banned-words-tags');
|
| 1046 |
+
tags.insertAdjacentHTML('beforeend',`<span class="tag">${escHtml(word)}<button class="tag-remove" onclick="removeTag('${escHtml(word)}')">×</button></span>`);
|
| 1047 |
+
}
|
| 1048 |
+
input.value='';
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
function removeTag(word) {
|
| 1052 |
+
if(!appConfig.automod?.bannedWords) return;
|
| 1053 |
+
appConfig.automod.bannedWords=appConfig.automod.bannedWords.filter(w=>w!==word);
|
| 1054 |
+
const tags=document.getElementById('banned-words-tags');
|
| 1055 |
+
if(tags) tags.innerHTML=appConfig.automod.bannedWords.map(w=>
|
| 1056 |
+
`<span class="tag">${escHtml(w)}<button class="tag-remove" onclick="removeTag('${escHtml(w)}')">×</button></span>`).join('');
|
| 1057 |
+
}
|
| 1058 |
+
|
| 1059 |
+
async function setAvatarColor(color) {
|
| 1060 |
+
currentUser.color=color;
|
| 1061 |
+
await DB.set(`users/${currentUser.username.toLowerCase()}/color`,color);
|
| 1062 |
+
updateTopbar();
|
| 1063 |
+
}
|
| 1064 |
+
|
| 1065 |
+
async function saveSettings() {
|
| 1066 |
+
const me=await DB.get(`users/${currentUser.username.toLowerCase()}`);
|
| 1067 |
+
if(!me) return clearModal();
|
| 1068 |
+
const newUser=document.getElementById('s-username')?.value.trim();
|
| 1069 |
+
if(newUser&&newUser!==currentUser.username) {
|
| 1070 |
+
if(newUser.length<2||newUser.length>20) { showToast('Username: 2-20 Zeichen','var(--danger)'); return; }
|
| 1071 |
+
if(!/^[a-zA-Z0-9_]+$/.test(newUser)) { showToast('Nur Buchstaben, Zahlen, _','var(--danger)'); return; }
|
| 1072 |
+
const existing=await DB.get(`users/${newUser.toLowerCase()}`);
|
| 1073 |
+
if(existing&&newUser.toLowerCase()!==currentUser.username.toLowerCase()) { showToast('Username bereits vergeben','var(--danger)'); return; }
|
| 1074 |
+
await DB.delete(`users/${currentUser.username.toLowerCase()}`);
|
| 1075 |
+
me.username=newUser;
|
| 1076 |
+
await DB.set(`users/${newUser.toLowerCase()}`,me);
|
| 1077 |
+
currentUser.username=newUser;
|
| 1078 |
+
}
|
| 1079 |
+
const newPass=document.getElementById('s-pass')?.value;
|
| 1080 |
+
const newPass2=document.getElementById('s-pass2')?.value;
|
| 1081 |
+
if(newPass) {
|
| 1082 |
+
if(newPass.length<4) { showToast('Passwort mind. 4 Zeichen','var(--danger)'); return; }
|
| 1083 |
+
if(newPass!==newPass2) { showToast('Passwörter stimmen nicht überein','var(--danger)'); return; }
|
| 1084 |
+
me.password=encode(newPass);
|
| 1085 |
+
}
|
| 1086 |
+
if(!me.settings) me.settings={};
|
| 1087 |
+
const langEl=document.getElementById('s-lang');
|
| 1088 |
+
if(langEl) me.settings.lang=langEl.value;
|
| 1089 |
+
if('translate' in _settingsToggles) me.settings.translate=_settingsToggles.translate;
|
| 1090 |
+
if('notif' in _settingsToggles) me.settings.notif=_settingsToggles.notif;
|
| 1091 |
+
await DB.set(`users/${me.username.toLowerCase()}`,me);
|
| 1092 |
+
if(hasRole('mod')&&appConfig.automod) {
|
| 1093 |
+
const maxlen=document.getElementById('s-maxlen');
|
| 1094 |
+
const spam=document.getElementById('s-spam');
|
| 1095 |
+
if(maxlen) appConfig.automod.maxMsgLength=parseInt(maxlen.value)||800;
|
| 1096 |
+
if(spam) appConfig.automod.spamThreshold=parseInt(spam.value)||5;
|
| 1097 |
+
if('am-enabled' in _settingsToggles) appConfig.automod.enabled=_settingsToggles['am-enabled'];
|
| 1098 |
+
if('caps' in _settingsToggles) appConfig.automod.capsFilter=_settingsToggles.caps;
|
| 1099 |
+
if('links' in _settingsToggles) appConfig.automod.linkFilter=_settingsToggles.links;
|
| 1100 |
+
await DB.set('config/automod',appConfig.automod);
|
| 1101 |
+
}
|
| 1102 |
+
currentUser={...me};
|
| 1103 |
+
userLanguage=me.settings.lang||'de';
|
| 1104 |
+
translationEnabled=me.settings.translate||false;
|
| 1105 |
+
updateTopbar(); clearModal();
|
| 1106 |
+
showToast('✓ Einstellungen gespeichert','var(--green)');
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
// ─── TICKETS ──────────────────────────────────────────────────
|
| 1110 |
+
async function openCreateTicket() {
|
| 1111 |
+
showModal(`<div class="modal-title">🎫 Ticket erstellen</div>
|
| 1112 |
+
<div class="modal-sub">Wende dich an das Team – wir helfen gerne!</div>
|
| 1113 |
+
<div class="modal-field"><label>Kategorie</label>
|
| 1114 |
+
<select id="t-cat">
|
| 1115 |
+
<option value="support">❓ Support</option>
|
| 1116 |
+
<option value="report">🚨 Meldung</option>
|
| 1117 |
+
<option value="appeal">⚖️ Ban-Appeal</option>
|
| 1118 |
+
<option value="other">💭 Sonstiges</option>
|
| 1119 |
+
</select></div>
|
| 1120 |
+
<div class="modal-field"><label>Betreff</label><input type="text" id="t-title" placeholder="Kurze Zusammenfassung" maxlength="80"></div>
|
| 1121 |
+
<div class="modal-field"><label>Beschreibung</label><textarea id="t-desc" placeholder="Beschreibe dein Anliegen ausführlich..." rows="4"></textarea></div>
|
| 1122 |
+
<div class="modal-btns">
|
| 1123 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 1124 |
+
<button class="modal-btn primary" onclick="submitTicket()">Ticket erstellen</button>
|
| 1125 |
+
</div>`);
|
| 1126 |
+
}
|
| 1127 |
+
|
| 1128 |
+
async function submitTicket() {
|
| 1129 |
+
const cat=document.getElementById('t-cat')?.value;
|
| 1130 |
+
const title=document.getElementById('t-title')?.value.trim();
|
| 1131 |
+
const desc=document.getElementById('t-desc')?.value.trim();
|
| 1132 |
+
if(!title||!desc) { showToast('Bitte alle Felder ausfüllen','var(--danger)'); return; }
|
| 1133 |
+
const id='TKT-'+String(Date.now()).slice(-5);
|
| 1134 |
+
await DB.push('tickets',{id,cat,title,desc,author:currentUser.username,status:'open',ts:Date.now()});
|
| 1135 |
+
clearModal(); showToast(`🎫 Ticket ${id} erstellt`,'var(--green)');
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
async function loadAdminTickets() {
|
| 1139 |
+
const el=document.getElementById('admin-tickets-list');
|
| 1140 |
+
if(!el) return;
|
| 1141 |
+
const data=await DB.get('tickets');
|
| 1142 |
+
const tickets=data?Object.values(data).sort((a,b)=>b.ts-a.ts):[];
|
| 1143 |
+
if(!tickets.length) { el.innerHTML='<div style="color:var(--muted);font-size:.85rem;text-align:center;padding:20px">Keine Tickets</div>'; return; }
|
| 1144 |
+
el.innerHTML=tickets.map(t=>`
|
| 1145 |
+
<div class="ticket-item ${t.status}" onclick="openTicketDetail('${escHtml(t.id)}')">
|
| 1146 |
+
<div class="ticket-meta">${t.id} · ${t.cat} · ${new Date(t.ts).toLocaleDateString('de-DE')} · ${t.author}</div>
|
| 1147 |
+
<div class="ticket-title">${escHtml(t.title)}</div>
|
| 1148 |
+
<div style="font-size:.75rem;color:${t.status==='open'?'var(--green)':'var(--muted)'}">● ${t.status==='open'?'Offen':'Geschlossen'}</div>
|
| 1149 |
+
</div>`).join('');
|
| 1150 |
+
}
|
| 1151 |
+
|
| 1152 |
+
async function openTicketDetail(id) {
|
| 1153 |
+
const data=await DB.get('tickets');
|
| 1154 |
+
if(!data) return;
|
| 1155 |
+
const entry=Object.entries(data).find(([,t])=>t.id===id);
|
| 1156 |
+
if(!entry) return;
|
| 1157 |
+
const[key,t]=entry;
|
| 1158 |
+
showModal(`<div class="modal-title">🎫 ${escHtml(t.id)}: ${escHtml(t.title)}</div>
|
| 1159 |
+
<div class="modal-sub">Von ${escHtml(t.author)} · ${new Date(t.ts).toLocaleDateString('de-DE')} · ${t.status}</div>
|
| 1160 |
+
<div style="background:rgba(0,0,0,0.3);padding:12px;border:1px solid var(--border);font-size:.9rem;margin-bottom:14px;border-radius:2px">${escHtml(t.desc)}</div>
|
| 1161 |
+
${hasRole('mod')?`<div class="modal-btns">
|
| 1162 |
+
<button class="modal-btn secondary" onclick="clearModal()">Schließen</button>
|
| 1163 |
+
<button class="modal-btn ${t.status==='open'?'danger-btn':'success-btn'}" onclick="toggleTicket('${key}','${id}')">
|
| 1164 |
+
${t.status==='open'?'Ticket schließen':'Ticket öffnen'}
|
| 1165 |
+
</button>
|
| 1166 |
+
</div>`:`<div class="modal-btns"><button class="modal-btn secondary" onclick="clearModal()">Schließen</button></div>`},true);
|
| 1167 |
+
}
|
| 1168 |
+
|
| 1169 |
+
async function toggleTicket(key,id) {
|
| 1170 |
+
const t=await DB.get(`tickets/${key}`);
|
| 1171 |
+
if(!t) return;
|
| 1172 |
+
t.status=t.status==='open'?'closed':'open';
|
| 1173 |
+
await DB.set(`tickets/${key}`,t);
|
| 1174 |
+
clearModal(); showToast(`Ticket ${id} ${t.status==='open'?'geöffnet':'geschlossen'}`,'var(--accent)');
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
// ─── SEARCH & PINS ────────────────────────────────────────────
|
| 1178 |
+
async function openSearchModal() {
|
| 1179 |
+
showModal(`<div class="modal-title">🔍 Nachrichten durchsuchen</div>
|
| 1180 |
+
<div class="modal-field"><label>Suchbegriff</label>
|
| 1181 |
+
<input type="text" id="search-q" placeholder="Suche im aktuellen Channel..." oninput="liveSearch(this.value)">
|
| 1182 |
+
</div>
|
| 1183 |
+
<div id="search-results" style="max-height:300px;overflow-y:auto;margin-top:10px"></div>
|
| 1184 |
+
<div class="modal-btns"><button class="modal-btn secondary" onclick="clearModal()">Schließen</button></div>`);
|
| 1185 |
+
}
|
| 1186 |
+
|
| 1187 |
+
async function liveSearch(query) {
|
| 1188 |
+
const results=document.getElementById('search-results');
|
| 1189 |
+
if(!query||query.length<2) { results.innerHTML=''; return; }
|
| 1190 |
+
const data=await DB.get(`msgs/${currentChannel}`);
|
| 1191 |
+
const msgs=data?Object.values(data).sort((a,b)=>a.ts-b.ts):[];
|
| 1192 |
+
const found=msgs.filter(m=>!m.system&&m.text&&m.text.toLowerCase().includes(query.toLowerCase()));
|
| 1193 |
+
if(!found.length) { results.innerHTML='<div style="color:var(--muted);text-align:center;padding:12px;font-size:.85rem">Keine Ergebnisse</div>'; return; }
|
| 1194 |
+
results.innerHTML=found.slice(-20).map(m=>`
|
| 1195 |
+
<div style="padding:8px 0;border-bottom:1px solid var(--border)">
|
| 1196 |
+
<div style="font-size:.72rem;color:var(--muted);font-family:Orbitron,monospace">${m.author} · ${new Date(m.ts).toLocaleDateString('de-DE')}</div>
|
| 1197 |
+
<div style="font-size:.9rem;color:var(--text)">${escHtml(m.text).replace(new RegExp(escHtml(query),'gi'),s=>`<mark style="background:rgba(0,212,255,0.2);color:var(--accent)">${s}</mark>`)}</div>
|
| 1198 |
+
</div>`).join('');
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
async function openPinsModal() {
|
| 1202 |
+
const data=await DB.get('pins');
|
| 1203 |
+
const pins=data?Object.values(data):[];
|
| 1204 |
+
const relevant=pins.filter(p=>p.channel===currentChannel);
|
| 1205 |
+
showModal(`<div class="modal-title">📌 Angepinnte Nachrichten</div>
|
| 1206 |
+
<div style="max-height:350px;overflow-y:auto">
|
| 1207 |
+
${!relevant.length?'<div style="color:var(--muted);text-align:center;padding:20px;font-size:.85rem">Keine angepinnten Nachrichten</div>':
|
| 1208 |
+
relevant.map(p=>`<div style="padding:10px 0;border-bottom:1px solid var(--border)">
|
| 1209 |
+
<div style="font-size:.7rem;color:var(--muted);font-family:Orbitron,monospace">📌 ${p.author} · angeheftet von ${p.by}</div>
|
| 1210 |
+
<div style="font-size:.9rem;color:var(--text);margin-top:4px">${escHtml(p.text)}</div>
|
| 1211 |
+
</div>`).join('')}
|
| 1212 |
+
</div>
|
| 1213 |
+
<div class="modal-btns"><button class="modal-btn secondary" onclick="clearModal()">Schließen</button></div>`);
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
// ─── SPAM CAPTCHA ─────────────────────────────────────────────
|
| 1217 |
+
function showSpamCaptchaModal() {
|
| 1218 |
+
const d=genCaptcha(); captchaData.spam=d;
|
| 1219 |
+
showModal(`<div class="modal-title">🤖 Anti-Spam Prüfung</div>
|
| 1220 |
+
<div class="modal-sub">Du schreibst zu schnell. Löse das Captcha.</div>
|
| 1221 |
+
<div class="captcha-modal-question" id="spam-q">${d.q}</div>
|
| 1222 |
+
<div class="modal-field"><label>Antwort</label><input type="number" id="spam-a" placeholder="?" onkeydown="if(event.key==='Enter')spamSubmit()"></div>
|
| 1223 |
+
<div class="auth-error" id="spam-err"></div>
|
| 1224 |
+
<div class="modal-btns">
|
| 1225 |
+
<button class="modal-btn secondary" onclick="clearModal()">Abbrechen</button>
|
| 1226 |
+
<button class="modal-btn primary" onclick="spamSubmit()">Bestätigen</button>
|
| 1227 |
+
</div>`);
|
| 1228 |
+
}
|
| 1229 |
+
|
| 1230 |
+
async function spamSubmit() {
|
| 1231 |
+
const ans=parseInt(document.getElementById('spam-a')?.value);
|
| 1232 |
+
if(ans!==captchaData.spam?.ans) {
|
| 1233 |
+
const d=genCaptcha(); captchaData.spam=d;
|
| 1234 |
+
const qEl=document.getElementById('spam-q'); if(qEl) qEl.textContent=d.q;
|
| 1235 |
+
const errEl=document.getElementById('spam-err'); if(errEl) errEl.textContent='❌ Falsche Antwort!';
|
| 1236 |
+
return;
|
| 1237 |
+
}
|
| 1238 |
+
clearModal(); spamTs=[];
|
| 1239 |
+
if(pendingSpamMsg) { await _sendMsg(pendingSpamMsg); pendingSpamMsg=null; }
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
// ─── MODAL ────────────────────────────────────────────────────
|
| 1243 |
+
function showModal(html,wide=false) {
|
| 1244 |
+
clearModal();
|
| 1245 |
+
const overlay=document.createElement('div');
|
| 1246 |
+
overlay.className='modal-overlay'; overlay.id='active-modal';
|
| 1247 |
+
overlay.innerHTML=`<div class="modal${wide?' wide':''}">${html}</div>`;
|
| 1248 |
+
overlay.onclick=e=>{ if(e.target===overlay) clearModal(); };
|
| 1249 |
+
document.getElementById('modal-container').appendChild(overlay);
|
| 1250 |
+
}
|
| 1251 |
+
|
| 1252 |
+
function clearModal() { document.getElementById('active-modal')?.remove(); }
|
| 1253 |
+
|
| 1254 |
+
function showKickedModal() {
|
| 1255 |
+
showModal(`<div class="modal-title">👢 Du wurdest gekickt</div>
|
| 1256 |
+
<div class="modal-sub">Ein Moderator hat dich aus dem Chat entfernt.</div>
|
| 1257 |
+
<div class="modal-btns">
|
| 1258 |
+
<button class="modal-btn primary" onclick="doLogout();clearModal()">Zum Login</button>
|
| 1259 |
+
</div>`);
|
| 1260 |
+
}
|
| 1261 |
+
|
| 1262 |
+
// ─── HELPERS ──────────────────────────────────────────────────
|
| 1263 |
+
function encode(s) { try { return btoa(unescape(encodeURIComponent(s))); } catch { return btoa(s); } }
|
| 1264 |
+
function decode(s) { try { return decodeURIComponent(escape(atob(s))); } catch { try { return atob(s); } catch { return ''; } } }
|
| 1265 |
+
|
| 1266 |
+
function escHtml(str) {
|
| 1267 |
+
return String(str||'')
|
| 1268 |
+
.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')
|
| 1269 |
+
.replace(/"/g,'"').replace(/'/g,''');
|
| 1270 |
+
}
|
| 1271 |
+
|
| 1272 |
+
function showBanned() {
|
| 1273 |
+
document.getElementById('banned-screen').style.display='flex';
|
| 1274 |
+
document.getElementById('auth-screen').style.display='none';
|
| 1275 |
+
document.getElementById('app').classList.remove('visible');
|
| 1276 |
+
}
|
| 1277 |
+
|
| 1278 |
+
function showAuthSuccess(msg) {
|
| 1279 |
+
const el=document.getElementById('auth-error');
|
| 1280 |
+
el.style.color='var(--green)'; el.textContent=msg;
|
| 1281 |
+
setTimeout(()=>{ el.style.color=''; el.textContent=''; },3000);
|
| 1282 |
+
}
|
| 1283 |
+
|
| 1284 |
+
function showToast(msg,color='var(--accent)') {
|
| 1285 |
+
const t=document.createElement('div');
|
| 1286 |
+
t.className='toast'; t.style.borderColor=color; t.style.color=color; t.textContent=msg;
|
| 1287 |
+
document.body.appendChild(t);
|
| 1288 |
+
setTimeout(()=>t.remove(),3000);
|
| 1289 |
+
}
|
| 1290 |
+
|
| 1291 |
+
// ─── INIT ─────────────────────────────────────────────────────
|
| 1292 |
+
(async function init() {
|
| 1293 |
+
refreshCaptcha('login');
|
| 1294 |
+
refreshCaptcha('reg');
|
| 1295 |
+
|
| 1296 |
+
await initFirebase();
|
| 1297 |
+
|
| 1298 |
+
// Show connection status
|
| 1299 |
+
const indicator=document.createElement('div');
|
| 1300 |
+
indicator.style.cssText='position:fixed;bottom:60px;right:20px;z-index:9998;background:rgba(10,21,32,0.98);border:1px solid;padding:6px 12px;font-family:Orbitron,monospace;font-size:.58rem;letter-spacing:.1em;clip-path:polygon(5px 0%,100% 0%,calc(100% - 5px) 100%,0% 100%)';
|
| 1301 |
+
if(firebaseReady) {
|
| 1302 |
+
indicator.style.borderColor='var(--green)'; indicator.style.color='var(--green)';
|
| 1303 |
+
indicator.textContent='● FIREBASE LIVE';
|
| 1304 |
+
} else {
|
| 1305 |
+
indicator.style.borderColor='var(--warn)'; indicator.style.color='var(--warn)';
|
| 1306 |
+
indicator.textContent='⚠ LOKAL – Firebase fehlt! Sieh SETUP.md';
|
| 1307 |
+
}
|
| 1308 |
+
document.body.appendChild(indicator);
|
| 1309 |
+
setTimeout(()=>indicator.remove(),8000);
|
| 1310 |
+
|
| 1311 |
+
const mod=(await DB.get('moderation'))||{};
|
| 1312 |
+
if(mod.banned_fps?.[MY_FP]) { showBanned(); return; }
|
| 1313 |
+
|
| 1314 |
+
// Ensure owner
|
| 1315 |
+
const ownerKey=OWNER_NAME.toLowerCase();
|
| 1316 |
+
const existingOwner=await DB.get(`users/${ownerKey}`);
|
| 1317 |
+
if(!existingOwner) {
|
| 1318 |
+
await DB.set(`users/${ownerKey}`,{
|
| 1319 |
+
username:OWNER_NAME, password:encode(OWNER_PASS),
|
| 1320 |
+
color:1, role:'owner', joined:Date.now(),
|
| 1321 |
+
settings:{lang:'de',translate:false,notif:true}
|
| 1322 |
+
});
|
| 1323 |
+
} else {
|
| 1324 |
+
await DB.set(`users/${ownerKey}/role`,'owner');
|
| 1325 |
+
}
|
| 1326 |
+
|
| 1327 |
+
let cfg=await DB.get('config');
|
| 1328 |
+
if(!cfg||!cfg.channels) {
|
| 1329 |
+
cfg={channels:window.DEFAULT_CHANNELS||[],automod:window.DEFAULT_AUTOMOD||{}};
|
| 1330 |
+
await DB.set('config',cfg);
|
| 1331 |
+
}
|
| 1332 |
+
appConfig=cfg;
|
| 1333 |
+
})();
|
index.html
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="de">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>NoahsChat</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
|
| 11 |
+
<!-- BANNED SCREEN -->
|
| 12 |
+
<div id="banned-screen">
|
| 13 |
+
<div class="banned-icon">🚫</div>
|
| 14 |
+
<div class="banned-title">GEBANNT</div>
|
| 15 |
+
<div class="banned-sub" id="banned-sub">Du wurdest permanent von NoahsChat gebannt.</div>
|
| 16 |
+
</div>
|
| 17 |
+
|
| 18 |
+
<!-- AUTH SCREEN -->
|
| 19 |
+
<div id="auth-screen">
|
| 20 |
+
<div class="auth-box">
|
| 21 |
+
<div class="auth-logo">Noahs<span>Chat</span></div>
|
| 22 |
+
<div class="auth-tagline">by NoahsAPP · v2.0</div>
|
| 23 |
+
|
| 24 |
+
<div class="auth-tabs">
|
| 25 |
+
<button class="auth-tab active" onclick="switchTab('login')">Login</button>
|
| 26 |
+
<button class="auth-tab" onclick="switchTab('register')">Registrieren</button>
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
<!-- LOGIN -->
|
| 30 |
+
<div id="tab-login">
|
| 31 |
+
<div class="auth-field">
|
| 32 |
+
<label>Username</label>
|
| 33 |
+
<input type="text" id="login-user" placeholder="dein username" autocomplete="off" onkeydown="if(event.key==='Enter')doLogin()">
|
| 34 |
+
</div>
|
| 35 |
+
<div class="auth-field">
|
| 36 |
+
<label>Passwort</label>
|
| 37 |
+
<input type="password" id="login-pass" placeholder="••••••••" onkeydown="if(event.key==='Enter')doLogin()">
|
| 38 |
+
</div>
|
| 39 |
+
<div class="captcha-box">
|
| 40 |
+
<div>
|
| 41 |
+
<div style="font-size:.6rem;color:var(--muted);letter-spacing:.15em;text-transform:uppercase;margin-bottom:4px">Anti-Bot</div>
|
| 42 |
+
<div class="captcha-question" id="login-q">? + ? = ?</div>
|
| 43 |
+
</div>
|
| 44 |
+
<input class="captcha-input" type="number" id="login-a" placeholder="?" onkeydown="if(event.key==='Enter')doLogin()">
|
| 45 |
+
<button class="captcha-refresh" onclick="refreshCaptcha('login')" title="Neu">↺</button>
|
| 46 |
+
</div>
|
| 47 |
+
<button class="auth-btn" onclick="doLogin()">Einloggen ▶</button>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<!-- REGISTER -->
|
| 51 |
+
<div id="tab-register" style="display:none">
|
| 52 |
+
<div class="auth-field">
|
| 53 |
+
<label>Username</label>
|
| 54 |
+
<input type="text" id="reg-user" placeholder="wähle einen username" autocomplete="off">
|
| 55 |
+
</div>
|
| 56 |
+
<div class="auth-field">
|
| 57 |
+
<label>Passwort</label>
|
| 58 |
+
<input type="password" id="reg-pass" placeholder="mindestens 4 Zeichen">
|
| 59 |
+
</div>
|
| 60 |
+
<div class="auth-field">
|
| 61 |
+
<label>Passwort bestätigen</label>
|
| 62 |
+
<input type="password" id="reg-pass2" placeholder="nochmal eingeben" onkeydown="if(event.key==='Enter')doRegister()">
|
| 63 |
+
</div>
|
| 64 |
+
<div class="captcha-box">
|
| 65 |
+
<div>
|
| 66 |
+
<div style="font-size:.6rem;color:var(--muted);letter-spacing:.15em;text-transform:uppercase;margin-bottom:4px">Anti-Bot</div>
|
| 67 |
+
<div class="captcha-question" id="reg-q">? + ? = ?</div>
|
| 68 |
+
</div>
|
| 69 |
+
<input class="captcha-input" type="number" id="reg-a" placeholder="?" onkeydown="if(event.key==='Enter')doRegister()">
|
| 70 |
+
<button class="captcha-refresh" onclick="refreshCaptcha('reg')" title="Neu">↺</button>
|
| 71 |
+
</div>
|
| 72 |
+
<button class="auth-btn" onclick="doRegister()">Account erstellen ▶</button>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div class="auth-error" id="auth-error"></div>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<!-- MAIN APP -->
|
| 80 |
+
<div id="app">
|
| 81 |
+
|
| 82 |
+
<!-- TOPBAR -->
|
| 83 |
+
<div class="topbar">
|
| 84 |
+
<a href="#" class="topbar-logo">Noahs<span>APP</span></a>
|
| 85 |
+
<div class="topbar-sep"></div>
|
| 86 |
+
<div class="topbar-channel">
|
| 87 |
+
<span id="topbar-channel-name"># allgemein</span>
|
| 88 |
+
</div>
|
| 89 |
+
<div class="topbar-actions">
|
| 90 |
+
<button class="icon-btn" onclick="openCreateTicket()" title="Ticket erstellen">🎫</button>
|
| 91 |
+
<button class="icon-btn" onclick="openSettings()" title="Einstellungen">⚙️</button>
|
| 92 |
+
<div class="topbar-sep"></div>
|
| 93 |
+
<div class="topbar-user">
|
| 94 |
+
<div class="user-avatar-sm" id="topbar-avatar" onclick="openSettings()"></div>
|
| 95 |
+
<span id="topbar-username" style="font-weight:700"></span>
|
| 96 |
+
<span class="topbar-role-badge" id="topbar-role-badge"></span>
|
| 97 |
+
<button class="logout-btn" onclick="doLogout()">Logout</button>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<!-- SIDEBAR -->
|
| 103 |
+
<div class="sidebar">
|
| 104 |
+
<div class="sidebar-scroll">
|
| 105 |
+
|
| 106 |
+
<!-- Channels -->
|
| 107 |
+
<div class="sidebar-section">
|
| 108 |
+
Channels
|
| 109 |
+
<span id="online-count" style="color:var(--green);font-family:'Orbitron',monospace">0</span>
|
| 110 |
+
</div>
|
| 111 |
+
<div id="channel-list"></div>
|
| 112 |
+
|
| 113 |
+
<div class="sidebar-divider"></div>
|
| 114 |
+
|
| 115 |
+
<!-- DMs -->
|
| 116 |
+
<div class="sidebar-section">Direktnachrichten</div>
|
| 117 |
+
<div id="dm-list"></div>
|
| 118 |
+
|
| 119 |
+
<div class="sidebar-divider"></div>
|
| 120 |
+
|
| 121 |
+
<!-- Members -->
|
| 122 |
+
<div class="sidebar-section">Mitglieder</div>
|
| 123 |
+
<div id="user-list"></div>
|
| 124 |
+
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<!-- Voice Panel -->
|
| 128 |
+
<div class="voice-panel" id="voice-panel">
|
| 129 |
+
<div class="voice-status-bar">
|
| 130 |
+
<div class="voice-active-dot"></div>
|
| 131 |
+
<div class="voice-name" id="voice-channel-name">🔊 Voice</div>
|
| 132 |
+
<div class="voice-controls">
|
| 133 |
+
<button class="voice-ctrl" id="voice-mute-btn" onclick="toggleMute()">🎙 Stumm</button>
|
| 134 |
+
<button class="voice-ctrl" id="voice-deaf-btn" onclick="toggleDeafen()">🔔 Taub</button>
|
| 135 |
+
<button class="voice-ctrl" style="color:var(--danger)" onclick="leaveVoice()">✕</button>
|
| 136 |
+
</div>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<!-- CHAT AREA -->
|
| 142 |
+
<div class="chat-area">
|
| 143 |
+
<div class="chat-header">
|
| 144 |
+
<div class="chat-header-info">
|
| 145 |
+
<div class="chat-header-title" id="chat-title">💬 allgemein</div>
|
| 146 |
+
<div class="chat-header-sub" id="chat-sub">Allgemeiner Chat für alle</div>
|
| 147 |
+
</div>
|
| 148 |
+
<div class="chat-header-actions">
|
| 149 |
+
<button class="icon-btn" id="search-btn" title="Suchen" onclick="openSearchModal()">🔍</button>
|
| 150 |
+
<button class="icon-btn" id="pins-btn" title="Angepinnte Nachrichten" onclick="openPinsModal()">📌</button>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<div class="messages" id="messages">
|
| 155 |
+
<div class="empty-chat">
|
| 156 |
+
<div class="empty-chat-icon">💬</div>
|
| 157 |
+
<p>Noch keine Nachrichten. Schreib was!</p>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<div id="timeout-bar" class="timeout-bar" style="display:none">
|
| 162 |
+
⏱ Du bist stummgeschaltet bis <span id="timeout-until"></span>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<div class="input-area">
|
| 166 |
+
<textarea class="msg-input" id="msg-input" placeholder="Nachricht schreiben..."
|
| 167 |
+
rows="1" onkeydown="handleKey(event)" oninput="autoResize(this)"></textarea>
|
| 168 |
+
<button class="send-btn" id="send-btn" onclick="sendMessage()">SEND</button>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
|
| 172 |
+
</div>
|
| 173 |
+
|
| 174 |
+
<!-- CONTEXT MENU -->
|
| 175 |
+
<div id="context-menu" style="display:none"></div>
|
| 176 |
+
|
| 177 |
+
<!-- MODAL CONTAINER -->
|
| 178 |
+
<div id="modal-container"></div>
|
| 179 |
+
|
| 180 |
+
<script>
|
| 181 |
+
// ─── DEFAULT DATA (from data.json equivalent) ─────────────────
|
| 182 |
+
window.DEFAULT_CHANNELS = [
|
| 183 |
+
{ id: 'ankuendigungen', name: 'ankündigungen', icon: '📢', sub: 'Wichtige Ankündigungen', adminOnly: true, category: 'info' },
|
| 184 |
+
{ id: 'regeln', name: 'regeln', icon: '📋', sub: 'Serverregeln', readOnly: true, category: 'info' },
|
| 185 |
+
{ id: 'allgemein', name: 'allgemein', icon: '💬', sub: 'Allgemeiner Chat für alle', category: 'chat' },
|
| 186 |
+
{ id: 'gaming', name: 'gaming', icon: '🎮', sub: 'Alles rund ums Gaming', category: 'chat' },
|
| 187 |
+
{ id: 'roblox', name: 'roblox', icon: '🧱', sub: 'Roblox & NoahsHacks', category: 'chat' },
|
| 188 |
+
{ id: 'musik', name: 'musik', icon: '🎵', sub: 'Musik & Playlists', category: 'chat' },
|
| 189 |
+
{ id: 'memes', name: 'memes', icon: '😂', sub: 'Memes & Witze', category: 'fun' },
|
| 190 |
+
{ id: 'off-topic', name: 'off-topic', icon: '💭', sub: 'Alles andere', category: 'fun' },
|
| 191 |
+
{ id: 'kunst', name: 'kunst', icon: '🎨', sub: 'Kreative Werke', category: 'fun' },
|
| 192 |
+
{ id: 'technik', name: 'technik', icon: '💻', sub: 'Tech & Coding', category: 'fun' },
|
| 193 |
+
{ id: 'voicetext', name: 'voice-lounge', icon: '🔊', sub: 'Begleitchat für Voice', category: 'chat' },
|
| 194 |
+
{ id: 'moderators', name: 'mod-logs', icon: '🛡', sub: 'Moderationslog', modOnly: true, category: 'staff' },
|
| 195 |
+
{ id: 'admin', name: 'admin-bereich', icon: '⚙️', sub: 'Nur für Admins', adminOnly: true, category: 'staff' }
|
| 196 |
+
];
|
| 197 |
+
|
| 198 |
+
window.DEFAULT_AUTOMOD = {
|
| 199 |
+
enabled: true,
|
| 200 |
+
maxMsgLength: 800,
|
| 201 |
+
spamThreshold: 5,
|
| 202 |
+
spamWindow: 10000,
|
| 203 |
+
bannedWords: ['scheiß', 'hurensohn', 'wichser', 'fick', 'arschloch'],
|
| 204 |
+
linkFilter: false,
|
| 205 |
+
capsFilter: true,
|
| 206 |
+
capsThreshold: 0.7
|
| 207 |
+
};
|
| 208 |
+
</script>
|
| 209 |
+
|
| 210 |
+
<!-- Search & Pins modals -->
|
| 211 |
+
<script>
|
| 212 |
+
async function openSearchModal() {
|
| 213 |
+
showModal(`
|
| 214 |
+
<div class="modal-title">🔍 Nachrichten durchsuchen</div>
|
| 215 |
+
<div class="modal-field">
|
| 216 |
+
<label>Suchbegriff</label>
|
| 217 |
+
<input type="text" id="search-q" placeholder="Suche im aktuellen Channel..." oninput="liveSearch(this.value)">
|
| 218 |
+
</div>
|
| 219 |
+
<div id="search-results" style="max-height:300px;overflow-y:auto;margin-top:10px"></div>
|
| 220 |
+
<div class="modal-btns">
|
| 221 |
+
<button class="modal-btn secondary" onclick="clearModal()">Schließen</button>
|
| 222 |
+
</div>`);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
async function liveSearch(query) {
|
| 226 |
+
const results = document.getElementById('search-results');
|
| 227 |
+
if (!query || query.length < 2) { results.innerHTML = ''; return; }
|
| 228 |
+
const msgs = (await DB.get('msgs_' + currentChannel)) || [];
|
| 229 |
+
const found = msgs.filter(m => !m.system && m.text && m.text.toLowerCase().includes(query.toLowerCase()));
|
| 230 |
+
if (!found.length) { results.innerHTML = '<div style="color:var(--muted);text-align:center;padding:12px;font-size:.85rem">Keine Ergebnisse</div>'; return; }
|
| 231 |
+
results.innerHTML = found.slice(-20).map(m => `
|
| 232 |
+
<div style="padding:8px 0;border-bottom:1px solid var(--border)">
|
| 233 |
+
<div style="font-size:.72rem;color:var(--muted);font-family:Orbitron,monospace">${m.author} · ${new Date(m.ts).toLocaleDateString('de-DE')}</div>
|
| 234 |
+
<div style="font-size:.9rem;color:var(--text)">${escHtml(m.text).replace(new RegExp(escHtml(query),'gi'), s => `<mark style="background:rgba(0,212,255,0.2);color:var(--accent)">${s}</mark>`)}</div>
|
| 235 |
+
</div>`).join('');
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
async function openPinsModal() {
|
| 239 |
+
const pins = (await DB.get('pins')) || [];
|
| 240 |
+
const relevant = pins.filter(p => p.channel === currentChannel);
|
| 241 |
+
showModal(`
|
| 242 |
+
<div class="modal-title">📌 Angepinnte Nachrichten</div>
|
| 243 |
+
<div style="max-height:350px;overflow-y:auto">
|
| 244 |
+
${!relevant.length ? '<div style="color:var(--muted);text-align:center;padding:20px;font-size:.85rem">Keine angepinnten Nachrichten</div>' :
|
| 245 |
+
relevant.map(p => `
|
| 246 |
+
<div style="padding:10px 0;border-bottom:1px solid var(--border)">
|
| 247 |
+
<div style="font-size:.7rem;color:var(--muted);font-family:Orbitron,monospace">📌 ${p.author} · angeheftet von ${p.by}</div>
|
| 248 |
+
<div style="font-size:.9rem;color:var(--text);margin-top:4px">${escHtml(p.text)}</div>
|
| 249 |
+
</div>`).join('')}
|
| 250 |
+
</div>
|
| 251 |
+
<div class="modal-btns">
|
| 252 |
+
<button class="modal-btn secondary" onclick="clearModal()">Schließen</button>
|
| 253 |
+
</div>`);
|
| 254 |
+
}
|
| 255 |
+
</script>
|
| 256 |
+
|
| 257 |
+
<!-- Firebase SDK -->
|
| 258 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-compat.js"></script>
|
| 259 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-database-compat.js"></script>
|
| 260 |
+
<script src="app.js"></script>
|
| 261 |
+
</body>
|
| 262 |
+
</html>
|
style.css
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;600;700&family=Space+Mono:wght@400;700&display=swap');
|
| 2 |
+
|
| 3 |
+
:root {
|
| 4 |
+
--bg: #050a0f;
|
| 5 |
+
--surface: #0a1520;
|
| 6 |
+
--surface2: #0d1c2e;
|
| 7 |
+
--surface3: #071018;
|
| 8 |
+
--border: rgba(0,212,255,0.12);
|
| 9 |
+
--accent: #00d4ff;
|
| 10 |
+
--accent2: #ff6b35;
|
| 11 |
+
--green: #4eff91;
|
| 12 |
+
--glow: rgba(0,212,255,0.25);
|
| 13 |
+
--text: #e0f4ff;
|
| 14 |
+
--muted: #4a7a99;
|
| 15 |
+
--danger: #ff4466;
|
| 16 |
+
--warn: #ffaa00;
|
| 17 |
+
--purple: #a855f7;
|
| 18 |
+
--gold: #ffd600;
|
| 19 |
+
--sidebar-w: 240px;
|
| 20 |
+
--topbar-h: 52px;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
* { margin:0; padding:0; box-sizing:border-box; }
|
| 24 |
+
|
| 25 |
+
body {
|
| 26 |
+
background: var(--bg);
|
| 27 |
+
color: var(--text);
|
| 28 |
+
font-family: 'Rajdhani', sans-serif;
|
| 29 |
+
height: 100vh;
|
| 30 |
+
overflow: hidden;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
::-webkit-scrollbar { width: 4px; }
|
| 34 |
+
::-webkit-scrollbar-track { background: transparent; }
|
| 35 |
+
::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.2); border-radius: 2px; }
|
| 36 |
+
|
| 37 |
+
/* ─── BANNED SCREEN ─── */
|
| 38 |
+
#banned-screen {
|
| 39 |
+
position: fixed; inset:0; z-index:9999;
|
| 40 |
+
display: none; align-items:center; justify-content:center;
|
| 41 |
+
background: rgba(5,0,5,0.98); flex-direction:column; gap:16px;
|
| 42 |
+
text-align:center;
|
| 43 |
+
}
|
| 44 |
+
.banned-icon { font-size:4rem; }
|
| 45 |
+
.banned-title { font-family:'Orbitron',monospace; font-size:1.5rem; color:var(--danger); font-weight:900; }
|
| 46 |
+
.banned-sub { color:var(--muted); font-size:0.9rem; letter-spacing:.1em; }
|
| 47 |
+
|
| 48 |
+
/* ─── AUTH SCREEN ─── */
|
| 49 |
+
#auth-screen {
|
| 50 |
+
position: fixed; inset:0; z-index:1000;
|
| 51 |
+
display: flex; align-items:center; justify-content:center;
|
| 52 |
+
background: var(--bg);
|
| 53 |
+
}
|
| 54 |
+
#auth-screen::before {
|
| 55 |
+
content:''; position:absolute; inset:0;
|
| 56 |
+
background-image: linear-gradient(rgba(0,212,255,0.04) 1px, transparent 1px), linear-gradient(90deg,rgba(0,212,255,0.04) 1px,transparent 1px);
|
| 57 |
+
background-size:60px 60px;
|
| 58 |
+
animation: gridMove 20s linear infinite;
|
| 59 |
+
}
|
| 60 |
+
@keyframes gridMove { to { transform:translateY(60px); } }
|
| 61 |
+
|
| 62 |
+
.auth-box {
|
| 63 |
+
position:relative; z-index:1;
|
| 64 |
+
background: linear-gradient(135deg, rgba(10,21,32,0.98), rgba(5,10,15,0.99));
|
| 65 |
+
border: 1px solid rgba(0,212,255,0.2);
|
| 66 |
+
padding: 44px 40px;
|
| 67 |
+
width:100%; max-width:440px;
|
| 68 |
+
clip-path: polygon(0 0,calc(100% - 24px) 0,100% 24px,100% 100%,24px 100%,0 calc(100% - 24px));
|
| 69 |
+
animation: boxIn 0.5s ease-out;
|
| 70 |
+
}
|
| 71 |
+
@keyframes boxIn { from { opacity:0; transform:translateY(30px) scale(0.97); } }
|
| 72 |
+
|
| 73 |
+
.auth-logo { font-family:'Orbitron',monospace; font-size:2rem; font-weight:900; color:var(--accent); text-shadow:0 0 30px var(--glow); margin-bottom:4px; text-align:center; }
|
| 74 |
+
.auth-logo span { color:var(--accent2); }
|
| 75 |
+
.auth-tagline { text-align:center; color:var(--muted); font-size:0.75rem; letter-spacing:.3em; text-transform:uppercase; margin-bottom:30px; }
|
| 76 |
+
|
| 77 |
+
.auth-tabs { display:flex; margin-bottom:24px; border-bottom:1px solid var(--border); }
|
| 78 |
+
.auth-tab { flex:1; padding:10px; background:none; border:none; color:var(--muted); cursor:pointer; font-family:'Orbitron',monospace; font-size:.7rem; letter-spacing:.2em; text-transform:uppercase; transition:color .2s; border-bottom:2px solid transparent; margin-bottom:-1px; }
|
| 79 |
+
.auth-tab.active { color:var(--accent); border-bottom-color:var(--accent); }
|
| 80 |
+
|
| 81 |
+
.auth-field { margin-bottom:14px; }
|
| 82 |
+
.auth-field label { display:block; font-size:.72rem; letter-spacing:.2em; color:var(--muted); text-transform:uppercase; margin-bottom:6px; }
|
| 83 |
+
.auth-field input {
|
| 84 |
+
width:100%; padding:11px 15px;
|
| 85 |
+
background:rgba(0,0,0,0.4);
|
| 86 |
+
border:1px solid var(--border);
|
| 87 |
+
color:var(--text); font-family:'Rajdhani',sans-serif; font-size:1rem; font-weight:600;
|
| 88 |
+
outline:none; transition:border-color .2s,box-shadow .2s;
|
| 89 |
+
clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%);
|
| 90 |
+
}
|
| 91 |
+
.auth-field input:focus { border-color:rgba(0,212,255,0.5); box-shadow:0 0 20px rgba(0,212,255,0.1); }
|
| 92 |
+
|
| 93 |
+
.captcha-box {
|
| 94 |
+
background:rgba(0,0,0,0.4); border:1px solid rgba(0,212,255,0.15);
|
| 95 |
+
padding:12px 14px; margin-bottom:14px;
|
| 96 |
+
display:flex; align-items:center; gap:12px;
|
| 97 |
+
clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%);
|
| 98 |
+
}
|
| 99 |
+
.captcha-question { font-family:'Orbitron',monospace; font-size:1rem; font-weight:700; color:var(--accent); flex:1; }
|
| 100 |
+
.captcha-input { width:70px; padding:8px 10px; background:rgba(0,0,0,0.5); border:1px solid var(--border); color:var(--text); font-family:'Orbitron',monospace; font-size:0.95rem; font-weight:700; outline:none; text-align:center; }
|
| 101 |
+
.captcha-input:focus { border-color:rgba(0,212,255,0.5); }
|
| 102 |
+
.captcha-refresh { background:none; border:none; cursor:pointer; color:var(--muted); font-size:1.1rem; transition:color .2s; padding:4px; }
|
| 103 |
+
.captcha-refresh:hover { color:var(--accent); }
|
| 104 |
+
|
| 105 |
+
.auth-btn { width:100%; padding:13px; background:var(--accent); border:none; color:var(--bg); cursor:pointer; font-family:'Orbitron',monospace; font-size:.78rem; font-weight:700; letter-spacing:.2em; text-transform:uppercase; clip-path:polygon(8px 0%,100% 0%,calc(100% - 8px) 100%,0% 100%); transition:all .2s; margin-top:6px; }
|
| 106 |
+
.auth-btn:hover { background:#33ddff; transform:translateY(-2px); box-shadow:0 8px 30px rgba(0,212,255,0.3); }
|
| 107 |
+
.auth-error { color:var(--danger); font-size:.85rem; text-align:center; margin-top:10px; min-height:20px; letter-spacing:.05em; }
|
| 108 |
+
|
| 109 |
+
/* ─── MAIN APP ─── */
|
| 110 |
+
#app { display:none; height:100vh; grid-template-columns:var(--sidebar-w) 1fr; grid-template-rows:var(--topbar-h) 1fr; }
|
| 111 |
+
#app.visible { display:grid; }
|
| 112 |
+
|
| 113 |
+
/* ─── TOPBAR ─── */
|
| 114 |
+
.topbar {
|
| 115 |
+
grid-column: 1 / -1;
|
| 116 |
+
background:rgba(5,10,15,0.98); border-bottom:1px solid var(--border);
|
| 117 |
+
display:flex; align-items:center; padding:0 16px; gap:12px;
|
| 118 |
+
backdrop-filter:blur(10px); position:relative; z-index:100;
|
| 119 |
+
}
|
| 120 |
+
.topbar-logo { font-family:'Orbitron',monospace; font-size:1rem; font-weight:900; color:var(--accent); text-shadow:0 0 15px var(--glow); text-decoration:none; white-space:nowrap; }
|
| 121 |
+
.topbar-logo span { color:var(--accent2); }
|
| 122 |
+
.topbar-sep { width:1px; height:24px; background:var(--border); }
|
| 123 |
+
.topbar-channel { flex:1; font-family:'Orbitron',monospace; font-size:.7rem; color:var(--muted); letter-spacing:.12em; }
|
| 124 |
+
.topbar-channel span { color:var(--accent); }
|
| 125 |
+
.topbar-actions { display:flex; align-items:center; gap:8px; }
|
| 126 |
+
.topbar-user { display:flex; align-items:center; gap:8px; font-size:.9rem; font-weight:600; }
|
| 127 |
+
.user-avatar-sm { width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-family:'Orbitron',monospace; font-size:.7rem; font-weight:900; border:1px solid var(--accent); color:var(--accent); background:rgba(0,212,255,0.08); flex-shrink:0; cursor:pointer; }
|
| 128 |
+
.topbar-role-badge { font-size:.85rem; }
|
| 129 |
+
.icon-btn { background:none; border:1px solid var(--border); color:var(--muted); padding:5px 10px; cursor:pointer; font-size:.85rem; transition:all .2s; clip-path:polygon(4px 0%,100% 0%,calc(100% - 4px) 100%,0% 100%); }
|
| 130 |
+
.icon-btn:hover { color:var(--accent); border-color:rgba(0,212,255,0.4); }
|
| 131 |
+
.logout-btn { background:none; border:1px solid rgba(255,68,102,0.3); color:var(--danger); padding:5px 10px; cursor:pointer; font-family:'Rajdhani',sans-serif; font-size:.8rem; letter-spacing:.1em; transition:all .2s; clip-path:polygon(4px 0%,100% 0%,calc(100% - 4px) 100%,0% 100%); }
|
| 132 |
+
.logout-btn:hover { background:rgba(255,68,102,0.1); border-color:var(--danger); }
|
| 133 |
+
|
| 134 |
+
/* ─── SIDEBAR ─── */
|
| 135 |
+
.sidebar { background:var(--surface3); border-right:1px solid var(--border); display:flex; flex-direction:column; overflow:hidden; }
|
| 136 |
+
.sidebar-scroll { flex:1; overflow-y:auto; padding-bottom:12px; }
|
| 137 |
+
|
| 138 |
+
.sidebar-section { padding:14px 14px 5px; font-family:'Orbitron',monospace; font-size:.56rem; letter-spacing:.3em; color:var(--muted); text-transform:uppercase; display:flex; align-items:center; justify-content:space-between; }
|
| 139 |
+
.sidebar-section button { background:none; border:none; color:var(--muted); cursor:pointer; font-size:1rem; line-height:1; padding:0 2px; transition:color .2s; }
|
| 140 |
+
.sidebar-section button:hover { color:var(--accent); }
|
| 141 |
+
|
| 142 |
+
.channel-category { padding:10px 14px 4px; font-family:'Orbitron',monospace; font-size:.52rem; letter-spacing:.25em; color:rgba(74,122,153,0.6); text-transform:uppercase; }
|
| 143 |
+
|
| 144 |
+
.channel-item { display:flex; align-items:center; gap:7px; padding:6px 14px; cursor:pointer; transition:background .15s,color .15s; font-size:.88rem; font-weight:600; color:var(--muted); position:relative; user-select:none; }
|
| 145 |
+
.channel-item:hover { background:rgba(0,212,255,0.05); color:var(--text); }
|
| 146 |
+
.channel-item.active { background:rgba(0,212,255,0.08); color:var(--accent); border-left:2px solid var(--accent); }
|
| 147 |
+
.channel-icon { font-size:.82rem; opacity:.7; }
|
| 148 |
+
.channel-name { flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
| 149 |
+
.unread-badge { background:var(--accent2); color:#fff; font-size:.6rem; font-weight:700; padding:1px 5px; border-radius:10px; font-family:'Orbitron',monospace; flex-shrink:0; }
|
| 150 |
+
.ch-locked { opacity:.4; cursor:default; }
|
| 151 |
+
.ch-locked:hover { background:none; color:var(--muted); }
|
| 152 |
+
|
| 153 |
+
.voice-channel { display:flex; align-items:center; gap:7px; padding:6px 14px; cursor:pointer; transition:background .15s; font-size:.88rem; font-weight:600; color:var(--muted); flex-direction:column; align-items:flex-start; }
|
| 154 |
+
.voice-ch-header { display:flex; align-items:center; gap:7px; width:100%; }
|
| 155 |
+
.voice-ch-header:hover { color:var(--text); }
|
| 156 |
+
.voice-ch-participants { padding-left:22px; display:flex; flex-direction:column; gap:2px; }
|
| 157 |
+
.voice-participant { font-size:.78rem; color:var(--green); display:flex; align-items:center; gap:5px; }
|
| 158 |
+
.voice-participant.muted { color:var(--muted); }
|
| 159 |
+
|
| 160 |
+
.sidebar-divider { height:1px; background:var(--border); margin:6px 14px; }
|
| 161 |
+
|
| 162 |
+
/* Role groups */
|
| 163 |
+
.role-group-header { display:flex; align-items:center; gap:6px; padding:8px 14px 3px; font-family:'Orbitron',monospace; font-size:.55rem; letter-spacing:.2em; text-transform:uppercase; color:var(--muted); cursor:pointer; }
|
| 164 |
+
.role-group-header:hover { color:var(--text); }
|
| 165 |
+
|
| 166 |
+
.user-item { display:flex; align-items:center; gap:8px; padding:5px 14px; cursor:pointer; transition:background .15s; font-size:.86rem; font-weight:600; color:var(--muted); }
|
| 167 |
+
.user-item:hover { background:rgba(0,212,255,0.05); color:var(--text); }
|
| 168 |
+
.user-item.me { cursor:default; }
|
| 169 |
+
.user-item.me:hover { background:none; }
|
| 170 |
+
.user-item.offline { opacity:.5; }
|
| 171 |
+
|
| 172 |
+
.online-dot { width:7px; height:7px; border-radius:50%; background:var(--green); box-shadow:0 0 5px var(--green); flex-shrink:0; }
|
| 173 |
+
.offline-dot { width:7px; height:7px; border-radius:50%; background:var(--muted); flex-shrink:0; }
|
| 174 |
+
.away-dot { width:7px; height:7px; border-radius:50%; background:var(--warn); flex-shrink:0; }
|
| 175 |
+
|
| 176 |
+
/* ─── CHAT AREA ─── */
|
| 177 |
+
.chat-area { display:flex; flex-direction:column; background:var(--bg); overflow:hidden; }
|
| 178 |
+
.chat-header { padding:10px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:12px; background:rgba(5,10,15,0.85); }
|
| 179 |
+
.chat-header-info { flex:1; }
|
| 180 |
+
.chat-header-title { font-family:'Orbitron',monospace; font-size:.85rem; font-weight:700; color:var(--text); }
|
| 181 |
+
.chat-header-sub { font-size:.76rem; color:var(--muted); letter-spacing:.05em; }
|
| 182 |
+
.chat-header-actions { display:flex; gap:6px; }
|
| 183 |
+
|
| 184 |
+
.messages { flex:1; overflow-y:auto; padding:16px 20px; display:flex; flex-direction:column; gap:1px; }
|
| 185 |
+
|
| 186 |
+
.day-divider { display:flex; align-items:center; gap:10px; margin:12px 0; color:var(--muted); font-size:.64rem; letter-spacing:.2em; text-transform:uppercase; font-family:'Orbitron',monospace; }
|
| 187 |
+
.day-divider::before, .day-divider::after { content:''; flex:1; height:1px; background:var(--border); }
|
| 188 |
+
|
| 189 |
+
.msg { display:flex; gap:10px; padding:3px 8px 3px; border-radius:2px; transition:background .15s; animation:msgIn .2s ease-out; }
|
| 190 |
+
@keyframes msgIn { from { opacity:0; transform:translateY(5px); } }
|
| 191 |
+
.msg:hover { background:rgba(255,255,255,0.02); }
|
| 192 |
+
.msg.consecutive { padding-top:0; }
|
| 193 |
+
.msg.consecutive .msg-avatar { opacity:0; pointer-events:none; }
|
| 194 |
+
.msg.consecutive .msg-header { display:none; }
|
| 195 |
+
|
| 196 |
+
.msg-avatar { width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-family:'Orbitron',monospace; font-size:.7rem; font-weight:900; flex-shrink:0; margin-top:2px; border:1px solid rgba(0,212,255,0.2); background:rgba(0,212,255,0.06); color:var(--accent); cursor:pointer; }
|
| 197 |
+
.msg-content { flex:1; min-width:0; }
|
| 198 |
+
.msg-header { display:flex; align-items:baseline; gap:8px; margin-bottom:2px; flex-wrap:wrap; }
|
| 199 |
+
.msg-name { font-family:'Orbitron',monospace; font-size:.7rem; font-weight:700; color:var(--accent); cursor:pointer; }
|
| 200 |
+
.msg-name:hover { text-decoration:underline; }
|
| 201 |
+
.msg-role-badge { font-size:.72rem; }
|
| 202 |
+
.msg-time { font-size:.65rem; color:var(--muted); letter-spacing:.05em; }
|
| 203 |
+
.msg-translated { font-size:.72rem; color:var(--muted); font-style:italic; margin-top:2px; border-left:2px solid rgba(0,212,255,0.2); padding-left:6px; }
|
| 204 |
+
.msg-text { font-size:.96rem; line-height:1.5; color:var(--text); word-break:break-word; font-weight:400; }
|
| 205 |
+
.msg-text a { color:var(--accent); text-decoration:none; }
|
| 206 |
+
.msg-text a:hover { text-decoration:underline; }
|
| 207 |
+
.msg-actions { display:none; gap:4px; margin-left:auto; }
|
| 208 |
+
.msg:hover .msg-actions { display:flex; }
|
| 209 |
+
.msg-action-btn { background:none; border:1px solid var(--border); color:var(--muted); padding:2px 7px; cursor:pointer; font-size:.7rem; border-radius:2px; transition:all .15s; }
|
| 210 |
+
.msg-action-btn:hover { color:var(--accent); border-color:rgba(0,212,255,0.4); }
|
| 211 |
+
.msg-action-btn.danger:hover { color:var(--danger); border-color:rgba(255,68,102,0.4); }
|
| 212 |
+
|
| 213 |
+
.msg-system { padding:5px 8px; font-size:.76rem; color:var(--muted); font-style:italic; letter-spacing:.04em; text-align:center; }
|
| 214 |
+
.msg-automod { padding:5px 8px; font-size:.76rem; color:var(--warn); letter-spacing:.04em; text-align:center; border:1px solid rgba(255,170,0,0.15); background:rgba(255,170,0,0.04); margin:4px 0; border-radius:2px; }
|
| 215 |
+
|
| 216 |
+
.pinned-banner { background:rgba(0,212,255,0.06); border:1px solid rgba(0,212,255,0.15); padding:8px 14px; font-size:.82rem; color:var(--muted); display:flex; gap:8px; align-items:center; }
|
| 217 |
+
.pinned-banner span { color:var(--accent); font-weight:700; }
|
| 218 |
+
|
| 219 |
+
.timeout-bar { padding:10px 20px; background:rgba(255,170,0,0.08); border-top:1px solid rgba(255,170,0,0.2); color:var(--warn); font-family:'Orbitron',monospace; font-size:.64rem; text-align:center; }
|
| 220 |
+
|
| 221 |
+
.input-area { padding:12px 20px; border-top:1px solid var(--border); background:rgba(5,10,15,0.8); display:flex; gap:8px; align-items:flex-end; }
|
| 222 |
+
.msg-input { flex:1; background:rgba(0,0,0,0.5); border:1px solid var(--border); color:var(--text); padding:10px 14px; font-family:'Rajdhani',sans-serif; font-size:.97rem; font-weight:500; outline:none; resize:none; min-height:42px; max-height:120px; transition:border-color .2s,box-shadow .2s; clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%); line-height:1.4; }
|
| 223 |
+
.msg-input:focus { border-color:rgba(0,212,255,0.4); box-shadow:0 0 20px rgba(0,212,255,0.08); }
|
| 224 |
+
.msg-input::placeholder { color:var(--muted); }
|
| 225 |
+
.msg-input:disabled { opacity:.4; cursor:not-allowed; }
|
| 226 |
+
.send-btn { padding:10px 16px; background:var(--accent); border:none; color:var(--bg); cursor:pointer; font-family:'Orbitron',monospace; font-size:.65rem; font-weight:700; letter-spacing:.15em; clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%); transition:all .2s; flex-shrink:0; height:42px; }
|
| 227 |
+
.send-btn:hover { background:#33ddff; transform:translateY(-1px); }
|
| 228 |
+
.send-btn:disabled { opacity:.4; cursor:not-allowed; transform:none; }
|
| 229 |
+
|
| 230 |
+
.empty-chat { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--muted); text-align:center; gap:10px; }
|
| 231 |
+
.empty-chat-icon { font-size:2.5rem; opacity:.3; }
|
| 232 |
+
.empty-chat p { font-family:'Orbitron',monospace; font-size:.64rem; letter-spacing:.1em; }
|
| 233 |
+
|
| 234 |
+
/* ─── VOICE PANEL ─── */
|
| 235 |
+
.voice-panel { display:none; flex-direction:column; border-top:1px solid var(--border); background:var(--surface3); }
|
| 236 |
+
.voice-panel.active { display:flex; }
|
| 237 |
+
.voice-status-bar { padding:8px 14px; display:flex; align-items:center; gap:8px; font-size:.8rem; }
|
| 238 |
+
.voice-active-dot { width:8px; height:8px; border-radius:50%; background:var(--green); box-shadow:0 0 8px var(--green); animation:pulse 2s infinite; flex-shrink:0; }
|
| 239 |
+
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.4} }
|
| 240 |
+
.voice-name { flex:1; font-family:'Orbitron',monospace; font-size:.65rem; color:var(--green); }
|
| 241 |
+
.voice-controls { display:flex; gap:4px; }
|
| 242 |
+
.voice-ctrl { background:none; border:1px solid var(--border); color:var(--muted); padding:4px 8px; cursor:pointer; font-size:.75rem; transition:all .15s; clip-path:polygon(3px 0%,100% 0%,calc(100% - 3px) 100%,0% 100%); }
|
| 243 |
+
.voice-ctrl:hover { color:var(--accent); border-color:rgba(0,212,255,0.4); }
|
| 244 |
+
.voice-ctrl.active { color:var(--danger); border-color:rgba(255,68,102,0.4); }
|
| 245 |
+
|
| 246 |
+
/* ─── TICKET PANEL ─── */
|
| 247 |
+
.ticket-item { padding:8px 14px; border-left:2px solid var(--border); margin:4px 0; transition:border-color .2s; cursor:pointer; }
|
| 248 |
+
.ticket-item:hover { border-left-color:var(--accent); background:rgba(0,212,255,0.03); }
|
| 249 |
+
.ticket-item.open { border-left-color:var(--green); }
|
| 250 |
+
.ticket-item.closed { border-left-color:var(--muted); opacity:.6; }
|
| 251 |
+
.ticket-meta { font-size:.7rem; color:var(--muted); font-family:'Orbitron',monospace; }
|
| 252 |
+
.ticket-title { font-size:.88rem; font-weight:600; color:var(--text); }
|
| 253 |
+
|
| 254 |
+
/* ─── CONTEXT MENU ─── */
|
| 255 |
+
#context-menu { position:fixed; z-index:5000; background:rgba(10,21,32,0.98); border:1px solid rgba(0,212,255,0.2); padding:6px 0; min-width:190px; clip-path:polygon(0 0,calc(100% - 10px) 0,100% 10px,100% 100%,0 100%); animation:ctxIn .15s ease-out; box-shadow:0 8px 40px rgba(0,0,0,0.5); }
|
| 256 |
+
@keyframes ctxIn { from { opacity:0; transform:scale(0.95); } }
|
| 257 |
+
.ctx-header { padding:8px 14px 6px; font-family:'Orbitron',monospace; font-size:.63rem; color:var(--accent); letter-spacing:.2em; border-bottom:1px solid var(--border); margin-bottom:4px; }
|
| 258 |
+
.ctx-item { padding:8px 14px; cursor:pointer; font-size:.88rem; font-weight:600; color:var(--text); display:flex; align-items:center; gap:8px; transition:background .1s; }
|
| 259 |
+
.ctx-item:hover { background:rgba(0,212,255,0.08); }
|
| 260 |
+
.ctx-item.danger { color:var(--danger); }
|
| 261 |
+
.ctx-item.danger:hover { background:rgba(255,68,102,0.08); }
|
| 262 |
+
.ctx-item.warn { color:var(--warn); }
|
| 263 |
+
.ctx-item.warn:hover { background:rgba(255,170,0,0.08); }
|
| 264 |
+
.ctx-item.success { color:var(--green); }
|
| 265 |
+
.ctx-item.success:hover { background:rgba(78,255,145,0.08); }
|
| 266 |
+
.ctx-divider { height:1px; background:var(--border); margin:4px 0; }
|
| 267 |
+
|
| 268 |
+
/* ─── MODALS ─── */
|
| 269 |
+
.modal-overlay { position:fixed; inset:0; z-index:6000; background:rgba(0,0,0,0.75); display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px); animation:fadeIn .2s ease-out; }
|
| 270 |
+
@keyframes fadeIn { from { opacity:0; } }
|
| 271 |
+
.modal { background:linear-gradient(135deg,rgba(10,21,32,0.99),rgba(5,10,15,0.99)); border:1px solid rgba(0,212,255,0.2); padding:30px 28px; width:100%; max-width:440px; max-height:90vh; overflow-y:auto; clip-path:polygon(0 0,calc(100% - 20px) 0,100% 20px,100% 100%,20px 100%,0 calc(100% - 20px)); animation:boxIn .3s ease-out; }
|
| 272 |
+
.modal.wide { max-width:600px; }
|
| 273 |
+
.modal-title { font-family:'Orbitron',monospace; font-size:.95rem; font-weight:700; color:var(--accent); margin-bottom:5px; }
|
| 274 |
+
.modal-sub { font-size:.84rem; color:var(--muted); margin-bottom:20px; }
|
| 275 |
+
.modal-field { margin-bottom:13px; }
|
| 276 |
+
.modal-field label { display:block; font-size:.7rem; letter-spacing:.15em; color:var(--muted); text-transform:uppercase; margin-bottom:5px; }
|
| 277 |
+
.modal-field input, .modal-field select, .modal-field textarea { width:100%; padding:10px 13px; background:rgba(0,0,0,0.5); border:1px solid var(--border); color:var(--text); font-family:'Rajdhani',sans-serif; font-size:.94rem; font-weight:600; outline:none; transition:border-color .2s; clip-path:polygon(5px 0%,100% 0%,calc(100% - 5px) 100%,0% 100%); }
|
| 278 |
+
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color:rgba(0,212,255,0.5); }
|
| 279 |
+
.modal-field select option { background:#0a1520; }
|
| 280 |
+
.modal-field textarea { resize:vertical; min-height:80px; }
|
| 281 |
+
.modal-field .hint { font-size:.72rem; color:var(--muted); margin-top:4px; }
|
| 282 |
+
.modal-tabs { display:flex; margin-bottom:20px; border-bottom:1px solid var(--border); }
|
| 283 |
+
.modal-tab { flex:1; padding:8px; background:none; border:none; color:var(--muted); cursor:pointer; font-family:'Orbitron',monospace; font-size:.62rem; letter-spacing:.15em; text-transform:uppercase; transition:color .2s; border-bottom:2px solid transparent; margin-bottom:-1px; }
|
| 284 |
+
.modal-tab.active { color:var(--accent); border-bottom-color:var(--accent); }
|
| 285 |
+
.modal-btns { display:flex; gap:8px; margin-top:18px; }
|
| 286 |
+
.modal-btn { flex:1; padding:11px; border:none; cursor:pointer; font-family:'Orbitron',monospace; font-size:.65rem; font-weight:700; letter-spacing:.15em; clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%); transition:all .2s; }
|
| 287 |
+
.modal-btn.primary { background:var(--accent); color:var(--bg); }
|
| 288 |
+
.modal-btn.primary:hover { background:#33ddff; }
|
| 289 |
+
.modal-btn.secondary { background:transparent; color:var(--muted); border:1px solid var(--border); }
|
| 290 |
+
.modal-btn.secondary:hover { color:var(--text); border-color:rgba(0,212,255,0.3); }
|
| 291 |
+
.modal-btn.danger-btn { background:var(--danger); color:#fff; }
|
| 292 |
+
.modal-btn.danger-btn:hover { background:#ff6680; }
|
| 293 |
+
.modal-btn.warn-btn { background:var(--warn); color:#000; }
|
| 294 |
+
.modal-btn.warn-btn:hover { background:#ffcc44; }
|
| 295 |
+
.modal-btn.success-btn { background:var(--green); color:#000; }
|
| 296 |
+
.modal-btn.success-btn:hover { background:#7fffb2; }
|
| 297 |
+
.captcha-modal-question { font-family:'Orbitron',monospace; font-size:2rem; font-weight:900; color:var(--accent); text-align:center; letter-spacing:.1em; margin:16px 0; text-shadow:0 0 20px var(--glow); }
|
| 298 |
+
|
| 299 |
+
/* ─── SETTINGS ─── */
|
| 300 |
+
.settings-section { margin-bottom:20px; }
|
| 301 |
+
.settings-section h4 { font-family:'Orbitron',monospace; font-size:.65rem; letter-spacing:.2em; color:var(--muted); text-transform:uppercase; margin-bottom:12px; padding-bottom:6px; border-bottom:1px solid var(--border); }
|
| 302 |
+
.toggle-row { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid rgba(0,212,255,0.06); }
|
| 303 |
+
.toggle-row label { font-size:.88rem; color:var(--text); }
|
| 304 |
+
.toggle { width:40px; height:20px; background:rgba(0,0,0,0.5); border:1px solid var(--border); border-radius:10px; cursor:pointer; position:relative; transition:background .2s; }
|
| 305 |
+
.toggle.on { background:rgba(0,212,255,0.3); border-color:rgba(0,212,255,0.5); }
|
| 306 |
+
.toggle::after { content:''; position:absolute; top:2px; left:2px; width:14px; height:14px; border-radius:50%; background:var(--muted); transition:all .2s; }
|
| 307 |
+
.toggle.on::after { left:22px; background:var(--accent); }
|
| 308 |
+
|
| 309 |
+
/* ─── AUTOMOD TAGS ─── */
|
| 310 |
+
.tag { display:inline-flex; align-items:center; gap:5px; background:rgba(0,212,255,0.08); border:1px solid rgba(0,212,255,0.2); color:var(--accent); padding:3px 10px; border-radius:2px; font-size:.78rem; margin:3px 2px; }
|
| 311 |
+
.tag-remove { background:none; border:none; color:var(--muted); cursor:pointer; font-size:.9rem; line-height:1; padding:0 1px; }
|
| 312 |
+
.tag-remove:hover { color:var(--danger); }
|
| 313 |
+
.tag-input { background:rgba(0,0,0,0.4); border:1px solid var(--border); color:var(--text); padding:5px 10px; font-family:'Rajdhani',sans-serif; font-size:.88rem; outline:none; margin-top:6px; }
|
| 314 |
+
.tag-input:focus { border-color:rgba(0,212,255,0.4); }
|
| 315 |
+
|
| 316 |
+
/* ─── TOAST ─── */
|
| 317 |
+
.toast { position:fixed; bottom:20px; right:20px; background:rgba(10,21,32,0.98); border:1px solid var(--accent); color:var(--accent); padding:10px 16px; font-family:'Orbitron',monospace; font-size:.65rem; letter-spacing:.12em; z-index:9999; animation:toastIn .3s ease-out; clip-path:polygon(6px 0%,100% 0%,calc(100% - 6px) 100%,0% 100%); max-width:300px; }
|
| 318 |
+
@keyframes toastIn { from { opacity:0; transform:translateY(20px); } }
|
| 319 |
+
|
| 320 |
+
/* ─── AVATAR COLORS ─── */
|
| 321 |
+
.av-color-0 { border-color:rgba(0,212,255,0.3)!important; color:#00d4ff!important; background:rgba(0,212,255,0.06)!important; }
|
| 322 |
+
.av-color-1 { border-color:rgba(255,107,53,0.3)!important; color:#ff6b35!important; background:rgba(255,107,53,0.06)!important; }
|
| 323 |
+
.av-color-2 { border-color:rgba(168,85,247,0.3)!important; color:#a855f7!important; background:rgba(168,85,247,0.06)!important; }
|
| 324 |
+
.av-color-3 { border-color:rgba(78,255,145,0.3)!important; color:#4eff91!important; background:rgba(78,255,145,0.06)!important; }
|
| 325 |
+
.av-color-4 { border-color:rgba(255,214,0,0.3)!important; color:#ffd600!important; background:rgba(255,214,0,0.06)!important; }
|
| 326 |
+
.name-color-0 { color:#00d4ff!important; }
|
| 327 |
+
.name-color-1 { color:#ff6b35!important; }
|
| 328 |
+
.name-color-2 { color:#a855f7!important; }
|
| 329 |
+
.name-color-3 { color:#4eff91!important; }
|
| 330 |
+
.name-color-4 { color:#ffd600!important; }
|
| 331 |
+
|
| 332 |
+
/* ─── TICKET BADGE ─── */
|
| 333 |
+
.ticket-badge { background:var(--purple); color:#fff; font-size:.6rem; font-weight:700; padding:1px 5px; border-radius:10px; font-family:'Orbitron',monospace; }
|
| 334 |
+
|
| 335 |
+
/* ─── SCROLLBAR CUSTOM ─── */
|
| 336 |
+
.messages::-webkit-scrollbar { width:3px; }
|
| 337 |
+
.sidebar-scroll::-webkit-scrollbar { width:3px; }
|
| 338 |
+
|
| 339 |
+
/* ─── RESPONSIVE ─── */
|
| 340 |
+
@media (max-width:768px) {
|
| 341 |
+
:root { --sidebar-w: 0px; }
|
| 342 |
+
.sidebar { display:none; }
|
| 343 |
+
#app.visible { grid-template-columns:1fr; }
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
/* ─── MISC ─── */
|
| 347 |
+
.divider { height:1px; background:var(--border); margin:10px 0; }
|
| 348 |
+
.txt-accent { color:var(--accent); }
|
| 349 |
+
.txt-danger { color:var(--danger); }
|
| 350 |
+
.txt-warn { color:var(--warn); }
|
| 351 |
+
.txt-green { color:var(--green); }
|
| 352 |
+
.txt-muted { color:var(--muted); }
|
| 353 |
+
.fw700 { font-weight:700; }
|
| 354 |
+
.mono { font-family:'Orbitron',monospace; font-size:.75rem; }
|