日期:2014-05-16 浏览次数:20728 次
//存储实时监控任务数据请求的对象 var relTimeTaskHashMap = { Set : function(key, value) { this[key] = value }, Get : function(key) { return this[key] }, Contains : function(key) { return this.Get(key) == null ? false : true }, Remove : function(key) { delete this[key] } }; //存储tab对象 var chartHashMap = { Set : function(key, value) { this[key] = value }, Get : function(key) { return this[key] }, Contains : function(key) { return this.Get(key) == null ? false : true }, Remove : function(key) { delete this[key] } }; //ajax请求的守护对象,负责ajax请求发起和停止 function RealTimeTaskDefend(){ var threadStatus; var callBackFunction; this.setCallBackFunction=function(callFunction){ this.callBackFunction=callFunction; } this.run=function(){ this.threadStatus=setInterval(this.callBackFunction,5000); } this.stop=function(){ clearTimeout(this.threadStatus); } } //新增加一个tab需要完成的动作 var realTimeTaskDefend = new RealTimeTaskDefend(); relTimeTaskHashMap.Set(tabPanelId, realTimeTaskDefend); chartHashMap.Set(tabPanelId,'实时监控的展现对象入口'); //发起监控请求需要完成的动作 var realTimeTaskDefend_run = relTimeTaskHashMap.Get(tabpanelId) realTimeTaskDefend_run.setCallBackFunction('实时监控的数据处理方法入口'); realTimeTaskDefend_run.run(); //结束监控请求需要完成的动作 var realTimeTaskDefend_stop = relTimeTaskHashMap.Get(tabPanelId); realTimeTaskDefend_stop .stop(); relTimeTaskHashMap.Remove(tabPanelId); chartHashMap.Remove(tabPanelId);