mirror of
https://gitlab.com/pancakes1234/wdiscordbotserver.git
synced 2025-06-16 07:14:21 -06:00
Update index.html
This commit is contained in:
parent
1d59e8f320
commit
78cc9701a8
@ -23,22 +23,20 @@
|
||||
}
|
||||
#messages {
|
||||
max-height: 300px; overflow-y: auto; border: 1px solid #ddd; padding: 10px; margin-bottom: 10px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
#message-input, #username-input, #signin-username, #signin-password {
|
||||
width: 70%; margin-right: 5px; padding: 5px;
|
||||
}
|
||||
#message-input, #username-input {
|
||||
width: 70%; margin-right: 5px;
|
||||
}
|
||||
#username-button, #send-button, #signin-button {
|
||||
margin-top: 5px;
|
||||
}
|
||||
#user-details {
|
||||
margin-top: 20px;
|
||||
#username-button, #send-button, #dm-button, #signin-button {
|
||||
margin-top: 5px; padding: 5px 10px;
|
||||
}
|
||||
.server-owner {
|
||||
color: red; font-weight: bold;
|
||||
}
|
||||
.developer {
|
||||
color: blue; font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -59,14 +57,6 @@
|
||||
<input id="message-input" autocomplete="off" placeholder="Type your message...">
|
||||
<button id="send-button">Send</button>
|
||||
|
||||
<!-- Selected User Details -->
|
||||
<div id="user-details">
|
||||
<h3>Selected User</h3>
|
||||
<p><strong>Username:</strong> <span id="selected-username"></span></p>
|
||||
<p><strong>Default Username:</strong> <span id="selected-default-username"></span></p>
|
||||
<button id="dm-button" disabled>Direct Message</button>
|
||||
</div>
|
||||
|
||||
<!-- Sign-In Form -->
|
||||
<div id="sign-in">
|
||||
<h3>Sign In</h3>
|
||||
@ -74,52 +64,73 @@
|
||||
<input id="signin-password" type="password" placeholder="Password">
|
||||
<button id="signin-button">Sign In</button>
|
||||
</div>
|
||||
|
||||
<!-- Private Chat Button -->
|
||||
<button id="dm-button" disabled>Direct Message</button>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const socket = io();
|
||||
|
||||
// DOM Elements
|
||||
const messages = document.getElementById('messages');
|
||||
const userList = document.getElementById('user-list');
|
||||
const usernameInput = document.getElementById('username-input');
|
||||
const usernameButton = document.getElementById('username-button');
|
||||
const messageInput = document.getElementById('message-input');
|
||||
const sendButton = document.getElementById('send-button');
|
||||
const userList = document.getElementById('user-list');
|
||||
const selectedUsername = document.getElementById('selected-username');
|
||||
const selectedDefaultUsername = document.getElementById('selected-default-username');
|
||||
const dmButton = document.getElementById('dm-button');
|
||||
const signinButton = document.getElementById('signin-button');
|
||||
const signinUsername = document.getElementById('signin-username');
|
||||
const signinPassword = document.getElementById('signin-password');
|
||||
const dmButton = document.getElementById('dm-button');
|
||||
|
||||
let username = "Anonymous";
|
||||
let selectedUserId = null;
|
||||
|
||||
// Handle Sign-In
|
||||
// Handle User Sign-In
|
||||
signinButton.addEventListener('click', () => {
|
||||
const signInUsername = signinUsername.value.trim();
|
||||
const signInPassword = signinPassword.value.trim();
|
||||
const username = signinUsername.value.trim();
|
||||
const password = signinPassword.value.trim();
|
||||
|
||||
if (signInUsername && signInPassword) {
|
||||
socket.emit('sign in', { username: signInUsername, password: signInPassword });
|
||||
if (username && password) {
|
||||
socket.emit('sign in', { username, password });
|
||||
signinUsername.value = '';
|
||||
signinPassword.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
// Update the User List
|
||||
socket.on('update users', (users) => {
|
||||
userList.innerHTML = '';
|
||||
for (const [id, user] of Object.entries(users)) {
|
||||
const item = document.createElement('li');
|
||||
item.textContent = user.username;
|
||||
|
||||
if (user.role === 'Server Owner') {
|
||||
item.classList.add('server-owner');
|
||||
} else if (user.role === 'Developer') {
|
||||
item.classList.add('developer');
|
||||
}
|
||||
|
||||
// Handle selecting a user for DM
|
||||
item.addEventListener('click', () => {
|
||||
selectedUserId = id;
|
||||
dmButton.disabled = false;
|
||||
});
|
||||
|
||||
userList.appendChild(item);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Username Updates
|
||||
usernameButton.addEventListener('click', () => {
|
||||
const newUsername = usernameInput.value.trim();
|
||||
if (newUsername) {
|
||||
username = newUsername;
|
||||
socket.emit('set username', username);
|
||||
alert(`Your username is now set to: ${username}`);
|
||||
socket.emit('set username', newUsername);
|
||||
usernameInput.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
// Send Chat Message
|
||||
// Send General Chat Messages
|
||||
sendButton.addEventListener('click', () => {
|
||||
const message = messageInput.value.trim();
|
||||
if (message) {
|
||||
@ -128,26 +139,22 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Update Online User List
|
||||
socket.on('update users', (users) => {
|
||||
userList.innerHTML = '';
|
||||
for (const [id, user] of Object.entries(users)) {
|
||||
const item = document.createElement('li');
|
||||
item.textContent = user.username;
|
||||
if (user.isServerOwner) {
|
||||
item.classList.add('server-owner');
|
||||
}
|
||||
item.addEventListener('click', () => {
|
||||
selectedUserId = id;
|
||||
selectedUsername.textContent = user.username;
|
||||
selectedDefaultUsername.textContent = user.defaultUsername;
|
||||
dmButton.disabled = false;
|
||||
});
|
||||
userList.appendChild(item);
|
||||
// Display Chat Messages
|
||||
socket.on('chat message', (msg) => {
|
||||
const item = document.createElement('li');
|
||||
if (msg.role === 'Server Owner') {
|
||||
item.style.color = 'red';
|
||||
item.textContent = `[Server Owner] ${msg.username}: ${msg.text}`;
|
||||
} else if (msg.role === 'Developer') {
|
||||
item.style.color = 'blue';
|
||||
item.textContent = `[Developer] ${msg.username}: ${msg.text}`;
|
||||
} else {
|
||||
item.textContent = `${msg.username}: ${msg.text}`;
|
||||
}
|
||||
messages.appendChild(item);
|
||||
});
|
||||
|
||||
// Handle Direct Message Button
|
||||
// Handle DM Button Click
|
||||
dmButton.addEventListener('click', () => {
|
||||
if (selectedUserId) {
|
||||
socket.emit('request dm', selectedUserId);
|
||||
@ -156,54 +163,19 @@
|
||||
|
||||
// Handle DM Requests
|
||||
socket.on('dm request', ({ from, roomId }) => {
|
||||
alert("You have a direct message request. Redirecting to the private chat...");
|
||||
socket.emit('accept dm', roomId);
|
||||
if (confirm('You have a DM request. Would you like to accept it?')) {
|
||||
socket.emit('accept dm', roomId);
|
||||
window.location.href = `/DM${roomId}`;
|
||||
}
|
||||
});
|
||||
|
||||
// Redirect to Private Chat
|
||||
// Handle DM Redirection
|
||||
socket.on('redirect dm', (roomId) => {
|
||||
window.location.href = `/DM${roomId}`;
|
||||
});
|
||||
|
||||
// Display Chat Messages
|
||||
socket.on('chat message', (msg) => {
|
||||
const item = document.createElement('li');
|
||||
if (msg.isServerOwner) {
|
||||
item.style.color = 'red';
|
||||
item.textContent = `[Server Owner] ${msg.username}: ${msg.text}`;
|
||||
} else {
|
||||
item.textContent = `${msg.username}: ${msg.text}`;
|
||||
}
|
||||
messages.appendChild(item);
|
||||
});
|
||||
|
||||
// Handle Chat Lock Status
|
||||
socket.on('chat lock status', (lockStatus) => {
|
||||
alert(`Chat is now ${lockStatus ? 'locked' : 'unlocked'}.`);
|
||||
});
|
||||
|
||||
// Clear All Messages
|
||||
socket.on('chat history', (history) => {
|
||||
messages.innerHTML = '';
|
||||
history.forEach((msg) => {
|
||||
const item = document.createElement('li');
|
||||
if (msg.isServerOwner) {
|
||||
item.style.color = 'red';
|
||||
}
|
||||
item.textContent = `${msg.username}: ${msg.text}`;
|
||||
messages.appendChild(item);
|
||||
});
|
||||
});
|
||||
|
||||
// Notify If Chat Is Locked
|
||||
socket.on('chat locked', () => {
|
||||
alert('Chat is currently locked. You cannot send messages.');
|
||||
});
|
||||
</script>
|
||||
<h4>Made by the LearnHelp Dev Team and by Pancakes (Twitter @posey_zac)</h4>
|
||||
<h4>ISSUE BOARD</h4>
|
||||
<ul>
|
||||
<li>DM API is not working, so no messages are going through - level severe</li>
|
||||
</ul>
|
||||
<h4>made by learnhelp.cc dev team and pancakes</h4>
|
||||
<p>version 1.6.33.E</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user