From ec494ee7f3ec167dbbc018667f527936df796497 Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Fri, 24 May 2013 17:39:10 -0600 Subject: [PATCH] Multiple chatroom support: namespace userlist DOM IDs --- js/client-chat.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/js/client-chat.js b/js/client-chat.js index 5fd21cbf2..75946dec3 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -872,7 +872,7 @@ }, construct: function() { var buf = ''; - buf += '
  • ' + (this.room.userCount.users || '0') + ' users
  • '; + buf += '
  • ' + (this.room.userCount.users || '0') + ' users
  • '; var users = []; if (this.room.users) { var self = this; @@ -888,7 +888,7 @@ buf += this.noNamedUsersOnline; } if (this.room.userCount.guests) { - buf += '
  • (' + this.room.userCount.guests + ' guest' + (this.room.userCount.guests == 1 ? '' : 's') + ')
  • '; + buf += '
  • (' + this.room.userCount.guests + ' guest' + (this.room.userCount.guests == 1 ? '' : 's') + ')
  • '; } this.$el.html(buf); }, @@ -914,11 +914,11 @@ }, updateUserCount: function() { var users = Math.max(this.room.userCount.users || 0, this.room.userCount.globalUsers || 0); - $('#usercount-users').html('' + users); + $('#' + this.room + '-usercount-users').html('' + users); }, updateCurrentUser: function() { - $('.userlist > .cur').attr('class', ''); - $('#userlist-user-' + me.userForm).attr('class', 'cur'); + $('.userlist > .cur').attr('class', ''); // this doesn't need to be namespaced + $('#' + this.room + '-userlist-user-' + me.userForm).attr('class', 'cur'); }, add: function(userid) { var users = this.$el.children(); @@ -940,7 +940,7 @@ $(this.constructItem(userid)).insertAfter($(users[right])); }, remove: function(userid) { - $('#userlist-user-' + userid).remove(); + $('#' + this.room + '-userlist-user-' + userid).remove(); }, buttonOnClick: function(userid) { if (app.user.get('named')) { @@ -953,7 +953,7 @@ var text = ''; // Sanitising the `userid` here is probably unnecessary, because // IDs can't contain anything dangerous. - text += ''; + text += ''; text += '