ericduran/chromeHAR

View on GitHub
js/scripts.min.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(a){"use strict";var b=Modernizr.draganddrop&&document.querySelector&&a.JSON;b?($(".network-larger-resources-status-bar-item").click(function(){$(this).toggleClass("toggled-on"),$(".network-log-grid").toggleClass("small")}),$(".sample").click(function(a){a.preventDefault();var b=angular.element("body").scope();$("#dropArea").removeClass("visible"),$.getJSON("sample.har",function(a){b.$apply(function(){b.updateHar(a)})})})):$("body").addClass("disabled")}(window);var Preferences=Preferences||{},WebInspector=WebInspector||{};String.prototype.startsWith=function(a){return!this.lastIndexOf(a,0)},String.sprintf=function(a){return String.vsprintf(a,Array.prototype.slice.call(arguments,1))},String.tokenizeFormatString=function(a,b){function c(a){f.push({type:"string",value:a})}function d(a,b,c){f.push({type:"specifier",specifier:a,precision:b,substitutionIndex:c})}function e(a){return!!/[0-9]/.exec(a)}for(var f=[],g=0,h=0,i=a.indexOf("%",h);-1!==i;i=a.indexOf("%",h)){if(c(a.substring(h,i)),h=i+1,e(a[h])){for(var j=parseInt(a.substring(h),10);e(a[h]);)++h;j>0&&"$"===a[h]&&(g=j-1,++h)}var k=-1;if("."===a[h])for(++h,k=parseInt(a.substring(h),10),isNaN(k)&&(k=0);e(a[h]);)++h;a[h]in b?(d(a[h],k,g),++g,++h):(c(a.substring(i,h+1)),++h)}return c(a.substring(h)),f},String.standardFormatters={d:function(a){return isNaN(a)?0:a},f:function(a,b){return a&&b.precision>-1&&(a=a.toFixed(b.precision)),isNaN(a)?b.precision>-1?Number(0).toFixed(b.precision):0:a},s:function(a){return a}},String.vsprintf=function(a,b){return String.format(a,b,String.standardFormatters,"",function(a,b){return a+b}).formattedResult},String.format=function(a,b,c,d,e){function f(){return'String.format("'+a+'", "'+b.join('", "')+'")'}function g(a){console.warn(f()+": "+a)}function h(a){console.error(f()+": "+a)}if(!a||!b||!b.length)return{formattedResult:e(d,a),unusedSubstitutions:b};for(var i=d,j=String.tokenizeFormatString(a,c),k={},l=0;l<j.length;++l){var m=j[l];"string"!==m.type?"specifier"===m.type?m.substitutionIndex>=b.length?(h("not enough substitution arguments. Had "+b.length+" but needed "+(m.substitutionIndex+1)+", so substitution was skipped."),i=e(i,"%"+(m.precision>-1?m.precision:"")+m.specifier)):(k[m.substitutionIndex]=!0,m.specifier in c?i=e(i,c[m.specifier](b[m.substitutionIndex],m)):(g("unsupported format character “"+m.specifier+"”. Treating as a string."),i=e(i,b[m.substitutionIndex]))):h('Unknown token type "'+m.type+'" found.'):i=e(i,m.value)}for(var n=[],l=0;l<b.length;++l)l in k||n.push(b[l]);return{formattedResult:i,unusedSubstitutions:n}},WebInspector.UIString=function(a){return Preferences.localizeUI&&(window.localizedStrings&&a in window.localizedStrings?a=window.localizedStrings[a]:(a in WebInspector._missingLocalizedStrings||(console.warn('Localized string "'+a+'" not found.'),WebInspector._missingLocalizedStrings[a]=!0),Preferences.showMissingLocalizedStrings&&(a+=" (not localized)"))),String.vsprintf(a,Array.prototype.slice.call(arguments,1))},Number.bytesToString=function(a,b){if("undefined"==typeof b&&(b=!0),1024>a)return WebInspector.UIString("%.0fB",a);var c=a/1024;if(b&&1024>c)return WebInspector.UIString("%.2fKB",c);if(1024>c)return WebInspector.UIString("%.0fKB",c);var d=c/1024;return b?WebInspector.UIString("%.2fMB",d):WebInspector.UIString("%.0fMB",d)},WebInspector.ParsedURL=function(a){this.isValid=!1,this.url=a,this.scheme="",this.host="",this.port="",this.path="",this.queryParams="",this.fragment="",this.folderPathComponents="",this.lastPathComponent="";var b=a.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);if(b)this.isValid=!0,this.scheme=b[1].toLowerCase(),this.host=b[2],this.port=b[3],this.path=b[4]||"/",this.fragment=b[5];else{if(this.url.startsWith("data:"))return void(this.scheme="data");if("about:blank"===this.url)return void(this.scheme="about");this.path=this.url}if(this.path){var c=this.path,d=c.indexOf("?");-1!==d&&(this.queryParams=c.substring(d+1),c=c.substring(0,d));var e=c.lastIndexOf("/");-1!==e?(this.folderPathComponents=c.substring(0,e),this.lastPathComponent=c.substring(e+1)):this.lastPathComponent=c}};var HAREntry=function(){"use strict";function a(a,b,c,d){this._entry=a,this._id=b,this.status=this._entry.response.status,this.statusText=this._entry.response.statusText,this.mimeType=this._entry.response.content.mimeType,this.receive=this.getReceive(),this.wait=this.getWait(),this.url=this._entry.request.url,this.method=this._entry.request.method,this.parsedURL=new WebInspector.ParsedURL(a.request.url),this.parsedURL.lastPathComponent||(this.parsedURL.lastPathComponent=this.parsedURL.url.indexOf("?")>-1?"?"+this.parsedURL.queryParams:this.parsedURL.host),this.name=this.getRequestName(),this.folder=this.getFolder(),this.size=this.getSize(),this.contentSize=this.getContentSize(),this.time=this.getTime(),this.latency=this.getLatency(),this.request=this.prepRequest(),this.reqHeadersCount=this._entry.request.headers.length,this.resHeadersCount=this._entry.response.headers.length,this.startedTime=c,this.graphs=this.graphs(d),this.nameSort=this.parsedURL.lastPathComponent,this.timeSort=this._entry.time,this.sizeSort=""}return a.prototype={getFolder:function(){var a=this.parsedURL.path,b=a.indexOf("?");-1!==b&&(a=a.substring(0,b));var c=a.lastIndexOf("/");return-1!==c?a.substring(0,c):""},getRequestName:function(){var a=[],b=this._entry.response.content.mimeType;return a["text/html"]="document",a["text/css"]="stylesheet",a["text/javascript"]="script",a["application/javascript"]="script",a["image/png"]="image",a["image/gif"]="image",a["image/jpeg"]="image",a[b]},getSize:function(){return this._entry.cached?0:Number.bytesToString(304===this._entry.response.status?this._entry.response.headersSize:this._entry.response.headersSize+this._entry.response.bodySize)},getContentSize:function(){return Number.bytesToString(this._entry.response.content.size)},getRawContentSize:function(){return this._entry.response.content.size},getTime:function(){return this._entry.time>0?this._entry.time:0},getLatency:function(){return this._entry.time>0?this._entry.time-this._entry.timings.receive:0},getReceive:function(){return this._entry.timings&&void 0!=this._entry.timings.receive?this._entry.timings.receive:0},getWait:function(){return this._entry.timings&&void 0!=this._entry.timings.wait?this._entry.timings.wait:0},prepRequest:function(){var a={};return a.startTime=new Date(this._entry.startedDateTime).getTime(),a.responseReceivedTime=a.startTime,a.endTime=a.startTime+this._entry.time,this.minimumBoundary=0,this.boundarySpan=100,this.diff=a.endTime-a.responseReceivedTime,a},graphs:function(a){var b={};return b.pOL=a.lastOnLoad,b.lOR=this.request.startTime-this.startedTime,b.Lat=this._entry.time-this.receive,b.end=this._entry.time+this.receive,b.latency_left=b.lOR/b.pOL*100,b.latency_right=100-(b.lOR+b.Lat)/b.pOL*100,b.receiving_left=(b.lOR+b.Lat)/b.pOL*100,b.receiving_right=100-(b.lOR+this._entry.time)/b.pOL*100,b}},a}();