📄 workershow.js
字号:
//支持CTRL+ENTER发信息
function ctrlEnter()
{
if(!window.event.ctrlKey&&window.event.keyCode==13) {
Chat.Send();
}
return false;
}
function Person(){}
Person.prototype.Name="";
Person.prototype.TrueName="";
Person.prototype.Status="";
Person.prototype.ClassID="";
Person.prototype.GuestCount=0;
var TypeMenu=
{
selected:null,
Persons:null,
Init:function()
{
var doc=XmlDocument("CustServiceType.xml");
var alHgih=$('UserList').style.height.replace('px','');
var tagHight=20;
var n=doc.getElementsByTagName("Item");
var listHeight=alHgih-tagHight*n.length;
var tmp="";
for(var i=0;i<n.length;i++)
{
tmp+='<div id="type'+n[i].getAttribute("Value")+'" style="background:url(images/titlek_bg.gif); height:23px;padding:3px 0 0px 23px;cursor:pointer" onclick="TypeMenu.SelectType('+n[i].getAttribute("Value")+')">'+n[i].childNodes[0].data+'</div>';
tmp+='<div id="menu'+n[i].getAttribute("Value")+'" style=" background:#F6F6EF;display:none; border-top: 1px solid #b0b0b0; height:'+listHeight+'px"></div>';
//alert(n[i].getAttribute("Value")+n[i].text);
}
$('UserList').innerHTML=tmp;
//$('UserList').insertAdjacentHTML("afterBegin",tmp);
},
SelectType:function(id)
{
if(this.selected!=null)
this.selected.style.display='none';
document.getElementById('menu'+id).style.display='block';
this.selected=document.getElementById('menu'+id);
},
LoadWorkers:function()
{
var data=worker.GetAllWorker();
this.Persons=new Object();
var tmp="";
for(var i=0;i<data.length;i++)
{
var p=new Person();
p.Name=data[i].Name;
p.TrueName=data[i].TrueName;
p.Status=data[i].Status;
p.ClassID=data[i].ClassID;
this.Persons[p.Name]=p;
var agr=p.Status>0 ? 'online' : 'unline';
document.getElementById('menu'+p.ClassID).innerHTML+="<div style='margin:3px 0 0 3px;padding:0 0 0px 15px;line-height:17px' id='worker_"+p.Name+"' class='"+agr+"' onClick='worker.ReplaceWork(this)'> "+p.TrueName+"</div>";
}
//alert(p.ClassID);
//alert(document.getElementById('menu'+p.ClassID).parentElement.id);
//document.getElementById('menu'+p.ClassID).innerHTML=tmp;
},
Update:function(online)
{
for( var k in this.Persons)
{
document.getElementById('worker_'+k).className= online[k]==undefined ? 'unline' : 'online';
}
}
}
var Chat=
{
List:null,
SelectingHtml:'<div class="tagl_1"></div> <div class="tagl_2">NAME</div><div class="tagl_3"></div>',
SelectedHtml:'<div class="tags_1"></div> <div class="tags_2" onClick="Chat.Select(this.parentNode.id)">NAME</div><div class="tags_3"></div>',
selectingID:'',
Select:function(id)
{
if(this.selectingID==id)return;
if(this.selectingID!="" && this.List[this.selectingID]!=undefined)
{
var loseHTML=this.SelectedHtml.replace('NAME',this.List[this.selectingID]);
var loseNode=createElement('div',{'id':this.selectingID},null,loseHTML);
document.getElementById(this.selectingID).parentNode.replaceChild(loseNode, document.getElementById(this.selectingID));
document.getElementById('show_'+this.selectingID).style.display='none';
}
var currHTML=this.SelectingHtml.replace('NAME',this.List[id]);
var currNode=createElement('div',{'id':id},null,currHTML);
document.getElementById(id).parentNode.replaceChild(currNode, document.getElementById(id));
document.getElementById('show_'+id).style.display='block';
this.selectingID=id;
},
Add:function(id)
{
var loseHTML=this.SelectedHtml.replace('NAME',this.List[id]);
var loseNode=createElement('div',{'id':id},{'float':'left'},loseHTML);
//alert(loseHTML);
document.getElementById('TagMenu').appendChild(loseNode);
$('ShowArea').insertBefore(createElement('div',{'id':'show_'+id},{'display':'none'}),document.getElementById("EndShow"));
},
Del:function(id)
{
document.getElementById('TagMenu').removeChild(document.getElementById(id));
$('ShowArea').removeChild(document.getElementById('show_'+id));
delete this.List[id];
if(id==this.selectingID)this.Select('WorkChannl');
},
Init:function()
{
this.List=new Object();
this.List["WorkChannl"]=workerCN.WorkChannl;
this.Add("WorkChannl");
this.Select("WorkChannl");
},
Update:function(newObj)
{
//处理客户离线
for(var k in this.List)
{
if(newObj[k]==undefined && k!='WorkChannl')
this.Del(k);//掉线了
else
delete newObj[k];
}
//处理新客户
for(var v in newObj)
{
this.List[v]=newObj[v];
this.Add(v);
}
},
Send:function()
{
if($('Input').value.trim()=="")return;
var showMessage="<span class='WorkerName'>"+worker.Name+"</span> <span class='ShowTime'>"+new Date()+"</span><br /><span class='Showinput'>"+$('Input').value.replace(/\n/g,"</span><br /><span class='Showinput'>");
document.getElementById('show_'+this.selectingID).appendChild(createElement('div',null,null,showMessage));
document.getElementById("EndShow").scrollIntoView();
worker.ChatWorker($('Input').value.replace(/\n/g,"<br />").replace(/\r/g,""),this.selectingID);
document.getElementById(this.selectingID).style.color="black";
$('Input').value="";
},
ReceivedByWorker:function(obj)
{
var i=0;
for(var k in obj)
{
var showMessage="<span class='WorkerName'>"+TypeMenu.Persons[k].TrueName+"</span> <span class='ShowTime'>"+new Date()+"</span><br />"+obj[k].replace(/⊕/g,"'");
document.getElementById('show_WorkChannl').appendChild(createElement('div',null,null,showMessage));
i++;
}
if(i>0)document.getElementById("EndShow").scrollIntoView();
},
ReceivedByGuest:function(obj)
{
var i=0;
for(var k in obj)
{
var showMessage="<span class='WorkerName'>"+this.List[k]+"</span> <span class='ShowTime'>"+new Date()+"</span><br />"+obj[k].replace(/⊕/g,"'");
document.getElementById('show_'+k).appendChild(createElement('div',null,null,showMessage));
if(showMessage != null)
{
/*var gst = document.getElementById("tagMenu").getElementsByTagName("DIV");
for(var x=0;x<gst.length;x++)
{
if(gst[x].id==k)
{
document.getElementById(k).style.color="red";
}
}*/
document.getElementById(k).style.color="red";
}
i++;
}
if(i>0)document.getElementById("EndShow").scrollIntoView();
//alert(showMessage);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -