-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
155 lines (128 loc) · 5.09 KB
/
index.js
File metadata and controls
155 lines (128 loc) · 5.09 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const btnProximo = document.getElementById('btn-proximo');
const btnNovoCalculo = document.getElementById('btn-novo-calculo');
const btnAnterior = document.getElementById('back');
const valor = document.getElementById('numero');
const img = document.getElementById('imgTipo');
const legenda = document.getElementById('legenda');
const main = document.getElementById('main');
const telaResultado = document.getElementById('resultado');
const loader = document.getElementById('loader');
let comprimentoTalabarte =0;
let alturaQueda = 0;
let resultado = 0;
const audio = new Audio();
audio.src = "click.mp3";
//card resultado
const divCardPrincipal = document.createElement('div');
divCardPrincipal.className = "principal-card-resultado";
telaResultado.appendChild(divCardPrincipal);
const cardImg = document.createElement('div');
cardImg.className = "cardImg";
const pInformacao = document.createElement('p');
pInformacao.className = "pInformacao";
pInformacao.textContent = "ATENÇÃO!";
const cardPInformacao = document.createElement('div');
cardPInformacao.className ="cardPInformacao";
cardPInformacao.appendChild(pInformacao);
divCardPrincipal.appendChild(cardImg);
telaResultado.appendChild(cardPInformacao);
const cardImagem = document.createElement('img');
cardImagem.src = "img/Menor que 1.png";
cardImagem.className = "cadrImagem";
cardImg.appendChild(cardImagem);
const cardInformacaoAbaixo = document.createElement('div');
cardInformacaoAbaixo.className = "cardInformacaoAbaixo";
cardImg.appendChild(cardInformacaoAbaixo);
const pInformacaoAbaixo = document.createElement('p');
pInformacaoAbaixo.className = "pInformacaoAbaixo";
pInformacaoAbaixo.textContent = "Fator de queda < 1";
cardInformacaoAbaixo.appendChild(pInformacaoAbaixo);
btnAnterior.addEventListener('click', function(){
audio.play();
if(comprimentoTalabarte>0){
valor.value = comprimentoTalabarte;
img.src = "img/talabarte.png";
legenda.textContent = "Informe o comprimento do talabarte";
btnProximo.textContent = "Próxima etapa";
comprimentoTalabarte = 0;
};
});
btnProximo.addEventListener('click', function(){
audio.play();
if(btnProximo.textContent !="Cálcular"){
if(valor.value ==""){
notificar("Informe o comprimento do talabarte!");
}else{
img.src = "img/imagem.png";
legenda.textContent = "Informe a altura da queda";
comprimentoTalabarte = valor.value;
valor.value = "";
btnProximo.textContent = "Cálcular";
};
}else{
if(valor.value ==""){
notificar("Informe a altura da queda!");
}else{
alturaQueda = valor.value;
calculo();
main.style.filter = "blur(35px)" /* Altere o valor para ajustar o nível de desfoque desejado */
main.style.transition = "filter 0.5s" /* Efeito de transição suave */
telaResultado.style.display ="flex";
};
};
});
function notificar(msg){
let divNotifica = document.createElement('div');
divNotifica.className = "divNotificacao";
let pNotificacao = document.createElement('p');
pNotificacao.className = "pNotificacao";
pNotificacao.textContent = msg
divNotifica.appendChild(pNotificacao);
main.appendChild(divNotifica);
setTimeout(function(){
divNotifica.style.display = "none";
}, 3000);
};
btnNovoCalculo.addEventListener('click', function(){
audio.play();
valor.value = "";
img.src = "img/talabarte.png";
legenda.textContent = "Informe o comprimento do talabarte";
btnProximo.textContent = "Próxima etapa";
telaResultado.style.display = "none";
main.style.filter ="none";
comprimentoTalabarte = 0;
alturaQueda = 0;
});
function calculo(){
resultado = alturaQueda/comprimentoTalabarte;
if(resultado < 1){
cardPInformacao.style.display = "none";
cardImagem.src = "img/Menor que 1.png";
pInformacao.textContent = "ATENÇÃO!";
pInformacaoAbaixo.textContent = "Fator de queda < 1";
cardInformacaoAbaixo.style.backgroundColor = "#00821A";
console.log("Resultado: "+ resultado.toFixed(2));
} else if(resultado == 1){
cardPInformacao.style.display = "flex";
cardImagem.src = "img/Maior que 1 e menor 2.png";
cardPInformacao.style.backgroundColor = "rgb(254, 152, 0)";
pInformacaoAbaixo.textContent = "Fator de queda = 1";
cardInformacaoAbaixo.style.backgroundColor = "rgb(254, 152, 0)";
console.log("Resultado: "+ resultado.toFixed(2));
}else if(resultado > 1){
cardPInformacao.style.display = "flex";
cardImagem.src = "img/maior ou igual 2.png";
cardPInformacao.style.backgroundColor = "#FF0E17";
cardInformacaoAbaixo.style.backgroundColor = "#FF0E17";
pInformacao.textContent = "CUIDADO!!";
pInformacaoAbaixo.textContent = "Fator de queda = 2";
console.log("Resultado: "+ resultado.toFixed(2));
};
};
window.onload= function(){
setTimeout(function(){
loader.style.display = "none";
main.style.display = "flex";
}, 1500)
};