generated from JohnFTitor/webpackTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (34 loc) · 971 Bytes
/
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
// Include your code here
import './styles/main.scss';
import {
displayPokemons,
displayLikes,
displayCounters,
addMenu,
} from './modules/generators.js';
import displayPopup from './modules/popup.js';
window.onload = async () => {
await displayPokemons();
await displayLikes();
displayPopup();
displayCounters();
addMenu();
};
const nav = document.querySelector('.nav');
const main = document.querySelector('main');
const linkTags = nav.querySelectorAll('a');
linkTags.forEach((tag) => {
const reGex = /#[\w-]+/g;
tag.addEventListener('click', async (event) => {
const pageId = event.target.href.match(reGex)[0];
main.innerHTML = '<h1> Pick your Favorite Pokemon! </h1>';
if (pageId === '#pokemons') {
await displayPokemons();
await displayLikes();
displayPopup();
displayCounters();
}
const navChild = document.querySelector('.nav-child');
navChild.setAttribute('data-active', 'false');
});
});