function DLM_createLoaderObj(){var t=document.createElement("div");(t=jQuery(t)).addClass("dlm_reports_loader");var e=document.createElement("img");return(e=jQuery(e)).attr("src",dlm_rs.img_path+"ajax-loader.gif"),t.append(e),t}jQuery(function(t){t.each(t(".dlm-reports-block-chart"),function(t,e){new DLM_Reports_Block_Chart(e)}),t.each(t(".dlm-reports-block-summary"),function(t,e){new DLM_Reports_Block_Summary(e)}),t.each(t(".dlm-reports-block-table"),function(t,e){new DLM_Reports_Block_Table(e)})});var DLM_Reports_Data=function(t){this.type=null,this.from=null,this.to=null,this.period=null,this.init=function(t){this.type=jQuery(t).data("type"),this.to=jQuery(t).data("to"),this.from=jQuery(t).data("from"),this.period=jQuery(t).data("period")},this.init(t)},DLM_Reports_Data_Fetch=function(t,e,a){this.id=t,this.data=e,this.cb=a,this.fetch()};DLM_Reports_Data_Fetch.prototype.fetch=function(){var t=this.id,e=this.cb,a=this.data.from,r=this.data.to,i=this.data.period;jQuery.get(ajaxurl,{action:"dlm_reports_data",nonce:dlm_rs.ajax_nonce,id:t,from:a,to:r,period:i},function(t){e(t)})};var DLM_Reports_Block_Chart=function(t){this.container=t,this.id=null,this.queryData=null,this.data=null,this.chart=null,this.setup=function(){this.id=jQuery(this.container).attr("id"),this.queryData=new DLM_Reports_Data(this.container),this.displayLoader(),this.fetch()},this.setup()};DLM_Reports_Block_Chart.prototype.displayLoader=function(){jQuery(this.container).append(DLM_createLoaderObj())},DLM_Reports_Block_Chart.prototype.hideLoader=function(){jQuery(this.container).find(".dlm_reports_loader").remove()},DLM_Reports_Block_Chart.prototype.fetch=function(){var e=this;new DLM_Reports_Data_Fetch(this.id,this.queryData,function(t){e.data=t,e.hideLoader(),e.render()})},DLM_Reports_Block_Chart.prototype.render=function(){null!==this.data&&(this.chart=new Chart({parent:this.container,title:"",data:this.data,type:this.queryData.type,height:250,show_dots:0,x_axis_mode:"tick",y_axis_mode:"span",is_series:1,format_tooltip_x:function(t){return(t+"").toUpperCase()},format_tooltip_y:function(t){return t+" downloads"}}))};var DLM_Reports_Block_Summary=function(t){this.container=t,this.id=null,this.data=null,this.data=null,this.chart=null,this.setup=function(){this.id=jQuery(this.container).attr("id"),this.data=new DLM_Reports_Data(this.container),this.displayLoader(),this.fetch()},this.setup()};DLM_Reports_Block_Summary.prototype.displayLoader=function(){jQuery(this.container).append(DLM_createLoaderObj())},DLM_Reports_Block_Summary.prototype.hideLoader=function(){jQuery(this.container).find(".dlm_reports_loader").remove()},DLM_Reports_Block_Summary.prototype.fetch=function(){var e=this;new DLM_Reports_Data_Fetch(this.id,this.data,function(t){e.data=t,e.hideLoader(),e.render()})},DLM_Reports_Block_Summary.prototype.render=function(){if(null!==this.data){var a=this;jQuery.each(this.data,function(t,e){jQuery(a.container).find("#"+t)&&jQuery(a.container).find("#"+t).find("span:first").html(e)})}};var DLM_Reports_Block_Table=function(t){this.container=t,this.id=null,this.data=null,this.data=null,this.chart=null,this.setup=function(){this.id=jQuery(this.container).attr("id"),this.data=new DLM_Reports_Data(this.container),this.displayLoader(),this.fetch()},this.setup()};DLM_Reports_Block_Table.prototype.displayLoader=function(){jQuery(this.container).append(DLM_createLoaderObj())},DLM_Reports_Block_Table.prototype.hideLoader=function(){jQuery(this.container).find(".dlm_reports_loader").remove()},DLM_Reports_Block_Table.prototype.fetch=function(){var e=this;new DLM_Reports_Data_Fetch(this.id,this.data,function(t){e.data=t,e.hideLoader(),e.render()})},DLM_Reports_Block_Table.prototype.render=function(){if(!(null===this.data||this.data.length<2)){var t=jQuery(document.createElement("table"));t.attr("cellspacing",0).attr("cellpadding",0).attr("border",0);for(var e=document.createElement("tr"),a=0;a