forked from VictorHSMoura/Prova-jQuery-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject.script.js
More file actions
37 lines (31 loc) · 1.06 KB
/
project.script.js
File metadata and controls
37 lines (31 loc) · 1.06 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
var totas_as_divisoes = ["all", "nike", "puma", "adidas", "asics"];
var todos_os_botoes = ["botao_all", "botao_nike", "botao_puma", "botao_adidas", "botao_asics"];
var divisao_atual = undefined;
function hide(element_id){
document.getElementById(element_id).style.display = 'none';
}
function flex(element_id){
document.getElementById(element_id).style.display = 'flex';
}
function updateButtonSelected(element_id){
if(element_id === divisao_atual){
document.getElementById('botao_' + element_id).style.borderBottom = '2px solid black'
}else{
document.getElementById('botao_' + element_id).style.borderBottom = 'none'
}
}
function atualizaBotoes(){
totas_as_divisoes.forEach(updateButtonSelected)
}
function mudarDivisaoDaPagina(element_id){
if(element_id === 'all'){
divisao_atual = element_id;
totas_as_divisoes.forEach(flex);
}
else{
divisao_atual = element_id
totas_as_divisoes.forEach(hide);
document.getElementById(element_id).style.display = 'flex';
}
atualizaBotoes()
}