[mw-devel] MW3 r1236 - trunk/webclient
dez at sucs.org
dez at sucs.org
Sat Nov 13 23:56:05 GMT 2010
Author: dez
Date: 2010-11-13 23:56:04 +0000 (Sat, 13 Nov 2010)
New Revision: 1236
Modified:
trunk/webclient/say.js
Log:
Implements an internal who list so user colours remain consistent
Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js 2010-11-13 16:05:53 UTC (rev 1235)
+++ trunk/webclient/say.js 2010-11-13 23:56:04 UTC (rev 1236)
@@ -230,21 +230,38 @@
}
function userInit(data, stat) {
+ userIndex=new Object;
+ data.sort(sortWho);
+ usercount=0;
+ for (var person in data) {
+ var thisUsername=data[person].username.toLowerCase();
+ if (thisUsername in userIndex) usercount--;
+ userIndex[thisUsername]=usercount;
+ usercount++;
+ }
+}
+function userAdd(data, stat) {
+ for (var person in data) {
+ var thisUsername=data[person].username.toLowerCase();
+ if (!(thisUsername in userIndex)) {
+ userIndex[thisUsername]=usercount;
+ usercount++;
+ }
+ }
}
function drawWhoList(data, stat) {
var idleness;
- userIndex=new Object;
+ if(typeof userIndex == "undefined") userInit(data, stat);
+ else userAdd(data, stat);
+
$("li").remove();
data.sort(sortWho);
- var usercount=0;
for (var person in data) {
idleness="";
if (data[person].idle>1800) idleness=" idle";
var thisUsername=data[person].username.toLowerCase();
- if (thisUsername in userIndex) usercount--;
- userIndex[thisUsername]=usercount;
var personinfo = "<div class=\"whoinfo\">";
if (data[person].hgwidth>0) personinfo += "<img src=\"https://sucs.org/pictures/people/"+data[person].username.toLowerCase()+".png\" width=\""+data[person].hgwidth+"\" height=\"64\" />";
else personinfo += "<img src=\"person.png\" width=\"64\" height=\"64\" />";
@@ -254,11 +271,8 @@
if (data[person].realname!=undefined) personinfo += data[person].realname+"<br />";
personinfo += "Room "+data[person].channel;
personinfo += "</div>";
- $("#wholist").append("<li class=\"who user_"+usercount+idleness+"\"><a href=\"#\">"+data[person].username+personinfo+"</a></li>");
- usercount++;
+ $("#wholist").append("<li class=\"who user_"+userIndex[thisUsername]+idleness+"\"><a href=\"#\">"+data[person].username+personinfo+"</a></li>");
}
- $("#debug").empty();
-// $("#debug").append(concatObject(userIndex));
}
function userProfile(data, stat) {
More information about the mw-devel
mailing list