Skip to content

Commit

Permalink
The scroll to bottom now works
Browse files Browse the repository at this point in the history
  • Loading branch information
stephensm authored and stephensm committed Aug 5, 2013
1 parent 3bfaae9 commit 2bb6ae9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 41 deletions.
31 changes: 22 additions & 9 deletions drawSaved.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var drawFinished=function(myMeatType,myMaxTemps)
var drawFinished=function(myMeatType,myMaxTemps,instructions,startingtemp)
{
var getState=function(temp)
{
Expand All @@ -11,6 +11,13 @@ var drawFinished=function(myMeatType,myMaxTemps)
return 6;

};
var directions=[myMeatType+" starts at "+startingtemp+ "\xB0C"];
for(var i=0;i<instructions.length;i++)
{
directions.push("Side 1 at "+instructions[i][1]+"\xB0C and Side 2 at "+instructions[i][2]+"\xB0C for"
+instructions[i][0]+" s");

}
var myMaxs=[];

for (var x = 0; x < 7; x++) {myMaxs.push(0);}
Expand Down Expand Up @@ -38,13 +45,17 @@ var drawFinished=function(myMeatType,myMaxTemps)
.attr("width", '50%')
.attr("height", '200px')
.append("g")
.attr("transform", "translate(" + 45 + "," + 130 + ")");
.attr("class",'savedInfo')
.attr("transform", "translate(" + 45 + "," + 130 + ")")


var legend = svgContainer.selectAll('g')

.data(tempScale[myMeatType])

.enter()
.append('g')

.attr('class', 'legend')
.style('fill', "black");

Expand All @@ -65,13 +76,7 @@ var drawFinished=function(myMeatType,myMaxTemps)
.attr('y', function(d, i){ return i<4? -125+8: -125+18})
.style('font-size','6pt')
.text(function(d){ return (100*d/(myMaxTemps.length)).toFixed(0) +"%"; });
var texts=svgContainer.selectAll("text")
.data([0])
.enter().append("text")
.attr("text-anchor", "left")
.attr("x", '-10%')
.attr("y", -130)
.text("Final Protein State Reached");

//Draw the Rectangle
var rectangle = svgContainer.selectAll("rect")
.data([0,0,0,0,0,0,0].concat(myMaxTemps.reverse()))
Expand All @@ -82,4 +87,12 @@ var rectangle = svgContainer.selectAll("rect")
.attr("height", '1px')
.style('fill', function(d,i) {
return color[myMeatType](getState(d))});
var texts=svgContainer.selectAll("text")
.data([0,1,2,3,4,5,6].concat(directions))
.enter().append("text")
.attr("x", -20)
.attr("y", function(d,i){return -50+(i-7)*10})
.text(function(d){return d})
.attr("font-size", "20px")

}
4 changes: 2 additions & 2 deletions graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ svg.append("text")
.attr("x",-height+margin.bottom/3)
.attr("transform", "rotate(-90)")
.text("Side 2");
drawFinished(meatType,maxTemps);
drawFinished(meatType,maxTemps);

