From e511808983edbf6771a5cb5c91ca4a055ba16a2a Mon Sep 17 00:00:00 2001 From: azitowolf Date: Tue, 5 May 2015 17:16:53 -0400 Subject: [PATCH 1/2] threw error on dollar sign --- exercise/index.html | 7 +++++-- exercise/page.js | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/exercise/index.html b/exercise/index.html index aa9e470..42c3952 100644 --- a/exercise/index.html +++ b/exercise/index.html @@ -10,13 +10,16 @@
-

Temperature in Fahrenheit:

-

Temperature in Celsius:

+

Temperature in Fahrenheit:

+

Temperature in Celsius:


+
+ +
diff --git a/exercise/page.js b/exercise/page.js index 6da39c1..30edc76 100644 --- a/exercise/page.js +++ b/exercise/page.js @@ -1,3 +1,8 @@ +$(document).ready(function(){ + + + + function convertFtoC (tempF) { return (tempF - 32) * 5/9; } @@ -5,3 +10,22 @@ function convertFtoC (tempF) { function convertCtoF (tempC) { return tempC * 9/5 + 32; } + + +$("#convert-to-c").click(function(){ + + + var cInput = $('#temp-c').val(); + var converted = convertCtoF(cInput); + $(".placeholder").html(converted.toString()); +}); + + +$("#convert-to-f").click(function(){ + var fInput = $('#temp-f').val(); + var converted = convertFtoC(fInput); + $(".placeholder").html(converted.toString()); +}); + + +}); From e0422bfbf8c4399f955b563ffd4048a2aab59afa Mon Sep 17 00:00:00 2001 From: azitowolf Date: Tue, 5 May 2015 23:06:11 -0400 Subject: [PATCH 2/2] finished fahrenheit converter. hold applause --- exercise/page.js | 40 ++++++++++++++++++++++++++++------------ exercise/styles.css | 1 + 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/exercise/page.js b/exercise/page.js index 30edc76..aee4332 100644 --- a/exercise/page.js +++ b/exercise/page.js @@ -1,8 +1,3 @@ -$(document).ready(function(){ - - - - function convertFtoC (tempF) { return (tempF - 32) * 5/9; } @@ -11,21 +6,42 @@ function convertCtoF (tempC) { return tempC * 9/5 + 32; } +function setBackground(){ + var tempInC = $('input[name="temp-c"]').val(); + if(tempInC < 0){ + $('body').css("background-color", "purple"); + } else if(tempInC < 10){ + $('body').css("background-color", "blue"); + } else if(tempInC < 20){ + $('body').css("background-color", "yellow"); + } else if(tempInC < 30){ + $('body').css("background-color", "orange"); + } else if(tempInC >= 30){ + $('body').css("background-color", "red"); + } +} + +$(document).ready(function(){ $("#convert-to-c").click(function(){ + console.log("firing"); + var fInput = $('input[name="temp-f"]').val(); + var converted = convertFtoC(fInput); + $('input[name="temp-c"]').val(converted); + setBackground(); +}); - var cInput = $('#temp-c').val(); +$("#convert-to-f").click(function(){ + console.log("firing"); + var cInput = $('input[name="temp-c"]').val(); var converted = convertCtoF(cInput); - $(".placeholder").html(converted.toString()); + $('input[name="temp-f"]').val(converted); + setBackground(); }); -$("#convert-to-f").click(function(){ - var fInput = $('#temp-f').val(); - var converted = convertFtoC(fInput); - $(".placeholder").html(converted.toString()); }); -}); + diff --git a/exercise/styles.css b/exercise/styles.css index 500cb3e..6c445c4 100644 --- a/exercise/styles.css +++ b/exercise/styles.css @@ -1,5 +1,6 @@ body { background-color: black; + -webkit-transition: 3s ease-in-out; } #center {