How can I make my counter look less fake?
Posted
by Eddy Pronk
on Stack Overflow
See other posts from Stack Overflow
or by Eddy Pronk
Published on 2010-05-20T03:17:59Z
Indexed on
2010/05/20
3:20 UTC
Read the original article
Hit count: 242
JavaScript
I'm using this bit of code to display the number of users on a site. My customer is complaining it looks fake. Any suggestions?
var visitors = 187584;
var updateVisitors = function()
{
visitors++;
var vs = visitors.toString(),
i = Math.floor(vs.length / 3),
l = vs.length % 3;
while (i-->0) if (!(l==0&&i==0))
vs = vs.slice(0,i*3+l)
+ ','
+ vs.slice(i*3+l);
$('#count').text(vs);
setTimeout(updateVisitors, Math.random()*2000);
};
setTimeout(updateVisitors, Math.random()*2000);
© Stack Overflow or respective owner