3 // don't emit events from inside the previews themselves
4 if( window.location.search.match( /receiver/gi ) ) { return; }
6 var socket = io.connect( window.location.origin ),
7 socketId = Math.random().toString().slice( 2 );
9 console.log( 'View slide notes at ' + window.location.origin + '/notes/' + socketId );
11 window.open( window.location.origin + '/notes/' + socketId, 'notes-' + socketId );
14 * Posts the current slide data to the notes window
18 var slideElement = Reveal.getCurrentSlide(),
19 notesElement = slideElement.querySelector( 'aside.notes' );
25 state: Reveal.getState()
28 // Look for notes defined in a slide attribute
29 if( slideElement.hasAttribute( 'data-notes' ) ) {
30 messageData.notes = slideElement.getAttribute( 'data-notes' );
33 // Look for notes defined in an aside element
35 messageData.notes = notesElement.innerHTML;
36 messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
39 socket.emit( 'statechanged', messageData );
43 // When a new notes window connects, post our current state
44 socket.on( 'new-subscriber', function( data ) {
48 // Monitor events that trigger a change in state
49 Reveal.addEventListener( 'slidechanged', post );
50 Reveal.addEventListener( 'fragmentshown', post );
51 Reveal.addEventListener( 'fragmenthidden', post );
52 Reveal.addEventListener( 'overviewhidden', post );
53 Reveal.addEventListener( 'overviewshown', post );
54 Reveal.addEventListener( 'paused', post );
55 Reveal.addEventListener( 'resumed', post );
57 // Post the initial state