first commit
This commit is contained in:
60
templates/chat.html
Normal file
60
templates/chat.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<style>
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
div {
|
||||
height: 88vh;
|
||||
width:100%;
|
||||
background-color: black;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
font-family: 'Consolas', 'Arial', sans-serif;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>WebChat...?</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script>
|
||||
<script>
|
||||
var socket;
|
||||
var nick = "dupel" + Math.round(Math.random() * 1000);
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.getElementById("nick").innerText = "Chatting as: " + nick;
|
||||
dick = document.getElementById("messages");
|
||||
box = document.getElementById("message");
|
||||
socket = io();
|
||||
socket.on("connect", function() {
|
||||
cpplus = document.createElement("p");
|
||||
cpplus.innerText = "Connected";
|
||||
dick.append(cpplus);
|
||||
})
|
||||
socket.on("disconnect", function() {
|
||||
cpplus = document.createElement("p");
|
||||
cpplus.innerText = "Disconnected";
|
||||
dick.append(cpplus);
|
||||
})
|
||||
socket.on("message", function(msg) {
|
||||
cpplus = document.createElement("p");
|
||||
cpplus.innerText = msg;
|
||||
dick.append(cpplus);
|
||||
})
|
||||
box.onkeypress = function(e) {
|
||||
if (e.key == "Enter") {
|
||||
socket.send(nick + "> " + box.value);
|
||||
box.value = "";
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<label id="nick"></label>
|
||||
<div id="messages" />
|
||||
<textarea rows="2" placeholder="We neeed to figure shit out..." id="message"></textarea>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user