client.js 1000 B

1234567891011121314151617181920212223242526272829303132333435
  1. (function() {
  2. // don't emit events from inside the previews themselves
  3. if ( window.location.search.match( /receiver/gi ) ) { return; }
  4. var socket = io.connect(window.location.origin);
  5. var socketId = Math.random().toString().slice(2);
  6. console.log('View slide notes at ' + window.location.origin + '/notes/' + socketId);
  7. Reveal.addEventListener( 'slidechanged', function( event ) {
  8. var nextindexh;
  9. var nextindexv;
  10. var slideElement = event.currentSlide;
  11. if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
  12. nextindexh = event.indexh;
  13. nextindexv = event.indexv + 1;
  14. } else {
  15. nextindexh = event.indexh + 1;
  16. nextindexv = 0;
  17. }
  18. var notes = slideElement.querySelector('aside.notes');
  19. var slideData = {
  20. notes : notes ? notes.innerHTML : '',
  21. indexh : event.indexh,
  22. indexv : event.indexv,
  23. nextindexh : nextindexh,
  24. nextindexv : nextindexv,
  25. socketId : socketId
  26. };
  27. socket.emit('slidechanged', slideData);
  28. } );
  29. }());