-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (28 loc) · 1.42 KB
/
script.js
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
var hamburguer = document.querySelector(".hamburguer");
hamburguer.addEventListener("click", function () {
document.querySelector(".sidebar").classList.toggle("show-menu");
document.querySelector(".hamburguer").classList.toggle("show-menu");
});
document.querySelector("#quantidade").addEventListener("change", atualizarPreco);
document.querySelector("#js").addEventListener("change", atualizarPreco);
document.querySelector("#layout-sim").addEventListener("change", atualizarPreco);
document.querySelector("#layout-nao").addEventListener("change", atualizarPreco);
document.querySelector("#prazo").addEventListener("change", function(){
const prazo = document.querySelector("#prazo").value;
document.querySelector("label[for=prazo]").innerHTML = `Prazo: ${prazo} semanas`
atualizarPreco()
});
function atualizarPreco(){
const quantidade = document.querySelector("#quantidade").value;
const temJS = document.querySelector("#js").checked;
const incluiLayout = document.querySelector("#layout-sim").checked;
const incluiLayoutNao = document.querySelector("#layout-nao").checked;
const prazo = document.querySelector("#prazo").value;
let preco = quantidade * 100;
if(temJS) preco *= 1.1
if(incluiLayout) preco += 500
if(incluiLayoutNao) preco = preco
let taxaUrgencia = 1 - prazo * 0.1
preco *= 1 + taxaUrgencia
document.querySelector("#preco").innerHTML = `R$ ${preco.toFixed(2)}`;
}