From 215617740d15f46022dce479f3f412b4d62f44f8 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 9 Nov 2015 16:23:57 +0100 Subject: [PATCH] server notes sync slide changes both ways, fixes #1425 --- plugin/notes-server/client.js | 5 +++++ plugin/notes-server/index.js | 4 ++++ plugin/notes-server/notes.html | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/plugin/notes-server/client.js b/plugin/notes-server/client.js index 719b495f..00b277ba 100644 --- a/plugin/notes-server/client.js +++ b/plugin/notes-server/client.js @@ -45,6 +45,11 @@ post(); } ); + // When the state changes from inside of the speaker view + socket.on( 'statechanged-speaker', function( data ) { + Reveal.setState( data.state ); + } ); + // Monitor events that trigger a change in state Reveal.addEventListener( 'slidechanged', post ); Reveal.addEventListener( 'fragmentshown', post ); diff --git a/plugin/notes-server/index.js b/plugin/notes-server/index.js index 75838de6..683f0645 100644 --- a/plugin/notes-server/index.js +++ b/plugin/notes-server/index.js @@ -26,6 +26,10 @@ io.on( 'connection', function( socket ) { socket.broadcast.emit( 'statechanged', data ); }); + socket.on( 'statechanged-speaker', function( data ) { + socket.broadcast.emit( 'statechanged-speaker', data ); + }); + }); [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) { diff --git a/plugin/notes-server/notes.html b/plugin/notes-server/notes.html index d924ad97..ad8c7190 100644 --- a/plugin/notes-server/notes.html +++ b/plugin/notes-server/notes.html @@ -221,6 +221,13 @@ } } + // Messages sent by reveal.js inside of the current slide preview + if( data && data.namespace === 'reveal' ) { + if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { + socket.emit( 'statechanged-speaker', { state: data.state } ); + } + } + } ); /**