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

View File

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