Navigation Menu

Skip to content

Commit

Permalink
that was easier than I thought. updated readme a bit more and. Need t…
Browse files Browse the repository at this point in the history
…o js doc the plugin and see if I've missed anything else
  • Loading branch information
William Harris committed Mar 30, 2011
1 parent 38df823 commit 25130e3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
16 changes: 12 additions & 4 deletions README.md
Expand Up @@ -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){
Expand All @@ -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
Expand Down
30 changes: 1 addition & 29 deletions client/js/jquery.socket.io.js
@@ -1,6 +1,6 @@
(function( $ ){

$.socketHandler = function() {
$.socketio = function() {

// Create SocketIO instance, connect
var socket = new io.Socket();
Expand Down Expand Up @@ -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);

}

});

});
26 changes: 26 additions & 0 deletions 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);

}

});

});
1 change: 1 addition & 0 deletions server-example/views/layout.jade
Expand Up @@ -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
Expand Down

0 comments on commit 25130e3

Please sign in to comment.