From cb37d415026c2421c164983b15d1f7c1c86a2559 Mon Sep 17 00:00:00 2001 From: unkelpehr Date: Sat, 27 Sep 2014 14:44:41 +0200 Subject: [PATCH] Bughunt --- public/js/cryptalk_modules/room.js | 46 +++++++++++++++----------- public/js/cryptalk_modules/settings.js | 3 +- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/public/js/cryptalk_modules/room.js b/public/js/cryptalk_modules/room.js index 790e6cf..3e6643c 100644 --- a/public/js/cryptalk_modules/room.js +++ b/public/js/cryptalk_modules/room.js @@ -12,16 +12,12 @@ */ -define( - { - compiles: ['$'], - requires: ['castrato','settings','templates'] - }, function ($, requires, data) { - - var - - // Private properties - room=false, +define({ + compiles: ['$'], + requires: ['castrato','settings','templates'] +}, function ($, requires) { + var // Private properties + room = false, // Require shortcuts mediator = requires.castrato, @@ -30,30 +26,43 @@ 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)); + 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)); + 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); + mediator.emit('console:error', templates.messages.leave_from_nowhere); } }, count = function() { if (room) { - mediator.emit('socket:emit','room:count'); + mediator.emit('socket:emit', 'room:count'); } else { mediator.emit('console:error', templates.messages.not_in_room); } @@ -63,5 +72,4 @@ define( mediator.on('command:join', join); mediator.on('command:leave', leave); mediator.on('command:count', count); - }); \ No newline at end of file diff --git a/public/js/cryptalk_modules/settings.js b/public/js/cryptalk_modules/settings.js index efe2bac..83ce147 100644 --- a/public/js/cryptalk_modules/settings.js +++ b/public/js/cryptalk_modules/settings.js @@ -36,6 +36,5 @@ define({ notifications: { maxOnePerMs: 3000 - }, - + } }); \ No newline at end of file