-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
410 lines (349 loc) · 12.2 KB
/
app.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
let resume = {
basicInfo: {},
education: [],
workExperience: [],
skills: [],
achievements: '',
projects: [],
socialLinks: {},
};
function displayContent(sectionId) {
const sections = document.querySelectorAll('.main-content > div');
const downloadButton = document.getElementById('downloadButton');
sections.forEach((section) => {
if (section.id === sectionId) {
section.style.display = 'block';
downloadButton.style.display = 'block';
} else {
section.style.display = 'none';
}
});
}
function addSkill() {
const skillInput = document.querySelector('#skills input[name="skill"]');
const skillList = document.getElementById('skill-list');
if (skillInput.value.trim() !== '') {
const skill = document.createElement('li');
skill.textContent = skillInput.value.trim();
skillList.appendChild(skill);
skillInput.value = '';
// Save the skill in the resume object
resume.skills.push(skill.textContent);
}
}
// Function to save basic info
function saveBasicInfo() {
const fullName = document.querySelector('input[name="Full name"]').value;
const mobileNumber = document.querySelector('input[name="Mobile Number"]').value;
const dob = document.querySelector('input[name="DOB"]').value;
const title = document.querySelector('input[name="Title"]').value;
const email = document.querySelector('input[name="Email"]').value;
const address = document.querySelector('textarea[name="address"]').value;
// Display saved basic info in the download section
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML = `
<h2>Download Resume</h2>
<p>Name: ${fullName}</p>
<p>Mobile: ${mobileNumber}</p>
<p>DOB: ${dob}</p>
<p>Email: ${email}</p>
<p>Title: ${title}</p>
<p>Address: ${address}</p>
`;
}
document.querySelector('#basic-info button').addEventListener('click', saveBasicInfo);
// Function to save education
function saveEducation() {
const instituteName = document.querySelector('input[name="institute name"]').value;
const state = document.querySelector('input[name="STATE"]').value;
const degree = document.querySelector('input[name="DEGREE"]').value;
const fieldOfStudy = document.querySelector('input[name="FIELD OF STUDY"]').value;
const startDate = document.querySelector('input[name="START DATE"]').value;
const percentageCGPA = document.querySelector('input[name="PERCENTAGE/CGPA"]').value;
const education = {
instituteName,
state,
degree,
fieldOfStudy,
startDate,
percentageCGPA,
};
resume.education.push(education);
// Display saved education in the download section
let educationHTML = '<h2>Education</h2>';
for (const edu of resume.education) {
educationHTML += `
<p>Institute: ${edu.instituteName}</p>
<p>State: ${edu.state}</p>
<p>Degree: ${edu.degree}</p>
<p>Field of Study: ${edu.fieldOfStudy}</p>
<p>Start Date: ${edu.startDate}</p>
<p>Percentage/CGPA: ${edu.percentageCGPA}</p>
`;
}
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += educationHTML;
}
// Add event listener for the education section
document.querySelector('#education button').addEventListener('click', saveEducation);
// Function to save work experience
function saveWorkExperience() {
const employer = document.querySelector('input[name="EMPLOYER"]').value;
const jobTitle = document.querySelector('input[name="JOB TITLE"]').value;
const startDate = document.querySelector('input[name="START DATE"]').value;
const state = document.querySelector('input[name="STATE"]').value;
const description = document.querySelector('textarea[name="DISCRIPTION"]').value;
const workExp = {
employer,
jobTitle,
startDate,
state,
description,
};
resume.workExperience.push(workExp);
// Display saved work experience in the download section
let workExpHTML = '<h2>Work Experience</h2>';
for (const exp of resume.workExperience) {
workExpHTML += `
<p>Employer: ${exp.employer}</p>
<p>Job Title: ${exp.jobTitle}</p>
<p>Start Date: ${exp.startDate}</p>
<p>State: ${exp.state}</p>
<p>Description: ${exp.description}</p>
`;
}
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += workExpHTML;
}
// Add event listener for the "Save" button in the work experience section
document.querySelector('#work-experience button').addEventListener('click', saveWorkExperience);
// Function to save skills
function saveSkills() {
const skillsInput = document.querySelector('#skills input[name="skill"]');
const skillsList = document.getElementById('skill-list');
const skills = Array.from(skillsList.children).map((skill) => skill.textContent);
resume.skills = skills;
// Display saved skills in the download section
const skillsHTML = `<h2>Skills</h2><p>${skills.join(', ')}</p>`;
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += skillsHTML;
}
// Add event listener for the "Save" button in the skills section
document.querySelector('#skills #add1').addEventListener('click', saveSkills);
// Function to save achievements
function saveAchievements() {
const achievements = document.querySelector('textarea[name="Achievements"]').value;
resume.achievements = achievements;
// Display saved achievements in the download section
const achievementsHTML = `<h2>Achievements</h2><p>${achievements}</p>`;
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += achievementsHTML;
}
// Add event listener for the "Save" button in the achievements section
document.querySelector('#achievements button').addEventListener('click', saveAchievements);
// Function to save projects
function saveProjects() {
const projectTitle = document.querySelector('input[name="Project Title"]').value;
const projectURL = document.querySelector('input[name="Project URL"]').value;
const projectDescription = document.querySelector('textarea[name="Project Description"]').value;
const project = {
projectTitle,
projectURL,
projectDescription,
};
resume.projects.push(project);
// Display saved projects in the download section
let projectsHTML = '<h2>Projects</h2>';
for (const proj of resume.projects) {
projectsHTML += `
<p>Project Title: ${proj.projectTitle}</p>
<p>Project URL: ${proj.projectURL}</p>
<p>Project Description: ${proj.projectDescription}</p>
`;
}
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += projectsHTML;
}
// Add event listener for the "Save" button in the projects section
document.querySelector('#projects button').addEventListener('click', saveProjects);
// Function to save social links
function saveSocialLinks() {
const github = document.querySelector('input[name="Github"]').value;
const linkedIn = document.querySelector('input[name="LinkedIn"]').value;
resume.socialLinks = {
github,
linkedIn,
};
// Display saved social links in the download section
const downloadSection = document.querySelector('#download');
downloadSection.innerHTML += `
<h2>Social Links</h2>
<p>Github: ${github}</p>
<p>LinkedIn: ${linkedIn}</p>
`;
}
// Add event listener for the "Save" button in the social links section
document.querySelector('#social-links button').addEventListener('click', saveSocialLinks);
function downloadResume() {
const fullName = document.querySelector('input[name="Full name"]').value;
const mobileNumber = document.querySelector('input[name="Mobile Number"]').value;
const dob = document.querySelector('input[name="DOB"]').value;
const title = document.querySelector('input[name="Title"]').value;
const email = document.querySelector('input[name="Email"]').value;
const address = document.querySelector('textarea[name="address"]').value;
let educationHTML = '<h2>Education</h2>';
for (const edu of resume.education) {
educationHTML += `
<p>Institute: ${edu.instituteName}</p>
<p>State: ${edu.state}</p>
<p>Degree: ${edu.degree}</p>
<p>Field of Study: ${edu.fieldOfStudy}</p>
<p>Start Date: ${edu.startDate}</p>
<p>Percentage/CGPA: ${edu.percentageCGPA}</p>
`;
}
let workExpHTML = '<h2>Work Experience</h2>';
for (const exp of resume.workExperience) {
workExpHTML += `
<p>Employer: ${exp.employer}</p>
<p>Job Title: ${exp.jobTitle}</p>
<p>Start Date: ${exp.startDate}</p>
<p>State: ${exp.state}</p>
<p>Description: ${exp.description}</p>
`;
}
let skillsHTML = '<h2>Skills</h2>';
if (resume.skills.length > 0) {
skillsHTML += '<ul>';
for (const skill of resume.skills) {
skillsHTML += `<li>${skill}</li>`;
}
skillsHTML += '</ul>';
}
let achievementsHTML = '';
if (resume.achievements !== '') {
achievementsHTML = `<h2>Achievements</h2><p>${resume.achievements}</p>`;
}
let projectsHTML = '<h2>Projects</h2>';
for (const proj of resume.projects) {
projectsHTML += `
<p>Project Title: ${proj.projectTitle}</p>
<p>Project URL: ${proj.projectURL}</p>
<p>Project Description: ${proj.projectDescription}</p>
`;
}
let socialLinksHTML = '';
if (resume.socialLinks.github || resume.socialLinks.linkedIn) {
socialLinksHTML = '<h2>Social Links</h2>';
if (resume.socialLinks.github) {
socialLinksHTML += `<p>Github: ${resume.socialLinks.github}</p>`;
}
if (resume.socialLinks.linkedIn) {
socialLinksHTML += `<p>LinkedIn: ${resume.socialLinks.linkedIn}</p>`;
}
}
const resumeHTML = `
<!DOCTYPE html>
<html>
<head>
<title>Resume</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff9f9;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
h2 {
color: #db75b4;
margin-bottom: 10px;
}
p {
margin: 0;
margin-bottom: 5px;
padding-top: 3%;
}
.basicinfo{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.skills{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.education{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.workexp{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.achive{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.project{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
.social{
border: 1px solid black;
padding: 2%;
margin-bottom: 2%;
}
</style>
</head>
<body>
<div id="download" class="container mt-5">
<div class="basicinfo">
<h2>Basic Information</h2>
<p>Name: ${fullName}</p>
<p>Mobile: ${mobileNumber}</p>
<p>DOB: ${dob}</p>
<p>Email: ${email}</p>
<p>Title: ${title}</p>
<p>Address: ${address}</p>
</div>
<div class="education">
${educationHTML}
</div>
<div class="workexp">
${workExpHTML}
</div>
<div class="skills">
${skillsHTML}
</div>
<div class="achive">
${achievementsHTML}
</div>
<div class="project">
${projectsHTML}
</div>
<div class="social">
${socialLinksHTML}
</div>
</div>
</body>
</html>
`;
const blob = new Blob([resumeHTML], { type: 'text/html' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'resume.html';
link.click();
}
document.getElementById('downloadButton').addEventListener('click', downloadResume);