2012-08-05 13:48:55 +00:00
|
|
|
(function() {
|
|
|
|
// don't emit events from inside the previews themselves
|
|
|
|
if ( window.location.search.match( /receiver/gi ) ) { return; }
|
2013-03-09 00:05:58 +00:00
|
|
|
var multiplex = Reveal.getConfig().multiplex;
|
2012-08-05 13:48:55 +00:00
|
|
|
|
|
|
|
var socket = io.connect(multiplex.url);
|
2013-03-08 23:49:28 +00:00
|
|
|
|
2013-04-05 18:45:17 +00:00
|
|
|
var notify = function( slideElement, indexh, indexv, origin ) {
|
|
|
|
if( typeof origin === 'undefined' && origin !== 'remote' ) {
|
|
|
|
var nextindexh;
|
|
|
|
var nextindexv;
|
|
|
|
|
|
|
|
var fragmentindex = Reveal.getCurrentFragmentIndex();
|
|
|
|
if (typeof fragmentindex == 'undefined') {
|
|
|
|
fragmentindex = 0;
|
|
|
|
}
|
2012-08-05 13:48:55 +00:00
|
|
|
|
2013-04-05 18:45:17 +00:00
|
|
|
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
|
|
|
|
nextindexh = indexh;
|
|
|
|
nextindexv = indexv + 1;
|
|
|
|
} else {
|
|
|
|
nextindexh = indexh + 1;
|
|
|
|
nextindexv = 0;
|
|
|
|
}
|
2012-08-05 13:48:55 +00:00
|
|
|
|
2013-04-05 18:45:17 +00:00
|
|
|
var slideData = {
|
|
|
|
indexh : indexh,
|
|
|
|
indexv : indexv,
|
|
|
|
indexf : fragmentindex,
|
|
|
|
nextindexh : nextindexh,
|
|
|
|
nextindexv : nextindexv,
|
|
|
|
secret: multiplex.secret,
|
|
|
|
socketId : multiplex.id
|
|
|
|
};
|
|
|
|
|
|
|
|
socket.emit('slidechanged', slideData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'slidechanged', function( event ) {
|
|
|
|
notify( event.currentSlide, event.indexh, event.indexv, event.origin );
|
2012-08-05 13:48:55 +00:00
|
|
|
} );
|
2013-04-05 18:45:17 +00:00
|
|
|
|
|
|
|
var fragmentNotify = function( event ) {
|
|
|
|
notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
|
|
|
|
};
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'fragmentshown', fragmentNotify );
|
|
|
|
Reveal.addEventListener( 'fragmenthidden', fragmentNotify );
|
|
|
|
}());
|