Skip to content

Commit

Permalink
parser checks for celsius/fahrenheit
Browse files Browse the repository at this point in the history
  • Loading branch information
laurabreiman committed Aug 9, 2013
1 parent 88700e0 commit 9ee6928
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion perfectSteak.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,21 @@ var perfectSteak = function (div) {
}

var parseRecipe = function(recipeStr){
var recipeStr = "3 cm Steak starts at 23°C 15 seconds at 180°C and 23°C 15 seconds at 180°C and 23°C"
var pattTemp = /\d+/g;
var pattCelsius = /\°(.+)$/g;

var numArray = recipeStr.match(pattTemp);
for(var i=0;i<numArray.length;i++){
numArray[i]=parseInt(numArray[i]);
}
//check if it's in celsius (celsius = true) or fahrenheit (celsius = false)
var celsius = true;
if(recipeStr.match(pattCelsius)[0].charAt(1) == "F"){
celsius = false;
}
console.log(celsius);

var parsedThickness = numArray.shift();
var startingTemp = numArray.shift();

Expand Down Expand Up @@ -234,7 +244,7 @@ var perfectSteak = function (div) {
var clicked=false;
var displayDiv = $("<div class='displayDiv'></div>");
var tableTabs = $('<ul class="nav nav-tabs"><li><a href="#table" data-toggle="tab">Table</a></li><li><a href="#text" data-toggle="tab">Text</a></li></ul>');
var tabContent = $("<div class='tab-content'><div class='tab-pane active' id='table'><table class='inputTable table table-striped'><tr><th class='inpTabHeader'>Duration (m:s)</th><th class='inpTabHeader'>Side 1 (&#176;C)</th><th class='inpTabHeader'>Side 2 (&#176;C)</th></tr></table></div><div class='tab-pane' id='text'><form><input type='text' id='recipeInput'></input></form></div></div>");
var tabContent = $("<div class='tab-content'><div class='tab-pane active' id='table'><table class='inputTable table table-striped'><tr><th class='inpTabHeader'>Duration (m:s)</th><th class='inpTabHeader'>Side 1 (&#176;C)</th><th class='inpTabHeader'>Side 2 (&#176;C)</th></tr></table></div><div class='tab-pane' id='text'><input type='text' id='recipeInput'></input></div></div>");
displayDiv.append(tableTabs,tabContent);

var addButton;
Expand Down Expand Up @@ -660,6 +670,8 @@ else{var sumtime=parseFloat(time[0]);}
var model = Model();
var view = View(div, model);

model.parseRecipe();

view.buildDisplay();
$('.inputTable').offset({top:0});

Expand Down

0 comments on commit 9ee6928

Please sign in to comment.