vendor/reveal.js/plugin/notes-server/notes.html in slide_hero-0.0.10 vs vendor/reveal.js/plugin/notes-server/notes.html in slide_hero-0.0.11
- old
+ new
@@ -193,31 +193,43 @@
if( data.socketId !== socketId ) { return; }
if( connected === false ) {
connected = true;
- setupIframes( data );
setupKeyboard();
setupNotes();
setupTimer();
}
handleStateMessage( data );
} );
+ // Load our presentation iframes
+ setupIframes();
+
+ // Once the iframes have loaded, emit a signal saying there's
+ // a new subscriber which will trigger a 'statechanged'
+ // message to be sent back
window.addEventListener( 'message', function( event ) {
var data = JSON.parse( event.data );
if( data && data.namespace === 'reveal' ) {
if( /ready/.test( data.eventName ) ) {
- socket.emit( 'connect', { socketId: socketId } );
+ socket.emit( 'new-subscriber', { socketId: socketId } );
}
}
+ // 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 } );
+ }
+ }
+
} );
/**
* Called when the main window sends an updated state.
*/
@@ -265,22 +277,21 @@
}
/**
* Creates the preview iframes.
*/
- function setupIframes( data ) {
+ function setupIframes() {
var params = [
'receiver',
'progress=false',
'history=false',
'transition=none',
'backgroundTransition=none'
].join( '&' );
- var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
- var currentURL = '/?' + params + '&postMessageEvents=true' + hash;
- var upcomingURL = '/?' + params + '&controls=false' + hash;
+ var currentURL = '/?' + params + '&postMessageEvents=true';
+ var upcomingURL = '/?' + params + '&controls=false';
currentSlide = document.createElement( 'iframe' );
currentSlide.setAttribute( 'width', 1280 );
currentSlide.setAttribute( 'height', 1024 );
currentSlide.setAttribute( 'src', currentURL );