-
Notifications
You must be signed in to change notification settings - Fork 21
/
script.js
63 lines (51 loc) · 1.57 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
const getDOM = selector => () => {
return document.querySelector(selector);
};
document.title = `${main.name} | ${main.role}`
// Values DOM nodes
const dom = {
main: {
name: getDOM('#main #name'),
mail: getDOM('#main #mail'),
img: getDOM('#main #img'),
role: getDOM('#main #role'),
connects: getDOM('#main #connects'),
links: getDOM('#main #links')
},
projects: getDOM('#projects'),
logo: getDOM('#projects-page #logo')
};
function assignDOM(dom, value, options) {
console.log('dom, value, img:', dom, value, img);
if (options && options.isImg) {
dom.src = value;
return;
}
if (options && options.isAdjacent) {
dom.insertAdjacentHTML('afterbegin', value);
}
dom.innerHTML = value;
}
// Assigning
// MAIN
assignDOM(dom.main.name(), main.name);
assignDOM(dom.main.mail(), main.mail);
dom.main.mail().href = `mailto:${main.mail}?Subject=Hello%20again`;
assignDOM(dom.main.img(), main.img, { isImg: true });
assignDOM(dom.main.role(), main.role);
// assignDOM(dom.main.links(), main.links)
// External Links (ICONS)
const connectsDOM = main.connects
.map(
({ name, iconName, link }) =>
`<a href=${link} target="_blank"><ion-icon name="${iconName}" title="${name}"></ion-icon></a>`
)
.join('\n');
assignDOM(dom.main.connects(), connectsDOM);
// Internal Links
const getLinks = links =>
links
.map(({ name, link }) => `<a href="${link}" class="text-pink-500" >${name}</a>`)
.map((link, index, links) => index === links.length - 1 ? link: `${link} - `)
.join('\n');
assignDOM(dom.main.links(), getLinks(main.links));