-
Notifications
You must be signed in to change notification settings - Fork 17
/
logica.js
64 lines (61 loc) · 1.82 KB
/
logica.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
/**
* JS - Operadores Lógicos
* @author Professor José de Assis
* https://joseassis.com.br
*/
let sw1 = false
let sw2 = false
let broken = false
let receive
let identify = window.location.pathname
function sw(receive) {
if (receive === 1 && sw1 === false) {
document.getElementById("sw1").src = "img/swon.png";
sw1 = true
} else if (receive === 1 && sw1 === true) {
document.getElementById("sw1").src = "img/swoff.png";
sw1 = false
} else if (receive === 2 && sw2 === false) {
document.getElementById("sw2").src = "img/swon.png";
sw2 = true
} else if (receive === 2 && sw2 === true) {
document.getElementById("sw2").src = "img/swoff.png";
sw2 = false
}
//lamp
if (receive === 3) {
let beep = new Audio();
beep.src = "glassbreaking.wav";
beep.play()
document.getElementById("lamp").src = "img/broken.jpg";
broken = true
}
//and
if (identify === "/simulador/and.html" && broken !== true) {
if (sw1 === true && sw2 === true) {
document.getElementById("lamp").src = "img/on.jpg"
} else {
document.getElementById("lamp").src = "img/off.jpg"
}
}
//or
if (identify === "/simulador/or.html" && broken !== true) {
if (sw1 === true || sw2 === true) {
document.getElementById("lamp").src = "img/on.jpg"
} else {
document.getElementById("lamp").src = "img/off.jpg"
}
}
//not
if (identify === "/simulador/not.html" && broken !== true) {
if (!sw1) {
document.getElementById("lamp").src = "img/on.jpg"
} else {
document.getElementById("lamp").src = "img/off.jpg"
}
}
}
// Atualizar automaticamente o ano (footer - copyright)
let ano = document.getElementById("copyrightYear")
let anoAtual = new Date().getFullYear()
ano.textContent = anoAtual