scripts.sonar-utils-min.js Maven / Gradle / Ivy
AJS.$.namespace("AJS.sonar.utils");AJS.sonar.utils.getTrendImage=function(A,C){if(A.trend===undefined||A["var"]===undefined){return""}else{if(A.trend===0&&A["var"]===0){return""}else{var B="/tendency/"+A["var"]+"-";if(A.trend===1){B=B+"green"}else{B=B+"black"}if(C){B=B+"-small"}return B+".png"}}};AJS.sonar.utils.getMeasureFromResource=function(B,C){for(var A in B.msr){if(B.msr[A].key===C){return B.msr[A]}}return{}};AJS.sonar.utils.getMetricFromMetricsArray=function(B,C){for(var A in B){if(B[A].key===C){return B[A]}}return{}};AJS.sonar.utils.isValidMetric=function(A){return !(A!=null&&A!==undefined&&A.key!==undefined)};AJS.sonar.utils.isValidMeasure=function(A){return !(A!=null&&A!==undefined&&A.key!==undefined)};AJS.sonar.utils.getColorMetrics=function(C){var A=new Array();for(var B in C){if(C[B].val_type==="LEVEL"||C[B].val_type==="PERCENT"){A.push(C[B])}}A.sort(function(E,D){return(E.name>D.name)-(D.name>E.name)});return A};AJS.sonar.utils.getSizeMetrics=function(B){var C=new Array();for(var A in B){if((B[A].val_type==="INT"||B[A].val_type==="FLOAT"||B[A].val_type==="MILLISEC")&&B[A].val_type!=="PERCENT"&&B[A].domain!=undefined&&B[A].domain!=null&&B[A].domain!==""){C.push(B[A])}}C.sort(function(E,D){return(E.name>D.name)-(D.name>E.name)});return C};AJS.sonar.utils.createMetricSelectElement=function(D,F,C,E,B){var A=AJS.$("").attr({name:D,id:F});AJS.$(C).each(function(G,H){AJS.$("").attr({value:H.key,selected:(H.key==E)}).text(H.name).appendTo(A)});if(B!=undefined&&B!=null){A.change(B)}return A};AJS.sonar.utils.randomNumber=function(){return Math.ceil((Math.random()*1000))};AJS.sonar.utils.getPercentage=function(A,B){return Math.ceil((A/B)*100)};AJS.sonar.utils.generateErrorMessageBox=function(C){var A=AJS.$("").addClass("empty-results");var B=AJS.$("
").addClass("styleless-list");AJS.$.each(C,function(E,D){B.append(AJS.$("").text(D))});B.appendTo(A);return A};AJS.sonar.utils.rgbToHex=function(C,B,A){return AJS.sonar.utils.toHex(C)+AJS.sonar.utils.toHex(B)+AJS.sonar.utils.toHex(A)};AJS.sonar.utils.toHex=function(A){if(A==null){return"00"}A=parseInt(A);if(A==0||isNaN(A)){return"00"}A=Math.max(0,A);A=Math.min(A,255);A=Math.round(A);return"0123456789ABCDEF".charAt((A-A%16)/16)+"0123456789ABCDEF".charAt(A%16)};AJS.sonar.utils.mixColors=function(B,A,D){var C={r:0,g:0,b:0};D/=100;C.r=Math.round((B.r*D)+(A.r*(1-D)));C.g=Math.round((B.g*D)+(A.g*(1-D)));C.b=Math.round((B.b*D)+(A.b*(1-D)));return C};