-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
205 lines (185 loc) · 7.06 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
const mobileMenu = document.getElementById('mobileMenu');
const menuIcon = document.getElementById('menu-icon');
menuIcon.addEventListener('click', () => {
mobileMenu.classList.toggle('open-mobileMenu');
});
document.querySelectorAll('.menu').forEach((n) => n.addEventListener('click', () => {
mobileMenu.classList.remove('open-mobileMenu');
}));
const projects = [
{
id: 'project1',
img: {
src: './images/besu-food1.png',
alt: 'Picture of project',
},
title: 'BESA Italian Food',
list: ['CANOPY', 'Back End Dev', '2015'],
description:
'Embark on a visual journey through a captivating display of Italian culinary delights and recipes .',
languages: ['HTML', 'CSS', 'JavaScript'],
liveUrl: 'https://sanemyburg.github.io/Module2-Capstone/dist/',
sourceUrl: 'https://github.com/SaneMyburg/Module2-Capstone',
},
{
id: 'project2',
img: {
src: './images/Forexdesktop.png',
alt: 'Picture of project',
},
title: 'ForeignExchange <br> Application',
list: ['Canopy', 'Back End Dev', '2015'],
description:
'Showcases forex pairs through integration with an API.',
languages: ['HTML', 'Ruby on rails', 'css', 'javascript'],
liveUrl: 'https://sanemforex-app.netlify.app/',
sourceUrl: 'https://github.com/SaneMyburg/forex-app/tree/features',
},
{
id: 'project3',
img: {
src: './images/spacedesktop.png',
alt: 'Picture of project',
},
title: 'Space Travelors Club',
list: ['Canopy', 'Back End Dev', '2015'],
description:
'A reservation website for rockets and spaceship travelers.',
languages: ['HTML', 'React', 'css', 'javascript'],
liveUrl: 'https://our-space-misssions.onrender.com/',
sourceUrl: 'https://github.com/zdnahom/space-travelers-hub',
},
{
id: 'project4',
img: {
src: './images/budgetdesktop.png',
alt: 'Picture of project',
},
title: 'Budget App',
list: ['Canopy', 'Back End Dev', '2015'],
description:
'Elevated financial organization with a user-friendly budget application designed to effortlessly manage and streamline your expenses.',
languages: ['HTML', 'Ruby on rails', 'css', 'javascript'],
liveUrl: 'https://smartbudget-41er.onrender.com/',
sourceUrl: 'https://github.com/SaneMyburg/Budget-App-V2/tree/budget-app',
},
];
const modalOverlay = document.querySelector('.modal-overlay');
function createModal() {
projects.forEach((input) => {
modalOverlay.innerHTML += `
<div class="modal" aria-controls="${input.id}">
<h6>${input.title}</h6>
<span class="close">×</span>
<ul class="modal-list">
</ul>
<img class="modal-img" src="${input.img.src}" alt="${input.img.alt}" />
<div class="description-container">
<p class="modal-description">
${input.description}
</p>
<div class="program-language">
<ul id="language-names">
<li>${input.languages[0]}</li>
<li>${input.languages[1]}</li>
<li>${input.languages[2]}</li>
</ul>
<hr>
<div class="modal-btns">
<button id="seeLive" class="seeLiveBtn" data-url="${input.liveUrl}">
See Live
<img src="./images/see-live.png" alt="Live img" />
</button>
<button class="seeSourceBtn" data-url="${input.sourceUrl}">
See Source
<img src="./images/see-source.png" alt="Github logo" />
</button>
</div>
</div>
</div>
</div> `;
});
addEventListeners(); // eslint-disable-line no-use-before-define
}
const addEventListeners = () => {
const seeLiveBtns = document.querySelectorAll('.seeLiveBtn');
const seeSourceBtns = document.querySelectorAll('.seeSourceBtn');
const redirectToLive = (event) => {
const liveUrl = event.currentTarget.getAttribute('data-url');
window.open(liveUrl, '_blank');
};
const redirectToSource = (event) => {
const sourceUrl = event.currentTarget.getAttribute('data-url');
window.open(sourceUrl, '_blank');
};
seeLiveBtns.forEach((btn) => btn.addEventListener('click', redirectToLive));
seeSourceBtns.forEach((btn) => btn.addEventListener('click', redirectToSource));
};
createModal();
const popupOverlay = document.querySelector('.modal-overlay');
const seeProjects = document.querySelectorAll('.see-projects');
const modal = popupOverlay.querySelectorAll('.modal');
seeProjects.forEach((card) => {
card.onclick = () => {
popupOverlay.style.display = 'flex';
const link = card.getAttribute('data-card');
modal.forEach((s) => {
const button = s.getAttribute('aria-controls');
if (link === button) {
s.classList.add('active');
}
});
};
});
modal.forEach((close) => {
close.querySelector('.close').onclick = () => {
close.classList.remove('active');
popupOverlay.style.display = 'none';
};
});
const form = document.getElementById('form');
const email = document.getElementById('mail');
const errorMsg = document.getElementById('error-msg');
form.addEventListener('submit', (e) => {
const message = 'Email must be small letters';
if (email.value.toLowerCase() === email.value) {
form.submit();
} else {
e.preventDefault();
errorMsg.innerText = message;
errorMsg.style.opacity = 1;
}
});
const toggleLanguages = () => { // eslint-disable-line no-unused-vars
const languageContainer = document.getElementById('language-container');
const toggleArrow = document.getElementById('toggle-arrow');
if (languageContainer.style.display === 'none' || languageContainer.style.display === '') {
languageContainer.style.display = 'flex';
toggleArrow.innerHTML = '<img src=".images/right-pointer.svg" alt="Right arrow" />';
} else {
languageContainer.style.display = 'none';
toggleArrow.innerHTML = '<img src=".images/down-pointer.svg" alt="Down arrow" />';
}
};
const toggleFrameworks = () => { // eslint-disable-line no-unused-vars
const languageContainer = document.getElementById('framework-container');
const toggleArrow = document.getElementById('toggle-arrow');
if (languageContainer.style.display === 'none' || languageContainer.style.display === '') {
languageContainer.style.display = 'flex';
toggleArrow.innerHTML = '<img src=".images/right-pointer.svg" alt="Right arrow" />';
} else {
languageContainer.style.display = 'none';
toggleArrow.innerHTML = '<img src=".images/down-pointer.svg" alt="Down arrow" />';
}
};
const toggleSkills = () => { // eslint-disable-line no-unused-vars
const languageContainer = document.getElementById('skills-container');
const toggleArrow = document.getElementById('toggle-arrow');
if (languageContainer.style.display === 'none' || languageContainer.style.display === '') {
languageContainer.style.display = 'flex';
toggleArrow.innerHTML = '<img src=".images/right-pointer.svg" alt="Right arrow" />';
} else {
languageContainer.style.display = 'none';
toggleArrow.innerHTML = '<img src=".images/down-pointer.svg" alt="Down arrow" />';
}
};