2012-08-05 15:48:55 +02:00
|
|
|
(function() {
|
|
|
|
// don't emit events from inside the previews themselves
|
|
|
|
if ( window.location.search.match( /receiver/gi ) ) { return; }
|
2013-03-09 01:05:58 +01:00
|
|
|
var multiplex = Reveal.getConfig().multiplex;
|
2012-08-05 15:48:55 +02:00
|
|
|
|
|
|
|
var socket = io.connect(multiplex.url);
|
2013-03-09 00:49:28 +01:00
|
|
|
|
2013-04-05 20:45:17 +02:00
|
|
|
var notify = function( slideElement, indexh, indexv, origin ) {
|
|
|
|
if( typeof origin === 'undefined' && origin !== 'remote' ) {
|
|
|
|
var nextindexh;
|
|
|
|
var nextindexv;
|
|
|
|
|
2013-04-16 14:59:35 +02:00
|
|
|
var fragmentindex = Reveal.getIndices().f;
|
2013-04-05 20:45:17 +02:00
|
|
|
if (typeof fragmentindex == 'undefined') {
|
|
|
|
fragmentindex = 0;
|
|
|
|
}
|
2012-08-05 15:48:55 +02:00
|
|
|
|
2013-04-05 20:45:17 +02:00
|
|
|
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
|
|
|
|
nextindexh = indexh;
|
|
|
|
nextindexv = indexv + 1;
|
|
|
|
} else {
|
|
|
|
nextindexh = indexh + 1;
|
|
|
|
nextindexv = 0;
|
2013-04-16 14:59:35 +02:00
|
|
|
}
|
2012-08-05 15:48:55 +02:00
|
|
|
|
2013-04-05 20:45:17 +02: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 15:48:55 +02:00
|
|
|
} );
|
2013-04-05 20:45:17 +02:00
|
|
|
|
|
|
|
var fragmentNotify = function( event ) {
|
|
|
|
notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
|
|
|
|
};
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'fragmentshown', fragmentNotify );
|
|
|
|
Reveal.addEventListener( 'fragmenthidden', fragmentNotify );
|
|
|
|
}());
|