From 1a219a4c2c5694168d81c239f9cc437c0e7fb15b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 12 May 2014 23:40:30 +0200 Subject: Update require.js --- js/slide-controller.js | 62 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'js/slide-controller.js') diff --git a/js/slide-controller.js b/js/slide-controller.js index 2af62e9..13faa93 100644 --- a/js/slide-controller.js +++ b/js/slide-controller.js @@ -1,6 +1,6 @@ /** * Remote control by: - * + * * @authors Pacien TRAN-GIRARD */ (function(window) { @@ -19,7 +19,8 @@ this.setup(); } - SlideController.MODES = [ 'local', 'remote', 'controller' ]; + + SlideController.MODES = ['local', 'remote', 'controller']; SlideController.prototype.setup = function() { @@ -62,17 +63,14 @@ // Only open popup from main deck. Avoid recursive popupception. if (!this.isPresenter) { var opts = 'menubar=no,location=yes,resizable=yes,scrollbars=no,status=no'; - var localPresenter = window.open(location.href, 'mywindow', - opts); + var localPresenter = window.open(location.href, 'mywindow', opts); // Loading in the popup? Turn the presenter mode on. localPresenter.addEventListener('load', function(e) { - localPresenter.document.body.classList - .add('with-notes'); + localPresenter.document.body.classList.add('with-notes'); }.bind(this), false); - window.addEventListener('message', this.onMessage_ - .bind(this), false); + window.addEventListener('message', this.onMessage_.bind(this), false); // Close popups if we reload the main window. window.addEventListener('beforeunload', function(e) { @@ -92,29 +90,32 @@ var addr = this.deck.config_.settings.remoteSocket; var channel = this.deck.config_.settings.remoteChannel; var password = (password != null) ? password : ''; - this.remoteSocket = io.connect(addr, { - 'query' : 'channel=' + channel + '&password=' + password, - 'force new connection' : true, - }); - this.remoteSocket.on('connect', function() { - var message = 'Connected to ' + channel + '@' + addr; - console.log(message); - alert(message); - }); + require([addr + 'socket.io/socket.io.js'], function(io) { + self.remoteSocket = io.connect(addr, { + 'query' : 'channel=' + channel + '&password=' + password, + 'force new connection' : true, + }); - this.remoteSocket.on('disconnect', function() { - var message = 'Diconnected from' + channel + '@' + addr; - console.log(message); - alert(message); - }); + self.remoteSocket.on('connect', function() { + var message = 'Connected to ' + channel + '@' + addr; + console.log(message); + alert(message); + }); + + self.remoteSocket.on('disconnect', function() { + var message = 'Diconnected from' + channel + '@' + addr; + console.log(message); + alert(message); + }); - this.remoteSocket.on('message', function(message) { - console.log('Received from remote: ' + message); - self.onMessage_({ - data : { - keyCode : parseInt(message[0]) - } + self.remoteSocket.on('message', function(message) { + console.log('Received from remote: ' + message); + self.onMessage_({ + data : { + keyCode : parseInt(message[0]) + } + }); }); }); @@ -123,7 +124,7 @@ } return true; - } + }; SlideController.prototype.onMessage_ = function(e) { @@ -134,8 +135,7 @@ // Restrict messages to being from this origin. Allow local developmet // from file:// though. // TODO: It would be dope if FF implemented location.origin! - if (this.mode === 'local' && e.origin != ORIGIN_ - && ORIGIN_.indexOf('file://') != 0) { + if (this.mode === 'local' && e.origin != ORIGIN_ && ORIGIN_.indexOf('file://') != 0) { alert('Someone tried to postMessage from an unknown origin'); return; } -- cgit v1.2.3