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
58 changes: 58 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./main.css">
<title>Thermometer Application</title>
</head>
<body>
<div id="convertorContainer">

<div id="topRow">
<h1>Temperature Scale Convertor</h1>
</div>

<div id="valueScale">
<label for="scaleType" id="scaleText">Scale</label>
<label for="tempValueBox" id="tempValueText">Value</label>
</div>

<div id="midRow">
<select name="scaleType" id="scaleType">
<option value="fahrenheit">Fahrenheit</option>
<option value="celsius">Celsius</option>
<option value="kelvin">Kelvin</option>
<option value="rankine">Rankine</option>
</select>
<input type="text" id="tempValueBox" name="tempValue">
<button type="button" id="calcButton">Calculate</button>
</div>

<div id="bottomRow">
<span id="fahrenheitTitle">Fahrenheit</span>
<span id="celsiusTitle">Celsius</span>
<span id="kelvinTitle">Kelvin</span>
<span id="rankineTitle">Rankine</span>
</div>

<div id="bottomRowOutput">
<div id="fahrenheitVal" class="outputValueBox">
<span>0 F</span>
</div>
<div id="celsiusVal" class="outputValueBox">
<span>0 C</span>
</div>
<div id="kelvinVal" class="outputValueBox">
<span>0 K</span>
</div>
<div id="rankineVal" class="outputValueBox">
<span>0 R</span>
</div>
</div>

</div>

<script src="./script.js"></script>
</body>
</html>
85 changes: 85 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

#convertorContainer {
width: 720px;
height: 420px;
border: 2px solid black;
margin: auto;
text-align: center;
}

#topRow {
font-size: 25px;
margin-left: auto;
margin-bottom: 60px;
}

#midRow {
display: flex;
justify-content: space-around;
align-items: baseline;
margin-bottom: 90px;
font-size: 20px;
padding-top: 5px;
}

#valueScale {
font-size: 22px;
margin-bottom: 3px;
text-align: left;
}

#scaleText {
margin-left: 80px;
}

#tempValueText {
margin-left: 200px;
}

#tempValueBox {
width: 160px;
height: 35px;
border: 2px solid black;
text-align: center;
font-size: 20px;
}

#calcButton {
width: 160px;
height: 40px;
background-color: #dde8faff;
border: 2px solid #728ebbff;
font-size: 20px;
}

#bottomRow {
display: flex;
justify-content: space-around;
font-size: 20px;
font-weight: 600;
}

#bottomRowOutput {
display: flex;
justify-content: space-around;
font-size: 20px;
margin-left: 20px;
margin-top: 20px;
}

#scaleType {
width: 160px;
height: 40px;
border: 2px solid black;
font-size: 20px;
}

#celsiusVal {
margin-left: 20px;
}

.outputValueBox {
width: 100px;
height: 35px;
text-align: center;
}
125 changes: 125 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

let celsiusTextVal = document.querySelector('#celsiusVal')
let fahrenheitTextVal = document.querySelector('#fahrenheitVal')
let kelvinTextVal = document.querySelector('#kelvinVal')
let rankineTextVal = document.querySelector('#rankineVal')
let scaleType = document.querySelector('#scaleType')

document.querySelector('#calcButton').addEventListener('click', totalConverts)

//Fahrenheit Function Conversions
function fahrenheitToCelsius () {
let fahrenheitInput = document.querySelector('#tempValueBox').value
let product = (parseInt(fahrenheitInput) - 32) * 5/9;
celsiusTextVal.innerHTML = product.toFixed(2) + ' C'
}
function fahrenheitValue () {
fahrenheitVal.innerHTML = document.querySelector('#tempValueBox').value + ' F'
}
function fahrenheitToKelvin () {
let fahrenheitInput = document.querySelector('#tempValueBox').value
let product = (parseInt(fahrenheitInput) - 32) * 5/9 + 273.15;
kelvinTextVal.innerHTML = product.toFixed(2) + ' K'
}
function fahrenheitToRankine () {
let fahrenheitInput = document.querySelector('#tempValueBox').value
let product = parseInt(fahrenheitInput) + 459.67;
rankineTextVal.innerHTML = product.toFixed(2) + ' R'
}
// End Fahrenheit Function Conversions

// Celsius Function Conversions
function celsiusValue () {
celsiusTextVal.innerHTML = document.querySelector('#tempValueBox').value + ' C'
}
function celsiusToFahrenheit () {
let celsiusInput = document.querySelector('#tempValueBox').value
let product = (parseInt(celsiusInput) * 9/5) + 32
fahrenheitTextVal.innerHTML = product.toFixed(2) + ' F'
}
function celsiusToKelvin () {
let celsiusInput = document.querySelector('#tempValueBox').value
let product = parseInt(celsiusInput) + 273.15
kelvinTextVal.innerHTML = product.toFixed(2) + ' K'
}
function celsiusToRankine () {
let celsiusInput = document.querySelector('#tempValueBox').value
let product = parseInt(celsiusInput) * 9/5 + 491.67
rankineTextVal.innerHTML = product.toFixed(2) + ' R'
}
// End Celsius Function Conversions

// Kelvin Function Conversions
function kelvinValue () {
kelvinTextVal.innerHTML = document.querySelector('#tempValueBox').value + ' K'
}

function kelvinToFahrenheit () {
let kelvinInput = document.querySelector('#tempValueBox').value
let product = (parseInt(kelvinInput) - 273.15) * 9/5 + 32
fahrenheitTextVal.innerHTML = product.toFixed(2) + ' F'
}

function kelvinToCelsius () {
let kelvinInput = document.querySelector('#tempValueBox').value
let product = parseInt(kelvinInput) - 273.15
celsiusTextVal.innerHTML = product.toFixed(2) + ' C'
}

function kelvinToRankine () {
let kelvinInput = document.querySelector('#tempValueBox').value
let product = parseInt(kelvinInput) * 1.8
rankineTextVal.innerHTML = product.toFixed(2) + ' R'
}
//End Kelvin Conversions

//Rankine Function Conversions
function rankineValue () {
rankineTextVal.innerHTML = document.querySelector('#tempValueBox').value + ' R'
}

function rankineToFahrenheit () {
let rankineInput = document.querySelector('#tempValueBox').value
let product = parseInt(rankineInput) - 459.67
fahrenheitTextVal.innerHTML = product.toFixed(2) + ' F'
}

function rankineToCelsius () {
let rankineInput = document.querySelector('#tempValueBox').value
let product = (parseInt(rankineInput) - 491.67) * 5/9
celsiusTextVal.innerHTML = product.toFixed(2) + ' C'
}

function rankineToKelvin () {
let rankineInput = document.querySelector('#tempValueBox').value
let product = parseInt(rankineInput) * 5/9
kelvinTextVal.innerHTML = product.toFixed(2) + ' K'
}
//End Rankine Conversions

function totalConverts () {
if (scaleType.value === 'fahrenheit') {
fahrenheitToCelsius()
fahrenheitValue()
fahrenheitToKelvin()
fahrenheitToRankine()
} else if (scaleType.value === 'celsius') {
celsiusValue()
celsiusToFahrenheit()
celsiusToKelvin()
celsiusToRankine()
} else if (scaleType.value === 'kelvin') {
kelvinValue()
kelvinToFahrenheit()
kelvinToCelsius()
kelvinToRankine()
} else if (scaleType.value === 'rankine') {
rankineValue()
rankineToFahrenheit()
rankineToCelsius()
rankineToKelvin()
}
}