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

Function openNotes

doc/cppnow-2017/plugin/notes/notes.js:14–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12var RevealNotes = (function() {
13
14 function openNotes() {
15 var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
16 jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
17 var notesPopup = window.open( jsFileLocation + 'notes.html', 'reveal.js - Notes', 'width=1100,height=700' );
18
19 /**
20 * Connect to the notes window through a postmessage handshake.
21 * Using postmessage enables us to work in situations where the
22 * origins differ, such as a presentation being opened from the
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
47 */
48 function post() {
49
50 var slideElement = Reveal.getCurrentSlide(),
51 notesElement = slideElement.querySelector( 'aside.notes' );
52
53 var messageData = {
54 namespace: 'reveal-notes',
55 type: 'state',
56 notes: '',
57 markdown: false,
58 whitespace: 'normal',
59 state: Reveal.getState()
60 };
61
62 // Look for notes defined in a slide attribute
63 if( slideElement.hasAttribute( 'data-notes' ) ) {
64 messageData.notes = slideElement.getAttribute( 'data-notes' );
65 messageData.whitespace = 'pre-wrap';
66 }
67
68 // Look for notes defined in an aside element
69 if( notesElement ) {
70 messageData.notes = notesElement.innerHTML;
71 messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';

Callers 1

notes.jsFile · 0.70

Calls 1

connectFunction · 0.70

Tested by

no test coverage detected