
var objAjax=new JAjax();
var ol=new onLineClass();

function loadPage(){
	
	var tools=new toolsClass();
	tools.add("","刷新","ol.loadList()","刷新在线名单")
	tools.add("","自动刷新","auto()","自动刷新在线名单")
	tools.add("","停止刷新","ol.isAuto=0","停止自动刷新在线名单")
	tools.create(toolsDiv)
	
	
	//alert(document.title);
	var t=new outTitle();
	t.add("用户名","","80");
	t.add("所属组","","80");
	t.add("所在页","","150");
	t.add("点击数","","80");
	t.add("来源","","80");
	t.add("连接次数","","80");
	t.add("IP","","100");
	t.add("地区","","100");
	t.add("活动时间","","80");
	t.obj=document.getElementById("onLineTitle");
	t.create();
	
	ol.loadList();
	loadBodyclick();
		setWH();	
	//alert(document.title);
}

function auto(){
	
	//if (ol.isAuto==0){
		
		ol.isAuto=1;
		ol.auto();
	//}else{
//		ol.isAuto=0;
//	}
}

function setWH(){
    var w=Element.getWidth(document.getElementById("winDiv"));
	var h=Element.getHeight(document.getElementById("winDiv"));
	
	var h1=Element.getHeight("toolsDiv");
	var h2=Element.getHeight("onLineTitle");
	var h3=Element.getHeight("countText");
	var objOnList=document.getElementById("onList");
	//alert("h:"+h+",h1:"+h1+",h2:"+h2+",h3:"+h3+",")
	objOnList.style.height=h-h1-h2-h3;
    
}


function onLineClass(){
	this.isAuto=0;
	
	this.auto=function(){
		if (this.isAuto==1){
			this.loadList();
			//alert("aa")
			setTimeout("ol.auto()",5000)	
		}else{
			return;	
		}
	}
	
	this.loadList=function(){
//		var objResponse=new JHttpResponse();
//		objResponse.write("url",url);
		var out=objAjax.getText("post","online.aspx?type=readAll",null,null);
		//alert(out);
		out= comminute(out,c1,c2);
		// 0  用户名
//          1 所属组
//         2 IP
//         3 IP所在地区
//          4 TITLE
//          5 JS检测到的当前页
//          6 JS检测到的当前点击数
//          7 来源
//          8 服务器连接数
//          9 最后服务器连接地址
//          10 最后连接服务器时间
//           11 唯一标识
		  var wData=new tabList();
		  wData.obj=document.getElementById("onList");
		  wData.rowid="userRow_";                          //行的ID
		  wData.rowClass="tabListBodyRow";                 //行的样式
		  wData.mode=1;                                    //数据显示的格式
		  wData.isCheckbox=false;                          //加上复选框
		  wData.onmouseroverRun="";           //鼠标移上
		  wData.onmouseroutRun="";             //鼠标移走
		  wData.onclickRun="";                    //鼠标单击
		  wData.ondblclickRun="";                   //鼠标双击
		  wData.add(raadArray(out,0,0),"onLineList","80");    //添加一列数据  用户名
		  wData.add(raadArray(out,1,0),"onLineList","80");    //添加一列数据 用户组
		  wData.add(raadArray(out,4,0),"onLineList","150");    //
		  wData.add(raadArray(out,6,0),"onLineList","80");    //
		  wData.add(raadArray(out,7,0),"onLineList","80");    //
		  wData.add(raadArray(out,8,0),"onLineList","80");    //
		  wData.add(raadArray(out,2,0),"onLineList","100");    //
		  wData.add(raadArray(out,3,0),"onLineList","100");    //
		  wData.add(raadArray(out,10,0),"onLineList","80");    //
		  wData.addid(raadArray(out,11,0));                         //添加行标识 TID
		  wData.create();	
		  
		  var cObj=document.getElementsByName("userRow__4"); //字符处理第
		  for (var i=0;i<cObj.length;i++){
			 cObj[i].innerHTML=delUrl(cObj[i].innerText);
		  }
		  
		  cObj=document.getElementsByName("userRow__2"); //字符处理第列
		  for (var i=0;i<cObj.length;i++){
			 var v=cObj[i].innerText;
			 v="<a href='"+out[i][5]+"'  target='_blank'>"+v+"</a>";
			 cObj[i].innerHTML=v;
		  }
		  
		  cObj=document.getElementsByName("userRow__8"); //字符处理第列
		  for (var i=0;i<cObj.length;i++){
			 var v=cObj[i].innerText;
			 v=v.split(" ");
			 cObj[i].innerText=v[1];
		  }
		  
		  cObj=document.getElementsByName("userRow__5"); //字符处理第列
		  for (var i=0;i<cObj.length;i++){
			 
			 cObj[i].title=out[i][9];
		  }
		  
		  
		  var x=0;
		  for (var i=0;i<out.length-1;i++){
			  if (out[i][5]!="" & out[i][6]!="0" & out[i][6]!=""){
				x++;  
			  }
		  }
		  
		  $("countText").innerText="   当前一共在线用户数:"+(out.length-1)+", 其中"+x+"个是有效用户 (无效用户是指的搜索引擎、数据采集程序或其它不显示页面的访问)";
	}
	
}

function delUrl(v){
	
	if (v=="") {return "";}
	var vbak=v;
	v=v.replace("http://","");
	v=v.split("/");
	return "<a  href='"+vbak+"' target='_blank'>"+ v[0]+"</a>";
	
}