Skip to content

Commit

Permalink
Working save the auto-updating total time
Browse files Browse the repository at this point in the history
  • Loading branch information
stephensm committed Jul 31, 2013
1 parent abfdfd8 commit 2952095
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 33 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ var n = boundaries[meatType].length*2+1, // number of layers
for(var i=0;i<boundaries[meatType].length;i++)
{
if(temp>=boundaries[meatType][i])return i;


}
return 5;

Expand Down
11 changes: 9 additions & 2 deletions heat-diffusion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function HeatSolver(startingTemps){

var tempArray = [startingTemps];

var D = .14; // in units of mm^2/sec

var timestep = 1;
Expand Down Expand Up @@ -208,7 +209,12 @@ var len= tempArray[0].length;
var graphlabels = [];
var temperatures = [];
var count=0;
var maxTemps = tempArray[0];
var maxTemps=[];
for(var i=0;i<tempArray[0].length;i++)
{
maxTemps.push(0)
}


for(var j=0; j<time_top_bottom.length; j++){
//set the conductivity of air to zero
Expand Down Expand Up @@ -243,7 +249,8 @@ var len= tempArray[0].length;
}
}
}

console.log(maxTemps);

var arrays = tempArray.length-1 ;
var len= tempArray[0].length;
var step = arrays/60.0;
Expand Down
2 changes: 2 additions & 0 deletions perfectSteak.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
overflow-y: auto;
width:100%;
height:300px;


}

#addButton{
Expand Down
82 changes: 56 additions & 26 deletions perfectSteak.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ var perfectSteak = function (div) {
//THIS IS FOR CHANGING THE ENTIRE DATA ARRAY
var dataChange = function (array) {
currentInfo["data"]=array;
console.log(currentInfo["data"])

}

var buildData=function(){
var newData=[];
console.log(currentInfo["numRows"]);

for (var g=0; g<currentInfo["numRows"]; g++){
var side1data=$("#inp1_"+g).val();
var side2data=$("#inp2_"+g).val();
var timedata=$("#row"+g+"time").val();
var side1data=parseFloat($("#inp1_"+g).val());
var side2data=parseFloat($("#inp2_"+g).val());
var timedata=parseFloat($("#row"+g+"time").val());
newData.push([timedata, side1data, side2data]);
}
console.log(newData)

dataChange(newData);
}

Expand All @@ -86,7 +86,8 @@ var perfectSteak = function (div) {
numRowsMinus:numRowsMinus,
convertTime:convertTime,
changeTime:changeTime,
addTime:addTime
addTime:addTime,
buildData:buildData
}
}

Expand All @@ -95,6 +96,8 @@ var perfectSteak = function (div) {

function View(div, model) {
var inputTable = $("<table class='inputTable table table-striped'></table>");
var clicked=false;
inputTable.change(function(){console.log("click"); model.buildData(); if(clicked){graph()}})
var displayDiv = $("<div class='displayDiv'></div>");
displayDiv.append(inputTable);
// div.append(displayDiv);
Expand Down Expand Up @@ -133,17 +136,27 @@ var perfectSteak = function (div) {
var len = model.currentInfo["data"].length;
var newData = []
// $("#cookButton").remove();

var sumtime=0;
for (var i = 0; i < model.currentInfo["numRows"]; i++) {
var iminus = i - 1;
addButton = $("<button class='btn btn-mini' id='addButton'>+</button>");
subButton = $("<button class='btn btn-mini' id='subButton'>-</button>");
flipButton = $("<button class='btn btn-mini' id='flipButton" + i + "'><font size=4px>&harr;</font></button>");

var row = $("<tr></tr>");
var minSecs=model.convertTime(i*model.timeStep);
console.log("minSecs"+minSecs)
var timeCol=$("<td id='timeCol"+i+"'>"+minSecs+"</td>")
if(i>0){
var vals=parseFloat($("#row" + (i-1) + "time").val());

var info=$("#timeCol"+(i-1)).html();
info = info.replace(":", ".").split('.');
console.log(info);
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 + "'>");
var inp2 = $("<input type='text' id='inp2_" + i + "'>");
Expand All @@ -152,28 +165,29 @@ var perfectSteak = function (div) {
var step2Col = $("<td id='row" + i + "side2' class='row" + i + "'></td>");
step2Col.append(inp2);
step1Col.append(flipButton);
row.append(timeCol, duration, step1Col, step2Col);
row.append( timeCol,duration, step1Col, step2Col);
inputTable.append(row);
if (i == model.currentInfo["numRows"] - 1) {
inputTable.append(addButton, subButton);
// displayDiv.append(cookButton);
}
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([parseFloat($("#row" + i + "time").val()), 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())])
} 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())])
}
timeFun(i);
Expand All @@ -191,10 +205,19 @@ var perfectSteak = function (div) {
flipButton = $("<button class='btn btn-mini' id='flipButton" + i + "'><font size=4px>&harr;</font></button>");
var row = $("<tr></tr>");
var i = model.currentInfo["numRows"] - 1;

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

var info=$("#timeCol"+(i-1)).html();
info = info.replace(":", ".").split('.');
console.log(info);
vals=vals+60*parseFloat(info[0])+parseFloat(info[1]);
var minSecs=model.convertTime(vals);
}
else{
var minSecs=model.convertTime(i*timeStep);
}

var minSecs=model.convertTime(i*model.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 Down Expand Up @@ -233,7 +256,7 @@ var perfectSteak = function (div) {

var subButtonFun = function () {
subButton.on("click", function () {
console.log(model.currentInfo["data"]);

model.numRowsMinus();
model.buildData();
delRow();
Expand All @@ -247,12 +270,13 @@ var perfectSteak = function (div) {
}
});
};

var CookButtonFun = function () {
cookButton.on("click", function () {
d3.select("svg")
var graph=function(){
d3.select("svg")
.remove();
d3.select("svg")
.remove();
model.dataClear();

for (var e = 0; e < model.currentInfo["numRows"]; e++) {
var curTime = parseFloat($("#row" + e + "time").val());
var cur1 = parseFloat($("#inp1_" + e).val());
Expand Down Expand Up @@ -289,7 +313,7 @@ var perfectSteak = function (div) {

//add to on click and calculate(blah,blah,blah, meatType)
var meatType = $("input[type='radio'][name='meat']:checked").attr('id');
console.log(meatType);

//THIS WILL COOK THE STEAK IF WE HAVE VALID INPUTS
if (OKtoCook==true){
var steak = [model.currentInfo["data"][0][1]];
Expand All @@ -299,6 +323,12 @@ var perfectSteak = function (div) {
steak.push(model.currentInfo["data"][0][2]);
calculate(model.currentInfo["data"], steak,meatType)
}
}
var CookButtonFun = function () {
cookButton.on("click", function () {
clicked=true;
graph();

});
}

Expand Down
3 changes: 0 additions & 3 deletions sample.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
var calculate=function(data,steak,meatType){

var myheatsolver = HeatSolver(steak);
var Thedata=myheatsolver.sixty_graph_arrays_duration(data);

var sampledata=Thedata.temps;
var flame=Thedata.points;
var timestep=1/Thedata.step;
var maxTemps=Thedata.maxTemps;
console.log(maxTemps);
graphSteak(sampledata,flame,timestep,meatType,maxTemps);

}

0 comments on commit 2952095

Please sign in to comment.