Skip to content

Instantly share code, notes, and snippets.

@haziqAhmed7
Last active September 26, 2015 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haziqAhmed7/42344030fcac99a32933 to your computer and use it in GitHub Desktop.
Save haziqAhmed7/42344030fcac99a32933 to your computer and use it in GitHub Desktop.
COCOMO
//define arrays
var array_modes = ['Organic', 'Semi-Detached', 'Embeded'];
//save states
var size, efforts ,time_development, staff_size, productivity;
var EFFORT, TIME_DEVELOPMENT;
/*
We define array of effort constant values.
*/
//organic
var effort = new Object();
effort.mode = 'Organic';
effort.a = 2.4;
effort.b = 1.05;
EFFORT = JSON.stringify(effort) + ',';
//Semi-Detached
effort.mode = 'Semi-Detached';
effort.a = 1.05;
effort.b = 1.12;
EFFORT = EFFORT + JSON.stringify(effort) + ',';
//Embeded
effort.mode = 'Embeded';
effort.a = 3.6;
effort.b = 1.20;
EFFORT = EFFORT + JSON.stringify(effort);
EFFORT = '[' + EFFORT + ']';
/*
We define array of Time Development constant values.
*/
//organic
var Development_Time = new Object();
Development_Time.mode = 'Organic';
Development_Time.a = 2.5;
Development_Time.b = 0.38;
TIME_DEVELOPMENT = JSON.stringify(Development_Time) + ',';
//Semi-Detached
Development_Time.mode = 'Semi-Detached';
Development_Time.a = 2.5;
Development_Time.b = 0.35;
TIME_DEVELOPMENT = TIME_DEVELOPMENT + JSON.stringify(Development_Time) + ',';
//Embeded
Development_Time.mode = 'Embeded';
Development_Time.a = 2.5;
Development_Time.b = 0.32;
TIME_DEVELOPMENT = TIME_DEVELOPMENT + JSON.stringify(Development_Time);
TIME_DEVELOPMENT = '[' + TIME_DEVELOPMENT + ']';
/*
Validate the user input by checking the given input is integer or not
On Invalid user input the textbox color will change and show appropriate error
*/
function Validate(value)
{
if(!isNaN(value))
{
$("#basic_size"). removeClass("basic_input_error");
$("#basic_err").hide();
return true;
}
else
{
$("#basic_err").show();
$("#basic_err").html("Input Value should be numeric only");
}
return false;
}
/*
*/
function check_size_constraints(slidervalue, textvalue)
{
if(slidervalue == 'Organic' && textvalue > 50)
{
$("#basic_size").addClass("basic_input_error");
$("#basic_err").show();
$("#basic_err").html("Organic Size should be between 2-50 KLOC");
return false;
}
else if(slidervalue == 'Semi-Detached' && textvalue > 300)
{
$("#basic_size").addClass("basic_input_error");
$("#basic_err").show();
$("#basic_err").html("Semi-Detached Size should be between 50-300 KLOC");
return false;
}
else if(slidervalue == 'Embeded' && textvalue < 300)
{
$("#basic_size").addClass("basic_input_error");
$("#basic_err").show();
$("#basic_err").html("Embeded Size should be above 300 KLOC");
return false;
}
$("#basic_size").removeClass("basic_input_error");
$("#basic_err").hide();
return true;
}
function calculate(slider_value, size_value)
{
if( Validate(size_value) && check_size_constraints(array_modes[slider_value], size_value) ){
console.log("Input Type Validate: " + Validate(size_value));
console.log("KLOC Type Validate: " + check_size_constraints(array_modes[slider_value], size_value));
//console.log(JSON.parse(EFFORT));
var eff = JSON.parse(EFFORT);
var m = eff[slider_value]['mode'];
var a = eff[slider_value]['a'];
var b = eff[slider_value]['b'];
//console.log(m +', ' + a + ', ' + b);
//Now calculate Effort
efforts = a * Math.pow(size_value, b);
efforts = Math.round(efforts);
//console.log("Effort: " + efforts);
//Now Calculate Time DEvelopment
//console.log(JSON.parse(TIME_DEVELOPMENT));
var time = JSON.parse(TIME_DEVELOPMENT);
m = time[slider_value]['mode'];
a = time[slider_value]['a'];
b = time[slider_value]['b'];
console.log(m +', ' + a + ', ' + b);
time_development = a * Math.pow(efforts, b);
time_development = Math.round(time_development);
//console.log("Time DEvelopment: " + time_development);
//Average Staff Size
staff_size = efforts / time_development;
staff_size = Math.round(staff_size);
//console.log("StaffSize: "+ staff_size);
//Productivity
productivity = (size_value * 1000) / efforts;
productivity = Math.round(productivity);
//console.log("Productivity: "+ productivity);
display_Table();
}
else{
alert("error");
}
}
/*
Display the calculated values in the table
*/
function display_Table()
{
$("#table_div").show();
$("#table_estimate").html("");
$("#table_estimate").slideDown(1000);
var table_heads = "<thead> <th>#</th><th>Value</th></thead>";
var table_values = table_heads + "<tr> <td> Effort </td> <td> "+ efforts + " StaffMonths </td> </tr>" +
"<tr> <td> TimeDevelopment </td> <td> "+ time_development + " Months </td> </tr>" +
"<tr> <td> StaffSize </td> <td> "+ staff_size + " </td> </tr>" +
"<tr> <td> Productivity </td> <td> "+ productivity + " LOC/Staff-Month </td> </tr>" ;
$("#table_estimate").append(table_values);
window.scrollTo(0,100);
}
function remove_table(){
$("#table_div").slideUp(500, function(){
//setTimeout(function(){},3000);
$("#table_estimate").html("");
$("#table_estimate").hide();
$("#table_div").hide();
});
window.scrollTo(0,0);
}
var cost_drivers;
//Values for Cost Effecting Drivers
var cost = new Object();
cost.driver = 'Rely';
cost.VeryLow = 0.75;
cost.Low = 0.88;
cost.Nominal = 1.00;
cost.High = 1.15;
cost.VeryHigh = 1.40;
cost.ExtraHigh = 1.40;
cost_drivers = JSON.stringify(cost) + ',';
cost.driver = 'DATA';
cost.VeryLow = 0.94;
cost.Low = 0.94;
cost.Nominal = 1.00;
cost.High = 1.08;
cost.VeryHigh = 1.16;
cost.ExtraHigh = 1.16;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'CPLX';
cost.VeryLow = 0.70;
cost.Low = 0.85;
cost.Nominal = 1.00;
cost.High = 1.15;
cost.VeryHigh = 1.30;
cost.ExtraHigh = 1.65;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'TIME';
cost.VeryLow = 1.00;
cost.Low = 1.00;
cost.Nominal = 1.00;
cost.High = 1.11;
cost.VeryHigh = 1.30;
cost.ExtraHigh = 1.66;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'STOR';
cost.VeryLow = 1.00;
cost.Low = 1.00;
cost.Nominal = 1.00;
cost.High = 1.06;
cost.VeryHigh = 1.21;
cost.ExtraHigh = 1.56;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'VIRT';
cost.VeryLow = 0.87;
cost.Low = 0.87;
cost.Nominal = 1.00;
cost.High = 1.15;
cost.VeryHigh = 1.30;
cost.ExtraHigh = 1.30;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'TURN';
cost.VeryLow = 0.87;
cost.Low = 0.87;
cost.Nominal = 1.00;
cost.High = 1.07;
cost.VeryHigh = 1.15;
cost.ExtraHigh = 1.15;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'ACAP';
cost.VeryLow = 1.46;
cost.Low = 1.19;
cost.Nominal = 1.00;
cost.High = 0.86;
cost.VeryHigh = 0.71;
cost.ExtraHigh = 0.71;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'AEXP';
cost.VeryLow = 1.29;
cost.Low = 1.13;
cost.Nominal = 1.00;
cost.High = 0.91;
cost.VeryHigh = 0.82;
cost.ExtraHigh = 0.82;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'PCAP';
cost.VeryLow = 1.42;
cost.Low = 1.17;
cost.Nominal = 1.00;
cost.High = 0.86;
cost.VeryHigh = 0.70;
cost.ExtraHigh = 0.70;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'VEXP';
cost.VeryLow = 1.21;
cost.Low = 1.10;
cost.Nominal = 1.00;
cost.High = 0.90;
cost.VeryHigh = 0.90;
cost.ExtraHigh = 0.90;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'LEXP';
cost.VeryLow = 1.14;
cost.Low = 1.07;
cost.Nominal = 1.00;
cost.High = 0.95;
cost.VeryHigh = 0.95;
cost.ExtraHigh = 0.95;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'MODP';
cost.VeryLow = 1.24;
cost.Low = 1.10;
cost.Nominal = 1.00;
cost.High = 0.91;
cost.VeryHigh = 0.82;
cost.ExtraHigh = 0.82;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'TOOL';
cost.VeryLow = 1.24;
cost.Low = 1.10;
cost.Nominal = 1.00;
cost.High = 0.91;
cost.VeryHigh = 0.82;
cost.ExtraHigh = 0.82;
cost_drivers = cost_drivers + JSON.stringify(cost) + ',';
cost.driver = 'SCED';
cost.VeryLow = 1.23;
cost.Low = 1.08;
cost.Nominal = 1.00;
cost.High = 1.04;
cost.VeryHigh = 1.10;
cost.ExtraHigh = 1.10;
cost_drivers = cost_drivers + JSON.stringify(cost);
cost_drivers = '[' + cost_drivers +']';
/*
Get the Cost Effecting derivers along with the values in JSON array
*/
function get_cost_drivers(){
return cost_drivers;
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="lolkittens" />
<title>COCOMO</title>
</head>
<link rel="stylesheet" href="css/style.css"/>
<link rel="stylesheet" href="css/table.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="js/Basic_Cocomo.js"></script>
<script type="text/javascript" src="js/Intermediate_Cocomo.js"></script>
<script type="text/javascript" src="js/Effort_drives.js"></script>
<body>
<script >
var modes = ['Organic', 'Semi-Detached', 'Embeded'];
var EAF = ['RELY', 'DATA', 'CPLX', 'TIME', 'STOR', 'VIRT', 'TURN', 'ACAP', 'AEXP', 'PCAP', 'VEXP', 'LEXP', 'MODP', 'TOOL', 'SCED'];
var EAF_values = ['VeryLow', 'Low', 'Nominal', 'High', 'VeryHigh', 'ExtraHigh'];
var slider_value = 1;
</script>
<!-- title div -->
<div id="title" class="title">
<h1 id="estimation_technique" class="title_h"> COCOMO </h1>
</div>
<br />
<div id="mode" class="buttonHolder">
<br />
<h2 class="para"> Select your mode </h2>
<button id="basic" class="modebutton" value="BASIC"> BASIC </button>
<button id="advance" class="modebutton"> Advance </button>
</div>
<!-- Table for Adjusting Effort adjustment Factors -->
<div id="effort_factors" class="eaf_tablea" style="display: none;">
</div>
<!-- BASIC COCOMO FORM and FIELDS -->
<div id="basic_form" class="basicHolder" style="display: none;">
<h2 id="basic_mode" class="basic_para">Semi-Detached</h2>
<div id="basic_slider" style="width: 10%; height:10px; padding-left: 12%; left: 30%;"></div>
<br />
<h2 class="basic_para"> Size in (KLOC)</h2>
<input id="basic_size" type="text" class="basic_input" placeholder="SIZE"/>
<div id="basic_err" class="basic_error" style="display: none;">Some error Generated</div>
<br /><br />
<button id="basic_submit" class="basic_button" onclick="calculate(slider_value, $('#basic_size').val())">Calculate</button>
<br /> <br />
</div>
<!-- Advanced COCOMO FORM and FIELDS -->
<div id="adv_form" class="advHolder" style="display: none;">
<h2 id="adv_mode" class="basic_para">Semi-Detached</h2>
<div id="adv_slider" style="width: 10%; height:10px; padding-left: 12%; left: 30%;"></div>
<br />
<h2 class="basic_para"> Size in (KLOC)</h2>
<input id="adv_size" type="text" class="basic_input" placeholder="SIZE"/>
<div id="adv_err" class="basic_error" style="display: none;">Some error Generated</div>
<br /><br />
<button id="adv_submit" class="basic_button" onclick="Estimate( modes[get_slidr_value()], $('#adv_size').val() )">Calculate</button>
<br /> <br />
</div>
<br />
<!-- DIV for Table -->
<div id="table_div" class="table_space" style="display: none;">
<table id="table_estimate" class="">
</table>
</div>
<script>
$(document).ready(function()
{
$("#basic").click(function()
{
$("#mode").fadeOut("fast",function()
{
$("#basic_form").slideDown(1000, function()
{
$("#basic_form").show();
});
});
});
//Show EAF table with form
$("#advance").click(function()
{
$("#mode").fadeOut("slow", function()
{
$("#effort_factors").slideDown(300, function()
{
//create sliders dynamically
construct_view();
$("#effort_factors").show();
$("#adv_form").show();
set_cost_drivers(JSON.parse(get_cost_drivers()));
});
});
});
//Create a basic mode Slider
$( "#basic_slider" ).slider(
{
value:1,
min: 0,
max: 2,
step: 1,
slide: function( event, ui )
{
slider_value = ui.value;
$( "#basic_mode" ).html( modes[ui.value] );
if($("#basic_size").val().length > 0)
{
if(check_size_constraints( modes[slider_value], $("#basic_size").val() ))
{
calculate(slider_value, $('#basic_size').val());
}
else
{
remove_table();
}
};
}
});
//Validate input during user typing
$("#basic_size").bind('input propertychange', function()
{
if( Validate_string($("#basic_size").val()) )
{
$("#basic_size").removeClass("basic_input_error");
check_size_constraints( modes[slider_value], $("#basic_size").val() );
}
else{
$("#basic_size").addClass("basic_input_error");
}
});
$("#adv_size").bind('input propertychange', function()
{
if( Validate_string($("#adv_size").val()) )
{
$("#adv_size").removeClass("adv_input_error");
adv_check_size_constraints( modes[get_slidr_value()], $("#adv_size").val() );
}
else
{
$("#adv_size").addClass("adv_input_error");
}
});
//Title Heading Click
$("#estimation_technique").click(function(){
if($("#basic_form").is(":visible"))
{
if($("#table_div").is(":visible"))
{
$("#table_estimate").html("");
$("#table_estimate").hide();
$("#table_div").hide();
}
$("#basic_form").fadeOut(100,function()
{
$("#basic_form").hide();
});
$("#mode").fadeIn(2000, function()
{
$("#mode").show();
});
}
else if($("#adv_form").is(":visible"))
{
if($("#table_div").is(":visible"))
{
$("#table_estimate").html("");
$("#table_estimate").hide();
$("#table_div").hide();
}
$("#adv_form").fadeOut(100,function()
{
$("#adv_form").hide();
$("#effort_factors").html("");
$("#effort_factors").hide();
});
$("#mode").fadeIn(2000, function()
{
$("#mode").show();
});
}
else{
$("#mode").show();
}
});
});
</script>
</body>
</html>
//Remeber states and values
var cost_drivers,EFFORT,TIME_DEVELOPMENT;
var modes = ['Organic', 'Semi-Detached', 'Embeded'];
var EAF = ['RELY', 'DATA', 'CPLX', 'TIME', 'STOR', 'VIRT', 'TURN', 'ACAP', 'AEXP', 'PCAP', 'VEXP', 'LEXP', 'MODP', 'TOOL', 'SCED'];
var EAF_values = ['VeryLow', 'Low', 'Nominal', 'High', 'VeryHigh', 'ExtraHigh'];
var tpis = ['Required Software Reliability', 'Database Size', 'Product Complexity', 'Execution Time Constraint', 'Machine Storage Constraint'
, 'Virtual Machine Volatility', 'Computer turn-around Time', 'Analyst Capability', 'Application Experience',
'Programmer Capability', 'Virtual Machine Experience', 'Programming Language Experience', 'Use of Modern Programming Techniques'
, 'Use of Software Tools', 'Required Development Schedule'];
/*
We define array of effort constant values.
*/
//organic
var effort = new Object();
effort.mode = 'Organic';
effort.a = 3.2;
effort.b = 1.05;
EFFORT = JSON.stringify(effort) + ',';
//Semi-Detached
effort.mode = 'Semi-Detached';
effort.a = 3.0;
effort.b = 1.12;
EFFORT = EFFORT + JSON.stringify(effort) + ',';
//Embeded
effort.mode = 'Embeded';
effort.a = 2.8;
effort.b = 1.20;
EFFORT = EFFORT + JSON.stringify(effort);
EFFORT = '[' + EFFORT + ']';
/*
We define array of Time Development constant values.
*/
//organic
var Development_Time = new Object();
Development_Time.mode = 'Organic';
Development_Time.a = 2.5;
Development_Time.b = 0.38;
TIME_DEVELOPMENT = JSON.stringify(Development_Time) + ',';
//Semi-Detached
Development_Time.mode = 'Semi-Detached';
Development_Time.a = 2.5;
Development_Time.b = 0.35;
TIME_DEVELOPMENT = TIME_DEVELOPMENT + JSON.stringify(Development_Time) + ',';
//Embeded
Development_Time.mode = 'Embeded';
Development_Time.a = 2.5;
Development_Time.b = 0.32;
TIME_DEVELOPMENT = TIME_DEVELOPMENT + JSON.stringify(Development_Time);
TIME_DEVELOPMENT = '[' + TIME_DEVELOPMENT + ']';
//Detect slider change value
var slider_value = 1;
//Set the cost Drives values
function set_cost_drivers(costDriver){
cost_drivers = costDriver;
console.log(cost_drivers);
}
//Gets the slider value to detect mode
function get_slidr_value(){
return slider_value;
}
/*
======================================================
UI methods
======================================================
*/
//Add Cost Effevtive drivers dynamically and bind them events
function construct_view()
{
//iterating every EAF factort
for(var i=0; i< EAF.length; i++)
{
//create a new div inside it create a new p and slider and instiante function to that slier
var divid = 'd'+EAF[i];
var hid = 'h'+EAF[i];
var pid = 'p'+EAF[i];
var slider = 's'+EAF[i];
var value = '<div id = "' + divid + '">' + '<h3 id = "' + hid + '" class = "tooltip" title="'+tpis[i]+ '" >' + EAF[i] + '</h3>' +
'<p id = "' + pid + '" >' + 'VeryLow' + '</p>'+
'<div id="' + slider + '"> </div> </div>';
$("#effort_factors").append(value);
$("#"+slider).slider(
{
value:0,
min: 0,
max: 6,
step: 1,
slide: function( event, ui ) { }
});
$("#"+ divid + "> div").map(function()
{
//console.log(this.id);
$("#"+this.id).on("slide", function(event, ui)
{
var p = this.id.substring(1);
//console.log("#p"+ p);
$("#p"+ p).html(EAF_values[ui.value]);
change_color(p);
if($("#adv_size").val().length > 0)
{
if(adv_check_size_constraints( modes[slider_value], $("#adv_size").val() ))
{
//calculate(slider_value, $('#basic_size').val());
Estimate(slider_value, $("#adv_size").val());
}
else
{
adv_remove_table();
}
}
});
});
}
create_adv_slider();
}
//Dynamically ceated sliders border effetc
function change_color(id)
{
//console.log("ID: " + id);
//console.log("#d"+id);
//Change SliderBorder
var text = $("#p"+id).text();
if(text == 'VeryLow' || text == 'Low')
{
$("#d"+id).css({"border": "solid #d41243"});
}
else if(text == 'VeryHigh' || text == 'High' || text == 'ExtraHigh')
{
$("#d"+id).css({"border": "solid #8ec127"});
}
else
{
$("#d"+id).css({"border": "solid white"});
}
}
//Create slider to detect mode.
function create_adv_slider()
{
$("#adv_slider").slider({
value:1,
min: 0,
max: 2,
step: 1,
slide: function( event, ui )
{
//slider_value = ui.value;
$( "#adv_mode" ).html( modes[ui.value] );
slider_value = ui.value;
if($("#adv_size").val().length > 0)
{
if(adv_check_size_constraints( modes[slider_value], $("#adv_size").val() ))
{
//calculate(slider_value, $('#basic_size').val());
Estimate(slider_value, $("#adv_size").val());
}
else
{
adv_remove_table();
}
};
}
});
}
/*
===================================
xxxxxxxx END UI METHODS xxxxxxxxxx
===================================
*/
/*
===================================
Validation Process
===================================
*/
/*
Validate the user input by checking the given input is integer or not
On Invalid user input the textbox color will change and show appropriate error
*/
function Validate_string(value)
{
if(!isNaN(value))
{
$("#adv_size"). removeClass("basic_input_error");
$("#adv_err").hide();
return true;
}
else
{
$("#adv_err").show();
$("#adv_err").html("Input Value should be numeric only");
}
return false;
}
//Validate the KLOC size accroding to the respective modes
function adv_check_size_constraints(slidervalue, textvalue)
{
$("#adv_err").hide();
if(slidervalue == 'Organic' && textvalue > 50)
{
$("#adv_size").addClass("basic_input_error");
$("#adv_err").show();
$("#adv_err").html("Organic Size should be between 2-50 KLOC");
return false;
}
else if(slidervalue == 'Semi-Detached' && textvalue > 300)
{
$("#adv_size").addClass("basic_input_error");
$("#adv_err").show();
$("#adv_err").html("Semi-Detached Size should be between 50-300 KLOC");
return false;
}
else if(slidervalue == 'Embeded' && textvalue < 300)
{
$("#adv_size").addClass("basic_input_error");
$("#adv_err").show();
$("#adv_err").html("Embeded Size should be above 300 KLOC");
return false;
}
$("#adv_size").removeClass("basic_input_error");
$("#adv_err").hide();
return true;
}
/*
=======================================
xxxxxxx End Validation Process xxxxxx
=======================================
*/
/*
=========================================
Estimation Techniques + Table Logic
=========================================
*/
function Estimate(slider, size){
var C = 1; //initialize the Cost Adjusting factor variable...
var counter = 0;
//Check input Type and KLOC size constraints according to selected mode...
if(Validate_string(size) && adv_check_size_constraints(slider, size))
{
//Get all the Cost adjusting factors values
$("#effort_factors"+ "> div").map(function()
{
var divid = 'd' + EAF[counter];
$("#"+divid+ "> div").map(function()
{
//GET the Slider value by p tag
var id = divid.substr(1);
id = "#p"+ id;
var value = $(id).text(); //Get value Low,Nominal,High.....
console.log("ID: "+ id + " Value: " + value);
var adjust_value = cost_drivers[counter][value]; //Get the driver value from the p tag
console.log("Adjust Factor: "+ adjust_value);
C = C * adjust_value;
});
counter++;
});
C = Math.round(C);
console.log("Effort Adjusting Factor: "+ C);
//GET Effor and then calculate effort
var eff = JSON.parse(EFFORT);
var m = eff[slider_value]['mode'];
var a = eff[slider_value]['a'];
var b = eff[slider_value]['b'];
var ef = Math.round((a * Math.pow(size,b)));
var ef = ef * C;
var time = JSON.parse(TIME_DEVELOPMENT);
m = time[slider_value]['mode'];
a = time[slider_value]['a'];
b = time[slider_value]['b'];
time = Math.round((a * Math.pow(ef, b)));
var staff= Math.round((ef/time));
var produ= Math.round( ((size*1000)/ef) );
createTable(ef, C, time, staff, produ);
}
else
{
//Validation failed remove the table and show error
adv_remove_table();
}
}
//Display table
function createTable(effort, cost, time, staffSize, productivity){
$("#table_div").show();
$("#table_estimate").html("");
$("#table_estimate").slideDown(1000,function()
{
var table_heads = "<thead> <th>#</th><th>Value</th></thead>";
var table_values = table_heads + "<tr> <td> Effort </td> <td> "+ effort + " StaffMonths </td> </tr>"+
"<tr> <td> Cost </td> <td> "+ cost + " </td> </tr>" +
"<tr> <td> TimeDevelopment </td> <td> "+ time + " Months</td> </tr>" +
"<tr> <td> StaffSize </td> <td> "+ staffSize + " Months</td> </tr>"+
"<tr> <td> Productivity </td> <td> "+ productivity + " LOC/Staff-Month</td> </tr>";
$("#table_estimate").html(table_values);
});
window.scrollTo(0,100);
}
//Remove the table since error has occured
function adv_remove_table(){
$("#table_div").slideUp(500, function(){
//setTimeout(function(){},3000);
$("#table_estimate").html("");
$("#table_estimate").hide();
$("#table_div").hide();
});
window.scrollTo(0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment