-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
341 lines (267 loc) · 10.6 KB
/
index.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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
// Toogle Mobile Menu
const menu = document.querySelector('.mobileMenu');
const mobileMenu = document.querySelector('.menu-mobile');
const toggleMenu = () => {
mobileMenu.classList.toggle('showMenu');
};
menu.addEventListener('click', () => toggleMenu());
mobileMenu.addEventListener('click', () => toggleMenu());
// Toogle pop Up Menu
const projects = [
{
id: 1,
title: 'EthioItSupport',
tech: ['html', 'Bootstrap', 'Ruby on rails'],
image: 'images/eits-cover.png',
card_img: 'images/ethioitsupport-bg.png',
description:
"EthioItSupport is an on-site and remote IT support company. Also engaged in web development and hosting services.A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
shortDesc:
'A web design for a Web development company. Tailored made with bootstap to the clients need.',
liveLink: 'https://ethioitsupport.com/',
sourceCode: 'https://github.com/abeltsew/ethioitsupport',
},
{
id: 2,
title: 'Friends conf',
tech: ['html', 'Bootstrap', 'Ruby on rails'],
image: 'images/friends-cover.png',
card_img: 'images/friends-bg.png',
description:
"Welcome to the Friends TV show cast reunion event! Join us for a night full of surprises, special guests, and the iconic cast members sharing their memories and behind-the-scenes stories. Let's celebrate the magic of Friends together! Taking place in Addis Ababa on April 2023.",
shortDesc:
'Friends Reunion Conference and Ticket purchase site. This is built with Javascript for interaction.',
liveLink: 'https://abeltsew.github.io/friends/',
sourceCode: 'https://github.com/abeltsew/friends',
},
{
id: 3,
title: 'Protfolio',
tech: ['html', 'Bootstrap', 'Ruby on rails'],
image: 'images/portfolio-cover.png',
card_img: 'images/portfolio-bg.png',
description:
"I can help you build a product , feature or website Look through some of my work and experience! If you like what you see and have a project you need coded, don't hestiate to contact me.",
shortDesc:
'This is showcase of my latest work and experience. You can find my various amazing projects in here.',
liveLink: 'https://abeltsew.github.io/portfolio/',
sourceCode: 'https://github.com/abeltsew/portfolio',
},
];
const popUpDetail = (project) => {
const modal = document.querySelector('.modal');
modal.classList.toggle('showModal');
const dark = document.querySelector('.work');
dark.style.backgroundColor = '#000';
const modalContent = document.createElement('div');
modalContent.classList.add('modal-content');
const modalTitle = document.createElement('div');
modalTitle.classList.add('modal-title');
const modalHeading = document.createElement('h2');
modalHeading.classList.add('modal-heading');
modalHeading.innerHTML = project.title;
const modalClose = document.createElement('h2');
modalClose.classList.add('modal-close');
modalClose.innerHTML = 'x';
const modalBtns = document.createElement('div');
modalBtns.classList.add('modal-btns');
const modalCardBtns = document.createElement('ul');
modalCardBtns.classList.add('modalCardBtns');
project.tech.forEach((techno) => {
const li = document.createElement('li');
const modalCardBtn = document.createElement('button');
modalCardBtn.classList.add('modalCardBtn');
modalCardBtn.innerHTML = techno;
li.appendChild(modalCardBtn);
modalCardBtns.appendChild(li);
});
modalBtns.appendChild(modalCardBtns);
modalTitle.appendChild(modalHeading);
modalTitle.appendChild(modalClose);
modalContent.appendChild(modalTitle);
modalContent.appendChild(modalBtns);
const modalImgDesc = document.createElement('div');
modalImgDesc.classList.add('modal-img-desc');
const modalImg = document.createElement('img');
modalImg.classList.add('modal-img');
modalImg.src = project.image;
modalImg.alt = 'Project wallpaper';
modalImgDesc.appendChild(modalImg);
const modalDescBtns = document.createElement('div');
modalDescBtns.classList.add('modal-desc-btns');
const modalDesc = document.createElement('p');
modalDesc.classList.add('modal-desc');
modalDesc.innerHTML = project.description;
modalDescBtns.appendChild(modalDesc);
const modalLinks = document.createElement('div');
modalLinks.classList.add('modal-links');
const modalLink = document.createElement('button');
modalLink.classList.add('modal-link');
modalLink.innerHTML = 'See Live';
modalLink.addEventListener('click', () => {
window.location.href = project.liveLink;
});
const liveImg = document.createElement('img');
liveImg.src = 'images/live-link.png';
modalLink.appendChild(liveImg);
modalLinks.appendChild(modalLink);
const modalLinkSource = document.createElement('button');
modalLinkSource.classList.add('modal-link');
modalLinkSource.innerHTML = 'See Source';
modalLinkSource.addEventListener('click', () => {
window.location.href = project.sourceCode;
});
const sourceImg = document.createElement('img');
sourceImg.src = 'images/source-link.png';
modalLinkSource.appendChild(sourceImg);
modalLinks.appendChild(modalLink);
modalLinks.appendChild(modalLinkSource);
modalDescBtns.appendChild(modalLinks);
modalImgDesc.appendChild(modalDescBtns);
modalContent.appendChild(modalImgDesc);
modal.appendChild(modalContent);
// close the Modal
const modalCloseBtn = document.querySelector('.modal-close');
modalCloseBtn.addEventListener('click', () => {
modal.classList.add('showModal');
modal.removeChild(modalContent);
const dark = document.querySelector('.work');
dark.style.backgroundColor = '#fff';
});
};
// Build Main project card
const mainProject = {
title: 'EthioItSupport',
mainImage: 'images/eits-cover.png',
image: 'images/eits-cover.png',
alt: 'Main project container',
description:
'Our web design company understands that driving “Revenue” is your bottom line. Our expert optimization techniques with tailored digital marketing solutions will transform simple landing pages into powerful digital selling tools.',
tech: ['CSS', 'HTML', 'Bootstrap', 'Ruby'],
};
const mainProjectInfo = document.querySelector('.projects');
const mainImg = document.createElement('img');
mainImg.classList.add('projectImg');
mainImg.src = mainProject.mainImage;
mainImg.alt = mainProject.alt;
mainProjectInfo.appendChild(mainImg);
const projectInfo = document.createElement('div');
projectInfo.classList.add('projectInfo');
const projectTitle = document.createElement('h2');
projectTitle.classList.add('projectTitle');
projectTitle.innerHTML = mainProject.title;
projectInfo.appendChild(projectTitle);
const projectDesc = document.createElement('p');
projectDesc.classList.add('projectDesc');
projectDesc.innerText = mainProject.description;
projectInfo.appendChild(projectDesc);
const tools = document.createElement('ul');
tools.classList.add('tools');
mainProject.tech.forEach((techno) => {
const li = document.createElement('li');
const btn = document.createElement('button');
btn.classList.add('toolsBtn');
btn.innerHTML = techno;
li.appendChild(btn);
tools.appendChild(li);
});
projectInfo.appendChild(tools);
const mainSeeBtn = document.createElement('button');
mainSeeBtn.classList.add('mainSeeBtn');
mainSeeBtn.innerHTML = 'See Project';
mainSeeBtn.addEventListener('click', () => popUpDetail(mainProject));
projectInfo.appendChild(mainSeeBtn);
mainProjectInfo.appendChild(projectInfo);
// build card
projects.forEach((project) => {
const cards = document.querySelector('.cards');
const cardContainer = document.createElement('div');
cardContainer.classList.add('cardContainer');
const card = document.createElement('div');
card.classList.add('card');
card.style.background = `linear-gradient(179.35deg, rgba(38, 38, 38, 0) 0.85%, rgba(38, 38, 38, 0.9) 84%),url(${
project.card_img ? './' + project.card_img : './images/card-bg.png'
})`;
card.style.backgroundPosition = 'center';
const cardTitle = document.createElement('h2');
cardTitle.innerHTML = project.title;
card.appendChild(cardTitle);
const cardDesc = document.createElement('p');
cardDesc.innerHTML = project.shortDesc;
card.appendChild(cardDesc);
const cardBtns = document.createElement('ul');
cardBtns.classList.add('cardBtns');
project.tech.forEach((btn) => {
const li = document.createElement('li');
const cardBtn = document.createElement('button');
cardBtn.classList.add('cardBtn');
cardBtn.innerHTML = btn;
li.appendChild(cardBtn);
cardBtns.appendChild(li);
});
card.appendChild(cardBtns);
cardContainer.appendChild(card);
// create and add see Button
const seeBtn = document.createElement('button');
seeBtn.classList.add('cardSeeProj');
seeBtn.id = project.id;
seeBtn.innerHTML = 'See project';
seeBtn.addEventListener('click', () => popUpDetail(project));
cardContainer.appendChild(seeBtn);
cards.appendChild(cardContainer);
});
// Form Validation
const form = document.querySelector('form');
const { email } = form.elements;
const error = document.querySelector('.error');
error.style.display = 'none';
const showError = (isError) => {
error.style.textAlign = 'center';
const emailField = document.getElementById('email');
if (isError) {
error.innerHTML = 'Email should be in Lower case';
error.style.display = 'inline';
emailField.style.borderBottom = 'solid red 1px';
} else {
error.innerHTML = '';
error.style.display = 'none';
emailField.style.border = 'none';
}
};
form.addEventListener('submit', (e) => {
e.preventDefault();
showError(false);
const isLowerCase = email.value === email.value.toLowerCase();
if (isLowerCase) {
form.submit();
localStorage.removeItem('formInput');
} else {
showError(true);
}
});
// Save to Local storage
const formInput = JSON.parse(localStorage.getItem('formInput')) || {
fullName: '',
email: '',
message: 'Hello Abel, I would like to get in touch with you...',
};
const saveFormInput = (key, value) => {
formInput[key] = value;
localStorage.setItem('formInput', JSON.stringify(formInput));
};
const fullName = document.getElementById('fullName');
fullName.value = formInput.fullName;
fullName.addEventListener('keyup', (e) => {
saveFormInput('fullName', e.target.value);
});
// add email and message local storage
const emailInput = document.getElementById('email');
emailInput.value = formInput.email;
emailInput.addEventListener('keyup', (e) => {
saveFormInput('email', e.target.value);
});
const message = document.getElementById('message');
message.value = formInput.message;
message.addEventListener('keyup', (e) => {
saveFormInput('message', e.target.value);
});