- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
112 lines (96 loc) · 4.05 KB
/
Copy pathscript.js
File metadata and controls
112 lines (96 loc) · 4.05 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
document.addEventListener('DOMContentLoaded',function(){
// Elementos
constsearchInput=document.getElementById('searchInput');
constsearchBtn=document.getElementById('searchBtn');
constfilterBtns=document.querySelectorAll('.filter-btn');
constresourceCards=document.querySelectorAll('.resource-card');
constgradeSections=document.querySelectorAll('.grade-section');
// Função de pesquisa
functionsearchResources(){
constsearchTerm=searchInput.value.toLowerCase().trim();
if(searchTerm===''){
// Mostrar todos os recursos se a pesquisa estiver vazia
resourceCards.forEach(card=>{
card.style.display='flex';
});
// Mostrar todas as seções
gradeSections.forEach(section=>{
section.style.display='block';
});
return;
}
// Ocultar todas as seções inicialmente
gradeSections.forEach(section=>{
section.style.display='none';
});
// Filtrar recursos com base no termo de pesquisa
lethasResults=false;
resourceCards.forEach(card=>{
constcardText=card.textContent.toLowerCase();
constcardTags=card.getAttribute('data-tags').toLowerCase();
if(cardText.includes(searchTerm)||cardTags.includes(searchTerm)){
card.style.display='flex';
// Mostrar a seção pai
constparentSection=card.closest('.grade-section');
if(parentSection){
parentSection.style.display='block';
}
hasResults=true;
}else{
card.style.display='none';
}
});
// Exibir mensagem se não houver resultados
if(!hasResults){
alert('Nenhum recurso encontrado para: '+searchTerm);
// Mostrar todos os recursos novamente
resourceCards.forEach(card=>{
card.style.display='flex';
});
// Mostrar todas as seções
gradeSections.forEach(section=>{
section.style.display='block';
});
}
}
// Evento de pesquisa
searchBtn.addEventListener('click',searchResources);
searchInput.addEventListener('keypress',function(e){
if(e.key==='Enter'){
searchResources();
}
});
// Filtrar por série
filterBtns.forEach(btn=>{
btn.addEventListener('click',function(){
// Remover classe ativa de todos os botões
filterBtns.forEach(b=>b.classList.remove('active'));
// Adicionar classe ativa ao botão clicado
this.classList.add('active');
constfilter=this.getAttribute('data-filter');
// Mostrar/ocultar seções com base no filtro
gradeSections.forEach(section=>{
if(filter==='all'){
section.style.display='block';
}else{
if(section.id==='grade-'+filter){
section.style.display='block';
}else{
section.style.display='none';
}
}
});
});
});
// Adicionar efeito de hover aos cards
resourceCards.forEach(card=>{
card.addEventListener('mouseenter',function(){
this.style.transform='translateY(-5px)';
this.style.boxShadow='0 10px 20px rgba(0, 0, 0, 0.1)';
});
card.addEventListener('mouseleave',function(){
this.style.transform='translateY(0)';
this.style.boxShadow='0 4px 6px rgba(0, 0, 0, 0.1)';
});
});
});