Skip to content
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
26 changes: 26 additions & 0 deletions root/Psuedo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Html Structure

-Set Temperature Scale as a header <h1>
-Add strong tags to header

-Set Fahrenheit as a paragraph element <p>
-Set value as an input element / input type numbers
-Set calculate as a button / input type submit ~ may need to change later

-Set Celsius as a paragraph element <p> with strong tags and a class

# CSS

-Add a solid border around all elements
- Center Header
- Align fahrenheit, value input and calculate button in a row. Center
- Set Button to blue
- Center Celsius

# Javascript

- Read the value inside of input box
- Grab the value inside of input
- Add value to the formula for celsius
- Output the value next to celsius element
-
59 changes: 59 additions & 0 deletions root/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function tempConvert() {
let scaleCalc = document.querySelector("#selectScale").value; //Takes the value of scale selector
let inputNum = parseFloat(document.querySelector("#inputValue").value); //Takes the value of user input

switch (scaleCalc) {
case "Fahrenheit": //Takes the value of fahrenheit and converts to other scales
document.querySelector("#getFahrenheit").innerHTML = inputNum + " F";

document.querySelector("#getCelsius").innerHTML =
(inputNum - 32) * (5 / 9) + " C";

document.querySelector("#getKelvin").innerHTML =
(inputNum - 32) * (5 / 9) + 273.15 + " K";

document.querySelector("#getRankine").innerHTML =
inputNum + 459.67 + " R";
break;

case "Celsius":
document.querySelector("#getCelsius").innerHTML = inputNum + " C";

document.querySelector("#getFahrenheit").innerHTML =
inputNum * (9 / 5) + 32 + " F";

document.querySelector("#getKelvin").innerHTML = inputNum + 273.15 + " K";

document.querySelector("#getRankine").innerHTML =
inputNum + 9 / 5 + 491.67 + " R";
break;

case "Kelvin":
document.querySelector("#getCelsius").innerHTML =
inputNum - 273.15 + " C";

document.querySelector("#getFahrenheit").innerHTML =
(inputNum - 273.15) * (9 / 5) + 32 + " F";

document.querySelector("#getKelvin").innerHTML = inputNum + " K";

document.querySelector("#getRankine").innerHTML = inputNum * 1.8 + " R";
break;

case "Rankine":
document.querySelector("#getCelsius").innerHTML =
((inputNum - 491.67) * 5) / 9 + " C";

document.querySelector("#getFahrenheit").innerHTML =
inputNum - 459.67 + " F";

document.querySelector("#getKelvin").innerHTML =
inputNum * (5 / 9) + " K";

document.querySelector("#getRankine").innerHTML = inputNum + " R";
break;

default:
console.log("Select a scale and enter a value");
}
}
46 changes: 46 additions & 0 deletions root/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temp Converter</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
<h1><strong>Temperature Scale Convertor</strong></h1>
<br>
<section class="container">
<!--Created Different Scale Options -->
<select id="selectScale">
<option value="Fahrenheit">Fahrenheit</option>
<option value="Celsius">Celsius</option>
<option value="Kelvin">Kelvin</option>
<option value="Rankine">Rankine</option>
</select>

<label for="inputValue">Value</label>
<!-- Able to use onchange -->
<input id="inputValue" type="number" name="value">
<!--onclick Event applied to button-->
<button class="btn btn-rounded btn-primary" onclick="tempConvert()">Calculate</button>

</section>
<br>
<!-- Created Class to adjust styling & added empty span for Conversion placement -->
<div class="conversions">
<label> Fahrenheit <span id="getFahrenheit"> </label>
<label> Celsius <span id="getCelsius"> </label>
<label> Kelvin <span id="getKelvin"> </label>
<label> Rankine <span id="getRankine"> </label>
</div>


<script src="app.js"> </script>

</body>

</html>
41 changes: 41 additions & 0 deletions root/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
* {
/* Set All Non Selectors To 0 Padding & Margin */
padding: 0;
margin: 0;
}

h1 {
text-align: center;
}

body {
border-style: solid;
}

.container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
justify-content: space-evenly;
}

.conversions {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
justify-content: space-evenly;
}

/* Chrome, Safari, Edge, Opera Remove Arrows and Spinners */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

/* Firefox Remove Arrows and Spinners*/
#inputValue {
-moz-appearance: textfield;
}