/* See license.txt for terms of usage */ define("tabs/harStats",["domplate/domplate","core/lib","i18n!nls/harStats","preview/harSchema","preview/harModel","core/cookies","domplate/infoTip","core/trace"],function(Domplate,Lib,Strings,HarSchema,HarModel,Cookies,InfoTip,Trace){with(Domplate){function PieBase(){}PieBase.prototype={data:[],title:"",getLabelTooltipText:function(e){return e.label+": "+Lib.formatSize(e.value)},cleanUp:function(){for(var e=0;e0?o.timings.ssl:0,timingPie.data[3].value+=o.timings.connect,timingPie.data[4].value+=o.timings.send,timingPie.data[5].value+=o.timings.wait,timingPie.data[6].value+=o.timings.receive,o.timings.ssl>0&&(timingPie.data[3].value-=o.timings.ssl);var u=o.response,a=u.bodySize>0?u.bodySize:0,f=u.content.mimeType,l=f?f.match(/^([^;]+)/)[1]:null,f=l?l:u.content.mimeType;htmlTypes[f]?(contentPie.data[0].value+=a,contentPie.data[0].count++):jsTypes[f]?(contentPie.data[1].value+=a,contentPie.data[1].count++):cssTypes[f]?(contentPie.data[2].value+=a,contentPie.data[2].count++):imageTypes[f]?(contentPie.data[3].value+=a,contentPie.data[3].count++):flashTypes[f]?(contentPie.data[4].value+=a,contentPie.data[4].count++):(contentPie.data[5].value+=a,contentPie.data[5].count++),trafficPie.data[0].value+=o.request.headersSize>0?o.request.headersSize:0,trafficPie.data[1].value+=o.request.bodySize>0?o.request.bodySize:0,trafficPie.data[2].value+=o.response.headersSize>0?o.response.headersSize:0,trafficPie.data[3].value+=a,o.response.status==206?(cachePie.data[1].value+=a,cachePie.data[1].count++):o.response.status==304?(cachePie.data[2].value+=a,cachePie.data[2].count++):a>0&&(cachePie.data[0].value+=a,cachePie.data[0].count++)}}Pie.draw(Lib.$(this.timingPie,"pieGraph"),timingPie),Pie.draw(Lib.$(this.contentPie,"pieGraph"),contentPie),Pie.draw(Lib.$(this.trafficPie,"pieGraph"),trafficPie),Pie.draw(Lib.$(this.cachePie,"pieGraph"),cachePie)},cleanUp:function(){timingPie.cleanUp(),contentPie.cleanUp(),trafficPie.cleanUp(),cachePie.cleanUp()},showInfoTip:function(e,t,n,r){return Pie.showInfoTip(e,t,n,r)},onSelectionChange:function(e){this.update(e)},show:function(e){if(this.isVisible())return;InfoTip.addListener(this),Lib.setClass(this.element,"opened"),e?$(this.element).slideDown():this.element.style.display="block";var t=this.timeline.getSelection();this.update(t)},hide:function(e){if(!this.isVisible())return;InfoTip.removeListener(this),Lib.removeClass(this.element,"opened"),e?$(this.element).slideUp():this.element.style.display="none"},isVisible:function(){return Lib.hasClass(this.element,"opened")},toggle:function(e){this.isVisible()?this.hide(e):this.show(e)},render:function(e){return this.element=this.tag.replace({},e),this.timingPie=Pie.render(timingPie,this.element),this.contentPie=Pie.render(contentPie,this.element),this.trafficPie=Pie.render(trafficPie,this.element),this.cachePie=Pie.render(cachePie,this.element),this.cachePie.style.borderRight=0,this.element}});var Pie=domplate({tag:TABLE({"class":"pagePieTable",cellpadding:0,cellspacing:0,_repObject:"$pie"},TBODY(TR(TD({"class":"pieBox",title:"$pie.title"}),TD(FOR("item","$pie.data",DIV({"class":"pieLabel",_repObject:"$item"},SPAN({"class":"box",style:"background-color: $item.color"}," "),SPAN({"class":"label"},"$item.label"))))))),render:function(e,t){var n=this.tag.append({pie:e},t),r=Lib.$(n,"pieBox"),i=document.createElement("canvas");return i.setAttribute("class","pieGraph "),i.setAttribute("height","100"),i.setAttribute("width","100"),r.appendChild(i),typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(i),n},draw:function(e,t){if(!e||!e.getContext)return;var n=e.getContext("2d"),r=Math.min(e.width,e.height)/2,i=[e.width/2,e.height/2];n.clearRect(0,0,e.width,e.height);var s=0,o=t.data,u=0;for(var a in o)u+=o[a].value;if(!u){n.beginPath(),n.moveTo(i[0],i[1]),n.arc(i[0],i[1],r,0,Math.PI*2,!1),n.closePath(),n.fillStyle="rgb(229,236,238)",n.lineStyle="lightgray",n.fill();return}for(var a=0;a