-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
67 lines (52 loc) · 2.08 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
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
var cumprimento = window.document.querySelector('h1#cumprimento');
var nome = window.document.querySelector('input#nome');
var conhecendo = window.document.querySelector('div#conhecendo');
var relogio = window.document.querySelector('div#relogio')
nome.addEventListener('keypress', checkEnter);
var data = new Date()
var hora = data.getHours()
var minutos = data.getMinutes()
var segundos = data.getSeconds()
function checkEnter(event) {
if (event.key === 'Enter') {
cumprimentar();
}
}
function cumprimentar() {
if (hora >= 0 && hora < 12) {
var horario = 'bom dia';
document.body.style.background = 'linear-gradient(180deg, rgba(255,242,168,1) 0%, rgba(63,251,240,1) 100%)';
} else if (hora >= 12 && hora < 18) {
var horario = 'boa tarde';
document.body.style.background = 'linear-gradient(180deg, rgba(148,187,233,1) 0%, rgba(238,174,202,1) 100%)';
} else {
var horario = 'boa noite';
document.body.style.background = 'linear-gradient(180deg, rgba(10,0,34,1) 0%, rgba(9,9,121,1) 30%, rgba(0,160,255,1) 100%)';
cumprimento.style.color = 'white'
conhecendo.style.color = 'white'
}
conhecendo.classList.add('fade-out');
cumprimento.innerHTML = `${horario}, ${nome.value} :)`;
cumprimento.classList.add('fade-in');
// Remove the fade-in and fade-out classes after their animation is completed
setTimeout(function() {
cumprimento.classList.remove('fade-in');
}, 1000); // Set the time to match the animation duration (1s)
relogio.style.display = 'block'
setInterval(function() {
data = new Date();
hora = data.getHours();
minutos = data.getMinutes();
segundos = data.getSeconds();
if (hora < 10) {
hora = `0${hora}`
}
if (minutos < 10) {
minutos = `0${minutos}`
}
if (segundos < 10) {
segundos = `0${segundos}`
}
relogio.innerHTML = `${hora} : ${minutos} : ${segundos}`;
}, 1000);
}