twan
twan

Reputation: 2659

Countdown flipclock and reset after counting to zero

http://flipclockjs.com/

I need a counter which counts down to zero from a certain time (for example 2 hours). After those two hours the timer needs to reset and starts again.

How can I do this? I can't find anything about it in their docs.

What I got now:

var clock = $('.your-clock').FlipClock({
  countdown : true,
});

Upvotes: 1

Views: 1581

Answers (3)

zuluk
zuluk

Reputation: 1577

Try this one:

var clock = $('.your-clock').FlipClock({
  countdown : true,
});
clock.setTime(10);
clock.start();
setTimeout(function(){ 
  checktime();
}, 1000);

function checktime(){
  t = clock.getTime();
  if(t<=0){
    clock.setTime(10);
    clock.start();
  }
  setTimeout(function(){ 
    checktime();
  }, 1000);
}

Upvotes: 2

Fanyo SILIADIN
Fanyo SILIADIN

Reputation: 792

I assume that you want to decrease every second? this is a non jquery way:

 var counter, myInterval;
    function createCountDown(startHourInSecond){
     counter = startHourInSecond;
     myInterval =window.setInterval(function(){
      counter --;
      if (counter ==0){
      clearInterval(myInterval);
      counter = startHourInSecond;
      createCountDown(counter);
      }
     }, 1000);

    }
createCountDown(7200);

Upvotes: 0

ydydyd
ydydyd

Reputation: 71

You can use method, see 'Chainable Methods' example.

clock.start(function() {
setInterval(function() {
    clock.stop().reset().start();
}, 7200);

});

Upvotes: 0

Related Questions