-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (38 loc) · 1.47 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
document.addEventListener('DOMContentLoaded', function() {
var filterBtns = document.getElementsByClassName('filter-btn');
for (var btn of filterBtns) {
btn.addEventListener('click', function() {
var current = document.getElementsByClassName('active');
if (current.length > 0) {
current[0].className = current[0].className.replace(" active", "");
}
this.className += " active";
var category = this.getAttribute('data-category');
filterSelection(category);
});
}
// Function to filter projects
function filterSelection(category) {
var projects = document.getElementsByClassName('project');
for (var i = 0; i < projects.length; i++) {
var project = projects[i];
if (category === 'all') {
project.style.display = "block";
} else if (category === 'other') {
if (!project.classList.contains('deep_learning') && !project.classList.contains('embedded_desktop_dev') && !project.classList.contains('openCV_robotics') &&!project.classList.contains('udemy')) {
project.style.display = "block";
} else {
project.style.display = "none";
}
} else {
if (project.classList.contains(category)) {
project.style.display = "block";
} else {
project.style.display = "none";
}
}
}
}
// Initialize to show all projects
filterSelection('all');
});