Skip to content

Commit

Permalink
Projet name was changed to Remote Control
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydson committed Nov 7, 2012
1 parent 90c8b10 commit bdfaeec
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
@@ -1,8 +1,8 @@
# Remote Slide
Remote Slide is a tool to control your HTML5 presentation slides remotely
# Remote Control
Remote Control is a tool to control your HTML5 presentation slides remotely

## The goal
The idea of Remote Slide is provide a way to control the slides of a HTML5 presentantion, remotely.
The idea of Remote Control is provide a way to control the slides of a HTML5 presentantion, remotely.
Your phone is your remote control!

## Dependencies
Expand All @@ -12,7 +12,7 @@ Your phone is your remote control!
* A modern Web Browser with WebSockets support in your phone [can i use websockets?](http://caniuse.com/#search=websockets)

## How it works
Remote Slide is based on [WebSockets](https://developer.mozilla.org/en-US/docs/WebSockets), so you may have a good and modern browser, like Firefox, Chrome or Opera.
Remote Control is based on [WebSockets](https://developer.mozilla.org/en-US/docs/WebSockets), so you may have a good and modern browser, like Firefox, Chrome or Opera.
The phone send a message through WebSockets to the server.
The server receive the message as an action that must be executed, like 'next' or 'previous'.
This action are emited to the HTML5 presentation.
Expand All @@ -36,7 +36,7 @@ The server will be available at port 81 [http:localhost:81](http:localhost:81),
Now, you need to add 2 JavaScript libraries to your HTML5 presentation:
```html
<script src="http://localhost:81/socket.io/socket.io.js"></script>
<script src="path/to/remote-slide.js"></script>
<script src="path/to/remote-control.js"></script>
```

You're almost ready to start the presentation!
Expand Down
6 changes: 3 additions & 3 deletions packge.json
@@ -1,7 +1,7 @@
{
"name": "remote-slide",
"name": "remote-control",
"version": "0.0.1",
"description": "Remote Slide is a remote slide tool",
"description": "Remote Control is a remote slide tool",
"main": "app.js",
"directories": {

Expand All @@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jaydson/remote-slide.git"
"url": "https://github.com/braziljs/remote-control.git"
},
"keywords": [
"slides",
Expand Down
62 changes: 62 additions & 0 deletions remote-control.js
@@ -0,0 +1,62 @@
/*global window*/
if (!window.io) {
throw 'Socket.io library is required. Make sure that node server is up';
}

(function (io) {

'use strict';

var RemoteControl = function () {},

priv = {
socket : null,
connected : false,

setAction : function (action, fn) {
priv.socket.on(action, fn);
},

getHash : function (str) {
var hash = 0,
i = 0,
strLen = str.length,
ch = null;

if (strLen === 0) {
return hash;
}

for (i; i < strLen; i++) {
ch = str.charCodeAt(i);
hash = ((hash << 5) - hash) + ch;
hash = hash & hash;
}

return Math.abs(hash);
}
};

RemoteControl.prototype.connect = function (socketserver) {
if (priv.connected === false) {
priv.socket = io.connect(socketserver);
priv.connected = true;
}
};

RemoteControl.prototype.on = function (action, fn) {
if (priv.connected) {
priv.setAction(action, fn);
} else {
throw '#RemoteControl - You must to connect before!';
}
};

RemoteControl.prototype.sync = function (pattern) {
pattern = priv.getHash((pattern || window.location.href));
priv.socket.emit('requestSync', pattern);
return pattern;
};

window.RemoteControl = RemoteControl;
}(window.io));

0 comments on commit bdfaeec

Please sign in to comment.