* 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.
()
| 36 | * file system. |
| 37 | */ |
| 38 | function connect() { |
| 39 | // Keep trying to connect until we get a 'connected' message back |
| 40 | var connectInterval = setInterval( function() { |
| 41 | notesPopup.postMessage( JSON.stringify( { |
| 42 | namespace: 'reveal-notes', |
| 43 | type: 'connect', |
| 44 | url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search, |
| 45 | state: Reveal.getState() |
| 46 | } ), '*' ); |
| 47 | }, 500 ); |
| 48 | |
| 49 | window.addEventListener( 'message', function( event ) { |
| 50 | var data = JSON.parse( event.data ); |
| 51 | if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) { |
| 52 | clearInterval( connectInterval ); |
| 53 | onConnected(); |
| 54 | } |
| 55 | } ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Posts the current slide data to the notes window |
no test coverage detected