Spaces:
Running
Running
Update index.html
Browse files- index.html +70 -18
index.html
CHANGED
@@ -1,19 +1,71 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Trollbox Lite</title>
|
6 |
+
<script src="https://cdn.socket.io/2.3.0/socket.io.min.js"></script>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<input id="username" type="text" placeholder="Enter your username">
|
10 |
+
<input id="message" type="text" placeholder="Type a message">
|
11 |
+
<button id="join">Join</button>
|
12 |
+
<button id="send">Send</button>
|
13 |
+
<ul id="messages"></ul>
|
14 |
+
|
15 |
+
<script>
|
16 |
+
const socket = io("https://www.windows93.net:8086", {
|
17 |
+
forceNew: true,
|
18 |
+
transportOptions: {
|
19 |
+
polling: {
|
20 |
+
extraHeaders: {
|
21 |
+
"Accept": "*/*",
|
22 |
+
"Accept-Encoding": "identity",
|
23 |
+
"Accept-Language": "*",
|
24 |
+
"Cache-Control": "no-cache",
|
25 |
+
"Connection": "keep-alive",
|
26 |
+
"Host": "www.windows93.net",
|
27 |
+
"Origin": "http://www.windows93.net",
|
28 |
+
"Pragma": "no-cache",
|
29 |
+
"Referer": 'http://www.windows93.net/trollbox/index.php',
|
30 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
});
|
35 |
+
|
36 |
+
// Join event
|
37 |
+
document.getElementById('join').onclick = function() {
|
38 |
+
const username = document.getElementById('username').value;
|
39 |
+
if (username) {
|
40 |
+
socket.emit("user joined", username, "lime", "", "");
|
41 |
+
alert(`Welcome ${username}!`);
|
42 |
+
document.getElementById('username').disabled = true; // Disable username input after joining
|
43 |
+
} else {
|
44 |
+
alert("Please enter a username.");
|
45 |
+
}
|
46 |
+
};
|
47 |
+
|
48 |
+
// Send message event
|
49 |
+
document.getElementById('send').onclick = function() {
|
50 |
+
const message = document.getElementById('message').value;
|
51 |
+
if (message) {
|
52 |
+
socket.send(message); // Send message directly
|
53 |
+
document.getElementById('message').value = ''; // Clear input
|
54 |
+
} else {
|
55 |
+
alert("Please enter a message.");
|
56 |
+
}
|
57 |
+
};
|
58 |
+
|
59 |
+
// Receive messages
|
60 |
+
socket.on("message", function(data) {
|
61 |
+
if (data.msg === "t!hello") {
|
62 |
+
socket.send("Hello, " + data.nick + "!"); // Respond to specific command
|
63 |
+
} else {
|
64 |
+
const item = document.createElement('li');
|
65 |
+
item.textContent = `${data.nick}: ${data.msg}`; // Display messages with sender's nickname
|
66 |
+
document.getElementById('messages').appendChild(item);
|
67 |
+
}
|
68 |
+
});
|
69 |
+
</script>
|
70 |
+
</body>
|
71 |
</html>
|