Skip to content

Commit

Permalink
update packaging and client for v2.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Nov 10, 2018
1 parent 88307ae commit a880fec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
84 changes: 42 additions & 42 deletions server/index.html
@@ -1,50 +1,50 @@
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<style>
* {
margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(150, 150, 225); border: none; padding: 10px; }
#messages { list-style-type: none; margin: 0; padding: 10px; }
#messages li { padding: 5px 5px; }
#messages li:nth-child(odd) { background: #eee; }
#main {overflow: auto;
height: calc(100% - 30px);
margin-bottom: 40px;}
#footer {
<head>
<title>Socket.IO chat</title>
<style>
* {
margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(150, 150, 225); border: none; padding: 10px; }
#messages { list-style-type: none; margin: 0; padding: 10px; }
#messages li { padding: 5px 5px; }
#messages li:nth-child(odd) { background: #eee; }
#main {overflow: auto;
height: calc(100% - 30px);
margin-bottom: 40px;}
#footer {
position: fixed;
bottom: 0;
right: 0px;
left: 0px;
height: 30px;}
</style>
</head>
<body>
<div id="main">
<ul id="messages"></ul>
</div>
<div id="footer">
<form action="">
<input id="m" autocomplete="off" placeholder="Type here..." /><button>Send</button>
</form>
</div>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io();
$('form').submit(function(){
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
window.scrollTo(0,document.body.scrollHeight);
});
</script>
</body>
</style>
</head>
<body>
<div id="main">
<ul id="messages"></ul>
</div>
<div id="footer">
<form action="">
<input id="m" autocomplete="off" placeholder="Type here..." /><button>Send</button>
</form>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io();
$('form').submit(function(){
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
window.scrollTo(0,document.body.scrollHeight);
});
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions server/package.json
@@ -1,9 +1,9 @@
{
"name": "socket-chat-example",
"version": "0.0.1",
"description": "my first socket.io app",
"version": "0.2.0",
"description": "basic chat example server with web client",
"dependencies": {
"express": "4.10.2",
"socket.io": "1.4.0"
"socket.io": "^2.0.0"
}
}

0 comments on commit a880fec

Please sign in to comment.