每xxxxx毫秒檢測一次是否在線,
TR_COUNT次之後設定改用戶為假死狀態(即不在當前頁面活動,afk..)
當頁面關閉時把停留時間送出,
/**//* ----------------------------------------------------------------------------
* Script Name: online.js
* Last Modified: 2008-4-13 22:25
* Author: meyu
* Copyright (c) 2008
* Purpose: 跟蹤在線時間
* ----------------------------------------------------------------------------*/
function TR_XMLHttpObject(url)...{
this.XMLHttp=null;
this.url=url;
this.init=function()...{
if(window.XMLHttpRequest)...{
this.XMLHttp=new XMLHttpRequest();
}else if(window.ActiveXObject)...{
this.XMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
};
this.init();
this.sendData=function(param)...{
with(this.XMLHttp)...{
open('GET',this.url+(param||''),true);
send(null);
}
};
}
if(/flag=flush/i.test(window.location.search))...{
var TR_COUNT=0;
var TR_x=new TR_XMLHttpObject(window.location.href.replace(/&?(?:flush_count=)(d+)/i,
function(a,d)...{
TR_COUNT=parseInt(d);
return "";
})
);
function send()...{
TR_COUNT++;
if(TR_COUNT < 120)...{
TR_x.sendData('&flush_count='+TR_COUNT);
}
}
window.setInterval(send,30000);
window.onunload=function()...{TR_x.sendData('&flush_count='+TR_COUNT);};
}