📄 main.js.svn-base
字号:
var friends = user.friends;
function loadUser(){
document.getElementById('loginEmail').firstChild.nodeValue = user.name;
document.getElementById('nickName').firstChild.nodeValue =user.nickName;
}
function Friend(email,nick,status,isBlock){
this.email = email;
this.nick = nick;
this.status = status;
this.isBlock = isBlock;
}
Friend.prototype.equals = function(another){
return!(!(this.email==another.email) || !(this.nick==another.nick) || !(this.isSameStatus(another)));
}
Friend.prototype.isSameStatus = function(another){
return !((!this.status==another.status) || !(this.isBlock==another.isBlock));
}
Friend.prototype.getGroup = function(){
if(this.isBlock == 1){
return document.getElementById("blockedFriends");
}else{
switch (this.status){
case "NLN":
case "PHN":
case "BSY":
case "IDL":
case "AWY":
case "BRB":
case "LUN":
return document.getElementById("onlineFriends");
case "FLN":
case "HDN":
return document.getElementById("offlineFriends");
default :
return document.getElementById("lastedFriends");
}
}
}
friends.put=function(friend){
if (this[friend.email]==undefined){
this.append(friend);
}
else{
this.modify(friend);
}
changeGroupBars();
}
friends.modify=function(friend){
if (this[friend.email].equals(friend)) return;
if ( !(this[friend.email].isSameStatus( friend )) ){
var _item = document.getElementById( hashCode(friend.email) );
_item.parentNode.removeChild(_item);
friend.getGroup().appendChild( _item );
}
else{
_item.firstChild.nodeValue = friend.nick;
}
}
friends.append=function(friend){
this[friend.email]=friend;
var _item = document.createElement("a");
_item.setAttribute("id",hashCode(friend.email));
_item.setAttribute("title","email:"+friend.email+"\n昵称:"+friend.nick+"\n状态:"+getStatus(friend.status));
//_item.setAttribute("style","margin-left:40px; display:block;");
_item.setAttribute("class","friend");
_item.setAttribute("href","#");
_item.setAttribute("onclick","changedisplay('conversation','mainUI');loadFriend(friend);");
_item.appendChild(document.createTextNode(friend.nick));
friend.getGroup().appendChild( _item );
}
function dealSpecialChar(str){
}
function changeGroupBars(){
changeGroup("lastedFriends","最近联系人(");
changeGroup("onlineFriends"," 联 机(");
changeGroup("offlineFriends"," 脱 机(");
changeGroup("blockedFriends"," 阻 止(");
}
function changeGroup(group,value){
var element =document.getElementById(group+"Bar");
var value =value+document.getElementById(group).childCount+")";
element.setAttribute("value",value);
if(document.getElementById(group).childCount>0)
{
var groupNode=document.getElementById(group);
for(i=groupNode.childCount-1;i>-1;i--){
}
}
}
function hashCode(str){
var h = 0, off = 0;
var len = str.length;
for(var i =len-1; i >=0; i--){
h = 31 * h + str.charCodeAt(off++);
}
return h % 2147483647;
}
function loadFriend(friend){
document.getElementById("Div1").firstChild.nodeValue =friend.email;
document.getElementById("Div2").firstChild.nodeValue =friend.nick;
}
function getStatus(statu){
switch(statu){
case "HDN":
return "显示为脱机";
break;
case "AWY":
return "离开";
break;
case "BRB":
return "马上回来";
break;
case "BSY":
return "忙碌";
break;
case "IDL":
return "空闲";
break;
case "FLN":
return "脱机";
break;
case "PHN":
return "接听电话";
break;
case "NLN":
return "联机";
break;
case "LUN":
return "外出就餐";
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -