-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw3-2.html
352 lines (307 loc) · 14.2 KB
/
hw3-2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Resume Generator</title>
<link rel="stylesheet" type="text/css" href="css/resume.css"/>
<script src="js/jquery.min.js"></script>
<script src="js/jspdf.debug.js"></script>
<script src="js/html2canvas.js"></script>
</head>
<body>
<!-- section for generator -->
<section id="resume_generator" style="visibility: visible; height: 20px;">
<h1>Resume Generator</h1>
1. Basic Introduction <br>
1-1. Profile image : <input type="file" id="portrait"> <br>
(You should add this web page as "trustable page" to load the local image.) <br>
1-2. Name : <input type="text" id="_name" placeholder="Kang-Uk, Seo"> <br>
1-3. Contact info <br>
Residence : <input type="text" id="_residence" placeholder="Anamdong"> <br>
E-mail : <input type="text" id="_email" placeholder="[email protected]"> <br>
Phone : <input type="text" id="_phone" placeholder="123-1234-1234"> <br>
Personal web page : <input type="text" id="_webpage" placeholder="www.example.com"> <br><br><br>
2. Objective <br>
<textarea id="_objective" rows="2" cols="40" placeholder="one paragraph(carrier goal)"></textarea> <br><br><br>
3. Education
<button id="addEdu" onclick="buttonEvent(true, 'edu_table')">Add itme</button>
<button id="deleteEdu" onclick="buttonEvent(false, 'edu_table')">Delete item</button>
<table id="edu_table">
<tr>
<th>From</th>
<th>To</th>
<th>School</th>
<th>Degree</th>
</tr>
<tr>
<td><input type="month" id="_edufrom0" size="30"></td>
<td><input type="month" id="_eduto0" size="30"></td>
<td><input type="text" id="_school0" size="30" placeholder="Korea univ"></td>
<td><input type="text" id="_degree0" size="30" placeholder="Degree"></td>
</tr>
</table>
<br><br>
3. Experience
<button id="addExp" onclick="buttonEvent(true, 'exp_table')">Add itme</button>
<button id="deleteExp" onclick="buttonEvent(false, 'exp_table')">Delete item</button>
<table id="exp_table">
<tr>
<th>From</th>
<th>To</th>
<th>Organization</th>
<th>Duty</th>
</tr>
<tr>
<td><input type="month" id="_expfrom0" size="30"></td>
<td><input type="month" id="_expto0" size="30"></td>
<td><input type="text" id="_organization0" size="30" placeholder="Korea Soft"></td>
<td><input type="text" id="_duty0" size="30" placeholder="Senior Web Designer"></td>
</tr>
</table>
<br><br>
4. Skills
<button id="addSkills" onclick="buttonEvent(true, 'skills_table')">Add itme</button>
<button id="deleteSkills" onclick="buttonEvent(false, 'skills_table')"> Delete item</button>
<table id="skills_table">
<tr>
<th>Category</th>
<th>Contents</th>
</tr>
<tr>
<td><input type="text" id="_category0" size="30" placeholder="Software knowledge"></td>
<td><textarea id="_contents0" rows="3" cols="20" placeholder="C+ C JAVA"></textarea></td>
</tr>
</table>
<br>
5. Works
<button id="addWorks" onclick="buttonEvent(true, 'works_table')">Add itme</button>
<button id="deleteWorks" onclick="buttonEvent(false, 'works_table')">Delete item</button>
<table id="works_table">
<tr>
<th>What works</th>
</tr>
<tr>
<td><input type="text" id="_works0" size="30" placeholder="Awards, Projects..."></td>
</tr>
</table>
<br>
<button id="submit" onclick="showresume()" style="width:100px; height:50px;">Submit</button>
<br><br>
</section>
<!-- section for result resume -->
<section id="resume_page" style="visibility: hidden">
<div id="resumeData"></div>
</section>
<!-- section for export -->
<section id="bottom" style="visibility: hidden">
<button id="goBack" onclick="goBack()" style="width:100px; height:50px;">goBack</button>
<button id="save" onclick="save()" style="width:100px; height:50px;">Save</button>
<br><br>
</section>
<script>
//Add or Delete items
function buttonEvent(Add, id) {
var wrapper = document.getElementById(id);
var index = wrapper.rows.length - 1;
var str = '';
if(Add) {
var newRow = wrapper.insertRow(index + 1);
switch(id){
case 'edu_table':
var cell0 = newRow.insertCell(0);
var cell1 = newRow.insertCell(1);
var cell2 = newRow.insertCell(2);
var cell3 = newRow.insertCell(3);
cell0.innerHTML = '<input type="month" id="_edufrom' + index + '" size="30">';
cell1.innerHTML = '<input type="month" id="_eduto' + index + '" size="30">';
cell2.innerHTML = '<input type="text" id="_school' + index + '" size="30" placeholder="Korea univ">';
cell3.innerHTML = '<input type="text" id="_degree' + index + '" size="30" placeholder="Degree">';
break;
case 'exp_table':
var cell0 = newRow.insertCell(0);
var cell1 = newRow.insertCell(1);
var cell2 = newRow.insertCell(2);
var cell3 = newRow.insertCell(3);
cell0.innerHTML = '<input type="month" id="_expfrom' + index + '" size="30">';
cell1.innerHTML = '<input type="month" id="_expto' + index + '" size="30">';
cell2.innerHTML = '<input type="text" id="_organization' + index + '" size="30" placeholder="Korea Soft">';
cell3.innerHTML = '<input type="text" id="_duty' + index + '" size="30" placeholder="Senier Web Designer">';
break;
case 'skills_table':
var cell0 = newRow.insertCell(0);
var cell1 = newRow.insertCell(1);
cell0.innerHTML = '<input type="text" id="_category' + index + '" size="30" placeholder="Software knowledge">';
cell1.innerHTML = '<textarea id="_contents' + index + '" rows="3" cols="20" placeholder="C+ C JAVA"></textarea>';
break;
case 'works_table':
var cell0 = newRow.insertCell(0);
cell0.innerHTML = '<input type="text" id="_works' + index + '" size="30" placeholder="Awards, Projects...">'
break;
}
}else {
if(index == 1) return;
wrapper.deleteRow(wrapper.rows.length-1);
}
}
// Submit button in resume_generator section
function showresume() {
var html = createHTML();
insertHTML('resumeData', html);
toggleVisibility('resume_generator');
toggleVisibility('resume_page');
toggleVisibility('bottom');
}
// create resume.html body data
function createHTML() {
// blablabla
var html = '';
html+='<div id="wrapper">';
html += NameForm();
html += ObjectiveForm();
html += EducationForm();
html += ExperienceForm();
html += SkillsForm();
html += WorksForm();
html += '</div>';
return html;
}
function NameForm() {
var NAME = '';
var img = document.getElementById('portrait').value;
var name = document.getElementById('_name').value;
var residence = document.getElementById('_residence').value;
var email = document.getElementById('_email').value;
var phone = document.getElementById('_phone').value;
var webpage = document.getElementById('_webpage').value;
NAME += '<div class="entry">';
NAME += '<img class="portrait" src="' + img + '" alt="sample" />';
console.log(img);
NAME += '<div class="self">';
NAME += '<h1 class="name">' + name + '<br></h1>';
NAME += '<ul><li>' + residence + '</li>';
NAME += '<li>' + email + ' </li>';
NAME += '<li>' + phone + '</li>';
NAME += '<li>' + webpage + '</li></ul></div></div>';
return NAME;
}
function ObjectiveForm() {
var OBJ = '';
var objective = document.getElementById('_objective').value;
OBJ += '<div class="entry">';
OBJ += '<h2>OBJECTIVE</h2>';
OBJ += '<p class="obj">' + objective+ '</p></div>';
return OBJ;
}
function EducationForm() {
var EDU = '';
var NumOfRows = document.getElementById('edu_table').rows.length - 1;
EDU += '<div class="entry">';
EDU += '<h2>EDUCATION</h2>';
for(var i = 0; i < NumOfRows; i++){
var from = document.getElementById('_edufrom' + i).value;
var to = document.getElementById('_eduto' + i).value;
var school = document.getElementById('_school' + i).value;
var degree = document.getElementById('_degree' + i).value;
EDU += '<div class="content">';
EDU += '<h3>' + from + ' ~ ' + to + '</h3>';
EDU += '<p>' + school + '<br>';
EDU += '<em>' + degree + '</em></p></div>';
}
EDU += '</div>';
return EDU;
}
function ExperienceForm() {
var EXP = '';
var NumOfRows = document.getElementById('exp_table').rows.length - 1;
EXP += '<div class="entry">';
EXP += '<h2>EXPERIENCE</h2>';
for(var i = 0; i < NumOfRows; i++){
var from = document.getElementById('_expfrom' + i).value;
var to = document.getElementById('_expto' + i).value;
var organization = document.getElementById('_organization' + i).value;
var duty = document.getElementById('_duty' + i).value;
EXP += '<div class="content">';
EXP += '<h3>' + from + ' ~ ' + to + '</h3>';
EXP += '<p>' + organization + '<br>';
EXP += '<em>' + duty + '</em></p></div>';
}
EXP += '</div>';
return EXP;
}
function SkillsForm() {
var SKILLS = '';
var NumOfRows = document.getElementById('skills_table').rows.length - 1;
SKILLS += '<div class="entry">';
SKILLS += '<h2>SKILLS</h2>';
for(var i = 0; i < NumOfRows; i++){
var category = document.getElementById('_category' + i).value;
var contents = document.getElementById('_contents' + i).value;
SKILLS += '<div class="content">';
SKILLS += '<h3>' + category +'</h3>';
SKILLS += '<table class="skills"><tr>'
contents = contents.split("\n");
for(var j = 0; j < contents.length; j++){
SKILLS += '<td>' + contents[j] + '</td>';
if((j+1)%3==0)
SKILLS += '</tr><tr>';
}
SKILLS += '</tr></table></div>';
}
SKILLS += '</div>';
return SKILLS;
}
function WorksForm() {
var WORKS = '';
var NumOfRows = document.getElementById('works_table').rows.length - 1;
WORKS += '<div class="entry">';
WORKS += '<h2>Works</h2>';
WORKS += '<ul class="works">';
for(var i = 0; i < NumOfRows; i++){
var works = document.getElementById('_works' + i).value;
WORKS += '<li>' + works + '</li>';
}
WORKS += '</ul></div>';
return WORKS;
}
function insertHTML(id, html) {
var el = document.getElementById(id);
if(!el) {
alert('Element with id ' + id + ' not found.');
}
el.innerHTML = html;
}
//Back button in bottom section
function goBack() {
toggleVisibility('resume_generator');
toggleVisibility('resume_page');
toggleVisibility('bottom');
}
function save() {
html2canvas(document.getElementById("resumeData")).then(
function(canvas) {
var imgData = canvas.toDataURL('image/jpeg', 1.0);
console.log('report image URL : '+ imgData);
var doc = new jsPDF('p', 'mm', 'a4');
var width = doc.internal.pageSize.getWidth();
var height = doc.internal.pageSize.getHeight();
doc.addImage(imgData, 'JPEG', 0, 0, width-90, height);
doc.save('resume.pdf');
}
)
}
function toggleVisibility(id) {
var dom = document.getElementById(id);
if(dom.style.visibility != "hidden"){
dom.style.visibility = "hidden";
dom.style.height="0px";
}
else if(dom.style.visibility == "hidden"){
dom.style.visibility = "visible";
dom.style.height="auto";
}
}
</script>
</body>