jQuery countdown serverSync for multiple countdowns
Hi,
I use jQuery CountDown on an auction website. There are multiple countdowns on the same page, and sometimes a countdown is updated (when a bid is made in the last 30 seconds of the countdown) via pusher.
The problem is that the countdown is not really reliable. When I open several navigators, there are some differences between the countdowns. Sometimes 3 or 4 seconds.
The options serverSync is used, but it seems that when the countdown is updated, the new value is not synchronized anymore ...
I would like to resync the coutwdowns each time a bid is made, or at a specific interval (every 5 seconds for example). Is there any way I can do that ?
Thx for your help,
G.
Here is the code I use for each countdowns (values comes from PHP) when the page is loaded :
- $(function () {
- $('#Countdown".$articles."').countdown({serverSync: serverTime,
- until: $.countdown.UTCDate(+1, $y, $m-1, $d, $h, $min, $sec, 0),
- onTick: highlightLast5,
- expiryText: '<div class=\"over\">Le vente est clôturée</div>',
- onExpiry: liftOff".$articles."});
- $('#Countdown".$articles."').countdown($.countdown.regionalOptions['fr']);
- });
The code when I update the countdown :
- var t = $("#Countdown"+data.lot).countdown('getTimes');
- t[6] += 30;
- $("#Countdown"+data.lot).countdown('option', 'until', t[0] + 'y ' + t[1] + 'o ' + t[2] + 'w ' + t[3] + 'd ' + t[4] + 'h ' + t[5] + 'm ' + t[6] + 's');