Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished quiz #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions exercise/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
<body>

<div id="center">
<p>Temperature in Fahrenheit: <input type="text" name="temp-f"></p>
<p>Temperature in Celsius: <input type="text"name="temp-c"></p>
<p>Temperature in Fahrenheit: <input id="temp-f" type="text" name="temp-f"></p>
<p>Temperature in Celsius: <input id="temp-c" type="text"name="temp-c"></p>
<p>
<button id="convert-to-c">Convert Fahrenheit to Celsius</button>
<br/>
<button id="convert-to-f">Convert Celsius to Fahrenheit</button>
</p>
</div>
<div class="placeholder">

</div>
</body>
</html>
40 changes: 40 additions & 0 deletions exercise/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,43 @@ function convertFtoC (tempF) {
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();
});


$("#convert-to-f").click(function(){
console.log("firing");
var cInput = $('input[name="temp-c"]').val();
var converted = convertCtoF(cInput);
$('input[name="temp-f"]').val(converted);
setBackground();
});


});



1 change: 1 addition & 0 deletions exercise/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
body {
background-color: black;
-webkit-transition: 3s ease-in-out;
}

#center {
Expand Down