reveal-js-base-theme/plugin/multiplex/master.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

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; }
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
var notify = function( slideElement, indexh, indexv, origin ) {
if( typeof origin === 'undefined' && origin !== 'remote' ) {
var nextindexh;
var nextindexv;
var fragmentindex = Reveal.getIndices().f;
if (typeof fragmentindex == 'undefined') {
fragmentindex = 0;
}
2012-08-05 15:48:55 +02:00
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
nextindexh = indexh;
nextindexv = indexv + 1;
} else {
nextindexh = indexh + 1;
nextindexv = 0;
}
2012-08-05 15:48:55 +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
} );
var fragmentNotify = function( event ) {
notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
};
Reveal.addEventListener( 'fragmentshown', fragmentNotify );
Reveal.addEventListener( 'fragmenthidden', fragmentNotify );
}());