From 3eb7038a153b12245cffbc840a727a764d82b333 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sun, 4 May 2014 10:10:21 +0200 Subject: sync server-side speaker notes after notes window opens --- plugin/notes-server/notes.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'plugin/notes-server/notes.html') diff --git a/plugin/notes-server/notes.html b/plugin/notes-server/notes.html index 4ff48f1..72d0317 100644 --- a/plugin/notes-server/notes.html +++ b/plugin/notes-server/notes.html @@ -187,7 +187,7 @@ var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; - socket.on( 'state', function( data ) { + socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours if( data.socketId !== socketId ) { return; } @@ -206,6 +206,18 @@ } ); + 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 } ); + } + } + + } ); + /** * Called when the main window sends an updated state. */ @@ -266,7 +278,7 @@ ].join( '&' ); var hash = '#/' + data.state.indexh + '/' + data.state.indexv; - var currentURL = '/?' + params + hash; + var currentURL = '/?' + params + '&postMessageEvents=true' + hash; var upcomingURL = '/?' + params + '&controls=false' + hash; currentSlide = document.createElement( 'iframe' ); -- cgit v1.2.3