MCPcopy Create free account
hub / github.com/boost-ext/di / connect

Function connect

doc/cppnow-2016/plugin/notes/notes.js:25–43  ·  view source on GitHub ↗

* 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.

()

Source from the content-addressed store, hash-verified

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

Callers 1

openNotesFunction · 0.70

Calls 2

parseMethod · 0.80
onConnectedFunction · 0.70

Tested by

no test coverage detected