Checks online every xxxxx milliseconds,
After TR_COUNT times, set the user to false dead state (that is, it is not active on the current page, afk ..)
When the page is closed, send the stay time,
/**//*----------------------------------------------------------------------------
* Script Name: online. js
* Last Modified:
* Author: meyu
* Copyright (c) 2008
* Purpose: tracking online time
*----------------------------------------------------------------------------*/
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 );};
}