-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
60 lines (54 loc) · 2.14 KB
/
functions.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
// Hide/Show cards
document.getElementById('section1').addEventListener('click', function() {
// Hide all cards
const cards = document.getElementsByClassName('card');
for (let i = 0; i < cards.length; i++) {
cards[i].style.display = 'None';
}
// Show selected
document.getElementById('about').style.display = 'block';
//Reset color
const items = document.getElementsByClassName('item');
for (let i = 0; i < items.length; i++) {
items[i].style.color = 'var(--color-text)';
}
// Turn color on
document.getElementById('section1').style.color = 'var(--color-accent2)';
});
document.getElementById('section2').addEventListener('click', function() {
const collection = document.getElementsByClassName('card');
for (let i = 0; i < collection.length; i++) {
collection[i].style.display = 'None';
}
document.getElementById('resume').style.display = 'block';
const items = document.getElementsByClassName('item');
for (let i = 0; i < items.length; i++) {
items[i].style.color = 'var(--color-text)';
}
document.getElementById('section2').style.color = 'var(--color-accent2)';
});
document.getElementById('section3').addEventListener('click', function() {
const collection = document.getElementsByClassName('card');
for (let i = 0; i < collection.length; i++) {
collection[i].style.display = 'None';
}
document.getElementById('tools').style.display = 'block';
const items = document.getElementsByClassName('item');
for (let i = 0; i < items.length; i++) {
items[i].style.color = 'var(--color-text)';
}
document.getElementById('section3').style.color = 'var(--color-accent2)';
});
// Auto-calculate age
var dob = document.getElementById('birthdate').textContent;
document.getElementById('age').innerHTML = getAge(dob);
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}