From e221e9b662a50f4a0492845ce3561a3bd26df9c9 Mon Sep 17 00:00:00 2001 From: unkelpehr Date: Sat, 27 Sep 2014 14:56:57 +0200 Subject: [PATCH] Bughunt --- public/js/cryptalk_modules/console.js | 2 +- public/js/cryptalk_modules/cryptalk.js | 90 +++++++++++++++----------- public/js/cryptalk_modules/host.js | 4 +- 3 files changed, 53 insertions(+), 43 deletions(-) diff --git a/public/js/cryptalk_modules/console.js b/public/js/cryptalk_modules/console.js index 127a850..bf7151c 100644 --- a/public/js/cryptalk_modules/console.js +++ b/public/js/cryptalk_modules/console.js @@ -210,7 +210,7 @@ define({ // Connect events for (var commandName in commands) { - if (commandName === '_require' && commandName !== 'post') { + if (commandName !== '_require' && commandName !== 'post') { mediator.on('console:' + commandName, commands[commandName]); } } diff --git a/public/js/cryptalk_modules/cryptalk.js b/public/js/cryptalk_modules/cryptalk.js index fc37749..171aa23 100644 --- a/public/js/cryptalk_modules/cryptalk.js +++ b/public/js/cryptalk_modules/cryptalk.js @@ -8,48 +8,60 @@ define({ var mediator = requires.castrato; // Route mediator messages - mediator.on('window:focused',function() { - mediator.emit('audio:off'); - mediator.emit('notification:off'); - }); + mediator + .on('window:focused', function() { + mediator.emit('audio:off'); + mediator.emit('notification:off'); + }) + .on('window:blurred',function() { + mediator.emit('audio:on'); + mediator.emit('notification:on'); + }) + .on('command:mute', function () { + mediator.emit('audio:mute'); + }) + .on('command:unmute', function () { + mediator.emit('audio:unmute'); + }) - mediator.on('window:blurred',function() { - mediator.emit('audio:on'); - mediator.emit('notification:on'); - }); + // Help console and host keep track of current states + .on('room:changed', function(room) { + mediator + .emit('console:param', { + room: room + }) + .emit('host:param', { + room: room + }); + }) + .on('nick:changed', function(nick) { + mediator.emit('console:param', { + nick: nick + }); + }) + .on('key:changed', function(key) { + mediator + .emit('console:param', { + key: key + }) + .emit('host:param', { + key: key + }); + }) - mediator.on('command:mute', function () { mediator.emit('audio:mute'); } ); - mediator.on('command:unmute', function () { mediator.emit('audio:unmute'); } ); + // Connect to the default host + .emit('command:connect', undefined, function() { + // Join room and set key if a hash in the format #Room:Key has been provided + if ((hash = window.location.hash)) { + parts = hash.slice(1).split(':'); - // Help console and host keep track of current states - mediator.on('room:changed', function(room) { - mediator.emit('console:param',{ room: room}); - mediator.emit('host:param',{ room: room}); - }); + if (parts[0]) { + mediator.emit('command:join', parts[0]); + } - mediator.on('nick:changed', function(nick) { - mediator.emit('console:param',{ nick: nick}); - }); - - mediator.on('key:changed', function(key) { - mediator.emit('console:param',{ key: key}); - mediator.emit('host:param',{ key: key}); - - }); - - // Connect to the default host - mediator.emit('command:connect', undefined, function() { - // Join room and set key if a hash in the format #Room:Key has been provided - if ((hash = window.location.hash)) { - parts = hash.slice(1).split(':'); - - if (parts[0]) { - mediator.emit('command:join', parts[0]); + if (parts[1]) { + mediator.emit('command:key', parts[1]); + } } - - if (parts[1]) { - mediator.emit('command:key', parts[1]); - } - } - }); + }); }); \ No newline at end of file diff --git a/public/js/cryptalk_modules/host.js b/public/js/cryptalk_modules/host.js index cadc642..5ebf430 100644 --- a/public/js/cryptalk_modules/host.js +++ b/public/js/cryptalk_modules/host.js @@ -252,7 +252,7 @@ define( param = function (p) { parameters = fandango.merge({}, parameters, p ); }; - + mediator.on('command:host', host); mediator.on('command:hosts', hosts); mediator.on('command:connect', connect); @@ -261,6 +261,4 @@ define( mediator.on('socket:emit', emit); mediator.on('host:param', param); - - }); \ No newline at end of file