diff options
author | xnum | 2015-11-23 20:38:26 +0800 |
---|---|---|
committer | xnum | 2015-11-23 20:38:26 +0800 |
commit | f51b7370f030c5cd1235fa7a23514a7e1ccef2dd (patch) | |
tree | b6f43191518b16f74ca33b1406567a0ffcaa6f32 /public/plugin/multiplex/master.js | |
parent | 75ae505a1544d8999e6705aad7ed96ff5a6eb0e5 (diff) |
Add Slide Mode
using reveal.js
and some part of reveal-md
Diffstat (limited to 'public/plugin/multiplex/master.js')
-rw-r--r-- | public/plugin/multiplex/master.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/public/plugin/multiplex/master.js b/public/plugin/multiplex/master.js new file mode 100644 index 00000000..b6a7eb7d --- /dev/null +++ b/public/plugin/multiplex/master.js @@ -0,0 +1,51 @@ +(function() { + // Don't emit events from inside of notes windows + if ( window.location.search.match( /receiver/gi ) ) { return; } + + var multiplex = Reveal.getConfig().multiplex; + + var socket = io.connect(multiplex.url); + + 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; + } + + if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { + nextindexh = indexh; + nextindexv = indexv + 1; + } else { + nextindexh = indexh + 1; + nextindexv = 0; + } + + 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 ); + } ); + + var fragmentNotify = function( event ) { + notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin ); + }; + + Reveal.addEventListener( 'fragmentshown', fragmentNotify ); + Reveal.addEventListener( 'fragmenthidden', fragmentNotify ); +}());
\ No newline at end of file |