sync server-side speaker notes after notes window opens
This commit is contained in:
		| @@ -36,10 +36,15 @@ | |||||||
| 			messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; | 			messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		socket.emit( 'state', messageData ); | 		socket.emit( 'statechanged', messageData ); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// When a new notes window connects, post our current state | ||||||
|  | 	socket.on( 'connect', function( data ) { | ||||||
|  | 		post(); | ||||||
|  | 	} ); | ||||||
|  |  | ||||||
| 	// Monitor events that trigger a change in state | 	// Monitor events that trigger a change in state | ||||||
| 	Reveal.addEventListener( 'slidechanged', post ); | 	Reveal.addEventListener( 'slidechanged', post ); | ||||||
| 	Reveal.addEventListener( 'fragmentshown', post ); | 	Reveal.addEventListener( 'fragmentshown', post ); | ||||||
|   | |||||||
| @@ -16,8 +16,12 @@ var opts = { | |||||||
|  |  | ||||||
| io.sockets.on( 'connection', function( socket ) { | io.sockets.on( 'connection', function( socket ) { | ||||||
|  |  | ||||||
| 	socket.on( 'state', function( state ) { | 	socket.on( 'connect', function( data ) { | ||||||
| 		socket.broadcast.emit( 'state', state ); | 		socket.broadcast.emit( 'connect', data ); | ||||||
|  | 	}); | ||||||
|  |  | ||||||
|  | 	socket.on( 'statechanged', function( data ) { | ||||||
|  | 		socket.broadcast.emit( 'statechanged', data ); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -187,7 +187,7 @@ | |||||||
| 			var socket = io.connect( window.location.origin ), | 			var socket = io.connect( window.location.origin ), | ||||||
| 				socketId = '{{socketId}}'; | 				socketId = '{{socketId}}'; | ||||||
|  |  | ||||||
| 			socket.on( 'state', function( data ) { | 			socket.on( 'statechanged', function( data ) { | ||||||
|  |  | ||||||
| 				// ignore data from sockets that aren't ours | 				// ignore data from sockets that aren't ours | ||||||
| 				if( data.socketId !== socketId ) { return; } | 				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. | 			 * Called when the main window sends an updated state. | ||||||
| 			 */ | 			 */ | ||||||
| @@ -266,7 +278,7 @@ | |||||||
| 				].join( '&' ); | 				].join( '&' ); | ||||||
|  |  | ||||||
| 				var hash = '#/' + data.state.indexh + '/' + data.state.indexv; | 				var hash = '#/' + data.state.indexh + '/' + data.state.indexv; | ||||||
| 				var currentURL = '/?' + params + hash; | 				var currentURL = '/?' + params + '&postMessageEvents=true' + hash; | ||||||
| 				var upcomingURL = '/?' + params + '&controls=false' + hash; | 				var upcomingURL = '/?' + params + '&controls=false' + hash; | ||||||
|  |  | ||||||
| 				currentSlide = document.createElement( 'iframe' ); | 				currentSlide = document.createElement( 'iframe' ); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user