cryptalk/public/js/lib/cryptalk.js

68 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2017-02-07 15:19:23 -05:00
// Main cryptalk module
2017-02-22 17:09:50 -05:00
define(['castrato','host','client','console'], function (mediator) {
2017-02-07 15:19:23 -05:00
// Route mediator messages
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');
})
// 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
});
})
// 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(':');
if (parts[0]) {
mediator.emit('command:join', parts[0]);
}
if (parts[1]) {
mediator.emit('command:key', parts[1]);
}
}
});
2014-09-26 08:46:35 -04:00
});