function setFieldAmount(field,val) { var obj = findCurrentObj("entry_form",field); if (obj) { // val= "$" + addCommas(val); // dollar way val= addCommas(val); //val= val.replace(/,/g," ") ; // for European format val= " " + val; //val= val.replace(".",","); // change decimal back now for European format obj.innerHTML= val; } } function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } var dHash = {}; function myDebug(key, value) { if (!dHash[key]) { alert(value); } dHash[key]="1"; } var RED = ""; //#db3737"; var YELLOW = ""; //"#eaac38"; var GREEN = ""; //"#425d2c"; function riskColor(prob,impact,risk) { if ("".length>0) { return noirlabRiskColor(prob,impact,risk); } if (risk>12) { return RED; } else if (risk>=4 && !(prob==2 && impact==2)) { return YELLOW; } else { return GREEN; } } function noirlabRiskColor(prob,impact,risk) { if (risk>19) { return RED; } else if (risk>9) { return YELLOW; } else { return GREEN; } } var noirlabScores = [ [ 10, 16, 20, 23, 25 ], [ 7, 13, 18, 22, 24 ], [ 4, 9, 15, 19, 21 ], [ 2, 6, 11, 14, 17 ], [ 1, 3, 5, 8, 12 ] ]; function riskScore(prob,impact) { if ("".length>0) { if (prob>0 && impact>0) { return noirlabScores[5-prob][impact-1]; } } return prob*impact; } // set the impact var impactFields = [ ]; var impactNames = [ ]; var impactValues = [ ]; var likelihoodValues = [ ]; var probAlpha= [ "", "A", "B", "C", "D", "E" ]; var probRange = [ "<10%", "10-30%", "30-50%", "50-70%", ">70%" ]; var probValue = [ 10, 30, 50, 70, 90 ]; var domainNotes = ""; function scoreFunction () { domainNotes= "Risk Impact scores are assigned values (1-5) based on the highest Risk Domain score:

"; for (var i=0;i<5; i++) { domainNotes+= "
- "+impactValues[i]+"="+(i+1)+"
"; } domainNotes+= "

Risk Likelihood scores are assigned values (1-5) :

"; for (var i=0;i<5; i++) { domainNotes+= "
- "+likelihoodValues[i]+"="+(i+1)+"
"; } domainNotes+= "

Each score then relates to a probability value of [ 10%, 30%, 50%, 70%, 90% ]
"; domainNotes+= "Residual scores are then calculated for each plan as follows:
"; if (document.entry_form) { var resImpactObj = jQuery("#field72"); var resImpactScoreObj = jQuery("#field74"); var resLikelihoodObj = jQuery("#field71"); var resLikelihoodScoreObj = jQuery("#field73"); var resRiskObj = jQuery("#field40"); var resRiskScoreObj = jQuery("#field75"); if (document.entry_form.cloneBugFlag) { // default back to "" resImpactObj.html(""); resImpactScoreObj.html(""); resLikelihoodObj.html(""); resLikelihoodScoreObj.html(""); resRiskObj.html(""); resRiskScoreObj.html(""); } domainNotes += "Residual Likelihood Score = Risk Probability Score * Reduction To Likelihood %
"; var reductionToLikelihood = "" + findCurrentObj("entry_form","field7").value; var resLikelihoodScore = riskLikelihoodScore; // this was set in EsaRiskResidualCustomUserField if (reductionToLikelihood) { resLikelihoodScore = Math.round(riskLikelihoodScore * (1-reductionToLikelihood/100)); } if (resLikelihoodScore>1) { domainNotes += resLikelihoodScore + " = " + riskLikelihoodScore + " * " + (1-reductionToLikelihood/100) +"
"; resLikelihoodObj.html(likelihoodValues[resLikelihoodScore-1]); resLikelihoodScoreObj.html(resLikelihoodScore); // probability resRiskObj.html(probValue[resLikelihoodScore-1]+"%"); } domainNotes += "Residual Impact Score is the highest of the residual impact scores where a reduction % is applied to each impact from the risk. Scores for each impact are :

"; var resImpactScore=0; for (var i=0;i<impactFields.length;i++) { var obj = findCurrentObj("entry_form","field" +impactFields[i]); if (obj) { var reduction = "" + obj.value; var score = window["riskImpactScore"+impactFields[i]]; // this was set in EsaRiskResidualCustomUserField if (reduction) { score = Math.round(score * (1-reduction/100)); } domainNotes += "<li>"+impactNames[i]+"="+score + " </li>"; if (resImpactScore<score) { resImpactScore= score; } } } if (resImpactScore>0) { domainNotes+= "

Residual Impact Score is "+resImpactScore+" ["+impactValues[resImpactScore-1]+"]
"; resImpactObj.html(impactValues[resImpactScore-1]); resImpactScoreObj.html(resImpactScore); } if (resLikelihoodScore>0&&resImpactScore>0) { var resRiskScore = riskScore(resLikelihoodScore,resImpactScore); domainNotes+= "Residual Risk Score is "+resRiskScore+"
"; resRiskScoreObj.html(resRiskScore); var color=riskColor(resLikelihoodScore,resImpactScore,resRiskScore); resRiskScoreObj.css("backgroundColor",color); } } setTimeout("scoreFunction()",500); } function showImpactDomainNotes(event) { fitDialog(event,{html: domainNotes, big: true }); } scoreFunction();