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

Function connect

doc/cppcon-2018/reveal.js/plugin/notes/notes.js:38–56  ·  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

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

Callers 1

openNotesFunction · 0.70

Calls 2

parseMethod · 0.80
onConnectedFunction · 0.70

Tested by

no test coverage detected