-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (30 loc) · 1.14 KB
/
script.js
File metadata and controls
33 lines (30 loc) · 1.14 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
// Setup skill level dots
(() => {
const skillLevelContainerArray = document.getElementsByClassName('skill-level');
const circleSize = 2;
const circleOffset = (x) => 3 * x + 1;
const emptyColor = 'var(--light)';
const filledColor = 'var(--dark)';
const ratingSvg = (level) => {
let levelSvg = `<svg xmlns='http://www.w3.org/2000/svg' viewbox='0 0 ${7*circleSize} ${circleSize}' height='10px' width='70px'>`;
for(let i = 0; i < 5; i++) {
levelSvg = levelSvg.concat(`<circle cx='${circleOffset(i)}' cy='1' r='1' fill='${level > i ? filledColor : emptyColor}'/>`)
}
return levelSvg.concat("</svg>");
}
for (let skillLevelContainer of skillLevelContainerArray) {
skillLevelContainer.innerHTML = ratingSvg(skillLevelContainer.getAttribute('level'));
};
})();
// Portrait Slideshow
(() => {
const portraitContainer = document.getElementById('portrait');
let portraitIdx = 1;
const setPortrait = () => {
portraitContainer.setAttribute('src', `public/img/portrait${portraitIdx}.png`);
if (portraitIdx === 3) portraitIdx = 1;
else portraitIdx++;
};
setPortrait();
setInterval(setPortrait, 5000)
})();