Open Rafafrias2012 opened 2 months ago
To implement the /settings
command, we need to make changes to both the backend and frontend files. The backend will handle the command and emit an event to the client, while the frontend will display a settings dialog with buttons for /name
and /color
commands.
/settings
Command to the Command List:
/settings
in the commands
object.var commands = {
// ... other commands
settings: (victim, param) => {
victim.socket.emit("openSettingsDialog");
},
// ... other commands
};
/settings
command is triggered./* Settings Dialog Styles */
#settings-dialog {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1000; /* Sit on top */
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 300px; /* Could be more or less, depending on screen size */
background-color: #fff;
border: 1px solid #000;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
padding: 20px;
box-sizing: border-box;
}
#settings-dialog h2 {
margin-top: 0;
font-size: 18px;
text-align: center;
}
#settings-dialog .settings-buttons {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
#settings-dialog .settings-button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 5px;
}
#settings-dialog .settings-button:hover {
background-color: #45a049;
}
/* Overlay effect: to cover the entire screen when the dialog is open */
#settings-overlay {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 999; /* Sit below the dialog */
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* Black with opacity */
}
div
element that will serve as the container for the settings dialog./name
and /color
commands inside the settings dialog container.<!DOCTYPE html>
<html>
<head>
<title>PWNWORLD</title>
<meta charset="utf-8" />
<meta name="description" content="Welcome to Tuk-PakWORLD! Join a fun community based around BonziBUDDY without any rules! Chat, joke, share media and more!"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="thumbnail" content="./download.jpg" />
<link rel="stylesheet" id="stylesheet" type="text/css" href="./style.css">
<link rel="icon" type="image/png" href="./img/favicon.png" sizes="32x32">
<script src="./lib/easeljs.min.js"></script>
<script src="./lib/preloadjs-0.6.2.min.js"></script>
<script src="./lib/jquery.min.js"></script>
<script src="./lib/seedrandom.min.js"></script>
<script src="./lib/socket.io-1.4.5.js"></script>
<script src="./lib/speakjs/speakClient.js"></script>
<script src="./lib/jquery.contextMenu.min.js"></script>
<script src="https://kit.fontawesome.com/7eb4dccc86.js" crossorigin="anonymous"></script>
<script src="./script.js"></script>
</head>
<body>
<div id="content">
<!-- Existing content -->
<!-- ... -->
<!-- New settings dialog -->
<div id="settings-dialog">
<h2>Settings</h2>
<button id="name-command">Change Name</button>
<button id="color-command">Change Color</button>
<button id="close-settings">Close</button>
</div>
</div>
<div id="titlebar">
<div id="minimize"></div>
<div id="maximize"></div>
<div id="close"></div>
</div>
<ad></ad>
</body>
</html>
Add Event Listener for /settings
Command:
/settings
command from the server.Create Functions to Handle Button Clicks:
/name
and /color
button clicks.Update the DOM to Show/Hide the Settings Dialog:
// Existing code
// ...
// Add event listener for /settings command
socket.on("openSettingsDialog", () => {
document.getElementById("settings-dialog").style.display = "block";
document.getElementById("settings-overlay").style.display = "block";
});
// Handle button clicks
document.getElementById("name-command").addEventListener("click", () => {
socket.emit("command", { list: ["name"] });
closeSettingsDialog();
});
document.getElementById("color-command").addEventListener("click", () => {
socket.emit("command", { list: ["color"] });
closeSettingsDialog();
});
document.getElementById("close-settings").addEventListener("click", () => {
closeSettingsDialog();
});
// Function to close the settings dialog
function closeSettingsDialog() {
document.getElementById("settings-dialog").style.display = "none";
document.getElementById("settings-overlay").style.display = "none";
}
This implementation ensures that when a user types /settings
, the server will instruct the client to open the settings dialog. The dialog will contain buttons for /name
and /color
commands, and the appropriate actions will be taken when these buttons are clicked.
Click here to create a Pull Request with the proposed solution
Files used for this task:
Hey @autopilot add a settings command uses auto /name command and auto /color command and class dialog(html, buttons, callback)