forked from reveal/multiplex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.js
36 lines (26 loc) · 972 Bytes
/
master.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function() {
// Don't emit events from inside of notes windows
if ( window.location.search.match( /receiver/gi ) ) { return; }
var multiplex = Reveal.getConfig().multiplex;
var socket = io.connect( multiplex.url );
function post( evt ) {
var messageData = {
state: Reveal.getState(),
secret: multiplex.secret,
socketId: multiplex.id,
content: (evt || {}).content
};
socket.emit( 'multiplex-statechanged', messageData );
};
// post once the page is loaded, so the client follows also on "open URL".
window.addEventListener( 'load', post );
// Monitor events that trigger a change in state
Reveal.on( 'slidechanged', post );
Reveal.on( 'fragmentshown', post );
Reveal.on( 'fragmenthidden', post );
Reveal.on( 'overviewhidden', post );
Reveal.on( 'overviewshown', post );
Reveal.on( 'paused', post );
Reveal.on( 'resumed', post );
document.addEventListener( 'send', post ); // broadcast custom events sent by other plugins
}());