Skip to content

Commit

Permalink
ALL WORKING HOPEFULLY
Browse files Browse the repository at this point in the history
  • Loading branch information
stephensm authored and stephensm committed Jul 30, 2013
2 parents ccb736c + 3a08edb commit 709e2c8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
8 changes: 7 additions & 1 deletion data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var tempScale={"Steak":
{'info':'Myoglobin denatures 60-70\xB0 C','position':2},
{'info':'Actin denatures 70-120\xB0 C','position':1},
{'info':'Browning reactions occur 120+\xB0 C','position':0}],

"Tuna":

[{'info':'lack of protein denaturization below 40\xB0 C','position':5},
{'info':'Myosin breaks down 40-50\xB0 C','position':4},
{'info':'Myocommata begins to rupture 50\xB0 C','position':3},
Expand All @@ -27,6 +29,7 @@ var tempScale={"Steak":
{'info':'Actin denatures 70-120\xB0 C','position':1},
{'info':'Browning reactions occur 120+\xB0 C','position':0}],


};

//color
Expand All @@ -39,14 +42,17 @@ var color = {
d3.scale.linear()
.domain([0,1,5,9,10])
.range(['#692901','#FAEEE6','#FA3491', '#FAEEE6','#692901']),

"Turkey":
d3.scale.linear()
.domain([0,1,5,9,10])
.range(['#692901','#FAEEE6','#B56980','#FAEEE6','#692901']),
"Tofu":
d3.scale.linear()
.domain([0,1,5,9,10])


.range(['#DE843A','#F7DEC8','#F5F2F0','#F7DEC8','#DE843A'])
};
//boundaries where color change occurs
var boundaries= {"Steak":[120,70,60,55,40], "Tuna": [90,70,60,50,40],"Turkey":[120,70,60,55,40],"Tuna":[120,70,60,55,40]};
var boundaries= {"Steak":[120,70,60,55,40], "Tuna": [90,70,60,50,40],"Turkey":[120,70,60,55,40],"Tuna":[120,70,60,55,40]};
8 changes: 4 additions & 4 deletions graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var svg = d3.select("body").append("svg")
.attr("x", width/1.3)
.attr("y", -margin.top/2)
.style("font-size",'30px')
.text("Steak temperature is: ______\xB0C");
.text(meatType+ " temperature is: ______\xB0C");

var layer = svg.selectAll(".layer")
.data(layers)
Expand Down Expand Up @@ -170,8 +170,8 @@ var rect = layer.selectAll("rect")
var Offset = document.getElementById("graphSteak").offsetTop;
var pos=parseInt(data[0].length-(event.pageY-Offset-margin.top)/(height/yStackMax));
var line=parseInt((event.pageX-margin.left)/(x.rangeBand()+1)-4.0);
$(d3.select('.mylabel')[0][0]).text("Steak temperature is "+ data[line][pos].toFixed(2)+ "\xB0C");

$(d3.select('.mylabel')[0][0]).text( meatType+ " temperature is "+ data[line][pos].toFixed(2)+ "\xB0C");
//$(d3.select('.mylabel')[0][0]).text("Steak temperature is "+ line.toFixed(2)+ "\xB0C");
})


Expand Down Expand Up @@ -236,7 +236,7 @@ svg.append("text")
.attr("x", -height/3)
.attr("y",-30)
.attr("transform", "rotate(-90)")
.text("Steak Thickness (cm)");
.text(meatType+" Thickness (cm)");

svg.append("text")
.attr("class", "y label1")
Expand Down
5 changes: 5 additions & 0 deletions perfectSteak.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@
position: relative;
top: 0%;
float: left;
}

#meatInp{
position:relative;
float:left;
}
29 changes: 23 additions & 6 deletions perfectSteak.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ var perfectSteak = function (div) {
timeFun(i);
flipButtonFun(i);
}

model.dataClear();
addButtonFun();
subButtonFun();
CookButtonFun();
};


var addRow = function (table) {
flipButton = $("<button class='btn btn-mini' id='flipButton" + i + "'><font size=4px>&harr;</font></button>");
var row = $("<tr></tr>");
Expand All @@ -145,12 +148,19 @@ var perfectSteak = function (div) {
table.append(row);
inp1.val(23);
inp2.val(23);
if (numRows==2){
subButton = $("<button class='btn btn-mini' id='subButton'>-</button>");
table.append(subButton);
subButtonFun();
}
model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())])
}


var delRow = function (table) {

$('.' + table.class + ' tr:last').remove();
}

var addButtonFun = function () {
addButton.on("click", function () {
numRows++;
Expand All @@ -159,7 +169,6 @@ var perfectSteak = function (div) {
};

var subButtonFun = function () {

subButton.on("click", function () {
numRows--;
delRow($(".inputTable"));
Expand All @@ -168,7 +177,6 @@ var perfectSteak = function (div) {
buildTable(numRows);
subButton.remove();
} else {

$(".inputTable").empty();
buildTable(numRows);
}
Expand Down Expand Up @@ -214,15 +222,16 @@ var perfectSteak = function (div) {
model.changeThickness(parseFloat($("#thicknessInp").val()))
};


//add to on click and calculate(blah,blah,blah, meatType)
var meatType = $("input[type='radio'][name='rate']:checked").val();
//THIS WILL COOK THE STEAK IF WE HAVE VALID INPUTS
if (OKtoCook==true){
var steak = [model.data[0][1]];
for (var m = 0; m < parseFloat($("#thicknessInp").val()) * 10; m++) {
steak.push(parseFloat($("#steakTemp").val()))
}
steak.push(model.data[0][2]);
calculate(model.data, steak)
calculate(model.data, $("input[type='radio'][name='rate']:checked").val()||steak)
}
});
}
Expand Down Expand Up @@ -264,13 +273,21 @@ var perfectSteak = function (div) {
//timeFun(0);

view.buildTable();

var thicknessInp = ($("<div id=thickInpDiv><input type='text' id='thicknessInp' value='6'></input> Meat Thickness (cm) </div>"));
var steakTemp = ($("<div id=tempInpDiv><input type='text' id='steakTemp' value='23'></input>Initial Meat Temperature (&#176;C)</div>"));
//Item to hold inputs of meat. Append meatInput to your display
var meatInput=$('<form id="meatInp">What color type of meat are you cooking?<br>'
+'<input type="radio" name="meat" id="Steak">Steak<br>'
+'<input type="radio" name="meat" id="Tuna">Tuna<br>'
+'<input type="radio" name="meat" id="Turkey">Turkey<br>'
+'<input type="radio" name="meat" id="Tofu">Tofu</form>');

// thicknessInp.change(function(){
// model.changethickness(thicknessInp.val());
// })

div.append(thicknessInp, steakTemp);
div.append(thicknessInp, steakTemp, meatInput);
};
return {
setup: setup
Expand Down
4 changes: 2 additions & 2 deletions sample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var calculate=function(data,steak,meatType){

var calculate=function(data,steak){
var meatType="fish";
var myheatsolver = HeatSolver(steak);
console.log(data);

Expand Down

0 comments on commit 709e2c8

Please sign in to comment.