-
-
Notifications
You must be signed in to change notification settings - Fork 455
/
script.js
54 lines (41 loc) · 1.4 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
jQuery(document).ready(function() {
jQuery('.toggle').click(function() {
jQuery('body').toggleClass("day");
jQuery('body').toggleClass("night");
});
});
const nav = document.querySelector(".nav");
let projects = [];
const experi = document.getElementById('cardd');
const searchBar = document.getElementById("searchbar");
searchBar.addEventListener('keyup', (e) => {
const searchString = e.target.value;
const filteredProjects = projects.filter( projects => {
return projects.name.toLowerCase().includes(searchString.toLowerCase());
});
console.log(filteredProjects)
displayProjects(filteredProjects);
});
const getProject = fetch('cards.json')
.then(response => response.json())
.then(data => {
projects = data;
displayProjects(projects)
console.log(projects)
});
const displayProjects = (projects) => {
const htmlString = projects
.map((project) => {
return`<div class="stylebox">
<p class="card-heading">${project.name}</p>
<div class="image" >
<img src="${project.image}" alt="">
</div>
<div class="card-data">
<a href=${project.link} target="_blank"><button class="btnn">View</button></a>
</div>
</div>`;
})
experi.innerHTML = htmlString;
}
getProject();