diff --git a/index.js b/index.js index 05c510b..2371daa 100644 --- a/index.js +++ b/index.js @@ -5,18 +5,17 @@ const http = require("http"); const server = http.createServer(app); const io = require("socket.io")(server, { cors: { - origin: "https://ewebglobal.com.au", + origin: "https://example.com", methods: ["GET", "POST"], }, }); const { Client, Intents, Collection, ThreadManager } = require("discord.js"); const dotenv = require("dotenv"); const uuid = require("uuid"); -const port = process.env.PORT || 3000; +const port = process.env.PORT || 40091; const fs = require("fs"); dotenv.config(); -app.use(express.static("public")); const client = new Client({ intents: [ Intents.FLAGS.GUILDS, @@ -74,10 +73,6 @@ client.once("ready", async () => { }); }); -app.get("/", (req, res) => { - res.sendFile(__dirname + "/public/index.html"); -}); - server.listen(port, () => { console.log(`Socket.IO server running at http://localhost:${port}/`); }); diff --git a/public/client.js b/public/client.js index 1e21266..5ff9a25 100644 --- a/public/client.js +++ b/public/client.js @@ -1,4 +1,10 @@ -var socket = io(); +var socket = io("", { + cors: { + origin: "https://example.com", + methods: ["GET", "POST"], + }, + transports: ["polling"], +}); var messages = document.getElementById("messages"); var form = document.getElementById("form"); @@ -25,10 +31,8 @@ form.addEventListener( socket.on("reply", function (msg) { var item = document.createElement("div"); item.classList.add("message"); - item.classList.add("messages-content"); item.textContent = `EWEB: ${msg}`; messages.appendChild(item); - window.scrollTo(0, document.body.scrollHeight); }); socket.on("chat message", function (msg) { var item = document.createElement("div"); @@ -36,5 +40,4 @@ socket.on("chat message", function (msg) { item.classList.add("message"); item.textContent = `You: ${msg}`; messages.appendChild(item); - window.scrollTo(0, document.body.scrollHeight); }); diff --git a/public/css.css b/public/css.css index c2bc503..d230424 100644 --- a/public/css.css +++ b/public/css.css @@ -60,6 +60,7 @@ } .message { + color: black; clear: both; float: left; padding: 6px 10px 7px; @@ -68,7 +69,7 @@ margin: 8px 0; font-size: 14px; line-height: 1.4; - margin-left: 35px; + margin-left: 5px; position: relative; border: 1px solid #ccc; /* text-shadow: 0 1px 1px rgb(0 0 0 / 20%); */ diff --git a/public/index.html b/public/index.html index 1321934..f9813b2 100644 --- a/public/index.html +++ b/public/index.html @@ -1,68 +1,19 @@ - - - - Socket.IO chat - - - -
-
-
-

EWEB Chat

-
-
-
-
-
- - - -
-
-
- - - - - +
+
+
+

EWEB Chat

+
+
+
+
+
+ + +
+
+