diff options
author | Hakim El Hattab | 2012-07-09 21:30:54 -0400 |
---|---|---|
committer | Hakim El Hattab | 2012-07-09 21:30:54 -0400 |
commit | 54f1fcf381dcf23e54f2b942268aa799969fa9ea (patch) | |
tree | f2af92b00479674f864dd1c1b60dfb655ca5b5e2 /plugin/speakernotes/client.js | |
parent | 21983c7b7fa434f083589ad80411a44fca4119e2 (diff) |
slidenotes becomes speakernotes to match wording in readme
Diffstat (limited to 'plugin/speakernotes/client.js')
-rw-r--r-- | plugin/speakernotes/client.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/plugin/speakernotes/client.js b/plugin/speakernotes/client.js new file mode 100644 index 0000000..1aba8b8 --- /dev/null +++ b/plugin/speakernotes/client.js @@ -0,0 +1,35 @@ +(function() { + // don't emit events from inside the previews themselves + if ( window.location.search.match( /receiver/gi ) ) { return; } + + var socket = io.connect(window.location.origin); + var socketId = Math.random().toString().slice(2); + + console.log('View slide notes at ' + window.location.origin + '/notes/' + socketId); + + Reveal.addEventListener( 'slidechanged', function( event ) { + var nextindexh; + var nextindexv; + var slideElement = event.currentSlide; + + if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { + nextindexh = event.indexh; + nextindexv = event.indexv + 1; + } else { + nextindexh = event.indexh + 1; + nextindexv = 0; + } + + var notes = slideElement.querySelector('aside.notes'); + var slideData = { + notes : notes ? notes.innerHTML : '', + indexh : event.indexh, + indexv : event.indexv, + nextindexh : nextindexh, + nextindexv : nextindexv, + socketId : socketId + }; + + socket.emit('slidechanged', slideData); + } ); +}()); |