Commits

Maciej Wiśniowski  committed 01db121

js changes

  • Participants
  • Parent commits d7e0d8b

Comments (0)

Files changed (1)

File dj_banner/static/dj_banner.js

+var banner_slots = [];
+
+function register_slot(name){
+    if (banner_slots.indexOf(name) == -1){
+        banner_slots.push(name);
+    }
+}
+
+jQuery(window).load(function(){
+    // find all banners
+    $('.banner_slot').each(function(){
+        var slug = $(this).id.split('_')[2];
+        register_slot(slug);
+    })
+    var l = banner_slots.length;
+    for (var i=0; i<l; i++){
+        var slug = banner_slots[i];
+        load_banner(slug);
+    }
+});
+
+
+function load_banner(slug){
+    // next url
+    var next = jQuery("#banner_next_" + slug);
+    var next_href = next.attr('href');
+
+    // time
+    var tm = $("#display_time_" + slug).html();
+    var itm = parseInt(tm) * 1000;
+    if (isNaN(itm)) itm=20000;
+
+    jQuery("#banner_slot_" + slug).load(next_href, function(resp, txt, xhr){setTimeout("load_banner('" + slug + "')", itm);});
+}