diff --git a/drawSaved.js b/drawSaved.js index d1fdb07..22a71d2 100644 --- a/drawSaved.js +++ b/drawSaved.js @@ -15,7 +15,7 @@ var drawFinished=function(myMeatType,myMaxTemps,instructions,startingtemp,side) var directions=[myMeatType+" starts at "+startingtemp+ "\xB0C"]; for(var i=0;i2){ - var timeMin=function(time){ - - var timeString=''; - for (var x=0; x2){ + var timeMin=function(time){ + + var timeString=''; + for (var x=0; x"); - var clicked=false; - +var clicked=false; + var displayDiv = $("
"); displayDiv.append(inputTable); @@ -243,27 +243,28 @@ var perfectSteak = function (div) { // d3.selectAll(".mysteak").remove(); var addButton; - var flipButton; var cookButton; var saveBut=$('Save'); - var cookButt=$(""); + var cookButt=$(""); + var addQuickButton = $(""); + var addTextButton = $(""); + var saveModal=$(''); + displayDiv.append(saveModal) - var saveModal=$(''); - displayDiv.append(saveModal) +saveBut.on("click", function(){ + +///var selectName=$("
") +//var name=$("#recipeName").val(); + +//model.saveRecipe(name); - saveBut.on("click", function(){ - - ///var selectName=$("
") - //var name=$("#recipeName").val(); - - //model.saveRecipe(name); - - }); +}); var updateTime=function(){ +<<<<<<< HEAD var time=0; for(var i=0;i
Saved Methods
"); - var dropdown1=$(''); - var dropdown2=$(''); - - - for(var key in model.currentInfo['recipe']){ - dropdown1.append($('')); - dropdown2.append($('')); - } - - - dropdownDiv.change(function(){ - - var e1 = document.getElementById("d1"); - var name1 = e1.options[e1.selectedIndex].text; - var e2 = document.getElementById("d2"); - var name2 = e2.options[e2.selectedIndex].text; - var info=model.currentInfo['recipe'][name1]; - d3.selectAll('.finalsteak').remove(); - drawFinished(info[0],info[1],info[2],info[3],0); - var inf=model.currentInfo['recipe'][name2]; - drawFinished(inf[0],inf[1],inf[2],inf[3],0); - }); - - - dropdownDiv.append(dropdown1,dropdown2); - $(".span6").prepend(dropdownDiv); - - } - - - var buildDisplay = function () { - if (model.currentInfo["OKToGraph"]){ - div.append("
"); - $(".table-container").append(displayDiv); - - $("#startModal").modal("show"); - - cookButton = $(".cookButton"); - - buildTable(); - } - else{ - (".") - } - - - addDropdown(); - } - - - var toF=function(C) - { - return (C*(5/9)+32 + "°F"); - } - var buildTable = function () { - var inpTabHeader = $("Duration (m:s)Side 1 (°C)Side 2 (°C)"); - inputTable.append(inpTabHeader); - var timeStep = model.timeStep; - var len = model.currentInfo["data"].length; - var newData = [] - var sumtime=0; - for (var i = 0; i < model.currentInfo["numRows"]; i++) { - var iminus = i - 1; - addButton = $(""); - flipButton = $(""); - - var row = $(""); - - if(i>0){ - var vals=parseFloat($("#row" + (i-1) + "time").val()); - - - } - - var duration = $(""); - var inp1 = $(""); - var inp2 = $(""); - var step1Col = $(""); - step1Col.append(inp1); - var step2Col = $(""); - step2Col.append(inp2); - step1Col.append(flipButton); - - row.append(duration, step1Col, step2Col); - inputTable.append(row); - if (i == model.currentInfo["numRows"] - 1) { - saveBut=$('Save'); - var saveModal=$(''); - var nameInp=$(''); - var okModal=$(''); - okModal.on("click", function(){ - + var addDropdown=function(){ + $(".dropdown").remove(); + + var dropdownDiv=$(""); + var dropdown1=$(''); + var dropdown2=$(''); + + + for(var key in model.currentInfo['recipe']){ + dropdown1.append($('')); + dropdown2.append($('')); + } + + + dropdownDiv.change(function(){ + + var e1 = document.getElementById("d1"); + var name1 = e1.options[e1.selectedIndex].text; + var e2 = document.getElementById("d2"); + var name2 = e2.options[e2.selectedIndex].text; + var info=model.currentInfo['recipe'][name1]; + d3.selectAll('.finalsteak').remove(); + drawFinished(info[0],info[1],info[2],info[3],0); + var inf=model.currentInfo['recipe'][name2]; + drawFinished(inf[0],inf[1],inf[2],inf[3],0); + }); + + + dropdownDiv.append(dropdown1,dropdown2); + $(".span9").prepend(dropdownDiv); + + } + + + var buildDisplay = function () { + if (model.currentInfo["OKToGraph"]){ + div.append("
"); + $(".table-container").append(displayDiv); + + $("#startModal").modal("show"); + + cookButton = $(".cookButton"); + + buildTable(); + } + else{ + (".") + } + + + addDropdown(); + } + + + var toF=function(C) + { + return (C*(5/9)+32 + "°F"); + } + var buildTable = function () { + var inpTabHeader = $("Duration (m:s)Side 1 (°C)Side 2 (°C)"); + inputTable.append(inpTabHeader); + var timeStep = model.timeStep; + var len = model.currentInfo["data"].length; + var newData = [] + var sumtime=0; + for (var i = 0; i < model.currentInfo["numRows"]; i++) { + var iminus = i - 1; + addButton = $(""); + + flipButton = $(""); + + var row = $(""); + + if(i>0){ + var vals=parseFloat($("#row" + (i-1) + "time").val()); + + + } + + var duration = $(""); + var inp1 = $(""); + var inp2 = $(""); + var step1Col = $(""); + step1Col.append(inp1); + var step2Col = $(""); + step2Col.append(inp2); + step1Col.append(flipButton); + + row.append(duration, step1Col, step2Col); + inputTable.append(row); + if (i == model.currentInfo["numRows"] - 1) { + saveBut=$('Save'); + var saveModal=$(''); + var nameInp=$(''); + var okModal=$(''); + okModal.on("click", function(){ + + + model.saveRecipe($("#recipeName").val()); + var name=$("#recipeName").val(); + var dropdown1=$("#d1"); + var dropdown2=$("#d2"); + dropdown1.append($('')); + dropdown2.append($('')); + var e1 = document.getElementById("d1"); + var name1 = e1.options[e1.selectedIndex].text; + var e2 = document.getElementById("d2"); + var name2 = e2.options[e2.selectedIndex].text; + var info=model.currentInfo['recipe'][name1]; + d3.selectAll('.finalsteak').remove(); + drawFinished(info[0],info[1],info[2],info[3],0); + var inf=model.currentInfo['recipe'][name2]; + drawFinished(inf[0],inf[1],inf[2],inf[3],0); + }) + saveModal.append(nameInp,okModal); + + + cookButt.on("click",function(){ + model.checkDiv() + model.buildData(); + updateTime(); + // for (var j=0; j1) + // {var time=parseFloat(timeInSecs[0])+60*parseFloat(timeInSecs[1]);} + // else{var time=parseFloat(timeInSecs[0]);} + // $("#row"+j+"time").val(time) + // } + //} + + + model.buildData(); + + if(clicked&&model.currentInfo["OKToGraph"]){graph(false)} + + else{ d3.selectAll(".containers").remove(); + d3.selectAll(".mysteak").remove(); model.saveRecipe($("#recipeName").val()); var name=$("#recipeName").val(); @@ -425,21 +465,22 @@ var perfectSteak = function (div) { model.dataClear(); - } +} - }) +}) - inputTable.append(addButton, saveBut, cookButt, saveModal); - addDropdown(); + inputTable.append(addButton);//, saveBut,saveModal); + $(".span3").append(cookButt,addQuickButton,addTextButton); + addDropdown(); } - var sumtime=0; - var time=$("#row" + i + "time").val().replace(':','.').split('.'); - for (var k=0;k"); var i = model.currentInfo["numRows"] - 1; - var row = $(""); +var row = $(""); - if(i>0){ - var vals=parseFloat($("#row" + (i-1) + "time").val()); +if(i>0){ +var vals=parseFloat($("#row" + (i-1) + "time").val()); var duration = $(""); @@ -492,27 +533,27 @@ var perfectSteak = function (div) { step2Col.append(inp2); step1Col.append(flipButton); row.append(duration, step1Col, step2Col); - $('#theTable').stop().animate({ - scrollTop: $("#theTable")[0].scrollHeight - }, 800); - +$('#theTable').stop().animate({ +scrollTop: $("#theTable")[0].scrollHeight +}, 800); + timeFun(i); flipButtonFun(i); table.append(row); inp1.val($("#inp1_" + (i-1)).val()); inp2.val($("#inp2_" + (i-1)).val()); - var sumtime=0; - var time=$("#row" + i + "time").val().replace(':','.').split('.'); - for (var k=0;k1){ - var sumtime=parseFloat(time[1]); +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]);} +sumtime+=parseFloat(60*time[0]); +} +else{var sumtime=parseFloat(time[0]);} - + model.dataAdd([sumtime, cur1, cur2]); } - var OKtoCook=true; //IF WE HAVE INVALID INPUTS, IT WILL BE CHANGED TO FALSE //THIS BIT IS CHECKING WHETHER THE THICKNESS AND INITIAL TEMP INPUTS ARE VALID @@ -612,26 +652,26 @@ var graph=function(isFirst){ } var CookButtonFun = function () { $(".cookButton").on("click", function () { - clicked=true; - model.checkDiv(); - d3.selectAll(".mysteak").remove(); - d3.selectAll(".containers").remove(); - if (model.currentInfo["OKToGraph"]){ - d3.selectAll("svg").remove(); +clicked=true; +model.checkDiv(); +d3.selectAll(".mysteak").remove(); +d3.selectAll(".containers").remove(); +if (model.currentInfo["OKToGraph"]){ +d3.selectAll("svg").remove(); model.dataClear(); - graph(true); - }; +graph(true); +}; }); } var timeFun = function (j) { $("#row" + j + "time").change(function () { - + if (j == 0) { timeStep = parseInt($("#row" + j + "time").value); } - + if (j == 0) { timeStep = parseInt($("#row" + j + "time").value); @@ -669,7 +709,7 @@ var graph=function(isFirst){ view.buildDisplay(); - $('.inputTable').offset({top:60}); + $('.inputTable').offset({top:1060});