Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update packaging and client for v2.0+
- Loading branch information
Showing
2 changed files
with
45 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |