-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
223 lines (176 loc) · 7.7 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
211
212
213
214
215
216
217
218
219
220
221
222
223
var portfolios = JSON.parse(localStorage.getItem('portfolios')) || {};
window.onload = function() {
console.debug('Slideenter animationn');
document.getElementById('container').classList.add('slide-in');
};
document.getElementById('image').addEventListener('change', function () {
const file = this.files[0];
const reader = new FileReader();
reader.addEventListener('load', function () {
const image = document.createElement('img');
image.src = reader.result;
image.style.maxWidth = '200px';
image.style.maxHeight = '200px';
const previewSection = document.getElementById('preview-section');
previewSection.innerHTML = '';
previewSection.appendChild(image);
}, false);
if (file) {
reader.readAsDataURL(file);
}
});
function generateRandomID() {
return Math.floor(Math.random() * 1000000/100);
}
function submitForm() {
var name = document.getElementById('name').value;
var image = document.getElementById('image').files[0];
var about = document.getElementById('about').value;
var age = document.getElementById('age').value;
var skills = document.getElementById('skills').value;
var achievements = document.getElementById('achievements').value;
var hobbies = document.getElementById('hobbies').value;
var creations = document.getElementById('creations').value;
var inventions = document.getElementById('inventions').value;
var aspirations = document.getElementById('aspirations').value;
var email = document.getElementById('email').value;
var phonenum = document.getElementById('phonenumber').value;
var id = document.getElementById('id').value;
var cass = document.getElementById('class') ? document.getElementById('class').value : null;
var car = document.getElementById('car') ? document.getElementById('car').value : null;
var edu = document.getElementById('education') ? document.getElementById('education').value : null;
var ex = document.getElementById('expr') ? document.getElementById('expr').value : null;
var adc = document.getElementById('adc') ? document.getElementById('adc').value : null
var pas = document.getElementById('pas') ? document.getElementById('pas').value : null
if (!id) {
id = generateRandomID();
document.getElementById('id').value = id;
var imageData = null;
if (image) {
var reader = new FileReader();
reader.onload = function(event) {
imageData = event.target.result;
portfolios[id] = {
name: name,
age: age,
image: imageData,
achievements: achievements,
about: about,
hobbies: hobbies,
creations: creations,
inventions: inventions,
aspirations: aspirations,
email: email,
phonenum: phonenum,
skills: skills,
cass: cass,
car: car,
edu: edu,
ex: ex,
adc:adc,
pas:pas
};
localStorage.setItem('portfolios', JSON.stringify(portfolios));
};
reader.readAsDataURL(image);
} else {
portfolios[id] = {
name: name,
age: age,
achievements: achievements,
about: about,
hobbies: hobbies,
creations: creations,
inventions: inventions,
aspirations: aspirations,
email: email,
phonenum: phonenum,
skills: skills,
cass : cass,
edu:edu,
ex:ex,
car: car,
adc:adc,
pas:pas
};
localStorage.setItem('portfolios', JSON.stringify(portfolios));
}
}
window.location.href = 'portfolio.html?id=' + id;
}
function add(){
var portfolioContent = '<button id = "cl" onclick="c()">Class</button>' ;
portfolioContent+= '<br>';
portfolioContent+= '<button id="car" onclick="f()">Career</button>' ;
portfolioContent+= '<br>';
portfolioContent+= '<button id = "edu" onclick="d()">Education</button>' ;
portfolioContent+= '<br>';
portfolioContent+= '<button id = "ex" onclick="g()">Experience</button>' ;
portfolioContent+= '<br>';
portfolioContent+= '<button id = "pa" onclick="p()">Professional Associations</button>';
portfolioContent+= '<br>';
portfolioContent+= '<button id = "Adi" onclick="a()">Additional Contact Information</button>';
var labelContainer = document.getElementById('lb');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function c(){
var label = "Class"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="class" rows="1"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb1');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function f(){
var label = "Career"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="car" rows="4"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb2');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function d(){
var label = "Education"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="education" rows="1"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb3');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function g(){
var label = "Experience"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="expr" rows="4"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb4');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function a(){
var label = "Additional Contact Information"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="adc" rows="4"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb5');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}
function p(){
var label = "Professional Associations"
var portfolioContent = '<div class="input-field" id="id-field">' ;
portfolioContent += '<p><strong>'+label+'</p>';
portfolioContent+= '<textarea id="pas" rows="4"></textarea>'
portfolioContent += '</div>';
var labelContainer = document.getElementById('lb6');
labelContainer.innerHTML = '';
labelContainer.insertAdjacentHTML('beforeend', portfolioContent);
}