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 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 impactOps = {}; var impact = 0; var domain = ""; for (var i=0; i<impactFields.length; i++) { var obj = findCurrentObj("entry_form","field"+impactFields[i]); var val = 0; if (obj) { // in case hidden val = "" + obj.value; impactOps=obj.options; } if (val>0) { if (domain.length>0) domain += ","; domain += impactNames[i].substring(0,1); if (val>impact) impact = val; } } if (impactOps.length>0) { jQuery("#field2").html(impactOps[impact].text+" "); // impact severity } jQuery("#field20").html(domain); // domain if (prob>0) { jQuery("#field40").html(probValue[prob-1]+"%"); //probability range } var minDelay = parseFloat(currentValueNoBlanks("entry_form","field25","0")); var maxDelay = parseFloat(currentValueNoBlanks("entry_form","field27","0")); var likelyDelay = parseFloat(currentValueNoBlanks("entry_form","field29","0")); var expectedDelay = (minDelay + (likelyDelay*4) + maxDelay) /6; jQuery("#field34").html(Math.round(expectedDelay)); var minCost = currentValueNoBlanks("entry_form","field24","0"); minCost = minCost.replace(/[^\.0-9]/g,""); // strip to number with decimal or $ minCost = parseFloat(minCost); var maxCost = currentValueNoBlanks("entry_form","field26","0"); maxCost = maxCost.replace(/[^\.0-9]/g,""); // strip to number with decimal or $ maxCost = parseFloat(maxCost); var likelyCost= currentValueNoBlanks("entry_form","field28","0"); likelyCost= likelyCost.replace(/[^\.0-9]/g,""); // strip to number with decimal or $ likelyCost= parseFloat(likelyCost); var costImpact = (minCost + (likelyCost*4) + maxCost) /6; setFieldAmount("field32",Math.round(costImpact)); var emv = costImpact * (probValue[prob-1]/100); setFieldAmount("field9",Math.round(emv)); // expected Monetary value = cost impact * probability var index = impact + probAlpha[prob]; jQuery("#field18").html(index+" "); //Index //var impact = "" + findCurrentObj("entry_form","field2").value; if ( impact>0) { impactScoreObj.value = impact; impactScoreObj.innerHTML = impactScoreObj.value; } 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 residualImpactFields = [ ]; var residualImpactNames = [ ]; var residualImpactValues = [ ]; function residualScoreFunction () { if (document.entry_form) { var probScoreObj = findCurrentObj("entry_form","field95"); var impactScoreObj = findCurrentObj("entry_form","field93"); var riskScoreObj = findCurrentObj("entry_form","field97"); if (document.entry_form.cloneBugFlag) { // default back to "" probScoreObj.innerHTML=""; impactScoreObj.innerHTML=""; riskScoreObj.innerHTML=""; } var probValObj = findCurrentObj("entry_form","field94"); var prob = 0; if (probValObj) { prob = probValObj.value; if ( prob>0) { probScoreObj.value = prob; probScoreObj.innerHTML = probScoreObj.value; } else { prob = 0; } } var residualImpactOps = {}; var impact = 0; //var domain = ""; for (var i=0; i<residualImpactFields.length; i++) { var obj = findCurrentObj("entry_form","field"+residualImpactFields[i]); var val = 0; if (obj) { // in case hidden val = "" + obj.value; residualImpactOps=obj.options; } if (val>0) { //if (domain.length>0) domain += ","; //domain += impactNames[i].substring(0,1); if (val>impact) impact = val; } } if (residualImpactOps.length>0) { jQuery("#field92").html(residualImpactOps[impact].text+" "); // impact severity } if (prob>0) { jQuery("#field96").html(probValue[prob-1]+"%"); //probability range } if ( impact>0) { impactScoreObj.value = impact; impactScoreObj.innerHTML = impactScoreObj.value; } 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();