From 72e9fc93952c1d4f3d7fffc84d5a172909a22a13 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Wed, 24 Sep 2014 22:52:09 +0200 Subject: [PATCH] Fixed behaviour on failed connect, minor cleanup. --- public/js/cryptalk_modules/cryptalk.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/public/js/cryptalk_modules/cryptalk.js b/public/js/cryptalk_modules/cryptalk.js index 3be0932..e0e552a 100644 --- a/public/js/cryptalk_modules/cryptalk.js +++ b/public/js/cryptalk_modules/cryptalk.js @@ -143,9 +143,10 @@ define({ if (host && host.connected) { done(); - return post('error', $.template(templates.messages.already_connected, { + post('error', $.template(templates.messages.already_connected, { host: host.name || 'localhost' })); + return done(); } if ($.isDigits(toHost)) { @@ -156,7 +157,8 @@ define({ request = host.path; } } else { - return post('error', 'Undefined host index: ' + toHost); + post('error', 'Undefined host index: ' + toHost); + return done(); } } else if (fandango.is(toHost, 'untyped')) { settings = toHost.settings; @@ -165,12 +167,14 @@ define({ } if (request) { - return require([request], function (settings) { + require([request], function (settings) { host.settings = settings; commands.connect(toHost, done); }, function () { - return post('error', 'Could not fetch host settings: ' + request); + post('error', 'Could not fetch host settings: ' + request); + return done(); }); + return done(); } // Push 'Connecting...' message @@ -193,7 +197,7 @@ define({ }) .on('room:joined', function (data) { - room = data; + room = $.escapeHtml(data); post('info', $.template(templates.messages.joined_room, { roomName: room })); // Automatically count persons on join @@ -342,7 +346,7 @@ define({ nick = payload; // Inform that the key has been set - post('info', $.template(templates.messages.nick_set, { nick: nick})); + post('info', $.template(templates.messages.nick_set, { nick: $.escapeHtml(nick)})); }, mute: function () {