MCPcopy Create free account
hub / github.com/boost-ext/sml / openNotes

Function openNotes

doc/cppnow-2019/reveal.js/plugin/notes/notes.js:16–152  ·  view source on GitHub ↗
( notesFilePath )

Source from the content-addressed store, hash-verified

14 var notesPopup = null;
15
16 function openNotes( notesFilePath ) {
17
18 if (notesPopup && !notesPopup.closed) {
19 notesPopup.focus();
20 return;
21 }
22
23 if( !notesFilePath ) {
24 var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
25 jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
26 notesFilePath = jsFileLocation + 'notes.html';
27 }
28
29 notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' );
30
31 if( !notesPopup ) {
32 alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' );
33 return;
34 }
35
36 /**
37 * Connect to the notes window through a postmessage handshake.
38 * Using postmessage enables us to work in situations where the
39 * origins differ, such as a presentation being opened from the
40 * file system.
41 */
42 function connect() {
43 // Keep trying to connect until we get a 'connected' message back
44 var connectInterval = setInterval( function() {
45 notesPopup.postMessage( JSON.stringify( {
46 namespace: 'reveal-notes',
47 type: 'connect',
48 url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search,
49 state: Reveal.getState()
50 } ), '*' );
51 }, 500 );
52
53 window.addEventListener( 'message', function( event ) {
54 var data = JSON.parse( event.data );
55 if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) {
56 clearInterval( connectInterval );
57 onConnected();
58 }
59 if( data && data.namespace === 'reveal-notes' && data.type === 'call' ) {
60 callRevealApi( data.methodName, data.arguments, data.callId );
61 }
62 } );
63 }
64
65 /**
66 * Calls the specified Reveal.js method with the provided argument
67 * and then pushes the result to the notes frame.
68 */
69 function callRevealApi( methodName, methodArguments, callId ) {
70
71 var result = Reveal[methodName].apply( Reveal, methodArguments );
72 notesPopup.postMessage( JSON.stringify( {
73 namespace: 'reveal-notes',

Callers 1

notes.jsFile · 0.70

Calls 1

connectFunction · 0.70

Tested by

no test coverage detected