/*
svg.append("g")
.attr("class", "grid")
Expand Down
71 changes: 41 additions & 30 deletions perfectSteak.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ var perfectSteak = function (div) {
//div.append("<div class='row'><div class='span6'><div class='container optionBar'></div></div><div class='span6'><div class='container //table-container'></div></div></div>")
//=======

div.append("<div class='row'><div class='span3'><div class='container optionBar'></div></div><div class='span3'><div class='container table-container'></div></div><div class='span6'></div></div>")
div.append("<div class='row'><div class='span3'><div class='container optionBar'></div></div><div class='span3'><div class='container table-container' id='theTable'></div></div><div class='span6'></div></div>")

//>>>>>>> 98101b5e50ec50526ddb403f94f4d68ebcd1d185
$(".table-container").append(displayDiv);
Expand Down Expand Up @@ -323,34 +323,40 @@ var toF=function(C)
var step2Col = $("<td id='row" + i + "side2' class='row" + i + "'></td>");
step2Col.append(inp2);
step1Col.append(flipButton);
//<<<<<<< HEAD
//=======

//>>>>>>> 98101b5e50ec50526ddb403f94f4d68ebcd1d185
row.append(duration, step1Col, step2Col);
inputTable.append(row);
if (i == model.currentInfo["numRows"] - 1) {
inputTable.append(addButton);
//>>>>>>> 98101b5e50ec50526ddb403f94f4d68ebcd1d185

}
var sumtime=0;
var time=$("#row" + i + "time").val().replace(':','.').split('.');
for (var k=0;k<time.length;k++)
{
sumtime+=parseFloat(time[k]);
}
console.log(sumtime);
if (len == 0) {

inp1.val(23);
inp2.val(23);
model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]);


model.dataAdd([sumtime, parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]);

} else if (i <= len) {

inp1.val(model.currentInfo["data"][i][1]);
inp2.val(model.currentInfo["data"][i][2]);

model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())])
model.dataAdd([sumtime, parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())])
} else {

inp1.val(model.currentInfo["data"][i - 1][1]);
inp2.val(model.currentInfo["data"][i - 1][2]);

model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + iminus).val()), parseFloat($("#inp2_" + iminus).val())])
model.dataAdd([sumtime, parseFloat($("#inp1_" + iminus).val()), parseFloat($("#inp2_" + iminus).val())])
}
timeFun(i);
flipButtonFun(i);
Expand All @@ -367,25 +373,12 @@ var toF=function(C)
flipButton = $("<button class='btn btn-mini' id='flipButton" + i + "'><font size=4px>&harr;</font></button>");
var i = model.currentInfo["numRows"] - 1;
var row = $("<tr id='row"+i+"'></tr>");



if(i>0){
var vals=parseFloat($("#row" + (i-1) + "time").val());
//>>>>>>> 98101b5e50ec50526ddb403f94f4d68ebcd1d185

//var info=$("#timeCol"+(i-1)).html();
//info = info.replace(":", ".").split('.');

//vals=vals+60*parseFloat(info[0])+parseFloat(info[1]);
//var minSecs=model.convertTime(vals);
}
//else{
//var minSecs=model.convertTime(i*timeStep);
//}


//var timeCol=$("<td id='timeCol"+i+"'>"+minSecs+"</td>");

var duration = $("<td ><input id='row" + i + "time' type='text' value='15'></td>");
var inp1 = $("<input type='text' id='inp1_" + i + "'>");
Expand All @@ -396,12 +389,23 @@ var toF=function(C)
step2Col.append(inp2);
step1Col.append(flipButton);
row.append(duration, step1Col, step2Col);
$('#theTable').stop().animate({
scrollTop: $("#theTable")[0].scrollHeight
}, 800);
console.log($("#theTable").scrollTop());
timeFun(i);
flipButtonFun(i);
table.append(row);
inp1.val($("#inp1_" + (i-1)).val());
inp2.val($("#inp2_" + (i-1)).val());
model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())])
var sumtime=0;
var time=$("#row" + i + "time").val().replace(':','.').split('.');
for (var k=0;k<time.length;k++)
{
sumtime+=parseFloat(60*k*time[k]);
}
console.log(sumtime);
model.dataAdd([sumtime, parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())])
closeRowFun();
}

Expand Down Expand Up @@ -440,19 +444,26 @@ var toF=function(C)


var graph=function(){
d3.select("svg")
.remove();
d3.select("svg")
.remove();
d3.select("svg")
d3.selectAll("svg")
.remove();

model.dataClear();

for (var e = 0; e < model.currentInfo["numRows"]; e++) {
var curTime = parseFloat($("#row" + e + "time").val());
var curTime = $("#row" + e + "time").val();
var cur1 = parseFloat($("#inp1_" + e).val());
var cur2 = parseFloat($("#inp2_" + e).val());
model.dataAdd([curTime, cur1, cur2]);

var time=curTime.replace(':','.').split('.');
if(time.length>1){
var sumtime=parseFloat(time[1]);

sumtime+=parseFloat(60*time[0]);
}
else{var sumtime=parseFloat(time[0]);}

console.log(sumtime);
model.dataAdd([sumtime, cur1, cur2]);
}

var OKtoCook=true; //IF WE HAVE INVALID INPUTS, IT WILL BE CHANGED TO FALSE
Expand Down

0 comments on commit 2bb6ae9

Please sign in to comment.