48 lines
903 B
JavaScript
48 lines
903 B
JavaScript
var VISITOR_COUNTER = document.getElementById("visitorCounter");
|
|
|
|
function formatNumber(n) {
|
|
n = n.toString();
|
|
var result = "";
|
|
var count = 0;
|
|
|
|
for (var i = n.length - 1; i >= 0; i--) {
|
|
result = n.charAt(i) + result;
|
|
count++;
|
|
|
|
if (count % 3 === 0 && i !== 0) {
|
|
result = "," + result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.onreadystatechange = function () {
|
|
if (xhttp.readyState === 4) {
|
|
|
|
if (xhttp.status === 200) {
|
|
try {
|
|
var site_data = eval("(" + xhttp.responseText + ")");
|
|
var views = site_data.info.views;
|
|
|
|
VISITOR_COUNTER.innerHTML = formatNumber(views);
|
|
|
|
} catch (e) {
|
|
VISITOR_COUNTER.innerHTML = "N/A";
|
|
}
|
|
|
|
} else {
|
|
VISITOR_COUNTER.innerHTML = "N/A";
|
|
}
|
|
}
|
|
};
|
|
|
|
xhttp.open(
|
|
"GET",
|
|
"http://www.veltron.net/counter.php?sitename=venith",
|
|
true
|
|
);
|
|
|
|
xhttp.send(null);
|