-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (63 loc) · 2.28 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<title>Conversor de Temperatura</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<header id="cabecalho">
<h1>Conversão de Temperaturas</h1>
</header>
<!-- Conteúdo do site -->
<section id="conteudo">
<p><b> Bem vindo ao conversor de temperatura. Digite uma temperatura e descubra qual será nas outras medidas. </p>
<table>
<tr>
<td>Celsius</td>
<td><input type="number" id="celsius"></td>
</tr>
<tr>
<td>Fahrenheit</td>
<td><input type="number" id="fahrenheit"></td>
</tr>
<tr>
<td>Kelvin</td>
<td><input type="number" id="kelvin"></td>
</tr>
</table>
<button id="converter">Converter</button>
<button id="limpar">Limpar</button>
<script type="text/javascript">
var botao = document.getElementById('converter');
botao.onclick = function(){
var celsius = document.getElementById('celsius').value;
var fahrenheit = document.getElementById('fahrenheit').value;
var kelvin = document.getElementById('kelvin').value;
if(celsius!=="" ){
document.getElementById('fahrenheit').value = (9*parseFloat(celsius/5)+32);
document.getElementById('kelvin').value = (parseFloat(celsius)+273.15);
}else if (fahrenheit!==""){
document.getElementById('celsius').value = (5*parseFloat(fahrenheit-32)/9);
document.getElementById('kelvin').value = ((parseFloat(fahrenheit)-32)*(5/9)+273.15);
}else if(kelvin!==""){
document.getElementById('celsius').value = (parseFloat(kelvin) - 273.15);
document.getElementById('fahrenheit').value = ((parseFloat(kelvin)-273.15)*(9/5)+32);
}
}
var limpar = document.getElementById('limpar');
limpar.onclick = function(){
document.getElementById('celsius').value = "";
document.getElementById('fahrenheit').value = "";
document.getElementById('kelvin').value = "";
}
</script>
<!-- Rodapé do site -->
<footer id="rodape">
<h3>Contato</h3>
<address>E-mail: <a href="mailto:[email protected]">Fábio dos Santos de Sousa</a></address>
<address>Fone: <a href="tel:+63 99223-5803">(63) 9 9223-5803</a></address>
<address>Social: <a href="http://instagram.com/fabiodosantosdesousa">@fabiodosantosdesousaa</a></address>
</footer>
</body>
</html>