From 9110dd0195e75ed6c9ec32ba9d05a3fe61515b9e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 13 May 2014 20:32:54 +0200 Subject: Separate controller and presenter modes --- js/slide-controller.js | 29 ++++++++++++++++++++--------- js/slide-deck.js | 22 +++++++++++----------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/js/slide-controller.js b/js/slide-controller.js index efb0097..bef37c4 100644 --- a/js/slide-controller.js +++ b/js/slide-controller.js @@ -13,6 +13,7 @@ this.mode = null; this.remoteSocket = null; this.isPresenter = window.opener; + this.isController = window.opener; this.keyLock = null; @@ -20,7 +21,7 @@ } - SlideController.MODES = ['local', 'remote', 'controller']; + SlideController.MODES = ['local', 'remote', 'controller', 'presenter']; SlideController.prototype.setup = function() { @@ -80,9 +81,12 @@ break; - case 'controller': + case 'presenter': this.isPresenter = true; document.body.classList.add('popup'); + + case 'controller': + this.isController = true; document.body.classList.add('with-notes'); var password = prompt("Broadcaster password"); @@ -192,6 +196,11 @@ return; } + // don't toggle speaker's notes for viewers + if (msg.keyCode === 80) { + return; + } + console.log("Sending: " + JSON.stringify(msg)); // // Send message to popup window. @@ -200,13 +209,15 @@ // } // Send message to main window. - if (this.isPresenter) { - if (this.mode === 'local') { - // TODO: It would be dope if FF implemented location.origin. - window.opener.postMessage(msg, '*'); - } - if (this.mode === 'controller') { - this.remoteSocket.emit('message', msg.keyCode); + if (this.isController) { + switch (this.mode) { + case 'local': + // TODO: It would be dope if FF implemented location.origin. + window.opener.postMessage(msg, '*'); + break; + case 'controller': + case 'presenter': + this.remoteSocket.emit('message', msg.keyCode); } } }; diff --git a/js/slide-deck.js b/js/slide-deck.js index f5d21c6..2943658 100644 --- a/js/slide-deck.js +++ b/js/slide-deck.js @@ -177,7 +177,7 @@ SlideDeck.prototype.onBodyKeyDown_ = function(e) { } // Forward keydowns to the main slides if we're the popup. - if (this.controller && this.controller.isPresenter) { + if (this.controller && this.controller.isController) { this.controller.sendMsg({ keyCode : e.keyCode }); @@ -504,11 +504,11 @@ SlideDeck.prototype.prevSlide = function(opt_dontPush) { // Toggle off speaker notes if they're showing when we move backwards on // the // main slides. If we're the speaker notes popup, leave them up. - if (this.controller && !this.controller.isPresenter) { - bodyClassList.remove('with-notes'); - } else if (!this.controller) { - bodyClassList.remove('with-notes'); - } + // if (this.controller && !this.controller.isPresenter) { + // bodyClassList.remove('with-notes'); + // } else if (!this.controller) { + // bodyClassList.remove('with-notes'); + // } this.prevSlide_ = this.curSlide_--; @@ -532,11 +532,11 @@ SlideDeck.prototype.nextSlide = function(opt_dontPush) { // Toggle off speaker notes if they're showing when we advanced on the // main // slides. If we're the speaker notes popup, leave them up. - if (this.controller && !this.controller.isPresenter) { - bodyClassList.remove('with-notes'); - } else if (!this.controller) { - bodyClassList.remove('with-notes'); - } + // if (this.controller && !this.controller.isPresenter) { + // bodyClassList.remove('with-notes'); + // } else if (!this.controller) { + // bodyClassList.remove('with-notes'); + // } this.prevSlide_ = this.curSlide_++; -- cgit v1.2.3