reveal.slidenotes.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (function() {
  2. // don't emit events from inside the previews themselves
  3. var qs = window.location.href.split('?');
  4. if (qs.length > 1 && qs[1].match('receiver')) { return; }
  5. var socket = io.connect(window.location.origin);
  6. var socketId = Math.random().toString().slice(2);
  7. console.log('View slide notes at ' + window.location.origin + '/_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. };
  28. socket.emit('slidechanged', slideData);
  29. } );
  30. }());