-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunity.html
More file actions
158 lines (131 loc) · 7.09 KB
/
Copy pathcommunity.html
File metadata and controls
158 lines (131 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<title>Hellcore | Community Chat</title>
<style>
/* Restored and updated body for shading */
body {
margin: 0;
padding: 0;
font-family: 'Segoe UI', sans-serif;
background-color: #050505; /* Fallback color */
background-image: url('shadimg.png'); /* Shaded background */
background-size: cover;
background-position: center;
color: white;
}
.overlay { min-height: 100vh; width: 100%; display: flex; flex-direction: column; align-items: center; }
/* --- NAV --- */
nav { display: flex; justify-content: center; gap: 15px; margin: 20px 0; flex-wrap: wrap; }
nav a { text-decoration: none; color: #fff; padding: 10px 18px; border-radius: 5px; transition: 0.3s; font-weight: 600; background: rgba(255, 255, 255, 0.05); }
nav a.active { color: #ff4e00; border: 1px solid #ff4e00; }
/* --- AUTH BOX --- */
.auth-container { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 78, 0, 0.3); padding: 40px; border-radius: 20px; width: 100%; max-width: 400px; margin-top: 50px; text-align: center; backdrop-filter: blur(5px); }
.auth-container h2 { color: #ff4e00; margin-bottom: 20px; }
input { width: 100%; padding: 12px; margin: 10px 0; background: rgba(17, 17, 17, 0.8); border: 1px solid #333; color: white; border-radius: 8px; box-sizing: border-box; outline: none; }
input:focus { border-color: #ff4e00; }
.submit-btn { width: 100%; background: #ff4e00; color: white; border: none; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.3s; margin-top: 10px; }
.submit-btn:hover { background: #ff7700; transform: translateY(-2px); }
/* --- CHAT BOX --- */
.chat-container { display: none; width: 90%; max-width: 800px; height: 70vh; background: rgba(255, 255, 255, 0.02); border: 1px solid #222; border-radius: 15px; margin-top: 20px; flex-direction: column; overflow: hidden; backdrop-filter: blur(5px); }
.chat-header { padding: 15px; background: rgba(255, 78, 0, 0.1); border-bottom: 1px solid #ff4e00; display: flex; justify-content: space-between; align-items: center; }
#chatDisplay { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 15px; border-radius: 10px; max-width: 70%; position: relative; }
.msg-other { background: rgba(34, 34, 34, 0.8); align-self: flex-start; border-left: 3px solid #ff4e00; }
.msg-me { background: #ff4e00; align-self: flex-end; }
.msg-user { font-size: 0.7rem; color: #aaa; margin-bottom: 4px; display: block; }
.chat-input-group { padding: 20px; background: rgba(10, 10, 10, 0.9); display: flex; gap: 10px; }
#messageInput { margin: 0; }
</style>
</head>
<body>
<div class="overlay">
<header><img src="logo.webp" class="logo" style="max-width: 150px; margin-top: 20px;"></header>
<nav>
<a href="home.html">Home</a>
<a href="community.html" class="active">Community Chat</a>
<a href="forums.html">Forums</a>
</nav>
<div id="authBox" class="auth-container">
<h2 id="authTitle">Join Hellcore</h2>
<input type="text" id="username" placeholder="Choose Username">
<input type="password" id="password" placeholder="Password">
<button class="submit-btn" onclick="handleAuth()">Login / Register</button>
<p id="authSwitch" style="font-size: 0.8rem; color: #666; margin-top: 15px;">Your account is saved locally.</p>
</div>
<div id="chatBox" class="chat-container">
<div class="chat-header">
<span id="welcomeUser">Global Chat</span>
<button onclick="logout()" style="background:none; border:none; color:#ff4e00; cursor:pointer;">Logout</button>
</div>
<div id="chatDisplay"></div>
<div class="chat-input-group">
<input type="text" id="messageInput" placeholder="Type a message..." onkeypress="if(event.key==='Enter') sendMessage()">
<button class="submit-btn" onclick="sendMessage()" style="width: 80px; margin: 0;">Send</button>
</div>
</div>
</div>
<script>
let currentUser = localStorage.getItem('loggedUser') || null;
window.onload = () => {
if(currentUser) showChat();
loadMessages();
};
function handleAuth() {
const user = document.getElementById('username').value.trim();
const pass = document.getElementById('password').value.trim();
if(user.length < 3) return alert("Username too short!");
let users = JSON.parse(localStorage.getItem('users_db')) || {};
if(users[user]) {
if(users[user] === pass) {
login(user);
} else {
alert("Wrong password!");
}
} else {
users[user] = pass;
localStorage.setItem('users_db', JSON.stringify(users));
login(user);
}
}
function login(user) {
currentUser = user;
localStorage.setItem('loggedUser', user);
showChat();
}
function logout() {
localStorage.removeItem('loggedUser');
location.reload();
}
function showChat() {
document.getElementById('authBox').style.display = 'none';
document.getElementById('chatBox').style.display = 'flex';
document.getElementById('welcomeUser').innerText = `Logged in as: ${currentUser}`;
}
function sendMessage() {
const input = document.getElementById('messageInput');
const text = input.value.trim();
if(!text) return;
let messages = JSON.parse(localStorage.getItem('chat_messages_db')) || [];
messages.push({ user: currentUser, text: text, time: Date.now() });
localStorage.setItem('chat_messages_db', JSON.stringify(messages));
input.value = "";
loadMessages();
}
function loadMessages() {
const display = document.getElementById('chatDisplay');
const messages = JSON.parse(localStorage.getItem('chat_messages_db')) || [];
display.innerHTML = messages.map(m => `
<div class="msg ${m.user === currentUser ? 'msg-me' : 'msg-other'}">
<span class="msg-user">${m.user}</span>
${m.text}
</div>
`).join('');
display.scrollTop = display.scrollHeight;
}
setInterval(loadMessages, 2000);
</script>
</body>
</html>