* Posts the current slide data to the notes window
()
| 14 | * Posts the current slide data to the notes window |
| 15 | */ |
| 16 | function post() { |
| 17 | |
| 18 | var slideElement = Reveal.getCurrentSlide(), |
| 19 | notesElement = slideElement.querySelector( 'aside.notes' ); |
| 20 | |
| 21 | var messageData = { |
| 22 | notes: '', |
| 23 | markdown: false, |
| 24 | socketId: socketId, |
| 25 | state: Reveal.getState() |
| 26 | }; |
| 27 | |
| 28 | // Look for notes defined in a slide attribute |
| 29 | if( slideElement.hasAttribute( 'data-notes' ) ) { |
| 30 | messageData.notes = slideElement.getAttribute( 'data-notes' ); |
| 31 | } |
| 32 | |
| 33 | // Look for notes defined in an aside element |
| 34 | if( notesElement ) { |
| 35 | messageData.notes = notesElement.innerHTML; |
| 36 | messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; |
| 37 | } |
| 38 | |
| 39 | socket.emit( 'statechanged', messageData ); |
| 40 | |
| 41 | } |
| 42 | |
| 43 | // When a new notes window connects, post our current state |
| 44 | socket.on( 'new-subscriber', function( data ) { |