Sha256: b075bbce9945cd49c1c6a2dde8a949132ff58e44704535004c5c39f7eb23d1cc

Contents?: true

Size: 947 Bytes

Versions: 5

Compression:

Stored size: 947 Bytes

Contents

(function(){

var badgeInterval;

spud.admin.dashboard = {
  init:function(){
    badgeInterval = setInterval(updateBadges, 30000);
    updateBadges();
  }
};

var updateBadges = function() {
  var url = tb.util.urlFor('admin/badges');
  $.ajax({
    url: url
  }).always(function(json) {
    if(json && json.data) {
      if(json.data.length === 0){
        clearInterval(badgeInterval);
      }
      else{
        json.data.forEach(function(eachBadge) {
          var id = "application_name_" + eachBadge.key;
          updateBadge(id, eachBadge.badge_count);
        });
      }
    }
  });
};

var updateBadge = function(badge_id, count) {
  var badgeIcon = $('#' + badge_id).find('.dash_icon_badge');
  if(badgeIcon.length === 0) {
    return;
  }
  else if (count === 0) {
    badgeIcon.toggle(false);
  }
  else if (count > 999) {
    badgeIcon.text("999+").toggle(true);
  }
  else {
    badgeIcon.text(count).toggle(true);
  }
};

})();

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tb_core-1.2.8 app/assets/javascripts/admin/core/dashboard.js
tb_core-1.2.7 app/assets/javascripts/admin/core/dashboard.js
tb_core-1.2.6 app/assets/javascripts/admin/core/dashboard.js
tb_core-1.2.4 app/assets/javascripts/admin/core/dashboard.js
tb_core-1.2.3 app/assets/javascripts/admin/core/dashboard.js