JJ Allaire | efa6ad4 | 2016-01-30 13:12:05 -0500 | [diff] [blame] | 1 | (function() { |
| 2 | |
| 3 | // Don't emit events from inside of notes windows |
| 4 | if ( window.location.search.match( /receiver/gi ) ) { return; } |
| 5 | |
| 6 | var multiplex = Reveal.getConfig().multiplex; |
| 7 | |
| 8 | var socket = io.connect( multiplex.url ); |
| 9 | |
| 10 | function post() { |
| 11 | |
| 12 | var messageData = { |
| 13 | state: Reveal.getState(), |
| 14 | secret: multiplex.secret, |
| 15 | socketId: multiplex.id |
| 16 | }; |
| 17 | |
| 18 | socket.emit( 'multiplex-statechanged', messageData ); |
| 19 | |
| 20 | }; |
| 21 | |
| 22 | // Monitor events that trigger a change in state |
| 23 | Reveal.addEventListener( 'slidechanged', post ); |
| 24 | Reveal.addEventListener( 'fragmentshown', post ); |
| 25 | Reveal.addEventListener( 'fragmenthidden', post ); |
| 26 | Reveal.addEventListener( 'overviewhidden', post ); |
| 27 | Reveal.addEventListener( 'overviewshown', post ); |
| 28 | Reveal.addEventListener( 'paused', post ); |
| 29 | Reveal.addEventListener( 'resumed', post ); |
| 30 | |
| 31 | }()); |