-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
140 lines (127 loc) · 4.55 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
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
document.querySelectorAll('.nav-link').forEach((n) => n.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}));
/* Pop up menu */
const projectList = [
{
title: 'Tonic',
description:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys 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.',
imageURL: 'assets/images/desktop-img-1.png',
company: 'CANOPY',
role: 'Back End Dev',
year: '2015',
tags: ['html', 'css', 'javascript', 'github', 'ruby', 'Bootstraps'],
},
{
title: 'Multi-Post Stories',
description:
'Experimental content creation feature that allows users to add to an existing story over the course of a day without spamming their friends.',
imageURL: 'assets/images/desktop-img2.png',
company: 'FACEBOOK',
role: 'Full Stack Dev',
year: '2015',
tags: ['html', 'css', 'javascript', 'github'],
},
{
title: 'Facebook 360',
description:
'AExploring the future of media in Facebook`s first Virtual Realityapp; a place to discover and enjoy 360 photos and videos onGear VR',
imageURL: 'assets/images/desktop-img3.png',
company: 'FACEBOOK',
role: 'Full Stack Dev',
year: '2015',
tags: ['html', 'css', 'javascript'],
},
{
title: 'Uber Navigation',
description:
'A smart assistant to make driving more safe, efficient, and fun by unlocking your most expensive computer: your car.',
imageURL: 'assets/images/desktop-img4.png',
company: 'Uber',
role: 'Lead Developer',
year: '2018',
tags: ['html', 'css', 'javascript'],
},
];
const pageBody = document.querySelector('body');
const submitBtn = document.querySelectorAll('.submit-btn');
for (let i = 0; i < projectList.length; i += 1) {
submitBtn[i].addEventListener('click', () => {
const popupContainer = document.createElement('div');
popupContainer.className = 'popup_container';
popupContainer.innerHTML = `
<div class='popup'>
<div class='popup_head'>
<h2>${projectList[i].title}</h2>
<span class='closeBtn' >X</span>
</div>
<div class="popup_body">
<div>${projectList[i].company} . ${projectList[i].role} . ${
projectList[i].year
} </div>
<img src=${projectList[i].imageURL} >
<div class="popup_details">
<p>${projectList[i].description}</p>
<div class='popup_tags_links'>
<div class='popup_tags'>
${projectList[i].tags
.map((tech) => ` <span class='tech'> ${tech} </span> `)
.join(' ')}
</div>
<div>
<button class='popup_btn'>See Live <img src="assets/images/Icon.png" ></button>
<button class='popup_btn'>See Source <img src="assets/images/github.svg"></button>
</div>
</div>
</div>
</div>
</div>
`;
pageBody.prepend(popupContainer);
const closeBtn = document.querySelector('.closeBtn');
closeBtn.addEventListener('click', () => {
pageBody.removeChild(popupContainer);
});
});
}
/* Form Validation */
const email = document.getElementById('email');
const form = document.getElementById('input');
const displayMsg = document.getElementById('form-message-error');
form.addEventListener('submit', (event) => {
if (email.value !== email.value.toLowerCase()) {
event.preventDefault();
displayMsg.style.visibility = 'visible';
displayMsg.classList.add('error-message');
displayMsg.textContent = 'Your email address should be in lowercase';
} else {
displayMsg.style.visibility = 'hidden';
}
});
/* Local Storage */
let userDetails = {
name: '',
email: '',
message: '',
};
if (localStorage.getItem('savedDetails') !== null) {
const finalDetails = localStorage.getItem('savedDetails');
userDetails = JSON.parse(finalDetails);
}
const input = document.querySelectorAll('input, textarea');
input.forEach((item) => {
item.value = userDetails[item.name];
item.addEventListener('input', (e) => {
userDetails[e.target.name] = e.target.value;
const userData = JSON.stringify(userDetails);
localStorage.setItem('savedDetails', userData);
});
});