-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.js
More file actions
32 lines (24 loc) · 1.03 KB
/
main.js
File metadata and controls
32 lines (24 loc) · 1.03 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
const display = document.querySelector('.display');
const cardTemplate = document.getElementById('card-template');
const Hover = document.querySelectorAll('.card');
// projection section display skeliton card
for (let i = 1; i <= 10; i++) {
const temp = cardTemplate.content.cloneNode(true);
temp.querySelector('.index').textContent = i;
display.append(temp);
}
fetch("project.json")
.then(res => res.json())
.then(posts => {
display.innerHTML = '';
posts.forEach(post => {
const card = cardTemplate.content.cloneNode(true);
card.querySelector('[data-title]').textContent = post.title;
card.querySelector('[data-body]').textContent = post.subtitle;
card.querySelector('.btn1').setAttribute("href", `${post.prjlink}`);
card.querySelector('.btn2').setAttribute("href", `${post.sourcecode}`);
card.querySelector('.index').textContent = post.id;
card.querySelector('.header-img').setAttribute("src", `${post.imglink}`);
display.append(card);
})
});