aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authortkaczmarzyk <tomasz+github@kaczmarzyk.net>2013-04-05 20:45:17 +0200
committertkaczmarzyk <tomasz+github@kaczmarzyk.net>2013-04-06 13:19:34 +0200
commitc12b780736e6388c460061f7d7f66fd1604f1208 (patch)
tree1ea66f0184028716035b6a85d1b040ce34fd0f0c /plugin
parent3040bc291700a23314e20fbed545b5f5d561a874 (diff)
downloadperl-software-in-gnu-guix-c12b780736e6388c460061f7d7f66fd1604f1208.tar
perl-software-in-gnu-guix-c12b780736e6388c460061f7d7f66fd1604f1208.tar.gz
broadcasting fragments state in multiplex plugin (#394)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/multiplex/client.js2
-rw-r--r--plugin/multiplex/master.js62
2 files changed, 41 insertions, 23 deletions
diff --git a/plugin/multiplex/client.js b/plugin/multiplex/client.js
index 0e0b39b..e6179f6 100644
--- a/plugin/multiplex/client.js
+++ b/plugin/multiplex/client.js
@@ -8,6 +8,6 @@
if (data.socketId !== socketId) { return; }
if( window.location.host === 'localhost:1947' ) return;
- Reveal.slide(data.indexh, data.indexv, null, 'remote');
+ Reveal.slide(data.indexh, data.indexv, data.indexf, 'remote');
});
}());
diff --git a/plugin/multiplex/master.js b/plugin/multiplex/master.js
index 75697d4..21c2e81 100644
--- a/plugin/multiplex/master.js
+++ b/plugin/multiplex/master.js
@@ -5,28 +5,46 @@
var socket = io.connect(multiplex.url);
- Reveal.addEventListener( 'slidechanged', function( event ) {
- var nextindexh;
- var nextindexv;
- var slideElement = event.currentSlide;
-
- if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
- nextindexh = event.indexh;
- nextindexv = event.indexv + 1;
- } else {
- nextindexh = event.indexh + 1;
- nextindexv = 0;
- }
+ 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;
+ }
- var slideData = {
- indexh : event.indexh,
- indexv : event.indexv,
- nextindexh : nextindexh,
- nextindexv : nextindexv,
- secret: multiplex.secret,
- socketId : multiplex.id
- };
+ if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
+ nextindexh = indexh;
+ nextindexv = indexv + 1;
+ } else {
+ nextindexh = indexh + 1;
+ nextindexv = 0;
+ }
- if( typeof event.origin === 'undefined' && event.origin !== 'remote' ) socket.emit('slidechanged', slideData);
+ 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