Skip to content

Instantly share code, notes, and snippets.

@darkyen

darkyen/Second.js

Created Sep 22, 2012
Embed
What would you like to do?
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
You can’t perform that action at this time.