move to django 1.4 and django-pipeline,
[wolnelektury.git] / apps / pdcounter / static / pdcounter / pdcounter.js
diff --git a/apps/pdcounter/static/pdcounter/pdcounter.js b/apps/pdcounter/static/pdcounter/pdcounter.js
new file mode 100755 (executable)
index 0000000..0352076
--- /dev/null
@@ -0,0 +1,36 @@
+(function($) {
+    $(function() {
+
+
+        $('#countdown').each(function() {
+            var $this = $(this);
+
+            var serverTime = function() {
+                var time = null;
+                $.ajax({url: '/zegar/',
+                    async: false, dataType: 'text',
+                    success: function(text) {
+                        time = new Date(text);
+                    }, error: function(http, message, exc) {
+                        time = new Date();
+                }});
+                return time;
+            }
+
+            if (LANGUAGE_CODE != 'en') {
+                $.countdown.setDefaults($.countdown.regional[LANGUAGE_CODE]);
+            }
+            else {
+                $.countdown.setDefaults($.countdown.regional['']);
+            }
+
+            var d = new Date($this.attr('data-year'), 0, 1);
+            function re() {location.reload()};
+            $this.countdown({until: d, format: 'ydHMS', serverSync: serverTime,
+                onExpiry: re, alwaysExpire: true});
+
+        });
+
+
+    });
+})(jQuery);
\ No newline at end of file