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

51 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2012-08-05 15:48:55 +02:00
(function() {
2013-09-15 17:52:40 +02:00
// Don't emit events from inside of notes windows
2012-08-05 15:48:55 +02:00
if ( window.location.search.match( /receiver/gi ) ) { return; }
2013-09-15 17:52:40 +02: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
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 );
}());