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};