Get the latest version:
Download »
Extract the js file somewhere below webroot on your webserver.
I prefer a folder "js" or "javascript".
What You need to do is:
<!doctype html>
<html>
<head>
(...)
<script src="/javascript/localstats.class.js"></script>
(...)
</head>
<body>
(...)
page content ...
(...)
<script>
var oStats=new localStats();
// track the request
oStats.track();
</script>
</body>
</html>
<p>
your page requests so far:
<span id="spanCounter"></span>
</p>
<script>
var oStats=new localStats();
document.getElementById("spanCounter").innerHTML=oStats.getCountTotal();
</script>
<!DOCTYPE html>
<html>
<head>
<title>localstats-Demo</title>
<script src="/axel/javascript/localstats/localstats.class.js"></script>
<style>
.localstatsbar{background:#ace;}
</style>
</head>
<body>
<div>Demo of statistics</div>
<div id="stats">[please wait ...]</div>
<script>
function renderStats(){
var sHtml='';
sHtml+='<h2>LocalStats</h2>';
var oStats=new localStats();
var myDate=new Date(oStats.getCountSince());
sHtml+='requests: <strong>'+oStats.getCountTotal() + '</strong> '
+'of <strong>'+oStats.getPageCount()
+'</strong> different pages since <em>' + myDate + '</em> '
+ oStats.renderTopTable(20)
;
document.getElementById("stats").innerHTML=sHtml;
}
window.setTimeout("renderStats()", 200);
</script>
</body>
</html>