-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
239 lines (216 loc) · 10.8 KB
/
main.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
const menu = document.querySelector('.menu');
const menuItems = document.querySelectorAll('.menuItem');
const hamburger = document.querySelector('.hamburger');
const closeIcon = document.querySelector('.closeIcon');
const menuIcon = document.querySelector('.menuIcon');
const toggleMenu = () => {
if (menu.classList.contains('showMenu')) {
menu.classList.remove('showMenu');
closeIcon.style.display = 'none';
menuIcon.style.display = 'block';
} else {
menu.classList.add('showMenu');
closeIcon.style.display = 'block';
menuIcon.style.display = 'none';
}
}
hamburger.addEventListener('click', toggleMenu);
menuItems.forEach((menuItem) => {
menuItem.addEventListener('click', toggleMenu);
});
// Modal Popup
const projects = [
{
name: 'Tonic',
details: ['CANOPY', 'Back End Dev', '2015'],
smallDescription:
'A daily selection of privately personalized reads; no accounts or sign-ups required.',
bigDescription:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum han printer took a galley of type and scrambled it 1960s with the releawn printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the relea",
imageUrlMobile: 'assets/photo1.png',
imageUrlDesktop: 'assets/photo1dt.png',
popupImageUrlMobile: 'assets/photo1.png',
popupImageUrlDesktop: 'assets/mydesktop.png',
technologiesPopup: [
'html',
'css',
'javaScript',
'github',
'Ruby',
'Bootstrap',
],
technologies: ['html', 'css', 'javaScript'],
linkLive: '',
linkSource: '',
},
{
name: 'Multi-Post Stories',
details: ['FACEBOOK', 'Full Stack Dev', '2015'],
smallDescription:
'Experimental content creation feature that allows users to add to an existing story over the course of a day without spamming their friends.',
bigDescription:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum han printer took a galley of type and scrambled it 1960s with the releawn printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the relea",
imageUrlMobile: 'assets/photo2.png',
imageUrlDesktop: 'assets/modalDesktop3.png',
technologiesPopup: ['html', 'Ruby on rails', 'css', 'javaScript'],
technologies: ['html', 'css', 'javaScript'],
popupImageUrlMobile: 'assets/photo2.png',
popupImageUrlDesktop: 'assets/modalDesktop3.png',
linkLive: '',
linkSource: '',
},
{
name: 'Facebook 360',
details: ['FACEBOOK', 'Full Stack Dev', '2015'],
smallDescription:
"Exploring the future of media in Facebook's first Virtual Reality app; a place to discover and enjoy 360 photos and videos on Gear VR.",
bigDescription:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum han printer took a galley of type and scrambled it 1960s with the releawn printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the relea",
imageUrlMobile: 'assets/photo3.png',
imageUrlDesktop: 'assets/modalDesktop.png',
technologiesPopup: ['html', 'Ruby on rails', 'css', 'javaScript'],
technologies: ['html', 'Ruby on rails', 'css', 'javaScript'],
popupImageUrlMobile: 'assets/photo3.png',
popupImageUrlDesktop: 'assets/modalDesktop.png',
linkLive: '',
linkSource: '',
},
{
name: 'Uber navigation',
details: ['Uber', 'Lead developer', '2018'],
smallDescription:
'A smart assistant to make driving more safe, efficient, and fun by unlocking your most expensive computer: your car.',
bigDescription:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releorem Ipsum is simply dummy text of the printing and typesetting industry.",
imageUrlMobile: 'assets/photo4.png',
imageUrlDesktop: 'assets/modalDeskto2.png',
technologiesPopup: ['html', 'Ruby on rails', 'css', 'javaScript'],
technologies: ['html', 'Ruby on rails', 'css', 'javaScript'],
popupImageUrlMobile: 'assets/images/photo4.png',
popupImageUrlDesktop: 'assets/modalDeskto2.png',
linkLive: '',
linkSource: '',
},
];
function g(e, isClass = false) {
if (isClass) {
return document.getElementsByClassName(e)[0];
}
return document.getElementById(e);
}
// eslint-disable-next-line no-unused-vars
function popup(projectIndex) {
const project = projects[projectIndex];
g('t').innerText = project.name;
g('mImage', true).src = project.imageUrlMobile;
g('mImageDsk', true).src = project.popupImageUrlDesktop;
g('modalText', true).innerText = project.bigDescription;
g('modalTextMobile', true).innerText = project.smallDescription;
g('myModal').style.display = 'block';
}
function init() {
for (let k = 0; k < projects.length; k += 1) {
const project = projects[k];
const template = document.createElement('template');
const technologies = project.technologies.map(
(t) => `<li class="langu">${t}</li>`,
);
template.innerHTML = `<div class="project-card desktop">
<div class="mobile-image">
<img src="${project.imageUrlMobile}" alt="First Card" />
</div>
<div class="desktop-image">
<img src="${project.imageUrlDesktop}" alt="First card-desktop" />
</div>
<div class="contents-two">
<h2 class="head">${project.name}</h2>
<h4 class="desktop_show">${project.name}</h4>
<div class="card-detail-box">
<ul class="cards-container">
<li class="card-detail canopy">CANOPY</li>
<li class="card-detail option">
<img src="assets/bullets.png" alt="bullet" class="circle" />
Back End Dev
</li>
<li class="card-detail option">
<img src="assets/bullets.png" alt="bullet" class="circle" />
2015
</li>
<li class="card-detail dcanopy2_face">CANOPY</li>
<li class="card-detail optiond2_full">
<img src="assets/bullets.png" alt="bullet" class="circle" />
Back End Dev
</li>
<li class="card-detail optiond2_full">
<img src="assets/bullets.png" alt="bullet" class="circle" />
2015
</li>
</ul>
<p class="instruction">${project.smallDescription}</p>
<p class="instruction-show">${project.smallDescription}</p>
<div class="language1 inline">
<ul> ${unescape(technologies.join(''))}</ul>
</div>
</div>
<button type="button" class="btn-one see-project" onclick="popup(${k})">
See project
</button>
</div>
</div>`;
g('projects').appendChild(template.content.firstChild);
}
}
const modal = document.getElementById('myModal');
const span = document.getElementsByClassName('close')[0];
// eslint-disable-next-line func-names
span.onclick = function () {
modal.style.display = 'none';
};
// eslint-disable-next-line func-names
window.onclick = function (event) {
if (event.target === modal) {
modal.style.display = 'none';
}
};
window.onload = init();
// Form Validation
const errorMessage = document.querySelector('.error-message');
const form = document.querySelector('.contact-form');
const formElement = form.querySelectorAll('input, textarea');
formElement.forEach((fe) => {
fe.addEventListener('input', () => {
errorMessage.style.display = 'none';
});
});
document.getElementById('submit').addEventListener('click', (e) => {
const email = document.getElementById('email').value;
const emailValidation = /[A-Z]/.test(email);
if (emailValidation) {
errorMessage.style.display = 'block';
e.preventDefault();
}
});
// Local-Storage
const clientName = document.getElementById('fname');
const clientEmail = document.getElementById('email');
const clientMessage = document.getElementById('textarea');
function useLocalStorage() {
const contactFormData = {
name: clientName.value,
email: clientEmail.value,
message: clientMessage.value,
};
localStorage.setItem('contactFormData', JSON.stringify(contactFormData));
}
const formInputs = document.querySelectorAll('input , textarea');
for (let j = 0; j < formInputs.length; j += 1) {
formInputs[j].addEventListener('change', () => {
useLocalStorage();
});
}
const formData = JSON.parse(localStorage.getItem('contactFormData'));
if (formData !== null) {
clientName.value = formData.name;
clientEmail.value = formData.email;
clientMessage.value = formData.message;
}