Skip to content

Commit a0bf81b

Browse files
committed
initial working done
1 parent d002a33 commit a0bf81b

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

Temperature Convertor/README.md

Whitespace-only changes.

Temperature Convertor/index.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>Hello Bulma!</title>
7+
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
8+
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
9+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
10+
<link rel="stylesheet" href="./style.css"
11+
</head>
12+
<body>
13+
<section class="section">
14+
<nav class="navbar">
15+
<div class="navbar-brand">
16+
<a href="#">Temperature Convertor</a>
17+
</div>
18+
</nav>
19+
<div class="container">
20+
<div id='input-container'>
21+
<input type="number" class="input is-medium input-childs" id='input' name='input' placeholder="Enter Temperature">
22+
<select name='from' class="input is-medium input-childs" id='from' form="conversion">
23+
<option value="celsius">Celsius</option>
24+
<option value="fahrenheit">Fahrenheit</option>
25+
<option value="kelvin">Kelvin</option>
26+
</select>
27+
<button class="button is-medium input-childs" disabled>
28+
<ion-icon name="play-forward-outline"></ion-icon>
29+
</button>
30+
<select name='to' class="input is-medium input-childs" id='to' form="conversion">
31+
<option value=""></option>
32+
<option value="fahrenheit">Fahrenheit</option>
33+
<option value="kelvin">Kelvin</option>
34+
<option value="celsius">Celsius</option>
35+
</select>
36+
</div>
37+
<div id='converted-value'>
38+
39+
</div>
40+
</div>
41+
</section>
42+
<script src="./script.js"></script>
43+
</body>
44+
</html>

Temperature Convertor/script.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
let done = document.getElementById('converted-value')
2+
3+
to.onchange = () => {
4+
done.innerHTML = ""
5+
let from = document.getElementById('from')
6+
let to = document.getElementById('to')
7+
8+
let fromValue = from.value
9+
let toValue = to.value
10+
11+
if(fromValue === toValue) {
12+
done.innerHTML = "Units should be different"
13+
}
14+
15+
if(fromValue === 'celsius' && toValue === 'kelvin') {
16+
celsiusToKelvin(fromValue, toValue)
17+
}
18+
19+
if(fromValue === 'celsius' && toValue === 'fahrenheit') {
20+
celsiusToFahrenheit(fromValue, toValue)
21+
}
22+
23+
if(fromValue === 'fahrenheit' && toValue === 'kelvin') {
24+
fahrenheitToKelvin(fromValue, toValue)
25+
}
26+
27+
if(fromValue === 'fahrenheit' && toValue === 'celsius') {
28+
fahrenheitToCelsius(fromValue, toValue)
29+
}
30+
31+
if(fromValue === 'kelvin' && toValue === 'fahrenheit') {
32+
KelvinToFahrenheit(fromValue, toValue)
33+
}
34+
35+
if(fromValue === 'kelvin' && toValue === 'celsius') {
36+
KelvinToCelsius(fromValue, toValue)
37+
}
38+
}
39+
40+
const celsiusToKelvin = (fromValue, toValue) => {
41+
alert(`${fromValue}, ${toValue}`)
42+
}
43+
44+
const celsiusToFahrenheit = (fromValue, toValue) => {
45+
alert(`${fromValue}, ${toValue}`)
46+
}
47+
48+
const fahrenheitToKelvin = (fromValue, toValue) => {
49+
alert(`${fromValue}, ${toValue}`)
50+
}
51+
52+
const fahrenheitToCelsius = (fromValue, toValue) => {
53+
alert(`${fromValue}, ${toValue}`)
54+
}
55+
56+
const KelvinToFahrenheit = (fromValue, toValue) => {
57+
alert(`${fromValue}, ${toValue}`)
58+
}
59+
60+
const KelvinToCelsius = (fromValue, toValue) => {
61+
alert(`${fromValue}, ${toValue}`)
62+
}

Temperature Convertor/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#input-container {
2+
display: flex;
3+
}
4+
5+
.input-childs {
6+
margin: 10px;
7+
}

0 commit comments

Comments
 (0)