var RED = "red"; //""; //#db3737"; var LIGHTRED = "#ff6347"; //""; //"#ff6347"; var YELLOW = "#ffef00"; //""; //"#eaac38"; var LIGHTGREEN = "#89C35C"; //""; //"#89C35C"; var GREEN = "limegreen"; //""; //"#425d2c"; function riskColor(prob,impact,risk) { if (risk>20) { return RED; } else if (risk>15) { return LIGHTRED; } else if (risk>10) { return YELLOW; } else if (risk>5) { return LIGHTGREEN; } else { return GREEN; } } function riskScore(prob,impact) { return prob*impact; } function numericOnly(val) { val = val.replace(/\D/g,''); // remove non numeric characters if (val.length==0) return 0; return parseInt(val); } function scoreFunction () { if (document.entry_form) { var urgencyScoreObj = findCurrentObj("entry_form","field19"); var riskScoreObj = findCurrentObj("entry_form","field16"); if (document.entry_form.cloneBugFlag) { // default back to "" urgencyScoreObj.innerHTML=""; riskScoreObj.innerHTML=""; } var priValObj = findCurrentObj("entry_form","mPriority"); var pri = 0; if (priValObj) { pri = numericOnly(priValObj.value); if ( pri<0) { pri = 0; } } var impactValObj = findCurrentObj("entry_form","field18"); var impact = 0; if (impactValObj) { impact = numericOnly(impactValObj.value); if ( impact<0) { impact = 0; } } var complexityValObj = findCurrentObj("entry_form","field21"); var complexity = 0; if (complexityValObj) { complexity = numericOnly(complexityValObj.value); if ( complexity<0) { complexity = 0; } } // urgency scoring var uscore=riskScore(impact,pri); var ucolor=riskColor(impact,pri,uscore); if ( uscore>0) { urgencyScoreObj.value = uscore; urgencyScoreObj.innerHTML = urgencyScoreObj.value; urgencyScoreObj.style.backgroundColor=ucolor; } // risk scoring var rscore=riskScore(impact,complexity); var rcolor=riskColor(impact,complexity,rscore); if ( rscore>0) { riskScoreObj.value = rscore; riskScoreObj.innerHTML = riskScoreObj.value; riskScoreObj.style.backgroundColor=rcolor; } } setTimeout("scoreFunction()",500); } // start recursive function call to run javascript on page scoreFunction();