From d5e1e899fae749fa3bbbb8738a8eed007f2d2610 Mon Sep 17 00:00:00 2001 From: Kate Roe Date: Thu, 1 Aug 2013 10:12:55 -0400 Subject: [PATCH 1/2] morning 8/1 --- perfectSteak.js | 157 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 107 insertions(+), 50 deletions(-) diff --git a/perfectSteak.js b/perfectSteak.js index cecf20c..0226961 100644 --- a/perfectSteak.js +++ b/perfectSteak.js @@ -11,28 +11,19 @@ var perfectSteak = function (div) { currentInfo["thickness"] = newVal; } - + + var checkDiv=function(){ currentInfo["OKToGraph"]=true; $(".alert").remove(); for (var h=0; h300){ - // var side1Alert=$("
Too high!
"); - // $("#row"+h+"side1").append(side1Alert); - // currentInfo["OKToGraph"]=false; - // } if(parseFloat($("#inp1_"+h).val())<0){ var side1Alert=$("
Too low!
"); $("#row"+h+"side1").append(side1Alert); currentInfo["OKToGraph"]=false; } - // if(parseFloat($("#inp2_"+h).val())>300){ - // var side2Alert=$("
Too high!
"); - // $("#row"+h+"side2").append(side2Alert); - // currentInfo["OKToGraph"]=false; - // } if(parseFloat($("#inp2_"+h).val())<0){ var side2Alert=$("
Too low!
"); $("#row"+h+"side2").append(side2Alert); @@ -43,14 +34,9 @@ var perfectSteak = function (div) { $("#duration"+h).append(timeAlert); currentInfo["OKToGraph"]=false; } - // if(parseFloat($("#row"+h+"time").val())>7200){ - // var timeAlert=$("
Max 2 hours
"); - // $("#duration"+h).append(timeAlert); - // currentInfo["OKToGraph"]=false; - // } } } - + var addTime=function(value){ currentInfo['time']+=value; } @@ -144,9 +130,14 @@ var perfectSteak = function (div) { displayDiv.append(inputTable); displayDiv.change(function(){ model.checkDiv() - console.log("display_div changed") model.buildData(); updateTime(); + for (var j=0; j60){ + $("#row"+j+"time").val(model.convertTime(timeInSecs)) + } + } if(clicked&&model.currentInfo["OKToGraph"]){graph()} else{d3.select("svg") .remove(); @@ -167,16 +158,16 @@ var perfectSteak = function (div) { 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 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(0); } - $("#timeCol"+(i)).html(" "+ minSecs); + //$("#timeCol"+(i)).html(" "+ minSecs); } } @@ -187,14 +178,61 @@ var perfectSteak = function (div) { if (model.currentInfo["OKToGraph"]){ console.log("isOK"); console.log("click"); - + div.append("
") $(".table-container").append(displayDiv); $("#startModal").modal("show"); cookButton = $(".cookButton"); - +// +// var thicknessInp = ($("
Meat Thickness (cm)
")); +// thicknessInp.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// var steakTemp = ($("
Initial Meat Temperature (°C)
")); +// steakTemp.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// //Item to hold inputs of meat. Append meatInput to your display +// var meatInput=$('
What type of meat are you cooking?
' +// +'Steak
' +// +'Tuna
' +// +'Turkey
'); +// meatInput.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// var cookbuttonrow = $("
Let's get cooking!"); +// +// var thicknessInp = ($("
Meat Thickness (cm)
")); +// thicknessInp.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// var steakTemp = ($("
Initial Meat Temperature (°C)
")); +// steakTemp.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// //Item to hold inputs of meat. Append meatInput to your display +// var meatInput=$('
What type of meat are you cooking?
' +// +'Steak
' +// +'Tuna
' +// +'Turkey
'); +// meatInput.change(function(){ +// model.checkDiv(); +// if(clicked&&model.currentInfo["OKToGraph"]){graph()}}); +// +// +// var cookbuttonrow = $("
Total Time(m:s)Duration (s)Side 1 (°C)Side 2 (°C)"); + var inpTabHeader = $("Duration (s)Side 1 (°C)Side 2 (°C)"); inputTable.append(inpTabHeader); var timeStep = model.timeStep; 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; @@ -222,28 +261,29 @@ var toF=function(C) if(i>0){ var vals=parseFloat($("#row" + (i-1) + "time").val()); - var info=$("#timeCol"+(i-1)).html(); - info = info.replace(":", ".").split('.'); + //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=$(""+minSecs+""); + // vals=vals+60*parseFloat(info[0])+parseFloat(info[1]); + // var minSecs=model.convertTime(vals); + } + // else{ + // var minSecs=model.convertTime(i*timeStep); + // } + //var timeCol=$(""+minSecs+""); var duration = $(""); var inp1 = $(""); - var inp2 = $(""); + var inp2 = $(""); var step1Col = $(""); step1Col.append(inp1); var step2Col = $(""); step2Col.append(inp2); step1Col.append(flipButton); - row.append( timeCol,duration, step1Col, step2Col); + row.append(duration, step1Col, step2Col); inputTable.append(row); if (i == model.currentInfo["numRows"] - 1) { inputTable.append(addButton, subButton); +// displayDiv.append(cookButton); } if (len == 0) { @@ -272,6 +312,7 @@ var toF=function(C) addButtonFun(); subButtonFun(); CookButtonFun(); + closeRowFun(); }; @@ -279,29 +320,29 @@ var toF=function(C) flipButton = $(""); var row = $(""); var i = model.currentInfo["numRows"] - 1; - if(i>0){ - var vals=parseFloat($("#row" + (i-1) + "time").val()); + if(i>0){ + var vals=parseFloat($("#row" + (i-1) + "time").val()); - var info=$("#timeCol"+(i-1)).html(); - info = info.replace(":", ".").split('.'); + //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); - } + //vals=vals+60*parseFloat(info[0])+parseFloat(info[1]); + //var minSecs=model.convertTime(vals); + } + //else{ + //var minSecs=model.convertTime(i*timeStep); + //} - var timeCol=$(""+minSecs+""); + //var timeCol=$(""+minSecs+""); var duration = $(""); var inp1 = $(""); var inp2 = $(""); var step1Col = $(""); step1Col.append(inp1); - var step2Col = $(""); + var step2Col = $(""); step2Col.append(inp2); step1Col.append(flipButton); - row.append(timeCol, duration, step1Col, step2Col); + row.append(duration, step1Col, step2Col); timeFun(i); flipButtonFun(i); table.append(row); @@ -313,6 +354,7 @@ var toF=function(C) subButtonFun(); } model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]) + closeRowFun(); } @@ -344,6 +386,15 @@ var toF=function(C) } }); }; + + var closeRowFun=function(){ + $(".closeRow").on("click", function(){ + console.log($(this).attr("id")) + rowNum=String($(this).attr("id")[]) + }); + } + + var graph=function(){ d3.select("svg") .remove(); @@ -411,9 +462,15 @@ var graph=function(){ var timeFun = function (j) { $("#row" + j + "time").change(function () { + console.log("timeFun") if (j == 0) { timeStep = parseInt($("#row" + j + "time").value); } + // var timeInSecs=parseFloat($("#row"+j+"time").val()); + // if (timeInSecs>60){ + // console.log("greaterthan60") + // $("#row"+j+"time").val(convertTime(timeInSecs)) + // } }) }; From 6a7c0ba4cc149b8bee7304b06d9ae6bff1027fe3 Mon Sep 17 00:00:00 2001 From: Kate Roe Date: Thu, 1 Aug 2013 11:38:57 -0400 Subject: [PATCH 2/2] bugs fixed for the x's --- perfectSteak.js | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/perfectSteak.js b/perfectSteak.js index 7146087..bebb729 100644 --- a/perfectSteak.js +++ b/perfectSteak.js @@ -154,7 +154,6 @@ var perfectSteak = function (div) { // div.append var addButton; - var subButton; var flipButton; var cookButton; var updateTime=function(){ @@ -269,7 +268,6 @@ var toF=function(C) for (var i = 0; i < model.currentInfo["numRows"]; i++) { var iminus = i - 1; addButton = $(""); - subButton = $(""); flipButton = $(""); var row = $(""); @@ -306,7 +304,7 @@ var toF=function(C) row.append(duration, step1Col, step2Col); inputTable.append(row); if (i == model.currentInfo["numRows"] - 1) { - inputTable.append(addButton, subButton); + inputTable.append(addButton); //>>>>>>> 98101b5e50ec50526ddb403f94f4d68ebcd1d185 } if (len == 0) { @@ -334,7 +332,6 @@ var toF=function(C) model.dataClear(); addButtonFun(); - subButtonFun(); CookButtonFun(); closeRowFun(); }; @@ -378,11 +375,6 @@ var toF=function(C) table.append(row); inp1.val($("#inp1_" + (i-1)).val()); inp2.val($("#inp2_" + (i-1)).val()); - if (model.currentInfo["numRows"]==2){ - subButton = $(""); - table.append(subButton); - subButtonFun(); - } model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]) closeRowFun(); } @@ -400,27 +392,22 @@ var toF=function(C) }); }; - var subButtonFun = function () { - subButton.on("click", function () { - - model.numRowsMinus(); - model.buildData(); - delRow(); - if (model.currentInfo["numRows"] == 1) { - $(".inputTable").empty(); - buildTable(model.currentInfo["numRows"]); - subButton.remove(); - } else { - $(".inputTable").empty(); - buildTable(model.currentInfo["numRows"]); - } - }); - }; var closeRowFun=function(){ $(".closeRow").on("click", function(){ var rowNum=String($(this).attr("id").charAt(3)) $("#row"+rowNum).remove(); + model.numRowsMinus(); + + //NOW WE NEED TO CHANGE THE ROW NUMBER OF ALL THE OTHER ROWS + for (var l=rowNum+1; l