1
0
Fork 0

adjust whitespace of notes code to match rest of project

This commit is contained in:
Hakim El Hattab 2012-07-01 16:43:43 -04:00
parent e2ba1c1142
commit 9608ac9d2d
2 changed files with 43 additions and 43 deletions

View File

@ -1,35 +1,35 @@
(function() { (function() {
// don't emit events from inside the previews themselves // don't emit events from inside the previews themselves
var qs = window.location.href.split('?'); var qs = window.location.href.split('?');
if (qs.length > 1 && qs[1].match('receiver')) { return; } if (qs.length > 1 && qs[1].match('receiver')) { return; }
var socket = io.connect(window.location.origin); var socket = io.connect(window.location.origin);
var socketId = Math.random().toString().slice(2); var socketId = Math.random().toString().slice(2);
console.log('View slide notes at ' + window.location.origin + '/_notes/' + socketId); console.log('View slide notes at ' + window.location.origin + '/_notes/' + socketId);
Reveal.addEventListener( 'slidechanged', function( event ) { Reveal.addEventListener( 'slidechanged', function( event ) {
var nextindexh; var nextindexh;
var nextindexv; var nextindexv;
var slideElement = event.currentSlide; var slideElement = event.currentSlide;
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
nextindexh = event.indexh; nextindexh = event.indexh;
nextindexv = event.indexv + 1; nextindexv = event.indexv + 1;
} else { } else {
nextindexh = event.indexh + 1; nextindexh = event.indexh + 1;
nextindexv = 0; nextindexv = 0;
} }
var notes = slideElement.querySelector('aside.notes'); var notes = slideElement.querySelector('aside.notes');
var slideData = { var slideData = {
notes : notes ? notes.innerHTML : '', notes : notes ? notes.innerHTML : '',
indexh : event.indexh, indexh : event.indexh,
indexv : event.indexv, indexv : event.indexv,
nextindexh : nextindexh, nextindexh : nextindexh,
nextindexv : nextindexv, nextindexv : nextindexv,
socketId : socketId socketId : socketId
}; };
socket.emit('slidechanged', slideData); socket.emit('slidechanged', slideData);
} ); } );
}()); }());

View File

@ -10,34 +10,34 @@ var staticDir = express.static;
io = io.listen(app); io = io.listen(app);
var opts = { var opts = {
port : 1947, port : 1947,
baseDir : __dirname + '/../../' baseDir : __dirname + '/../../'
}; };
io.sockets.on('connection', function(socket) { io.sockets.on('connection', function(socket) {
socket.on('slidechanged', function(slideData) { socket.on('slidechanged', function(slideData) {
socket.broadcast.emit('slidedata', slideData); socket.broadcast.emit('slidedata', slideData);
}); });
}); });
app.configure(function() { app.configure(function() {
[ 'css', 'assets', 'js', 'lib' ].forEach(function(dir) { [ 'css', 'assets', 'js', 'lib' ].forEach(function(dir) {
app.use('/' + dir, staticDir(opts.baseDir + dir)); app.use('/' + dir, staticDir(opts.baseDir + dir));
}); });
}); });
app.get("/", function(req, res) { app.get("/", function(req, res) {
fs.createReadStream(opts.baseDir + '/index.html').pipe(res); fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
}); });
app.get("/_notes/:socketId", function(req, res) { app.get("/_notes/:socketId", function(req, res) {
fs.readFile(opts.baseDir + 'slidenotes/notes.html', function(err, data) { fs.readFile(opts.baseDir + 'lib/slidenotes/notes.html', function(err, data) {
res.send(Mustache.to_html(data.toString(), { res.send(Mustache.to_html(data.toString(), {
socketId : req.params.socketId socketId : req.params.socketId
})); }));
}); });
// fs.createReadStream(opts.baseDir + 'slidenotes/notes.html').pipe(res); // fs.createReadStream(opts.baseDir + 'slidenotes/notes.html').pipe(res);
}); });
// Actually listen // Actually listen