Compare commits
No commits in common. '2b49232e6d40647f37d965c75e4c1aba44f039c9' and '2b4072a6b74cf913ceeb42e8ce547a6239a19823' have entirely different histories.
2b49232e6d
...
2b4072a6b7
@ -1,40 +1,8 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Chat App</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1> A new Chat App </h1>
|
||||
|
||||
<ul id='messages'></ul>
|
||||
<form id='form'>
|
||||
<input id='input'autocomplete='off'/><button type='submit'>Send</button>
|
||||
</form>
|
||||
|
||||
|
||||
<h1> Hello Angelus from index.html file </h1>
|
||||
<p>This is some text </p>
|
||||
<script src='/socket.io/socket.io.js'></script>
|
||||
<script>
|
||||
const socket = io();
|
||||
const form = document.getElementById('form');
|
||||
const input = document.getElementById('input');
|
||||
const messages = document.getElementById('messages');
|
||||
|
||||
// send message
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
if(input.value) {
|
||||
socket.emit('chat message',input.value);
|
||||
input.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
//receive message
|
||||
socket.on('chat message', function(msg){
|
||||
const item = document.createElement('li');
|
||||
item.textContent = msg;
|
||||
messages.appendChild(item);
|
||||
});
|
||||
</script>
|
||||
<script>var socket = io();</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue