I found a javascript function that increments a value and then it's showed in a html div. It works perfectly in every browser except Firefox, and I'm really struggling to get a reason why.
The code looks like this:
<script type="text/javascript">
$(window).load(function(){
var amount = document.getElementById('amount');
var start = new Date("March 12, 2014 12:28:00").getTime();
var current;
update();
function update() {
var current = (new Date().getTime() - start)/1000*1.00+0;
amount.innerText = formatMoney(current);
}
setInterval(update,1000);
function formatMoney(amount) {
var dollars = Math.floor(amount).toString().split('');
var cents = (Math.round((amount%1)*100)/100).toString().split(',')[1];
if(typeof cents == 'undefined'){
cents = '00';
}else if(cents.length == 1){
cents = cents + '0';
}
var str = '';
for(i=dollars.length-1; i>=0; i--){
str += dollars.splice(0,1);
if(i%3 == 0 && i != 0) str += '.';
}
return str + ' ' + '€';
}
});
</script>
<div id='amount'></div>