client.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. window.open(window.location.origin + '/notes/' + socketId, 'notes-' + socketId)
  8. Reveal.addEventListener( 'slidechanged', function( event ) {
  9. var nextindexh;
  10. var nextindexv;
  11. var slideElement = event.currentSlide;
  12. if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
  13. nextindexh = event.indexh;
  14. nextindexv = event.indexv + 1;
  15. } else {
  16. nextindexh = event.indexh + 1;
  17. nextindexv = 0;
  18. }
  19. var notes = slideElement.querySelector('aside.notes');
  20. var slideData = {
  21. notes : notes ? notes.innerHTML : '',
  22. indexh : event.indexh,
  23. indexv : event.indexv,
  24. nextindexh : nextindexh,
  25. nextindexv : nextindexv,
  26. socketId : socketId,
  27. markdown : notes ? typeof notes.getAttribute('data-markdown') === 'string' : false
  28. };
  29. socket.emit('slidechanged', slideData);
  30. } );
  31. }());