-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (29 loc) · 1001 Bytes
/
app.js
File metadata and controls
34 lines (29 loc) · 1001 Bytes
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
/**
* APP PWA - Etanol x Gasolina
* @author Luiz Fernando
* @version 2.0
*/
//================================================
//Registro do service worker
// se o navegador de internet suportar este recurso
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js')
.then(() => {
console.log("service worker registrado!")
})
}
//=================================================
function calcular() {
//capturar os valores das caixas de input
let gasolina = document.getElementById('gasolina').value
let etanol = document.getElementById('etanol').value
let kmlGasolina = document.getElementById('kmGasolina').value
let kmlEtanol = document.getElementById('kmEtanol').value
//cálculo da vantagem
if (etanol < (kmlEtanol / kmlGasolina) * gasolina) {
document.getElementById('status').src = "img/etanol.png"
} else {
document.getElementById('status').src = "img/gasolina.png"
}
}