This commit is contained in:
unkelpehr 2014-09-27 14:44:41 +02:00
parent 276220eaf4
commit cb37d41502
2 changed files with 28 additions and 21 deletions

View File

@ -12,15 +12,11 @@
*/
define(
{
define({
compiles: ['$'],
requires: ['castrato','settings','templates']
}, function ($, requires, data) {
var
// Private properties
}, function ($, requires) {
var // Private properties
room = false,
// Require shortcuts
@ -30,21 +26,34 @@ define(
join = function(payload) {
if (room !== false) {
mediator.emit('console:error',$.template(templates.messages.already_in_room, { room: room }));
mediator.emit('console:error',
$.template(templates.messages.already_in_room, {
room: room
})
);
} else if (payload.length >= settings.room.maxLen) {
mediator.emit('console:error', $.template(templates.messages.room_name_too_long));
} else if (payload.length < settings.room.minLen) {
mediator.emit('console:error', $.template(templates.messages.room_name_too_short));
} else {
room = payload;
mediator.emit('room:changed', room );
mediator.emit('socket:emit',{ data: 'room:join' , payload: $.SHA1(room) } );
mediator
.emit('room:changed', room)
.emit('socket:emit', {
data: 'room:join',
payload: $.SHA1(room)
});
}
},
leave = function() {
if (room !== false) {
mediator.emit('socket:emit',{ data: 'room:leave' , payload: $.SHA1(room) } );
mediator.emit('socket:emit', {
data: 'room:leave',
payload: $.SHA1(room)
});
room = false;
} else {
mediator.emit('console:error', templates.messages.leave_from_nowhere);
@ -63,5 +72,4 @@ define(
mediator.on('command:join', join);
mediator.on('command:leave', leave);
mediator.on('command:count', count);
});

View File

@ -36,6 +36,5 @@ define({
notifications: {
maxOnePerMs: 3000
},
}
});