这是部分的JS代码
目的是想处理出群的管理员和创建者
附件里提供完整的JS代码和需要用到的处理代码内容
this.setGroupInfo = function(W) {
var V = W.ginfo;
var N = W.minfo;
var J = W.stats;
var al = {};
for (var ag = J.length; ag--;) {
var Y = J[ag];
al[Y.uin] = J[ag];
}
var Q = W.cards || [];
var U = this.getGroupByCode(V.code);
U.setLevel(V.level);
var ab = this.getSelfUin();
U.setAnnouncement(V.memo || " ");
var af = V.members;
var ak = [];
var T = false;
var ai = 0;
for (var ae = 0; ae < af.length; ae++) {
var ad = "common";
if (af[ae].mflag & 1) {
ad = "manager";
if (af[ae].muin === ab) {
T = true;
}
} else {
if (af[ae].mflag & 2) {
ad = "manager2";
if (af[ae].muin === ab) {
T = true;
}
}
}
if (af[ae].muin == V.owner) {
ad = "master";
if (af[ae].muin === ab) {
T = true;
}
}
var O = af[ae].muin;
var aj = N[ae].nick;
var S = N[ae].nick;
if (S == "") {
S = String(O);
}
var R = (al[O] && al[O]["stat"]) || 20;
var aa = (al[O] && al[O]["client_type"]) || 10000;
if (R != 20 || O === ab) {
ai++;
}
var X = aj;
var ah = aj;
for (var ac = 0; ac < Q.length; ac++) {
if (Q[ac].muin == O) {
S = Q[ac].card;
break;
}
}
var an = this.getUserByUin(af[ae].muin);
if (an) {
var P = alloy.util.code2state(R);
if (an.uin != ab) {
an.setState(P);
an.gstate = R;
}
if (an.type === "groupBuddy" || an.uin === ab) {
var am = (S ? S: an.showName);
an.setUsercard(V.code, am);
} else {
S = S === aj ? an.showName: S;
}
an.setClientType(aa);
} else {
var Z = {
uin: O,
nick: aj,
clientType: aa,
state: alloy.util.code2state(R)
};
an = this.createUser(Z);
an.type = "groupBuddy";
an.group = U;
an.gstate = R;
}
var am = (S ? S: an.showName);
an.setUsercard(V.code, am);
ak[ae] = {
uin: O,
flag: ad,
gcode: V.code,
nick: aj,
htmlNick: j.string.encodeHtmlSimple(aj),
titleNick: (aj),
showName: X,
htmlShowName: j.string.encodeHtmlSimple(X),
titleShowName: j.string.encodeHtmlAttributeSimple(X),
allName: ah,
htmlAllName: j.string.encodeHtmlSimple(ah),
titleAllName: ah,
usercard: j.string.encodeHtmlSimple(S)
};
ak[ae].info = an;
U.uin2members[O] = ak[ae];
}
U.isLoadInfo = true;
U.hasManageAuthority = T;
U.updateMembers(ak, ai);
s.notifyObservers(this, "GroupInfoChange", U);
};
|