-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
74 lines (66 loc) · 3.8 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="img/pokeball.png">
<title>Pokemon</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="row" id="centro">
<div class="col-4 text-center shadow-3-strong top-0 end-0" id="pokedex">
<header></header>
<div id="d-center">
<p><span id="nombre"></span></p>
<!--sprite Normal--><p> <span id="foto"></span><br>
<!--sprite shiny--><span id="shiny"></span></p>
<hr><p>Tipo <span id="tipo"></span></p>
<p>Altura <span id="altura"></span><br>Peso <span id="peso"></span></p>
</div>
<footer></footer>
</div>
<div class="col-8 position-relative top-0 start-30 px-5" id="pokemones">
<h3 class="text-black display-2 py-4 navbar navbar-expand-lg navbar-light fixed">Pokedex</h3>
<div class="row" id="poke"></div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
for (let i=1;i<152;i++){
let pokemon ={};
$('#poke').append(`<div class="col-2 "><img id="${i}" src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${i}.png"></div>`);
// console.log (poke);
}
$('img').on('click', function(){
// $('tipo').children().remove();
const showPokemon = $(this).attr('id');
let pokes={};
console.log(showPokemon);
$.get(`https://pokeapi.co/api/v2/pokemon/${showPokemon}`,function(data){
pokes = data;
console.log (data);
$('#nombre').html(pokes.name);
$('#altura').html(pokes.height/10+'mt');
$('#peso').html(pokes.weight/10+' kg');
$('#foto').html(`<img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${showPokemon}.png">`);
$('#shiny').html(`<span>Shiny<br><img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/${showPokemon}.png">
<img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/${showPokemon}.png"></span>`);
let tipos ='';
for(let i = 0; i < pokes.types.length; i++) {
tipos += "<br><span>" + pokes.types[i].type.name + "</span>";
}
$("#tipo").html(tipos);
$("#tipo").append(types.join(' - '))
}); $('#tipo').children().remove();
});
});
</script>
</body>
</html>