-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
97 lines (82 loc) · 2.86 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
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
const Base64 = {
decode: s => Uint8Array.from(atob(s), c => c.charCodeAt(0)),
encode: b => btoa(String.fromCharCode(...new Uint8Array(b)))
};
async function loadWorks() {
let resp = await fetch('https://api.github.com/repos/vstruk01/uPortfolio/contents/data/works.json', {
method: 'GET'
})
// let resp = await fetch('http://127.0.0.1:5500/data/works.json', {
// method: 'GET'
// })
if (resp.ok) {
let works = await resp.json();
return JSON.parse(String.fromCharCode.apply(null, Base64.decode(works.content)));
// return works;
} else {
console.log('error load works');
return []
}
}
async function loadAbout() {
let resp = await fetch('https://api.github.com/repos/vstruk01/uPortfolio/contents/data/about-lists.json', {
method: 'GET'
})
// let resp = await fetch('http://127.0.0.1:5500/data/about-lists.json', {
// method: 'GET'
// })
if (resp.ok) {
let about = await resp.json();
return JSON.parse(String.fromCharCode.apply(null, Base64.decode(about.content)));
// return about;
} else {
console.log('error load works');
return []
}
}
async function renderWorks() {
let work_html = document.getElementById('work');
let works = await loadWorks();
for (let work of works) {
let obj = `<div class="cardProject">
<span class="TitleCard">
${work.name}
</span>
<p>`;
for (const team of work.team) {
obj += `<a href="${team.github}" target="_blank">
<img src="${team.image}" alt="${team.name}">
</a>`;
}
obj += `</p>
<p><strong>Description</strong>: ${work.description}</p>
<p><strong>Time</strong>: ${work.time}</p>
<p><strong>Technology</strong>:`;
for (const teg of work.technology) {
obj += `<span class="teg">${teg}</span>`
}
obj += `</p>
<p><strong>Skills</strong>: ${work.skills}</p>
<a class="linkCard" href="${work.github}" target="_blank">github</a>
</div>`;
work_html.innerHTML += obj;
}
}
async function renderAbout() {
let about_h = document.getElementById('about');
let abouts_list = await loadAbout();
for (let list of abouts_list) {
let obj = `<div class="about-list">
<p class="about-title">
${list.nameColumn}
</p>
<div>`
for (let item of list.items) {
obj += `<div class="about-item">${item}</div>`
}
obj += `</div></div>`
about_h.innerHTML += obj
}
}
renderAbout();
renderWorks();