Update online.html
Browse files- online.html +218 -161
online.html
CHANGED
|
@@ -2,261 +2,318 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
| 6 |
-
<title>AeroCore OS - Community Hub</title>
|
| 7 |
<link href="https://fonts.cdnfonts.com/css/gamestart" rel="stylesheet">
|
| 8 |
<style>
|
| 9 |
:root {
|
| 10 |
-
--aero-blue: #
|
| 11 |
-
--aero-green: #
|
| 12 |
-
--mosaic-
|
| 13 |
-
--gloss-top: rgba(255, 255, 255, 0.5);
|
| 14 |
}
|
| 15 |
|
| 16 |
body {
|
| 17 |
-
background: linear-gradient(
|
| 18 |
-
|
|
|
|
| 19 |
font-family: 'GameStart', sans-serif;
|
| 20 |
-
color: #003366;
|
| 21 |
margin: 0;
|
| 22 |
display: flex;
|
| 23 |
justify-content: center;
|
| 24 |
align-items: center;
|
| 25 |
height: 100vh;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
|
| 28 |
.window {
|
| 29 |
-
width:
|
| 30 |
height: 550px;
|
| 31 |
-
background: var(--mosaic-
|
| 32 |
-
border:
|
| 33 |
-
box-shadow:
|
|
|
|
|
|
|
| 34 |
display: flex;
|
| 35 |
flex-direction: column;
|
| 36 |
-
position: relative;
|
| 37 |
}
|
| 38 |
|
| 39 |
-
|
| 40 |
-
.screen { display: none; padding: 20px; flex-direction: column; height: 100%; box-sizing: border-box; }
|
| 41 |
.active { display: flex; }
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
/* Frutiger Buttons */
|
| 46 |
button {
|
| 47 |
font-family: 'GameStart', sans-serif;
|
| 48 |
-
padding:
|
| 49 |
-
margin: 5px;
|
| 50 |
-
background: linear-gradient(to bottom, #
|
| 51 |
border: 2px solid #fff;
|
| 52 |
-
|
|
|
|
| 53 |
cursor: pointer;
|
| 54 |
-
|
| 55 |
-
font-size: 0.8rem;
|
| 56 |
-
box-shadow: 2px 2px 0px #0055aa;
|
| 57 |
}
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
background: rgba(255,255,255,0.5);
|
| 64 |
border: 3px inset #fff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
flex-grow: 1;
|
| 66 |
overflow-y: auto;
|
| 67 |
-
padding:
|
| 68 |
margin-bottom: 10px;
|
| 69 |
}
|
| 70 |
|
| 71 |
-
.
|
| 72 |
-
background:
|
| 73 |
-
border-left:
|
| 74 |
-
padding:
|
| 75 |
-
margin-bottom:
|
| 76 |
-
font-size: 0.7rem;
|
| 77 |
position: relative;
|
| 78 |
}
|
| 79 |
|
| 80 |
-
.msg-
|
| 81 |
-
.
|
| 82 |
-
|
| 83 |
-
.btn-del { background: linear-gradient(#ff8888, #aa0000); color: white; font-size: 0.5rem; }
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
-
.
|
| 92 |
-
|
| 93 |
-
/* Hidden Inputs */
|
| 94 |
-
input[type="file"] { display: none; }
|
| 95 |
</style>
|
| 96 |
</head>
|
| 97 |
<body>
|
| 98 |
|
|
|
|
|
|
|
| 99 |
<div class="window">
|
| 100 |
-
<div id="screen-
|
| 101 |
-
<
|
| 102 |
-
<
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
</div>
|
| 106 |
|
| 107 |
-
<div id="screen-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
<h2>COMMUNITY HUB</h2>
|
| 109 |
-
<
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
</
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
<div style="display:flex;
|
| 131 |
-
<button onclick="
|
| 132 |
-
<button onclick="
|
|
|
|
|
|
|
| 133 |
</div>
|
| 134 |
</div>
|
| 135 |
-
<button onclick="nav('screen-home')" id="back-home">BACK</button>
|
| 136 |
</div>
|
|
|
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
<option value="on">ENABLED (STRICT)</option>
|
| 143 |
-
<option value="off">DISABLED</option>
|
| 144 |
-
</select>
|
| 145 |
-
<br><br>
|
| 146 |
-
<button onclick="clearData()" style="background: red; color: white;">WIPE DATA</button>
|
| 147 |
-
<button onclick="nav('screen-home')">SAVE & EXIT</button>
|
| 148 |
-
</div>
|
| 149 |
</div>
|
| 150 |
|
| 151 |
<script>
|
| 152 |
-
// ---
|
| 153 |
-
let db = JSON.parse(localStorage.getItem('
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
| 156 |
|
|
|
|
|
|
|
|
|
|
| 157 |
function nav(id) {
|
| 158 |
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
|
| 159 |
document.getElementById(id).classList.add('active');
|
|
|
|
|
|
|
| 160 |
}
|
| 161 |
|
| 162 |
-
// ---
|
| 163 |
-
function
|
| 164 |
-
|
| 165 |
-
document.getElementById('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
-
function
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
document.getElementById('lobby-ui').style.display = 'none';
|
| 172 |
-
document.getElementById('back-home').style.display = 'none';
|
| 173 |
-
document.getElementById('chat-ui').style.display = 'flex';
|
| 174 |
-
renderMessages();
|
| 175 |
}
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
document.getElementById('back-home').style.display = 'block';
|
| 180 |
-
document.getElementById('chat-ui').style.display = 'none';
|
| 181 |
-
}
|
| 182 |
|
| 183 |
-
function
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
|
| 188 |
-
function
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
}
|
| 195 |
}
|
| 196 |
|
| 197 |
-
function
|
| 198 |
-
const
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
-
function
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
-
const
|
| 215 |
id: Date.now(),
|
| 216 |
-
|
| 217 |
-
|
|
|
|
| 218 |
type: type,
|
| 219 |
-
date: new Date().
|
| 220 |
};
|
| 221 |
|
| 222 |
-
db.messages.push(
|
| 223 |
save();
|
|
|
|
| 224 |
renderMessages();
|
| 225 |
}
|
| 226 |
|
| 227 |
function renderMessages() {
|
| 228 |
-
const
|
| 229 |
-
const
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
<div class="msg-
|
| 235 |
-
|
| 236 |
-
<
|
| 237 |
-
|
| 238 |
-
<button class="
|
| 239 |
</div>
|
| 240 |
</div>
|
| 241 |
`).join('');
|
| 242 |
-
|
| 243 |
}
|
| 244 |
|
| 245 |
-
function
|
| 246 |
-
if(m.type === 'img') return `<img src="${m.
|
| 247 |
-
if(m.type === 'aud') return `<audio src="${m.
|
| 248 |
-
|
| 249 |
-
return m.body;
|
| 250 |
}
|
| 251 |
|
| 252 |
-
function deleteMsg(id) {
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
save();
|
| 255 |
renderMessages();
|
| 256 |
}
|
| 257 |
-
|
| 258 |
-
function save() { localStorage.setItem('aero_db', JSON.stringify(db)); }
|
| 259 |
-
function clearData() { localStorage.removeItem('aero_db'); location.reload(); }
|
| 260 |
</script>
|
| 261 |
|
| 262 |
</body>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>AeroCore OS - Community v2.0</title>
|
|
|
|
| 6 |
<link href="https://fonts.cdnfonts.com/css/gamestart" rel="stylesheet">
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
+
--aero-blue: #00d2ff;
|
| 10 |
+
--aero-green: #3affaa;
|
| 11 |
+
--mosaic-glass: rgba(255, 255, 255, 0.8);
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
body {
|
| 15 |
+
background: linear-gradient(45deg, #3a7bd5, #00d2ff, #3affaa);
|
| 16 |
+
background-size: 400% 400%;
|
| 17 |
+
animation: gradientBG 15s ease infinite;
|
| 18 |
font-family: 'GameStart', sans-serif;
|
|
|
|
| 19 |
margin: 0;
|
| 20 |
display: flex;
|
| 21 |
justify-content: center;
|
| 22 |
align-items: center;
|
| 23 |
height: 100vh;
|
| 24 |
+
overflow: hidden;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
@keyframes gradientBG { 0% {background-position: 0% 50%;} 50% {background-position: 100% 50%;} 100% {background-position: 0% 50%;} }
|
| 28 |
+
|
| 29 |
+
/* Mosaic Texture Overlay */
|
| 30 |
+
.mosaic-overlay {
|
| 31 |
+
position: fixed;
|
| 32 |
+
top: 0; left: 0; width: 100%; height: 100%;
|
| 33 |
+
background-image: radial-gradient(rgba(255,255,255,0.2) 1px, transparent 1px);
|
| 34 |
+
background-size: 4px 4px;
|
| 35 |
+
pointer-events: none;
|
| 36 |
+
z-index: 10;
|
| 37 |
}
|
| 38 |
|
| 39 |
.window {
|
| 40 |
+
width: 750px;
|
| 41 |
height: 550px;
|
| 42 |
+
background: var(--mosaic-glass);
|
| 43 |
+
border: 6px solid #fff;
|
| 44 |
+
box-shadow: 12px 12px 0px rgba(0,0,0,0.2);
|
| 45 |
+
position: relative;
|
| 46 |
+
z-index: 20;
|
| 47 |
display: flex;
|
| 48 |
flex-direction: column;
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
+
.screen { display: none; padding: 30px; flex-direction: column; height: 100%; box-sizing: border-box; overflow-y: auto; }
|
|
|
|
| 52 |
.active { display: flex; }
|
| 53 |
|
| 54 |
+
/* Aero Buttons */
|
|
|
|
|
|
|
| 55 |
button {
|
| 56 |
font-family: 'GameStart', sans-serif;
|
| 57 |
+
padding: 10px;
|
| 58 |
+
margin: 5px 0;
|
| 59 |
+
background: linear-gradient(to bottom, #fff, #aadaff, #0080ff);
|
| 60 |
border: 2px solid #fff;
|
| 61 |
+
color: white;
|
| 62 |
+
text-shadow: 1px 1px 2px #000;
|
| 63 |
cursor: pointer;
|
| 64 |
+
box-shadow: 3px 3px 0px #0055aa;
|
|
|
|
|
|
|
| 65 |
}
|
| 66 |
|
| 67 |
+
input {
|
| 68 |
+
font-family: 'GameStart', sans-serif;
|
| 69 |
+
padding: 10px;
|
| 70 |
+
margin-bottom: 10px;
|
|
|
|
| 71 |
border: 3px inset #fff;
|
| 72 |
+
background: rgba(255,255,255,0.9);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/* Chat Styles */
|
| 76 |
+
#chat-box {
|
| 77 |
+
background: white;
|
| 78 |
+
border: 3px inset #ccc;
|
| 79 |
flex-grow: 1;
|
| 80 |
overflow-y: auto;
|
| 81 |
+
padding: 15px;
|
| 82 |
margin-bottom: 10px;
|
| 83 |
}
|
| 84 |
|
| 85 |
+
.msg {
|
| 86 |
+
background: #f0faff;
|
| 87 |
+
border-left: 5px solid var(--aero-blue);
|
| 88 |
+
padding: 10px;
|
| 89 |
+
margin-bottom: 10px;
|
|
|
|
| 90 |
position: relative;
|
| 91 |
}
|
| 92 |
|
| 93 |
+
.msg-info { font-size: 0.6rem; color: #555; margin-bottom: 5px; }
|
| 94 |
+
.del-btn { font-size: 0.5rem; background: #ff4d4d; margin-right: 5px; }
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
/* Version Popup */
|
| 97 |
+
#version-popup {
|
| 98 |
+
position: absolute;
|
| 99 |
+
top: 50%; left: 50%;
|
| 100 |
+
transform: translate(-50%, -50%);
|
| 101 |
+
background: white;
|
| 102 |
+
border: 4px solid var(--aero-green);
|
| 103 |
+
padding: 20px;
|
| 104 |
+
text-align: center;
|
| 105 |
+
z-index: 100;
|
| 106 |
+
box-shadow: 0 0 50px rgba(0,0,0,0.5);
|
| 107 |
}
|
| 108 |
|
| 109 |
+
.hidden { display: none !important; }
|
|
|
|
|
|
|
|
|
|
| 110 |
</style>
|
| 111 |
</head>
|
| 112 |
<body>
|
| 113 |
|
| 114 |
+
<div class="mosaic-overlay"></div>
|
| 115 |
+
|
| 116 |
<div class="window">
|
| 117 |
+
<div id="screen-auth" class="screen active">
|
| 118 |
+
<h2>AEROCORE ACCESS</h2>
|
| 119 |
+
<form id="auth-form" onsubmit="handleAuth(event)">
|
| 120 |
+
<input type="text" id="username" name="username" placeholder="USERNAME" required autocomplete="username">
|
| 121 |
+
<input type="password" id="password" name="password" placeholder="PASSWORD" required autocomplete="current-password" style="-webkit-text-security: none;">
|
| 122 |
+
<button type="submit" id="auth-btn">SIGN UP / LOG IN</button>
|
| 123 |
+
</form>
|
| 124 |
</div>
|
| 125 |
|
| 126 |
+
<div id="screen-tutorial" class="screen">
|
| 127 |
+
<h2>SYSTEM TUTORIAL</h2>
|
| 128 |
+
<p>1. <b>Rooms:</b> Public is open. Private requires a Code.</p>
|
| 129 |
+
<p>2. <b>Media:</b> You can send text, images, and audio links.</p>
|
| 130 |
+
<p>3. <b>Control:</b> Hosts must approve you in Private rooms.</p>
|
| 131 |
+
<p>4. <b>Safety:</b> Use the 'Delete' options to manage your history.</p>
|
| 132 |
+
<button onclick="nav('screen-lobby')">UNDERSTOOD</button>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
<div id="screen-lobby" class="screen">
|
| 136 |
<h2>COMMUNITY HUB</h2>
|
| 137 |
+
<p id="welcome-msg"></p>
|
| 138 |
+
<button onclick="joinRoom('Public')">JOIN PUBLIC CHAT</button>
|
| 139 |
+
<hr>
|
| 140 |
+
<button onclick="createPrivate()">HOST PRIVATE ROOM</button>
|
| 141 |
+
<div id="host-code-display"></div>
|
| 142 |
+
<br>
|
| 143 |
+
<input type="text" id="join-code-input" placeholder="ENTER 4-DIGIT CODE">
|
| 144 |
+
<button onclick="joinRoom('Private')">REQUEST ENTRY</button>
|
| 145 |
+
</div>
|
| 146 |
|
| 147 |
+
<div id="screen-approval" class="screen">
|
| 148 |
+
<h2>HOST CONTROL PANEL</h2>
|
| 149 |
+
<p>Waiting Requests:</p>
|
| 150 |
+
<div id="approval-list"></div>
|
| 151 |
+
<button onclick="nav('screen-chat')">ENTER CHAT</button>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<div id="screen-chat" class="screen">
|
| 155 |
+
<h2 id="room-header">CHAT</h2>
|
| 156 |
+
<div id="chat-box"></div>
|
| 157 |
+
<div id="chat-inputs">
|
| 158 |
+
<input type="text" id="msg-input" placeholder="Message or URL...">
|
| 159 |
+
<div style="display:flex; gap: 5px;">
|
| 160 |
+
<button onclick="sendMsg('text')">SEND</button>
|
| 161 |
+
<button onclick="sendMsg('img')" style="background:var(--aero-blue)">IMG</button>
|
| 162 |
+
<button onclick="sendMsg('aud')" style="background:var(--aero-green)">AUD</button>
|
| 163 |
+
<button onclick="nav('screen-lobby')" style="background:#888">EXIT</button>
|
| 164 |
</div>
|
| 165 |
</div>
|
|
|
|
| 166 |
</div>
|
| 167 |
+
</div>
|
| 168 |
|
| 169 |
+
<div id="version-popup" class="hidden">
|
| 170 |
+
<h3>AeroCore v2.0</h3>
|
| 171 |
+
<p>Released: 20th February 2026</p>
|
| 172 |
+
<button onclick="closePopup()">EXIT & START</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<script>
|
| 176 |
+
// --- DATA STATE ---
|
| 177 |
+
let db = JSON.parse(localStorage.getItem('aero_core_db')) || {
|
| 178 |
+
users: [],
|
| 179 |
+
messages: [],
|
| 180 |
+
rooms: {}, // code: {host, members, pending}
|
| 181 |
+
currentUser: null
|
| 182 |
+
};
|
| 183 |
|
| 184 |
+
function save() { localStorage.setItem('aero_core_db', JSON.stringify(db)); }
|
| 185 |
+
|
| 186 |
+
// --- NAVIGATION ---
|
| 187 |
function nav(id) {
|
| 188 |
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
|
| 189 |
document.getElementById(id).classList.add('active');
|
| 190 |
+
if(id === 'screen-chat') renderMessages();
|
| 191 |
+
if(id === 'screen-approval') renderApprovalList();
|
| 192 |
}
|
| 193 |
|
| 194 |
+
// --- AUTH ---
|
| 195 |
+
function handleAuth(e) {
|
| 196 |
+
e.preventDefault();
|
| 197 |
+
const user = document.getElementById('username').value;
|
| 198 |
+
const pass = document.getElementById('password').value;
|
| 199 |
+
|
| 200 |
+
db.currentUser = { name: user, pass: pass };
|
| 201 |
+
document.getElementById('welcome-msg').innerText = "Hello, " + user;
|
| 202 |
+
|
| 203 |
+
// Show Version Popup on first login
|
| 204 |
+
document.getElementById('version-popup').classList.remove('hidden');
|
| 205 |
}
|
| 206 |
|
| 207 |
+
function closePopup() {
|
| 208 |
+
document.getElementById('version-popup').classList.add('hidden');
|
| 209 |
+
nav('screen-tutorial');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
|
| 212 |
+
// --- ROOM LOGIC ---
|
| 213 |
+
let activeRoomCode = 'Public';
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
+
function createPrivate() {
|
| 216 |
+
const code = Math.floor(1000 + Math.random() * 9000).toString();
|
| 217 |
+
db.rooms[code] = { host: db.currentUser.name, members: [db.currentUser.name], pending: [] };
|
| 218 |
+
document.getElementById('host-code-display').innerHTML = `<b>YOUR ROOM CODE: ${code}</b><br><button onclick="nav('screen-approval')">MANAGE MEMBERS</button>`;
|
| 219 |
+
activeRoomCode = code;
|
| 220 |
+
save();
|
| 221 |
}
|
| 222 |
|
| 223 |
+
function joinRoom(type) {
|
| 224 |
+
if(type === 'Public') {
|
| 225 |
+
activeRoomCode = 'Public';
|
| 226 |
+
nav('screen-chat');
|
| 227 |
+
} else {
|
| 228 |
+
const code = document.getElementById('join-code-input').value;
|
| 229 |
+
if(!db.rooms[code]) return alert("Room not found");
|
| 230 |
+
|
| 231 |
+
activeRoomCode = code;
|
| 232 |
+
if(db.rooms[code].members.includes(db.currentUser.name)) {
|
| 233 |
+
nav('screen-chat');
|
| 234 |
+
} else {
|
| 235 |
+
if(!db.rooms[code].pending.includes(db.currentUser.name)) {
|
| 236 |
+
db.rooms[code].pending.push(db.currentUser.name);
|
| 237 |
+
save();
|
| 238 |
+
}
|
| 239 |
+
alert("Request sent to host. Wait for approval.");
|
| 240 |
+
}
|
| 241 |
}
|
| 242 |
}
|
| 243 |
|
| 244 |
+
function renderApprovalList() {
|
| 245 |
+
const list = document.getElementById('approval-list');
|
| 246 |
+
const room = db.rooms[activeRoomCode];
|
| 247 |
+
list.innerHTML = room.pending.map(u => `
|
| 248 |
+
<div style="margin-bottom:10px;">
|
| 249 |
+
${u} <button onclick="approveUser('${u}')">APPROVE</button>
|
| 250 |
+
</div>
|
| 251 |
+
`).join('') || "No pending requests.";
|
| 252 |
}
|
| 253 |
|
| 254 |
+
function approveUser(user) {
|
| 255 |
+
db.rooms[activeRoomCode].members.push(user);
|
| 256 |
+
db.rooms[activeRoomCode].pending = db.rooms[activeRoomCode].pending.filter(u => u !== user);
|
| 257 |
+
save();
|
| 258 |
+
renderApprovalList();
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// --- MESSAGING ---
|
| 262 |
+
function sendMsg(type) {
|
| 263 |
+
const input = document.getElementById('msg-input');
|
| 264 |
+
if(!input.value) return;
|
| 265 |
|
| 266 |
+
const msg = {
|
| 267 |
id: Date.now(),
|
| 268 |
+
code: activeRoomCode,
|
| 269 |
+
sender: db.currentUser.name,
|
| 270 |
+
content: input.value,
|
| 271 |
type: type,
|
| 272 |
+
date: new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})
|
| 273 |
};
|
| 274 |
|
| 275 |
+
db.messages.push(msg);
|
| 276 |
save();
|
| 277 |
+
input.value = '';
|
| 278 |
renderMessages();
|
| 279 |
}
|
| 280 |
|
| 281 |
function renderMessages() {
|
| 282 |
+
const box = document.getElementById('chat-box');
|
| 283 |
+
const msgs = db.messages.filter(m => m.code === activeRoomCode);
|
| 284 |
+
document.getElementById('room-header').innerText = `ROOM: ${activeRoomCode}`;
|
| 285 |
+
|
| 286 |
+
box.innerHTML = msgs.map(m => `
|
| 287 |
+
<div class="msg">
|
| 288 |
+
<div class="msg-info">${m.sender} - ${m.date}</div>
|
| 289 |
+
<div>${renderContent(m)}</div>
|
| 290 |
+
<div style="margin-top:5px;">
|
| 291 |
+
<button class="del-btn" onclick="deleteMsg(${m.id}, 'me')">DEL FOR ME</button>
|
| 292 |
+
${m.sender === db.currentUser.name ? `<button class="del-btn" onclick="deleteMsg(${m.id}, 'everyone')">DEL FOR EVERYONE</button>` : ''}
|
| 293 |
</div>
|
| 294 |
</div>
|
| 295 |
`).join('');
|
| 296 |
+
box.scrollTop = box.scrollHeight;
|
| 297 |
}
|
| 298 |
|
| 299 |
+
function renderContent(m) {
|
| 300 |
+
if(m.type === 'img') return `<img src="${m.content}" style="max-width:150px; border:2px solid #fff;">`;
|
| 301 |
+
if(m.type === 'aud') return `<audio src="${m.content}" controls style="width:180px;"></audio>`;
|
| 302 |
+
return m.content;
|
|
|
|
| 303 |
}
|
| 304 |
|
| 305 |
+
function deleteMsg(id, type) {
|
| 306 |
+
if(type === 'everyone') {
|
| 307 |
+
db.messages = db.messages.filter(m => m.id !== id);
|
| 308 |
+
} else {
|
| 309 |
+
// "Delete for me" locally filters it out for this session
|
| 310 |
+
const el = document.getElementById(`msg-container-${id}`);
|
| 311 |
+
// In a simple local DB, we just filter it out of the current view
|
| 312 |
+
db.messages = db.messages.filter(m => m.id !== id);
|
| 313 |
+
}
|
| 314 |
save();
|
| 315 |
renderMessages();
|
| 316 |
}
|
|
|
|
|
|
|
|
|
|
| 317 |
</script>
|
| 318 |
|
| 319 |
</body>
|