Repository navigation
Expand file tree
/
Copy pathgenerate.js
More file actions
142 lines (105 loc) · 3.71 KB
/
Copy pathgenerate.js
File metadata and controls
142 lines (105 loc) · 3.71 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
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
const cv = JSON.parse(localStorage.getItem('curriculum') || '{}');
for (const span of document.querySelectorAll('span')) {
if (span.hasAttribute('id') && Object.keys(cv).includes(span.getAttribute('id'))) {
span.textContent = cv[span.getAttribute('id')];
}
}
for (const esperienza of cv?.esperienze || []) {
const row = aggiungiDettaglio(esperienza);
document.querySelector('#listaEsperienze')?.appendChild(row);
}
for (const istruzione of cv?.istruzione || []) {
const row = aggiungiDettaglio(istruzione);
document.querySelector('#listaIstruzione')?.appendChild(row);
}
for (const lingua of cv?.lingue || []) {
const el = aggiungiLingua(lingua);
document.querySelector('#listaLingue')?.appendChild(el);
}
for (const competenza of cv?.competenze || []) {
const el = aggiungiCompetenza(competenza);
document.querySelector('#listaCompetenze')?.appendChild(el);
}
function aggiungiLingua(lang) {
const el = div('space-below');
const linguaContainer = div();
const lingua = span('secondary bold');
lingua.textContent = lang.lingua;
linguaContainer.appendChild(lingua);
const livelloContainer = div();
const livello = span();
livello.textContent = lang.livello;
livelloContainer.appendChild(livello);
el.appendChild(linguaContainer);
el.appendChild(livelloContainer);
return el;
}
function aggiungiCompetenza(comp) {
const el = div();
const compatenzaContainer = div();
const compatenza = span('secondary bold');
compatenza.textContent = comp;
compatenzaContainer.appendChild(compatenza);
el.appendChild(compatenzaContainer);
return el;
}
function aggiungiDettaglio(dettaglio) {
const row = div('row');
const columnShort = div('column short');
const placeContainer = div();
const place = span('secondary bold');
place.textContent = dettaglio.luogo;
placeContainer.appendChild(place);
const periodContainer = div();
const period = span('secondary');
period.textContent = dettaglio.periodo;
periodContainer.appendChild(period);
columnShort.appendChild(placeContainer);
columnShort.appendChild(periodContainer);
const columnLong = div('column long');
const titleContainer = div();
const title = span('primary bold');
title.textContent = dettaglio.titolo;
titleContainer.appendChild(title);
const subtitleContainer = div();
const subtitle = span('primary');
subtitle.textContent = dettaglio.sottotitolo;
subtitleContainer.appendChild(subtitle);
const descriptionContainer = div();
const description = span();
description.textContent = dettaglio.descrizione;
descriptionContainer.appendChild(description);
columnLong.appendChild(titleContainer);
columnLong.appendChild(subtitleContainer);
columnLong.appendChild(descriptionContainer);
row.appendChild(columnShort);
row.appendChild(columnLong);
return row;
}
function div(classi) {
const div = document.createElement('div');
for (const classe of classi?.split(' ') || []) {
div.classList.add(classe);
}
return div;
}
function span(classi) {
const span = document.createElement('span');
if (classi) {
for (const classe of classi?.split(' ') || []) {
span.classList.add(classe);
}
}
return span;
}
function saveCurriculum() {
const json = JSON.parse(localStorage.getItem('curriculum') || '{}');
const jsonString = JSON.stringify(json, null, 2);
const blob = new Blob([jsonString], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "curriculum.json";
a.click();
URL.revokeObjectURL(url);
}