diff --git a/eStreamChat/Scripts/eStreamChat.js b/eStreamChat/Scripts/eStreamChat.js index 9d61e82..eafe6ef 100644 --- a/eStreamChat/Scripts/eStreamChat.js +++ b/eStreamChat/Scripts/eStreamChat.js @@ -139,11 +139,12 @@ $(function () { } // Set default active tab - if (!messengerMode) + if (!messengerMode) { activePanel = $('#panel-room'); - else { - $('#panel-room').attr('id', 'panel-' + messengerTargetUserId); - activePanel = $('#panel-' + messengerTargetUserId); + } else { + // replace non-alphanumeric characters in the userid + $('#panel-room').attr('id', 'panel-' + messengerTargetUserId.replace(/[^\w]/g, '_')); + activePanel = $('#panel-' + messengerTargetUserId.replace(/[^\w]/g, '_')); } // Prepare the text formatting buttons @@ -881,10 +882,12 @@ function getPanelForMessage(message) { } function getPanelByUserId(userId) { - if (userId == null) + if (userId == null) { return $('#panel-room'); - else - return $('#panel-' + userId); + } else { + // replace non-alphanumeric characters in the userid + return $('#panel-' + userId.replace(/[^\w]/g, '_')); + } } $.fn.setCursorPosition = function(pos) {