Skip to content

Instantly share code, notes, and snippets.

@darkyen
Created September 22, 2012 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkyen/3766018 to your computer and use it in GitHub Desktop.
Save darkyen/3766018 to your computer and use it in GitHub Desktop.
Second
var uuid = require( 'node-uuid' ),
engines = require( './engines.js' ),
util = require( './util.js' );
/**
* This is what the code must do:
* - Connect to the websocket.
* - Create a channel which name is a generated UUID.
* - Listen on "send key" event from the websocket to get
* a keyCode.
* - Inject some code to run the next/previous command
*/
var socket = io.connect( 'http://remoteprez.margaine.com:8080/' );
var channel = uuid.v4(),
engine = engines.guess();
function MapEm(){
return { top:arguments[0],
bottom:arguments[1],
left:arguments[2],
right:arguments[3]
};
}
var mapping = {
'impress.js': MapEm('impress().prev()','impress().next()','impress().prev()','impress().next()'),\
'reveal.js': MapEm('Reveal.navigateUp()','Reveal.navigateDown()','Reveal.navigateLeft()','Reveal.navigateRight()'),
'html5slides':MapEm('prevSlide()','nextSlide()','prevSlide()','nextSlide()'),
'csss': MapEm('slideshow.previous()','slideshow.next()','slideshow.previous()','slideshow.next()');
};
if ( !engine ) {
alert( "You're not on a supported presentation page. Sorry." );
}
else {
socket.on( 'connect', function() {
// Emit an event to create the channel
socket.emit( 'create channel', channel );
// Display the link/qrcode
require( './html.js' )( channel, engine );
// Listen on the "send key" event
socket.on( 'send direction', function( engine, direction ) {
// Mapping object
// Just inject the right function
util.injectCode( mapping[ engine ][ direction ] );
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment