I found this script on a website and I’m trying to change it up a little bit and see if I can get some usability out of it. Of course, I will give credit to the place I found it. So, can anyone help me understand this script a bit more? I would like to be able to change up the amount of change each second. Currently, it looks like .0004 per second. I would also like to be able to set the starting value. (Like where did the counter start?)
Any help would be greatly appreciated.
[CODE]<html>
<head>
<script type=”text/javascript”>
<!–
function element(id) {
if (document.getElementById) {
return document.getElementById(id);
} else if (window[id]) {
return window[id];
}
return null;
}
var COUNT = [
[ 1171429200000, 102400 ],
[ 1181797200000, 106496 ]
];
var storage;
function updateStorage() {
if (!storage) {
return;
}
var current = (new Date()).getTime();
var i;
for (i = 0; i < COUNT.length; i++) {
if (current < COUNT[i][0]) {
break;
}
}
if (i == 0) {
setTimeout(updateStorage, 1000);
} else if (i == COUNT.length) {
storage.innerHTML = COUNT[i – 1][1];
} else {
var ts = COUNT[i – 1][0];
var bs = COUNT[i – 1][1];
storage.innerHTML = formatStorage(((current-ts) / (COUNT[i][0]-ts) * (COUNT[i][1]-bs)) + bs);
setTimeout(updateStorage, 1000);
}
}
var PAD = ‘.0000’;
function formatStorage(num) {
var str = String(num);
var dot = str.indexOf(‘.’);
if (dot < 0) {
return str + PAD;
} if (PAD.length > (str.length – dot)) {
return str + PAD.substring(str.length – dot);
} else {
return str.substring(0, dot + PAD.length);
}
}
// –>
</script>
</head>
<body>
Storage Counter: <b id=”storage”></b> MB
<script type=”text/javascript”>
<!–
storage = element(“storage”);
updateStorage();
// –>
</script>
</body>
</html>