Merge branch 'master' of https://github.com/fnp/wolnelektury
[wolnelektury.git] / wolnelektury / static / js / pdcounter.js
1 (function($) {
2     $(function() {
3
4
5         $('#countdown').each(function() {
6             var $this = $(this);
7
8             var serverTime = function() {
9                 var time = null;
10                 $.ajax({url: '/zegar/',
11                     async: false, dataType: 'text',
12                     success: function(text) {
13                         time = new Date(text);
14                     }, error: function(http, message, exc) {
15                         time = new Date();
16                 }});
17                 return time;
18             }
19
20             if (LANGUAGE_CODE != 'en') {
21                 $.countdown.setDefaults($.countdown.regional[LANGUAGE_CODE]);
22             }
23             else {
24                 $.countdown.setDefaults($.countdown.regional['']);
25             }
26
27             var d = new Date($this.attr('data-year'), 0, 1);
28             function re() {location.reload()};
29             $this.countdown({until: d, format: 'ydHMS', serverSync: serverTime,
30                 onExpiry: re, alwaysExpire: true});
31
32         });
33
34
35     });
36 })(jQuery)