Browse files

that was easier than I thought. updated readme a bit more and. Need t…

…o js doc the plugin and see if I've missed anything else
  • Loading branch information...
1 parent 38df823 commit 25130e31f87b511e458c436e98478ea60aa07d3a William Harris committed Mar 30, 2011
Showing with 40 additions and 33 deletions.
  1. +12 −4 README.md
  2. +1 −29 client/js/jquery.socket.io.js
  3. +26 −0 client/js/main.js
  4. +1 −0 server-example/views/layout.jade
View
16 README.md
@@ -3,7 +3,7 @@
$(document).ready( function () {
- var jqSH = $.socketHandler();
+ var jqSH = $.socketio();
// greet the user on their console
$(jqSH).bind('greeting', function(event, message){
@@ -14,19 +14,27 @@
});
+## How it works
-## Repository Layout
+It binds:
-the wrapper branch shows how it works behind the scenes
+1) socket.io messages sent from the server to jquery events and
-the master or plugin branch allows you to just include and go
+2) jquery events fired from the browser to socket.io messages sent from the client
## Usage
there is both a client and a (node.js) server example in this repository to help you get started
+## Repository Layout
+
+the wrapper branch shows how it works behind the scenes
+
+the master or plugin branch allows you to just include and go
+
+
## Credits
client code and parts of the server code inspired by this article
View
30 client/js/jquery.socket.io.js
@@ -1,6 +1,6 @@
(function( $ ){
- $.socketHandler = function() {
+ $.socketio = function() {
// Create SocketIO instance, connect
var socket = new io.Socket();
@@ -45,31 +45,3 @@
}
})( jQuery );
-
-
-$(document).ready( function () {
-
- var jqSH = $.socketHandler();
-
- // greet the user on their console
- $(jqSH).bind('greeting', function(event, message){
-
- if(window.console) console.log(message);
-
- });
-
- //the client is calling the client
- $(jqSH).bind('calling', function(event, message){
-
- var messageContainer = $("div#message");
-
- if (messageContainer.length) {
-
- messageContainer.effect("pulsate", { times:6 }, 1500);
- messageContainer.text(message);
-
- }
-
- });
-
-});
View
26 client/js/main.js
@@ -0,0 +1,26 @@
+$(document).ready( function () {
+
+ var jqSH = $.socketio();
+
+ // greet the user on their console
+ $(jqSH).bind('greeting', function(event, message){
+
+ if(window.console) console.log(message);
+
+ });
+
+ //the client is calling the client
+ $(jqSH).bind('calling', function(event, message){
+
+ var messageContainer = $("div#message");
+
+ if (messageContainer.length) {
+
+ messageContainer.effect("pulsate", { times:6 }, 1500);
+ messageContainer.text(message);
+
+ }
+
+ });
+
+});
View
1 server-example/views/layout.jade
@@ -7,6 +7,7 @@ html
script(src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js")
script(src="socket.io/socket.io.js")
script(src="js/jquery.socket.io.js")
+ script(src="js/main.js")
link(rel="stylesheet", type="text/css", href="css/styles.css")
body

0 comments on commit 25130e3

Please sign in to comment.