From 60f2eb9fb3c4443fbc43d387e866f383f0f70d67 Mon Sep 17 00:00:00 2001 From: Rebecca Murphey Date: Thu, 7 Jun 2012 23:21:14 -0400 Subject: taking a stab at a presenter notes server --- js/slidenotes.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 js/slidenotes.js (limited to 'js') diff --git a/js/slidenotes.js b/js/slidenotes.js new file mode 100644 index 0000000..9a4f152 --- /dev/null +++ b/js/slidenotes.js @@ -0,0 +1,32 @@ +(function() { + // don't emit events from inside the previews themselves + var qs = window.location.href.split('?'); + if (qs.length > 1 && qs[1].match('receiver')) { return; } + + var socket = io.connect('http://localhost:1947'); + + 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 + }; + + socket.emit('slidechanged', slideData); + } ); +}()); \ No newline at end of file -- cgit v1.2.3 From 0163ffcb435a8d5584a934afcf3eda0156c14fdd Mon Sep 17 00:00:00 2001 From: Rebecca Murphey Date: Sun, 17 Jun 2012 18:43:29 -0400 Subject: use current host/port --- js/slidenotes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/slidenotes.js b/js/slidenotes.js index 9a4f152..ef05062 100644 --- a/js/slidenotes.js +++ b/js/slidenotes.js @@ -3,8 +3,8 @@ var qs = window.location.href.split('?'); if (qs.length > 1 && qs[1].match('receiver')) { return; } - var socket = io.connect('http://localhost:1947'); - + var socket = io.connect(window.location.origin); + Reveal.addEventListener( 'slidechanged', function( event ) { var nextindexh; var nextindexv; -- cgit v1.2.3 From 677ef9919be61249c2527086e093333b9f2ec03d Mon Sep 17 00:00:00 2001 From: Rebecca Murphey Date: Sun, 17 Jun 2012 18:43:54 -0400 Subject: broadcast socket id as part of slidedata --- js/slidenotes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/slidenotes.js b/js/slidenotes.js index ef05062..8a0865a 100644 --- a/js/slidenotes.js +++ b/js/slidenotes.js @@ -4,6 +4,8 @@ if (qs.length > 1 && qs[1].match('receiver')) { return; } var socket = io.connect(window.location.origin); + var socketId = socket.socket.sessionid; + console.log('View slide notes at ' + window.location.origin + '/_notes/' + socketId); Reveal.addEventListener( 'slidechanged', function( event ) { var nextindexh; @@ -24,9 +26,10 @@ indexh : event.indexh, indexv : event.indexv, nextindexh : nextindexh, - nextindexv : nextindexv + nextindexv : nextindexv, + socketId : socketId }; socket.emit('slidechanged', slideData); } ); -}()); \ No newline at end of file +}()); -- cgit v1.2.3 From 8980f8accb5cd24e79d44caa3466011c31c44a38 Mon Sep 17 00:00:00 2001 From: Rebecca Murphey Date: Sun, 17 Jun 2012 18:59:43 -0400 Subject: fix socket id --- js/slidenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/slidenotes.js b/js/slidenotes.js index 8a0865a..4e0ebab 100644 --- a/js/slidenotes.js +++ b/js/slidenotes.js @@ -4,7 +4,7 @@ if (qs.length > 1 && qs[1].match('receiver')) { return; } var socket = io.connect(window.location.origin); - var socketId = socket.socket.sessionid; + var socketId = Math.random().toString().slice(2); console.log('View slide notes at ' + window.location.origin + '/_notes/' + socketId); Reveal.addEventListener( 'slidechanged', function( event ) { -- cgit v1.2.3