annotate www/p/plugin/speakernotes/client.js @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents 49c94f63b8b0
children
rev   line source
rc-web@42 1 (function() {
rc-web@42 2 // don't emit events from inside the previews themselves
rc-web@42 3 if ( window.location.search.match( /receiver/gi ) ) { return; }
rc-web@42 4
rc-web@42 5 var socket = io.connect(window.location.origin);
rc-web@42 6 var socketId = Math.random().toString().slice(2);
rc-web@42 7
rc-web@42 8 console.log('View slide notes at ' + window.location.origin + '/notes/' + socketId);
rc-web@42 9
rc-web@42 10 Reveal.addEventListener( 'slidechanged', function( event ) {
rc-web@42 11 var nextindexh;
rc-web@42 12 var nextindexv;
rc-web@42 13 var slideElement = event.currentSlide;
rc-web@42 14
rc-web@42 15 if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
rc-web@42 16 nextindexh = event.indexh;
rc-web@42 17 nextindexv = event.indexv + 1;
rc-web@42 18 } else {
rc-web@42 19 nextindexh = event.indexh + 1;
rc-web@42 20 nextindexv = 0;
rc-web@42 21 }
rc-web@42 22
rc-web@42 23 var notes = slideElement.querySelector('aside.notes');
rc-web@42 24 var slideData = {
rc-web@42 25 notes : notes ? notes.innerHTML : '',
rc-web@42 26 indexh : event.indexh,
rc-web@42 27 indexv : event.indexv,
rc-web@42 28 nextindexh : nextindexh,
rc-web@42 29 nextindexv : nextindexv,
rc-web@42 30 socketId : socketId
rc-web@42 31 };
rc-web@42 32
rc-web@42 33 socket.emit('slidechanged', slideData);
rc-web@42 34 } );
rc-web@42 35 }());