-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
210 lines (160 loc) · 6.55 KB
/
script.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
// alert("preview")
// WORK EXPERIENCE FIELD
function addNewWeField(){
// console.log("mmmmmmm");
let newNode=document.createElement('textarea');
newNode.classList.add('form-control');
newNode.classList.add ('weField');
newNode.classList.add ("mt-2");
newNode.setAttribute("placeholder" , "enter here");
newNode.setAttribute("rows" , 2);
let weOb = document.getElementById('we');
let weAddButtonOb = document.getElementById('weAddButton');
weOb.insertBefore(newNode,weAddButtonOb);
}
// EDUCATION FIELD
function addNewEduField(){
let newNode=document.createElement('textarea');
newNode.classList.add('form-control');
newNode.classList.add ('eduField');
newNode.classList.add ("mt-2");
newNode.setAttribute("placeholder" , "enter here");
newNode.setAttribute("rows" , 2);
let eduOb = document.getElementById('edu');
let eduAddButtonOb = document.getElementById('eduAddButton');
eduOb.insertBefore(newNode,eduAddButtonOb);
}
// projects
function addNewPjField(){
let newNode=document.createElement('textarea');
newNode.classList.add('form-control');
newNode.classList.add ('pjField');
newNode.classList.add ("mt-2");
newNode.setAttribute("placeholder" , "enter here");
newNode.setAttribute("rows" , 2);
let pjOb = document.getElementById('pj');
let pjAddButtonOb = document.getElementById('pjAddButton');
pjOb.insertBefore(newNode,pjAddButtonOb);
}
// skills
function addNewSkField(){
let newNode=document.createElement('textarea');
newNode.classList.add('form-control');
newNode.classList.add ('skField');
newNode.classList.add ("mt-2");
newNode.setAttribute("placeholder" , "enter here");
newNode.setAttribute("rows" , 1);
let skOb = document.getElementById('sk');
let skAddButtonOb = document.getElementById('skAddButton');
skOb.insertBefore(newNode,skAddButtonOb);
}
// languages
function addNewlgField(){
let newNode=document.createElement('textarea');
newNode.classList.add('form-control');
newNode.classList.add ('lgField');
newNode.classList.add ("mt-2");
newNode.setAttribute("placeholder" , "enter here");
newNode.setAttribute("rows" , 1);
let lgOb = document.getElementById('lg');
let lgAddButtonOb = document.getElementById('lgAddButton');
lgOb.insertBefore(newNode,lgAddButtonOb);
}
///////////////////////////////////////
document.getElementById("download").style.display = "none";
// generating cv function
function generateCV(){
// console.log("generating....");
let nameField = document.getElementById("nameField").value;
let nameT = document.getElementById("nameT");
nameT.innerHTML = nameField;
document.getElementById("addressT").innerHTML = document.getElementById("addressField").value;
document.getElementById("contactT").innerHTML = document.getElementById("contactField").value;
document.getElementById("emailT").innerHTML = document.getElementById("emailField").value;
document.getElementById("lkT").innerHTML = document.getElementById("lkField").value;
document.getElementById("ttT").innerHTML = document.getElementById("ttField").value;
document.getElementById("wbT").innerHTML = document.getElementById("wbField").value;
document.getElementById("gtT").innerHTML = document.getElementById("wbField").value;
document.getElementById("pfT").innerHTML = document.getElementById("pfField").value;
document.getElementById("psT").innerHTML = document.getElementById("psField").value;
// work experience
let wes = document.getElementsByClassName("weField");
let str = '';
for(let e of wes){
str= str + `<div class="education_content">> <div class="education_time" id="time">
<span class="education_rounder"></span>
<span class="education_line" ></span>
</div>${e.value} </div>`;
}
document.getElementById("weT").innerHTML = str;
//eductaion string
let edus = document.getElementsByClassName("eduField");
let str1 = '';
for(let e of edus){
str1= str1 + `<div class="education_content"> <div class="education_time" id="time">
<span class="education_rounder"></span>
<span class="education_line" ></span>
</div> ${e.value} </div>`;
}
document.getElementById("eduT").innerHTML = str1;
//projects string
let pjs = document.getElementsByClassName("pjField");
let str2 = '';
for(let e of pjs){
str2= str2 + `<div class="education_content"> <div class="education_time" id="time">
<span class="education_rounder"></span>
<span class="education_line" ></span>
</div> ${e.value} </div>`;
}
document.getElementById("pjT").innerHTML = str2;
// skills
let sks = document.getElementsByClassName("skField");
let str3 = '';
for(let e of sks){
str3= str3 + `<li> <span class="skills_circle" id="c"></span>${e.value} </li>`;
}
document.getElementById("skT").innerHTML = str3;
// languages
let lgs = document.getElementsByClassName("lgField");
let str4 = '';
for(let e of lgs){
str4= str4 + `<li> ${e.value} </li>`;
}
document.getElementById("lgT").innerHTML = str4;
//image field
let file=document.getElementById("imageField").files[0];
console.log(file);
let reader=new FileReader();
reader.readAsDataURL(file);
console.log(reader.result);
//set image to template
reader.onloadend =function(){
document.getElementById("imageT").src= reader.result;
}
document.getElementById("goback").style.display = "block";
document.getElementById("download").style.display = "block";
document.getElementById("cv-form").style.display = "none";
document.getElementById("cv-template").style.display = "grid";
}
// goback
function formCV(){
document.getElementById("goback").style.display = "none";
document.getElementById("cv-form").style.display = "block";
document.getElementById("cv-template").style.display = "none";
document.getElementById("download").style.display = "none";
}
const areaCv = document.getElementById("cv-template");
let resumeButton =document.getElementById("download");
let opt = {
margin: 0,
filename: 'myResume.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 4 },
jsPDF: { format: 'a4', orientation: 'portrait' }
};
function printCV(){
html2pdf(areaCv,opt)
}
resumeButton.addEventListener('click', ()=>{
generateResume()
})