-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlampada.html
45 lines (41 loc) · 1.48 KB
/
lampada.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/lampada.css">
</head>
<body>
<div onfocus="piscarsair()" onmouseout="piscarsair()" onmouseenter="piscar()" onclick="piscar()" class="lampada"></div>
<h1>Movimente o mause varias vezes para gerar energia!</h1>
<script>
let lamp = document.querySelector('.lampada');
let estado = ['img/ligada.png', 'img/desligada.png', 'img/destruida.png']
let cor = document.querySelector('body')
let cont = 0
let status = true
function piscar() {
if(status == true) {
lamp.style = 'background-image: url(' + estado[0] + ')'
cont++
console.log(cont)
cor.style = 'background: rgb(0, '+cont+', 0)'
}
}
function piscarsair() {
if(status == true) {
lamp.style = 'background-image: url(' + estado[1] + ')'
cont++
console.log(cont)
}
}
function quebrar() {
lamp.style = 'background-image: url(' + estado[2] + ')'
status = false
alert("MUITAAA ENERGIA GERADA! RECARREGUE A PAGINA")
}
</script>
</body>
</html>