1/** 2 * 3 * @type {{addBadgeArea, runAlarmBadgeSystem}} 4 */ 5var ALARM_BADGE = function(){ 6 var alarm_count = 0; 7 var alarm_area_list = []; 8 var runAlarmBadgeSystem = function(){ 9 getAlarmCount(function(count){ 10 makeBadge(count); 11 }); 12 }; 13 var getAlarmCount = function (callback) { 14 $.ajax({ 15 type: 'GET', 16 url: ('/ajax/get_alarm_count.cm'), 17 dataType: 'json', 18 async: true, 19 success: function (res) { 20 if(res.msg === 'SUCCESS'){ 21 alarm_count = parseInt(res.count); 22 }else{ 23 alarm_count = 0; 24 } 25 if(typeof callback === 'function'){ 26 callback(alarm_count); 27 } 28 } 29 }); 30 }; 31 32 var addBadgeArea = function($obj,tpl){ 33 var $tmp = {'obj':$obj,'tpl' : tpl}; 34 alarm_area_list.push($tmp); 35 }; 36 37 var makeBadge = function(alarm_count){ 38 if(alarm_count === 0) 39 return; 40 $.each(alarm_area_list,function(e, $_tmp){ 41 insertHtml($_tmp.obj,$_tmp.tpl,alarm_count); 42 }); 43 }; 44 45 var updateBadge = function(){ 46 var $badge_cnt = $("._badge_cnt"); 47 if($badge_cnt.length > 0){ 48 $badge_cnt.each(function(){ 49 $(this).remove(); 50 }); 51 } 52 }; 53 54 var insertHtml = function($obj,tpl,count){ 55 var html = getTemplateConvert(tpl,{'count':count}); 56 $obj.html(html); 57 }; 58 return { 59 'addBadgeArea' : function($obj,tpl){ 60 addBadgeArea($obj,tpl); 61 }, 62 'runAlarmBadgeSystem' : function(){ 63 runAlarmBadgeSystem(); 64 }, 65 'insertHtml' : function($obj,tpl,count){ 66 insertHtml($obj,tpl,count); 67 }, 68 'updateBadge' : function(){ 69 updateBadge(); 70 } 71 } 72}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.