-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.ts
152 lines (114 loc) · 4.1 KB
/
script.ts
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
var html2pdf: any;
function updateName(): void {
const userNameInput = (
document.getElementById("user-input") as HTMLInputElement
).value;
const userEmailInput = (
document.getElementById("user-email") as HTMLInputElement
).value;
const userPhoneInput = (
document.getElementById("user-phone") as HTMLInputElement
).value;
const userEducationInput = (
document.getElementById("user-Education") as HTMLInputElement
).value;
const userExperienceInput = (
document.getElementById("user-Experience") as HTMLInputElement
).value;
if (!userNameInput.trim()) {
alert("Please enter your name");
return;
}
if (!userEmailInput.trim()) {
alert("Please enter your Email");
return;
}
if (!userPhoneInput.trim()) {
alert("Please enter your Phone");
return;
}
if (!userEducationInput.trim()) {
alert("Please enter your Education");
return;
}
const userResume = document.querySelector(".resume") as HTMLElement;
userResume.style.display = "block";
const nameParagraph = document.getElementById("name") as HTMLParagraphElement;
nameParagraph.textContent = userNameInput;
const emailParagraph = document.getElementById(
"email"
) as HTMLParagraphElement;
emailParagraph.textContent = userEmailInput;
const userPhone = document.getElementById("phone") as HTMLParagraphElement;
userPhone.textContent = userPhoneInput;
const userEdu = document.getElementById("user-edu") as HTMLParagraphElement;
userEdu.textContent = userEducationInput;
const userExp = document.getElementById("user-exp") as HTMLParagraphElement;
userExp.textContent = userExperienceInput;
const inputElement = document.getElementById(
"skillsInput"
) as HTMLInputElement;
const skillsInput = inputElement.value;
const skillsArray = skillsInput
.split(",")
.map((skill) => skill.trim())
.filter((skill) => skill.length > 0);
const listElement = document.getElementById("skillsList") as HTMLUListElement;
listElement.innerHTML = "";
skillsArray.forEach((skill) => {
const listItem = document.createElement("li");
listItem.textContent = skill;
listElement.appendChild(listItem);
});
function downloadResume(): void {
const downloadBtn = document.getElementById("download-resume");
downloadBtn?.addEventListener("click", function () {
const resumeElement = document.querySelector(".container");
if (resumeElement) {
const opt = {
margin: 1,
filename: "Resume.pdf",
image: { type: "jpeg", quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: "in", format: "letter", orientation: "portrait" },
};
html2pdf().from(resumeElement).set(opt).save();
} else {
alert("Resume element not found!");
}
});
}
downloadResume();
function makeSectionsEditable(): void {
const editableElements = document.querySelectorAll(
"[contenteditable='true']"
);
editableElements.forEach((element) => {
element.addEventListener("input", () => {
const elementId = element.id;
const updatedContent = element.textContent?.trim() || "";
console.log(`Updated ${elementId}: ${updatedContent}`);
});
});
}
document.addEventListener("DOMContentLoaded", () => {
makeSectionsEditable();
});
function generateShareableLink(): void {
const userName = (document.getElementById("name") as HTMLParagraphElement)
?.textContent;
if (userName?.trim()) {
const encodedName = encodeURIComponent(userName.trim());
const currentUrl = window.location.href.split('?')[0];
const shareableLink = `${currentUrl}?user=${encodedName}`;
// Display the shareable link
const linkElement = document.getElementById("shareable-link");
if (linkElement) {
linkElement.innerHTML = `<a href="${shareableLink}" target="_blank">${shareableLink}</a>`;
}
} else {
alert("Please enter a valid username.");
}
}
document.getElementById("generate-link-btn")?.addEventListener("click", generateShareableLink);
}