-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpreview.js
200 lines (169 loc) · 7.09 KB
/
preview.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
hamBttn = document.querySelector('.ham');
hamMenu = document.querySelector('.sideMenu');
previewPanel = document.querySelector('.previewMain');
let count = 0;
document.querySelector('.goBackBttn').addEventListener('click', ()=>{
document.querySelector('.formViewPort').style.display = 'flex';
document.querySelector('.preview').style.display = 'none';
const eep = document.querySelector('.resumeEEP');
const aip = document.querySelector('.resumeAIP');
const prof = document.querySelector('.resumeProf')
while(eep.firstChild)
{
eep.removeChild(eep.lastChild);
}
while(aip.firstChild)
{
aip.removeChild(aip.lastChild);
}
while(prof.firstChild)
{
prof.removeChild(prof.lastChild);
}
const resumeAbout = document.querySelector('.about');
if(resumeAbout.firstChild)
{
resumeAbout.removeChild(resumeAbout.lastChild);
}
const resumeName = document.querySelector('.name');
if(resumeName.firstChild)
{
resumeName.removeChild(resumeName.lastChild);
}
});
const controlTitle = ['Name', 'About', 'Titles Left', 'Contents Left', 'Titles Right', 'Contents Right', 'Hyperlinks'];
const outputClassList = ['name', 'about', 'wcardTitle', 'wcardList', 'hcardTitle', 'hcardList', 'prof'];
const defaultFontSize = [40, 14, 24, 9, 24, 14, 12]
const selectColorForMe3 = () => {
const colorList = ['#ffadad', '#ffd6a5', '#fdffb6', '#caffbf', '#9bf6ff', '#a0c4ff', '#bdb2ff', '#ffc6ff',
'#fbf8cc', '#fde4cf', '#ffcfd2', '#f1c0e8', '#cfbaf0', '#a3c4f3', '#90dbf4', '#8eecf5', '#98f5e1', '#b9fbc0'];
const i = Math.floor(Math.random() * colorList.length);
return colorList[i];
}
for(let i = 0; i < controlTitle.length; i++){
const container = document.createElement('div');
const addysun = document.createElement('button');
const subs = document.createElement('button');
const text = document.createElement('div');
container.setAttribute('class', 'fontControlBttnContainer');
addysun.setAttribute('class', 'fontAppender');
subs.setAttribute('class', 'fontDecrease');
text.setAttribute('class', 'indicator');
text.innerText = `${controlTitle[i]}: ${defaultFontSize[i]}`;
addysun.innerText = '+';
subs.innerText = '-';
text.style.filter = `drop-shadow(0 3px 0px ${selectColorForMe3()}) drop-shadow(0 2px 0px black)`;
let counter = defaultFontSize[i];
addysun.addEventListener('click', ()=>{
++counter;
const font = document.querySelectorAll(`.${outputClassList[i]}`);
text.innerText = `${controlTitle[i]}: ${counter}`;
for(let j = 0; j < font.length; j++){
font[j].style.fontSize = `${counter}px`;
}
});
subs.addEventListener('click', ()=>{
const font = document.querySelectorAll(`.${outputClassList[i]}`);
if(counter > 1)
{
--counter;
text.innerText = `${controlTitle[i]}: ${counter}`;
for(let j = 0; j < font.length; j++){
font[j].style.fontSize = `${counter}px`;
}
}
});
container.appendChild(subs);
container.appendChild(text);
container.appendChild(addysun);
document.querySelector('.fontControlBox').appendChild(container);
}
document.querySelector('.downloadBttn').addEventListener('click', ()=>{
html2canvas(document.querySelector('.resume')).then(canvas => {
document.body.appendChild(canvas);
canvas.style.display = 'none';
return canvas;
})
.then(canvas => {
const image = canvas.toDataURL('image/png');
const a = document.createElement('a');
a.setAttribute('download', 'resume.png')
a.setAttribute('href', image)
a.click()
canvas.remove()
})
})
document.querySelector('.templateControlCard').style.filter = `drop-shadow(0 5px 0px ${selectColorForMe3()}) drop-shadow(0 2px 0px black)`;
document.querySelector('.fontControlCard').style.filter = `drop-shadow(0 5px 0px ${selectColorForMe3()}) drop-shadow(0 2px 0px black)`;
document.querySelector('.fontControlCardImage').style.backgroundColor = `${selectColorForMe3()}`;
const templeNames = ['Plain Sheet',
'Evergreen',
'Yellow Desert',
'Green Desert',
'Blue Desert',
'Yellow Liner',
'Violet Liner',
'Aqua Liner',
'Pink Liner',
'Auto',
'Dark-G',
'Dark-R',
'Dark Sheet',
'Dark-G',
'Cool Fire',
'The Gray Side',
'Greyed Only',
'Black Rose'];
let counter1 = 1;
document.querySelector('.templateControlAppend').addEventListener('click', ()=>{
++counter1;
if(counter1 === 18)
counter1 = 1;
document.querySelector('.tempImage').setAttribute('src', `template${counter1}.png`);
document.querySelector('link').setAttribute('href', `template${counter1}.css`);
document.querySelector('.templateControlCardText').innerText = `${templeNames[counter1 - 1]}`
})
document.querySelector('.templateControlBack').addEventListener('click', () =>{
--counter1;
if(counter1 === 0)
counter1 = 18;
document.querySelector('.tempImage').setAttribute('src', `template${counter1}.png`);
document.querySelector('link').setAttribute('href', `template${counter1}.css`);
document.querySelector('.templateControlCardText').innerText = `${templeNames[counter1 - 1]}`
})
const textFamily = ['Urbanist',
'Vidaloka',
'Fredoka',
'Roboto',
'Arima Madurai',
'Sora',
'Baloo 2',
'Abhaya Libre',
'Saira',
'Bree Serif',
'Raleway',
'Montserrat',
'Merriweather',
'Ubuntu Mono',
'Poppins',
'Ramaraja',
'Playfair Display'];
let counter2 = 1;
document.querySelector('.fontControlAppend').addEventListener('click', ()=>{
++counter2;
if(counter2 === 17)
counter2 = 0;
document.querySelector('.fontBoxed').style.fontFamily = `${textFamily[counter2]}`;
document.querySelector('.resume').style.fontFamily = `${textFamily[counter2]}`;
document.querySelector('.fontControlCardText').innerText = `${textFamily[counter2]}`;
document.querySelector('.fontControlCardImage').style.backgroundColor = `${selectColorForMe3()}`;
})
document.querySelector('.fontControlBack').addEventListener('click', () =>{
--counter2;
if(counter2 === -1)
counter2 = 16;
document.querySelector('.fontBoxed').style.fontFamily = `${textFamily[counter2]}`;
document.querySelector('.resume').style.fontFamily = `${textFamily[counter2]}`;
document.querySelector('.fontControlCardText').innerText = `${textFamily[counter2]}`;
document.querySelector('.fontControlCardImage').style.backgroundColor = `${selectColorForMe3()}`;
})