-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
322 lines (284 loc) · 11.4 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
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
const barIcon = document.querySelector('.bar-icon');
const mobileMenuDropdown = document.querySelector('.dropdown-menu');
const lists = document.querySelectorAll('.menu-nav-links > li');
const body = document.querySelector('.main-body');
const closeIcon = document.querySelector('.dropdown-menu-icon');
const form = document.getElementById('form');
const email = document.getElementById('email');
const userName = document.getElementById('name');
const message = document.getElementById('textarea');
barIcon.addEventListener('click', () => {
mobileMenuDropdown.style.display = 'block';
body.style.overflow = 'hidden';
});
lists.forEach((element) => {
element.addEventListener('click', () => {
mobileMenuDropdown.style.display = 'none';
body.style.overflow = 'visible';
});
});
closeIcon.addEventListener('click', () => {
mobileMenuDropdown.style.display = 'none';
body.style.overflow = 'visible';
});
userName.onchange = function updateName() {
const data = JSON.parse(window.localStorage.getItem('userData'));
data.name = userName.value;
window.localStorage.setItem('userData', JSON.stringify(data));
};
email.onchange = function updateEmail() {
const data = JSON.parse(window.localStorage.getItem('userData'));
data.email = email.value;
window.localStorage.setItem('userData', JSON.stringify(data));
};
message.onchange = function updateMessage() {
const data = JSON.parse(window.localStorage.getItem('userData'));
data.message = message.value;
window.localStorage.setItem('userData', JSON.stringify(data));
};
function saveData() {
const data = {
name: userName.value,
email: email.value,
message: message.value,
};
window.localStorage.setItem('userData', JSON.stringify(data));
}
function submitForm(e) {
e.preventDefault();
const error = document.getElementById('error');
error.className = 'error-message';
const userEmail = email.value;
if (userEmail !== userEmail.toLowerCase()) {
error.innerHTML = 'Please let your email be in lower case';
e.preventDefault();
} else {
error.innerHTML = '';
}
saveData();
}
form.onsubmit = submitForm;
function getData() {
const savedData = JSON.parse(window.localStorage.getItem('userData'));
if (savedData !== null) {
email.value = savedData.email;
userName.value = savedData.name;
message.value = savedData.message;
}
}
getData();
const details = [
{
name: 'Terappy',
description: 'Terappy is a platform where individuals with mental health issues can easily find therapist and other mental health professional. The user can find and book appointments with therapists, and also choose the medium of communication (audio / video). Weekly progress of user is monitored',
featuredImage: './assets/images/terappy-desktop.JPG',
featuredImage2: './assets/images/terappy-mobile.JPG',
technology: ['React', 'Netlify', 'MongoDB', 'Node'],
liveVersion: 'https://terappy.netlify.app/',
source: 'https://github.com/Amedzro-Elikplim/Terappy-frontend/',
btn1Name: 'See live',
btn2Name: 'See source',
},
{
name: 'Stock tracker',
description: 'Stocker tracker is built as part of Meta and Andela initiative to train developers across africa.It is software used to keep track of stocks in the health sector(clinic, hospital) etc.The frontend is built using react and CORE UI template and hosted on netlify.The backend is built with node, graphql and hosted on heroku',
featuredImage: './assets/images/tracker-desktop.JPG',
featuredImage2: './assets/images/tracker-mobile.JPG',
technology: ['React', 'Nodejs', 'Graphql', 'MongoDB'],
liveVersion: 'https://stock-tracker01.netlify.app/#/',
source: 'https://github.com/BuildForSDGCohort2/Team-235-Frontend',
btn1Name: 'See live',
btn2Name: 'See source',
},
{
name: 'Minimalist',
description: 'A simple Todo app to add list of books a user has read. It is implemented using HTML, CSS, Webpack, JavaScript and modular architecture. A todo is saved and displayed in Realtime. A todo can be removed from the list of to-dos. Data persistence is implemented using local Storage API.',
featuredImage: './assets/images/minimalist-desktop.JPG',
featuredImage2: './assets/images/minimalist-mobile.JPG',
technology: ['Html', 'Css', 'Javascript', 'Webpack'],
liveVersion: 'https://amedzro-elikplim.github.io/Minimalist/dist/',
source: 'https://github.com/Amedzro-Elikplim/Minimalist',
btn1Name: 'See live',
btn2Name: 'See source',
},
{
name: 'Hacfiery Developers Summit',
description: 'This is a platform dedicated to Hackfiery Developers Global Summit 2022. It showcase the speakers, previous conferences and their respective locations',
featuredImage: './assets/images/hackfiery-desktop.JPG',
featuredImage2: './assets/images/hackfiery-mobile.JPG',
technology: ['Html', 'CSS', 'Javascript', 'Boostrap'],
liveVersion: 'https://amedzro-elikplim.github.io/Hacfiery-Developers/',
source: 'https://github.com/Amedzro-Elikplim/Hacfiery-Developers',
btn1Name: 'See live',
btn2Name: 'See source',
},
{
name: 'Leaderboard',
description: 'The leaderboard website displays scores submitted by different players. It also allows you to submit your score. All data is preserved thanks to an external Leaderboard API service.',
featuredImage: './assets/images/leaderboard-desktop.JPG',
featuredImage2: './assets/images/leaderboard-mobile.JPG',
technology: ['Javascript', 'REST API', 'HTML', 'CSS'],
liveVersion: 'https://amedzro-elikplim.github.io/Leaderboard/dist/',
source: 'https://github.com/Amedzro-Elikplim/Leaderboard',
btn1Name: 'See live',
btn2Name: 'See source',
},
{
name: 'MadLib Game',
description: 'Mad Libs is the world’s greatest word game and can make anyone the funniest person in the room! Mad Libs are stories with words removed and replaced by blank spaces. One player acts as the “reader” and asks the other players, who haven’t seen the story, to fill in the blanks with adjectives, nouns, exclamations, colors, adjectives, and more. These words are inserted into the blanks and thenthe story is read aloud to hilarious results. For more information visit [ http://www.madlibslive.com/whats-a-mad-lib ].',
featuredImage: './assets/images/madlib-desktop.JPG',
featuredImage2: './assets/images/madlib-mobile.JPG',
technology: ['Javascript', 'Bootstrap', 'HTML', 'CSS'],
liveVersion: 'https://amedzro-elikplim.github.io/Madlibs/',
source: 'https://github.com/Amedzro-Elikplim/Madlibs',
btn1Name: 'See live',
btn2Name: 'See source',
},
];
const workSection = document.querySelector('.work-section');
const arrClassName = ['project', 'project-reverse project', 'project', 'project-reverse1 project', 'project', 'project-reverse project'];
const arrInfo = [
'project-info-container1',
'project-info-container2',
'project-info-container3',
'project-info-container4',
];
const popInfo = [
'project-info-container1',
'project-info-container2',
'project-info-container3',
'project-info-container4',
];
function heading(name) {
const heading = document.createElement('h1');
heading.innerHTML = name;
heading.className = 'heading';
return heading;
}
function description(descrip) {
const description = document.createElement('p');
description.innerHTML = descrip;
description.className = 'description';
return description;
}
function projectImage(image, image2) {
const projectImage = document.createElement('img');
const source = (window.innerWidth < 700) ? image2 : image;
projectImage.src = source;
projectImage.className = 'projectImage';
return projectImage;
}
function liveLink(liveVersion) {
const link1 = document.createElement('a');
const div1 = document.createElement('div');
const div2 = document.createElement('div');
link1.append(div1, div2);
div1.innerHTML = details[0].btn1Name;
div2.innerHTML = '<i class="fas fa-external-link-alt"></i>';
link1.href = liveVersion;
link1.className = 'links';
return link1;
}
function sourceLink(source) {
const link2 = document.createElement('a');
const div1 = document.createElement('div');
const div2 = document.createElement('div');
div1.innerHTML = details[0].btn2Name;
div2.innerHTML = '<i class="fab fa-github"></i>';
link2.href = source;
link2.append(div1, div2);
link2.className = 'links';
return link2;
}
function popup(name, descrip, image, image2, projectName, liveVersion, source) {
const desktopProjectContainer = document.querySelector('.project');
const projectContainer = document.querySelector(name);
const backgroundDiv = document.createElement('div');
const container = document.createElement('div');
const closeIcon = document.createElement('div');
const technology = document.createElement('ul');
const buttonWrapper = document.createElement('div');
buttonWrapper.className = 'button-wrapper';
technology.className = 'list';
container.className = 'project-container';
backgroundDiv.className = 'background-div';
closeIcon.innerHTML = '<i class="fas fa-times"></i>';
closeIcon.className = 'close-button';
container.classList.add('visible');
backgroundDiv.classList.add('scroll');
heading(projectName);
description(descrip);
projectImage(image, image2);
const arr = details[0].technology;
for (let i = 0; i < arr.length; i += 1) {
const link = document.createElement('li');
link.innerHTML = arr[i];
technology.appendChild(link);
}
closeIcon.addEventListener('click', () => {
container.classList.toggle('hidden');
body.classList.remove('noScroll');
backgroundDiv.classList.toggle('hidden');
});
buttonWrapper.append(liveLink(liveVersion), sourceLink(source));
container
.append(closeIcon,
heading(projectName),
projectImage(image, image2), description(descrip), technology, buttonWrapper);
backgroundDiv.appendChild(container);
const attach = window.innerWidth < 567 ? projectContainer : desktopProjectContainer;
attach.appendChild(backgroundDiv);
}
function projectTemplate(className, infoContainer, popInfo,
description, name, image, image2, liveVersion, source, tech1, tech2, tech3, tech4) {
const project = `
<div class=${className}>
<div class="project-image-container">
<img
src= ${image}
alt="project image"
class="project-image"
/>
</div>
<div>
<div class=${infoContainer}>
<h2 class="project-name">${name}</h2>
<p class="project-description">
${description}
</p>
</div>
<button onclick="popup('.${popInfo}', '${description}', '${image}', '${image2}', '${name}', '${liveVersion}', '${source}')" class="project-button project-button1">See project</button>
<div class="technologies">
<ul>
<li>${tech1}</li>
<li>${tech2}</li>
<li>${tech3}</li>
<li>${tech4}</li>
</ul>
</div>
</div>
</div>
`;
return project;
}
for (let i = 0; i < details.length; i += 1) {
workSection.innerHTML += projectTemplate(
arrClassName[i],
arrInfo[i],
popInfo[i],
details[i].description,
details[i].name,
details[i].featuredImage,
details[i].featuredImage2,
details[i].liveVersion,
details[i].source,
details[i].technology[0],
details[i].technology[1],
details[i].technology[2],
details[i].technology[3],
);
}
const mobile = 'small';
if (mobile === 'large') {
popup();
}