-
Notifications
You must be signed in to change notification settings - Fork 0
/
tamplates.js
53 lines (52 loc) · 2.66 KB
/
tamplates.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
// HTML ------------------------------------
function renderLoadedPokemonHTML(type, img, namePokemon, backgroundColor, allPokemon, i) {
let mainContent = document.getElementById('main-content');
let secondType = allPokemon[i]['types'][1] ? `2. type: ${allPokemon[i]['types'][1]['type']['name'].charAt(0).toUpperCase() + allPokemon[i]['types'][1]['type']['name'].slice(1)}` : '';
mainContent.innerHTML += /* HTML */ `
<div onclick="openPokedexInfo(${i})">
<div class="cards" style="background-color: ${backgroundColor};">
<div class="cards-headline">
<h2 class="padding-12">${namePokemon.charAt(0).toUpperCase() + namePokemon.slice(1)}</h2>
<span class="padding-12 bold">${allPokemon[i]['id']}</span>
</div>
<div class="cards-type">
<span>1. type: ${type.charAt(0).toUpperCase() + type.slice(1)}</span><br>
<span>${secondType}</span>
</div>
<div class="cards-img">
<img src="${img}">
</div>
</div>
</div>`;
}
function openPokedexInfoHTML(type, img, namePokemon, backgroundColor, allPokemon, i) {
let pokedexCard = document.getElementById('pokedex-card');
let secondType = allPokemon[i]['types'][1] ? `2. type: ${allPokemon[i]['types'][1]['type']['name'].charAt(0).toUpperCase() + allPokemon[i]['types'][1]['type']['name'].slice(1)}` : '';
document.getElementById('pokedex-card').classList.remove("d-none");
pokedexCard.innerHTML = /* HTML */ `
<div class="pokedex-wrapper">
<div onclick="hidePokedexCard()" id="pokedex" style="background-color: ${backgroundColor};">
<div class="cards-headline">
<h2 class="padding-12">${namePokemon.charAt(0).toUpperCase() + namePokemon.slice(1)}</h2>
<span class="padding-12 bold">${allPokemon[i]['id']}</span>
</div>
<div class="cards-type">
<span>1. type: ${type.charAt(0).toUpperCase() + type.slice(1)}</span> <br>
<span>${secondType}</span>
</div>
<div class="cards-img">
<img src="${img}">
</div>
</div>
<div class="navigation-btn">
<span onclick="previousPokemon(${i})" id="previous" src="./img/previous.png" alt="PREVIOUS"> <</span>
<br>
<span onclick="nextPokemon(${i})" id="next" src="./img/next.png" alt="NEXT">> </span>
</div>
<div onclick="hidePokedexCard()" class="info-container">
<div class="chart-container">
<canvas id="myChart"></canvas><br>
</div>
</div>
</div>`;
}