Update online.html
Browse files- online.html +139 -181
online.html
CHANGED
|
@@ -2,206 +2,162 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<title>AeroCore OS
|
| 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.
|
| 12 |
}
|
| 13 |
|
| 14 |
body {
|
| 15 |
-
background: linear-gradient(
|
| 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 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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 |
-
|
| 42 |
-
|
| 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;
|
| 52 |
.active { display: flex; }
|
| 53 |
|
| 54 |
-
/* Aero
|
| 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 |
-
|
| 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 |
-
|
| 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 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
/* Version Popup */
|
| 97 |
#version-popup {
|
| 98 |
-
position: absolute;
|
| 99 |
-
|
| 100 |
-
|
| 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="
|
| 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"
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
</form>
|
| 124 |
</div>
|
| 125 |
|
| 126 |
<div id="screen-tutorial" class="screen">
|
| 127 |
<h2>SYSTEM TUTORIAL</h2>
|
| 128 |
-
<p>
|
| 129 |
-
<p>
|
| 130 |
-
<p>
|
| 131 |
-
<p>
|
| 132 |
-
<button onclick="nav('screen-lobby')">
|
| 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
|
| 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
|
| 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 |
-
<
|
|
|
|
|
|
|
|
|
|
| 156 |
<div id="chat-box"></div>
|
| 157 |
-
<
|
| 158 |
-
|
| 159 |
-
<
|
| 160 |
-
|
| 161 |
-
|
| 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>
|
| 172 |
<button onclick="closePopup()">EXIT & START</button>
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<script>
|
| 176 |
-
// ---
|
| 177 |
-
let db = JSON.parse(localStorage.getItem('
|
| 178 |
-
users: [],
|
| 179 |
messages: [],
|
| 180 |
-
rooms: {}
|
| 181 |
-
currentUser: null
|
| 182 |
};
|
|
|
|
|
|
|
| 183 |
|
| 184 |
-
function save() { localStorage.setItem('
|
| 185 |
|
| 186 |
-
// ---
|
| 187 |
-
function
|
| 188 |
-
|
| 189 |
-
document.getElementById(
|
| 190 |
-
if(
|
| 191 |
-
if(id === 'screen-approval') renderApprovalList();
|
| 192 |
-
}
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
}
|
| 206 |
|
| 207 |
function closePopup() {
|
|
@@ -209,15 +165,22 @@
|
|
| 209 |
nav('screen-tutorial');
|
| 210 |
}
|
| 211 |
|
| 212 |
-
// ---
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
|
|
|
| 215 |
function createPrivate() {
|
| 216 |
const code = Math.floor(1000 + Math.random() * 9000).toString();
|
| 217 |
-
db.rooms[code] = { host:
|
| 218 |
-
document.getElementById('host-code-display').
|
| 219 |
activeRoomCode = code;
|
| 220 |
save();
|
|
|
|
| 221 |
}
|
| 222 |
|
| 223 |
function joinRoom(type) {
|
|
@@ -226,17 +189,20 @@
|
|
| 226 |
nav('screen-chat');
|
| 227 |
} else {
|
| 228 |
const code = document.getElementById('join-code-input').value;
|
| 229 |
-
if(!db.rooms[code])
|
| 230 |
-
|
|
|
|
|
|
|
| 231 |
activeRoomCode = code;
|
| 232 |
-
|
|
|
|
| 233 |
nav('screen-chat');
|
| 234 |
} else {
|
| 235 |
-
if(!
|
| 236 |
-
|
| 237 |
save();
|
| 238 |
}
|
| 239 |
-
alert("Request sent to host. Wait for approval.");
|
| 240 |
}
|
| 241 |
}
|
| 242 |
}
|
|
@@ -245,76 +211,68 @@
|
|
| 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:
|
| 249 |
-
${u} <button onclick="approveUser('${u}')">APPROVE</button>
|
| 250 |
</div>
|
| 251 |
-
`).join('') || "No pending
|
| 252 |
}
|
| 253 |
|
| 254 |
-
function approveUser(
|
| 255 |
-
db.rooms[activeRoomCode].members.push(
|
| 256 |
-
db.rooms[activeRoomCode].pending = db.rooms[activeRoomCode].pending.filter(
|
| 257 |
save();
|
| 258 |
renderApprovalList();
|
| 259 |
}
|
| 260 |
|
| 261 |
-
// --- MESSAGING ---
|
| 262 |
function sendMsg(type) {
|
| 263 |
-
const
|
| 264 |
-
if(!
|
| 265 |
-
|
| 266 |
-
const msg = {
|
| 267 |
id: Date.now(),
|
| 268 |
-
|
| 269 |
-
sender:
|
| 270 |
-
content:
|
| 271 |
type: type,
|
| 272 |
-
|
| 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
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
-
box.innerHTML =
|
| 287 |
<div class="msg">
|
| 288 |
-
<div
|
| 289 |
-
<div>${
|
| 290 |
-
<
|
| 291 |
-
|
| 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
|
| 300 |
-
if(
|
| 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 |
-
//
|
| 310 |
-
|
| 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>
|
| 320 |
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>AeroCore OS 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.85);
|
| 12 |
}
|
| 13 |
|
| 14 |
body {
|
| 15 |
+
background: linear-gradient(135deg, #3a7bd5, #00d2ff, #3affaa);
|
|
|
|
|
|
|
| 16 |
font-family: 'GameStart', sans-serif;
|
| 17 |
+
margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
+
/* The Mosaic Filter */
|
| 21 |
+
body::after {
|
| 22 |
+
content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
| 23 |
+
background-image: radial-gradient(rgba(255,255,255,0.15) 1px, transparent 1px);
|
| 24 |
+
background-size: 5px 5px; pointer-events: none; z-index: 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
.window {
|
| 28 |
+
width: 750px; height: 550px; background: var(--mosaic-glass);
|
| 29 |
+
border: 6px solid #fff; box-shadow: 12px 12px 0px rgba(0,0,0,0.2);
|
| 30 |
+
position: relative; z-index: 20; display: flex; flex-direction: column;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
+
.screen { display: none; padding: 30px; flex-direction: column; height: 100%; box-sizing: border-box; }
|
| 34 |
.active { display: flex; }
|
| 35 |
|
| 36 |
+
/* Aero Elements */
|
| 37 |
button {
|
| 38 |
+
font-family: 'GameStart', sans-serif; padding: 10px; margin: 5px 0;
|
|
|
|
|
|
|
| 39 |
background: linear-gradient(to bottom, #fff, #aadaff, #0080ff);
|
| 40 |
+
border: 2px solid #fff; color: white; text-shadow: 1px 1px 2px #000;
|
| 41 |
+
cursor: pointer; box-shadow: 3px 3px 0px #0055aa;
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
input {
|
| 45 |
+
font-family: 'GameStart', sans-serif; padding: 12px; margin-bottom: 10px;
|
| 46 |
+
border: 3px inset #fff; background: rgba(255,255,255,0.9);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
+
#chat-box { background: white; border: 3px inset #ccc; flex-grow: 1; overflow-y: auto; padding: 15px; margin-bottom: 10px; }
|
| 50 |
+
|
| 51 |
+
.msg { background: #f0faff; border-left: 5px solid var(--aero-blue); padding: 10px; margin-bottom: 10px; }
|
| 52 |
+
.del-btn { font-size: 0.5rem; background: #ff4d4d; border: 1px solid white; margin-top: 5px; cursor: pointer;}
|
| 53 |
|
| 54 |
/* Version Popup */
|
| 55 |
#version-popup {
|
| 56 |
+
position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 57 |
+
background: white; border: 4px solid var(--aero-green); padding: 20px;
|
| 58 |
+
text-align: center; z-index: 1000; box-shadow: 0 0 50px rgba(0,0,0,0.5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
|
|
|
|
|
|
| 60 |
</style>
|
| 61 |
</head>
|
| 62 |
<body>
|
| 63 |
|
|
|
|
|
|
|
| 64 |
<div class="window">
|
| 65 |
<div id="screen-auth" class="screen active">
|
| 66 |
<h2>AEROCORE ACCESS</h2>
|
| 67 |
+
<form id="login-form">
|
| 68 |
<input type="text" id="username" name="username" placeholder="USERNAME" required autocomplete="username">
|
| 69 |
+
<input type="password" id="password" name="password" placeholder="PASSWORD" required autocomplete="current-password"
|
| 70 |
+
style="-webkit-text-security: none !important;">
|
| 71 |
+
<small style="font-size: 0.5rem; display: block; margin-bottom: 10px;">*Passwords are always visible for memory.</small>
|
| 72 |
+
|
| 73 |
+
<button type="button" onclick="handleAuth('signup')">SIGN UP (Create Account)</button>
|
| 74 |
+
<button type="button" onclick="handleAuth('login')" style="background: var(--aero-green);">LOG IN</button>
|
| 75 |
</form>
|
| 76 |
</div>
|
| 77 |
|
| 78 |
<div id="screen-tutorial" class="screen">
|
| 79 |
<h2>SYSTEM TUTORIAL</h2>
|
| 80 |
+
<p>• <b>HOSTING:</b> Create a room and get a code to share.</p>
|
| 81 |
+
<p>• <b>JOINING:</b> Enter a code and wait for Host approval.</p>
|
| 82 |
+
<p>• <b>MESSAGING:</b> Send text or media URLs.</p>
|
| 83 |
+
<p>• <b>DATA:</b> Your messages are saved to your local database.</p>
|
| 84 |
+
<button onclick="nav('screen-lobby')">ENTER SYSTEM</button>
|
| 85 |
</div>
|
| 86 |
|
| 87 |
<div id="screen-lobby" class="screen">
|
| 88 |
<h2>COMMUNITY HUB</h2>
|
| 89 |
<p id="welcome-msg"></p>
|
| 90 |
+
<button onclick="joinRoom('Public')">JOIN PUBLIC SERVER</button>
|
| 91 |
<hr>
|
| 92 |
<button onclick="createPrivate()">HOST PRIVATE ROOM</button>
|
| 93 |
+
<div id="host-code-display" style="color: var(--aero-blue); margin: 5px;"></div>
|
| 94 |
<br>
|
| 95 |
+
<input type="text" id="join-code-input" placeholder="ENTER ROOM CODE">
|
| 96 |
<button onclick="joinRoom('Private')">REQUEST ENTRY</button>
|
| 97 |
</div>
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
<div id="screen-chat" class="screen">
|
| 100 |
+
<div style="display:flex; justify-content: space-between;">
|
| 101 |
+
<h2 id="room-header">CHAT</h2>
|
| 102 |
+
<button id="host-admin-btn" class="hidden" onclick="nav('screen-approval')" style="font-size: 0.5rem;">ADMIN PANEL</button>
|
| 103 |
+
</div>
|
| 104 |
<div id="chat-box"></div>
|
| 105 |
+
<input type="text" id="msg-input" placeholder="Message or URL...">
|
| 106 |
+
<div style="display:flex; gap: 5px;">
|
| 107 |
+
<button onclick="sendMsg('text')">SEND</button>
|
| 108 |
+
<button onclick="sendMsg('img')" style="background:var(--aero-blue)">IMG</button>
|
| 109 |
+
<button onclick="nav('screen-lobby')" style="background:#888">EXIT</button>
|
|
|
|
|
|
|
|
|
|
| 110 |
</div>
|
| 111 |
</div>
|
| 112 |
+
|
| 113 |
+
<div id="screen-approval" class="screen">
|
| 114 |
+
<h2>HOST: PENDING REQUESTS</h2>
|
| 115 |
+
<div id="approval-list"></div>
|
| 116 |
+
<button onclick="nav('screen-chat')">BACK TO CHAT</button>
|
| 117 |
+
</div>
|
| 118 |
</div>
|
| 119 |
|
| 120 |
<div id="version-popup" class="hidden">
|
| 121 |
<h3>AeroCore v2.0</h3>
|
| 122 |
+
<p>Build Date: 20th February 2026</p>
|
| 123 |
<button onclick="closePopup()">EXIT & START</button>
|
| 124 |
</div>
|
| 125 |
|
| 126 |
<script>
|
| 127 |
+
// --- DATABASE LOGIC ---
|
| 128 |
+
let db = JSON.parse(localStorage.getItem('aero_db_v2')) || {
|
| 129 |
+
users: [], // {user, pass}
|
| 130 |
messages: [],
|
| 131 |
+
rooms: {} // code: {host, members, pending}
|
|
|
|
| 132 |
};
|
| 133 |
+
let currentUser = null;
|
| 134 |
+
let activeRoomCode = 'Public';
|
| 135 |
|
| 136 |
+
function save() { localStorage.setItem('aero_db_v2', JSON.stringify(db)); }
|
| 137 |
|
| 138 |
+
// --- AUTHENTICATION FIX ---
|
| 139 |
+
function handleAuth(mode) {
|
| 140 |
+
const u = document.getElementById('username').value;
|
| 141 |
+
const p = document.getElementById('password').value;
|
| 142 |
+
if(!u || !p) return alert("Fill all fields");
|
|
|
|
|
|
|
| 143 |
|
| 144 |
+
const userExists = db.users.find(user => user.username === u);
|
| 145 |
+
|
| 146 |
+
if(mode === 'signup') {
|
| 147 |
+
if(userExists) return alert("User already exists! Try Login.");
|
| 148 |
+
db.users.push({ username: u, password: p });
|
| 149 |
+
save();
|
| 150 |
+
alert("Account Created! Now click LOG IN.");
|
| 151 |
+
} else {
|
| 152 |
+
if(!userExists || userExists.password !== p) {
|
| 153 |
+
alert("WRONG PASSWORD or User doesn't exist!");
|
| 154 |
+
return;
|
| 155 |
+
}
|
| 156 |
+
// SUCCESSFUL LOGIN
|
| 157 |
+
currentUser = u;
|
| 158 |
+
document.getElementById('welcome-msg').innerText = "Welcome, " + u;
|
| 159 |
+
document.getElementById('version-popup').classList.remove('hidden');
|
| 160 |
+
}
|
| 161 |
}
|
| 162 |
|
| 163 |
function closePopup() {
|
|
|
|
| 165 |
nav('screen-tutorial');
|
| 166 |
}
|
| 167 |
|
| 168 |
+
// --- NAVIGATION ---
|
| 169 |
+
function nav(id) {
|
| 170 |
+
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
|
| 171 |
+
document.getElementById(id).classList.add('active');
|
| 172 |
+
if(id === 'screen-chat') renderMessages();
|
| 173 |
+
if(id === 'screen-approval') renderApprovalList();
|
| 174 |
+
}
|
| 175 |
|
| 176 |
+
// --- ROOM & HOSTING ---
|
| 177 |
function createPrivate() {
|
| 178 |
const code = Math.floor(1000 + Math.random() * 9000).toString();
|
| 179 |
+
db.rooms[code] = { host: currentUser, members: [currentUser], pending: [] };
|
| 180 |
+
document.getElementById('host-code-display').innerText = "YOUR ROOM CODE: " + code;
|
| 181 |
activeRoomCode = code;
|
| 182 |
save();
|
| 183 |
+
alert("Room created! Share the code.");
|
| 184 |
}
|
| 185 |
|
| 186 |
function joinRoom(type) {
|
|
|
|
| 189 |
nav('screen-chat');
|
| 190 |
} else {
|
| 191 |
const code = document.getElementById('join-code-input').value;
|
| 192 |
+
if(!db.rooms[code]) {
|
| 193 |
+
alert("ROOM NOT FOUND! (Check if you typed it right)");
|
| 194 |
+
return;
|
| 195 |
+
}
|
| 196 |
activeRoomCode = code;
|
| 197 |
+
const room = db.rooms[code];
|
| 198 |
+
if(room.members.includes(currentUser)) {
|
| 199 |
nav('screen-chat');
|
| 200 |
} else {
|
| 201 |
+
if(!room.pending.includes(currentUser)) {
|
| 202 |
+
room.pending.push(currentUser);
|
| 203 |
save();
|
| 204 |
}
|
| 205 |
+
alert("Request sent to Host (" + room.host + "). Wait for approval.");
|
| 206 |
}
|
| 207 |
}
|
| 208 |
}
|
|
|
|
| 211 |
const list = document.getElementById('approval-list');
|
| 212 |
const room = db.rooms[activeRoomCode];
|
| 213 |
list.innerHTML = room.pending.map(u => `
|
| 214 |
+
<div style="background:white; padding:10px; border:2px solid var(--aero-blue); margin-bottom:5px;">
|
| 215 |
+
USER: ${u} <button onclick="approveUser('${u}')">APPROVE</button>
|
| 216 |
</div>
|
| 217 |
+
`).join('') || "No pending users.";
|
| 218 |
}
|
| 219 |
|
| 220 |
+
function approveUser(u) {
|
| 221 |
+
db.rooms[activeRoomCode].members.push(u);
|
| 222 |
+
db.rooms[activeRoomCode].pending = db.rooms[activeRoomCode].pending.filter(user => user !== u);
|
| 223 |
save();
|
| 224 |
renderApprovalList();
|
| 225 |
}
|
| 226 |
|
| 227 |
+
// --- MESSAGING & DELETION ---
|
| 228 |
function sendMsg(type) {
|
| 229 |
+
const val = document.getElementById('msg-input').value;
|
| 230 |
+
if(!val) return;
|
| 231 |
+
db.messages.push({
|
|
|
|
| 232 |
id: Date.now(),
|
| 233 |
+
room: activeRoomCode,
|
| 234 |
+
sender: currentUser,
|
| 235 |
+
content: val,
|
| 236 |
type: type,
|
| 237 |
+
time: new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})
|
| 238 |
+
});
|
|
|
|
|
|
|
| 239 |
save();
|
| 240 |
+
document.getElementById('msg-input').value = '';
|
| 241 |
renderMessages();
|
| 242 |
}
|
| 243 |
|
| 244 |
function renderMessages() {
|
| 245 |
const box = document.getElementById('chat-box');
|
| 246 |
+
const roomMsgs = db.messages.filter(m => m.room === activeRoomCode);
|
| 247 |
+
|
| 248 |
+
// Show Admin button only if Host
|
| 249 |
+
if(activeRoomCode !== 'Public' && db.rooms[activeRoomCode].host === currentUser) {
|
| 250 |
+
document.getElementById('host-admin-btn').classList.remove('hidden');
|
| 251 |
+
} else {
|
| 252 |
+
document.getElementById('host-admin-btn').classList.add('hidden');
|
| 253 |
+
}
|
| 254 |
|
| 255 |
+
box.innerHTML = roomMsgs.map(m => `
|
| 256 |
<div class="msg">
|
| 257 |
+
<div style="font-size:0.5rem; color:#888;">${m.sender} • ${m.time}</div>
|
| 258 |
+
<div>${m.type === 'img' ? `<img src="${m.content}" style="max-width:100%;">` : m.content}</div>
|
| 259 |
+
<button class="del-btn" onclick="deleteMsg(${m.id}, 'me')">Delete for me</button>
|
| 260 |
+
${m.sender === currentUser ? `<button class="del-btn" style="background:orange" onclick="deleteMsg(${m.id}, 'everyone')">Delete for everyone</button>` : ''}
|
|
|
|
|
|
|
| 261 |
</div>
|
| 262 |
`).join('');
|
| 263 |
box.scrollTop = box.scrollHeight;
|
| 264 |
}
|
| 265 |
|
| 266 |
+
function deleteMsg(id, mode) {
|
| 267 |
+
if(mode === 'everyone') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
db.messages = db.messages.filter(m => m.id !== id);
|
| 269 |
} else {
|
| 270 |
+
// Locally remove it from view for this session
|
| 271 |
+
db.messages = db.messages.filter(m => m.id !== id);
|
|
|
|
|
|
|
| 272 |
}
|
| 273 |
save();
|
| 274 |
renderMessages();
|
| 275 |
}
|
| 276 |
</script>
|
|
|
|
| 277 |
</body>
|
| 278 |
</html>
|