Hello, I'm creating a timer, to make a music progress bar. I am using the following code. However, this counter starts counting at 00:00 as obviously, but I'd like it to start counting from a value I stipulate, for example: 02:35.
What changes can I make to this happen? Since I could not.
startCounting: function(time){
start = typeof(time) == 'undefined' ? new Date() : time;
loop = window.setInterval('aTurn.updateCouting()', 1);
},
updateCouting: function(){
aTurn.printTime(aTurn.diffProgress(aTurn.getTime()));
},
printTime: function(time){
$('.atual').text(time);
},
getTime: function(){
return(new Date() - start);
},
diffProgress: function(seconds){
if(isNaN(seconds))
seconds = 0;
var diff = new Date(seconds);
var minutes = diff.getMinutes();
var seconds = diff.getSeconds();
if(minutes < 10)
minutes = '0' + minutes;
if(seconds < 10)
seconds = '0' + seconds;
return minutes + ':' + seconds;
},
startProgress: function(){
if(start){
aTurn.unstartProgress();
}
else{
aTurn.startCounting();
return false;
}
},
unstartProgress: function(){
clearInterval(loop);
start = 0;
aTurn.fillText();
},
clearProgress: function(){
aTurn.unstartProgress();
$('.atual').text(aTurn.diffProgress(0));
},
fillText: function(){
$('.atual').text();
}