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; } var probAlpha= [ "", "A", "B", "C", "D", "E" ]; var probRange = [ "<10%", "10-30%", "30-50%", "50-70%", ">70%" ]; var probValue = [ 10, 30, 50, 70, 90 ]; function scoreFunction () { if (document.entry_form) { var probScoreObj = findCurrentObj("entry_form","field3"); var impactScoreObj = findCurrentObj("entry_form","field4"); var riskScoreObj = findCurrentObj("entry_form","field5"); if (document.entry_form.cloneBugFlag) { // default back to "" probScoreObj.innerHTML=""; impactScoreObj.innerHTML=""; riskScoreObj.innerHTML=""; } var probValObj = findCurrentObj("entry_form","field1"); var prob = 0; if (probValObj) { prob = probValObj.value; if ( prob>0) { probScoreObj.value = prob; probScoreObj.innerHTML = probScoreObj.value; } else { prob = 0; } } var impactValObj = findCurrentObj("entry_form","field49"); var impact = 0; if (impactValObj) { impact = impactValObj.value; if ( impact>0) { impactScoreObj.value = impact; impactScoreObj.innerHTML = impactValObj.value; } else { impact = 0; } } if (prob>0) { jQuery("#field40").html(probValue[prob-1]+"%"); //probability range } var index = impact + probAlpha[prob]; jQuery("#field18").html(index+" "); //Index var score=riskScore(prob,impact); var color=riskColor(prob,impact,score); if ( score>0) { riskScoreObj.value = score; riskScoreObj.innerHTML = riskScoreObj.value; riskScoreObj.style.backgroundColor=color; } residualScoreFunction(); } setTimeout("scoreFunction()",500); } // set the impact var residualImpactNames = [ ]; var residualImpactValues = [ ]; function residualScoreFunction () { if (document.entry_form) { var probScoreObj = findCurrentObj("entry_form","field87"); var impactScoreObj = findCurrentObj("entry_form","field86"); var riskScoreObj = findCurrentObj("entry_form","field92"); if (document.entry_form.cloneBugFlag) { // default back to "" probScoreObj.innerHTML=""; impactScoreObj.innerHTML=""; riskScoreObj.innerHTML=""; } var probValObj = findCurrentObj("entry_form","field90"); var prob = 0; if (probValObj) { prob = probValObj.value; if ( prob>0) { probScoreObj.value = prob; probScoreObj.innerHTML = probScoreObj.value; } else { prob = 0; } } var impactValObj = findCurrentObj("entry_form","field85"); var impact = 0; if (impactValObj) { impact = impactValObj.value; if ( impact>0) { impactScoreObj.value = impact; impactScoreObj.innerHTML = impactValObj.value; } else { impact = 0; } } if (prob>0) { jQuery("#field91").html(probValue[prob-1]+"%"); //probability range } var index = impact + probAlpha[prob]; jQuery("#field88").html(index+" "); //Index var score=riskScore(prob,impact); var color=riskColor(prob,impact,score); if ( score>0) { riskScoreObj.value = score; riskScoreObj.innerHTML = riskScoreObj.value; riskScoreObj.style.backgroundColor=color; } } } // start recursive function call to run javascript on page scoreFunction();