-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
103 lines (85 loc) · 2.98 KB
/
script.js
File metadata and controls
103 lines (85 loc) · 2.98 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
const d = window.RESUME_DATA;
function setText(id, text) {
const el = document.getElementById(id);
if (el) el.textContent = text ?? "";
}
function setLink(id, href) {
const el = document.getElementById(id);
if (!el) return;
el.href = href;
el.style.display = href ? "inline-flex" : "none";
}
function renderPills(id, items) {
const el = document.getElementById(id);
if (!el) return;
el.innerHTML = "";
(items || []).forEach((s) => {
const pill = document.createElement("span");
pill.className = "pill";
pill.textContent = s;
el.appendChild(pill);
});
}
function renderListSection(containerId, items, type) {
const el = document.getElementById(containerId);
if (!el) return;
el.innerHTML = "";
(items || []).forEach((item) => {
const wrap = document.createElement("div");
const head = document.createElement("div");
head.className = "item-head";
const left = document.createElement("div");
const title = document.createElement("div");
title.className = "item-title";
const sub = document.createElement("div");
sub.className = "item-sub";
if (type === "experience") {
title.textContent = `${item.title} — ${item.company}`;
sub.textContent = item.location || "";
} else if (type === "projects") {
title.textContent = item.name;
if (item.link) {
const a = document.createElement("a");
a.className = "inline";
a.href = item.link;
a.target = "_blank";
a.rel = "noreferrer";
a.textContent = "Link";
sub.appendChild(a);
}
} else if (type === "education") {
title.textContent = item.school;
sub.textContent = item.degree || "";
}
left.appendChild(title);
left.appendChild(sub);
const date = document.createElement("div");
date.className = "item-date";
date.textContent = item.dates || "";
head.appendChild(left);
head.appendChild(date);
wrap.appendChild(head);
if (item.bullets && item.bullets.length) {
const ul = document.createElement("ul");
item.bullets.forEach((b) => {
const li = document.createElement("li");
li.textContent = b;
ul.appendChild(li);
});
wrap.appendChild(ul);
}
el.appendChild(wrap);
});
}
setText("name", d.name);
setText("headline", d.headline);
setText("location", d.location);
setText("summary", d.summary);
setText("updated", d.updatedText);
setLink("github", d.github);
setLink("linkedin", d.linkedin);
setLink("website", d.website);
renderPills("skills", d.skills);
renderListSection("experience", d.experience, "experience");
renderListSection("projects", d.projects, "projects");
renderListSection("education", d.education, "education");