2014-09-21 13:53:57 -04:00
|
|
|
// Main cryptalk module
|
|
|
|
define({
|
2014-09-18 12:21:07 -04:00
|
|
|
compiles: ['$'],
|
2014-09-26 08:46:35 -04:00
|
|
|
requires: ['castrato','console','host','client']
|
2014-09-18 12:21:07 -04:00
|
|
|
}, function ($, requires, data) {
|
2014-09-25 17:43:24 -04:00
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
// Require shortcut
|
|
|
|
var mediator = requires.castrato;
|
2014-09-21 08:00:55 -04:00
|
|
|
|
2014-09-23 13:54:36 -04:00
|
|
|
// Route mediator messages
|
2014-09-24 11:20:20 -04:00
|
|
|
mediator.on('window:focused',function() {
|
|
|
|
mediator.emit('audio:off');
|
|
|
|
mediator.emit('notification:off');
|
2014-09-23 13:54:36 -04:00
|
|
|
});
|
2014-09-26 08:46:35 -04:00
|
|
|
|
2014-09-24 11:20:20 -04:00
|
|
|
mediator.on('window:blurred',function() {
|
2014-09-26 08:46:35 -04:00
|
|
|
mediator.emit('audio:on');
|
2014-09-24 11:20:20 -04:00
|
|
|
mediator.emit('notification:on');
|
2014-09-23 13:54:36 -04:00
|
|
|
});
|
2014-09-18 12:21:07 -04:00
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
mediator.on('command:mute', function () { mediator.emit('audio:mute'); } );
|
|
|
|
mediator.on('command:unmute', function () { mediator.emit('audio:unmute'); } );
|
2014-09-22 16:11:13 -04:00
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
// 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});
|
|
|
|
});
|
|
|
|
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});
|
|
|
|
|
|
|
|
});
|
2014-09-25 17:43:24 -04:00
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
// 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) {
|
2014-09-22 16:11:13 -04:00
|
|
|
parts = hash.slice(1).split(':');
|
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
parts[0] && mediator.emit('command:join',parts[0]);
|
|
|
|
parts[1] && mediator.emit('command:key',parts[1]);
|
|
|
|
}
|
2014-09-22 16:11:13 -04:00
|
|
|
});
|
2014-09-21 14:45:20 -04:00
|
|
|
|
2014-09-26 08:46:35 -04:00
|
|
|
});
|