-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
79 lines (66 loc) · 2.58 KB
/
script.js
File metadata and controls
79 lines (66 loc) · 2.58 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
/**
* Calculate experience time, based on resume dates.
*/
document.addEventListener("DOMContentLoaded", () => {
const months = {
"Jan": 1, "Feb": 2, "Mar": 3,
"Apr": 4, "May": 5, "Jun": 6,
"Jul": 7, "Aug": 8, "Sep": 9,
"Oct": 10, "Nov": 11, "Dec": 12
};
const experienceItems = document.querySelectorAll('.experience-item');
let totalYears = 0;
let totalMonths = 0;
experienceItems.forEach(item => {
const dateRange = item.querySelector('p').textContent.match(/([A-Za-z]{3}) (\d{4})\s–\s([A-Za-z]{3}) (\d{4})/);
if (dateRange) {
const startMonth = months[dateRange[1]];
const startYear = parseInt(dateRange[2], 10);
const endMonth = months[dateRange[3]];
const endYear = parseInt(dateRange[4], 10);
const startDate = new Date(startYear, startMonth - 1);
const endDate = new Date(endYear, endMonth - 1);
const experienceDuration = calculateExperienceDuration(startDate, endDate);
totalYears += experienceDuration.years;
totalMonths += experienceDuration.months;
// If totalMonths is 12 or more, adjust totalYears and totalMonths
if (totalMonths >= 12) {
totalYears += Math.floor(totalMonths / 12);
totalMonths = totalMonths % 12;
}
}
});
// Only update the duration element once
const durationElement = document.getElementById('timeExperience');
durationElement.innerHTML = `Experience Time: ${totalYears} years ${totalMonths} months`;
function calculateExperienceDuration(startDate, endDate) {
const diffYears = endDate.getFullYear() - startDate.getFullYear();
const diffMonths = endDate.getMonth() - startDate.getMonth();
let years = diffYears;
let months = diffMonths;
if (diffMonths < 0) {
years -= 1;
months += 12;
}
return { years, months };
}
});
/**
* Download resume like PDF
*/
// async function getResumePDF() {
// const { jsPDF } = window.jspdf;
// const doc = new jsPDF();
// // Get the content you want to include in the PDF
// const content = document.body; // Or select a specific section
// // Convert HTML content to PDF
// doc.html(content, {
// callback: function (doc) {
// // Save the PDF with a specified filename
// doc.save('patrick_faustino_camelo.pdf');
// },
// margin: [10, 10, 10, 10], // Adjust margins
// x: 10,
// y: 10
// });
// };