* Connect to the notes window through a postmessage handshake. * Using postmessage enables us to work in situations where the * origins differ, such as a presentation being opened from the * file system.
()
| 23 | * file system. |
| 24 | */ |
| 25 | function connect() { |
| 26 | // Keep trying to connect until we get a 'connected' message back |
| 27 | var connectInterval = setInterval( function() { |
| 28 | notesPopup.postMessage( JSON.stringify( { |
| 29 | namespace: 'reveal-notes', |
| 30 | type: 'connect', |
| 31 | url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search, |
| 32 | state: Reveal.getState() |
| 33 | } ), '*' ); |
| 34 | }, 500 ); |
| 35 | |
| 36 | window.addEventListener( 'message', function( event ) { |
| 37 | var data = JSON.parse( event.data ); |
| 38 | if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) { |
| 39 | clearInterval( connectInterval ); |
| 40 | onConnected(); |
| 41 | } |
| 42 | } ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Posts the current slide data to the notes window |
no test coverage detected