* 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.
()
| 66 | * file system. |
| 67 | */ |
| 68 | function connect() { |
| 69 | |
| 70 | const presentationURL = deck.getConfig().url; |
| 71 | |
| 72 | const url = typeof presentationURL === 'string' ? presentationURL : |
| 73 | window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search; |
| 74 | |
| 75 | // Keep trying to connect until we get a 'connected' message back |
| 76 | connectInterval = setInterval( function() { |
| 77 | speakerWindow.postMessage( JSON.stringify( { |
| 78 | namespace: 'reveal-notes', |
| 79 | type: 'connect', |
| 80 | state: deck.getState(), |
| 81 | url |
| 82 | } ), '*' ); |
| 83 | }, 500 ); |
| 84 | |
| 85 | window.addEventListener( 'message', onPostMessage ); |
| 86 | |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Calls the specified Reveal.js method with the provided argument |
no test coverage detected
searching dependent graphs…