diff --git a/PokeDex/.DS_Store b/PokeDex/.DS_Store new file mode 100644 index 0000000..353d97d Binary files /dev/null and b/PokeDex/.DS_Store differ diff --git a/PokeDex/Images/pokeball.jpeg b/PokeDex/Images/pokeball.jpeg new file mode 100644 index 0000000..7ad00cc Binary files /dev/null and b/PokeDex/Images/pokeball.jpeg differ diff --git a/PokeDex/Images/pokemon-bg.jpeg b/PokeDex/Images/pokemon-bg.jpeg new file mode 100644 index 0000000..8c64c6c Binary files /dev/null and b/PokeDex/Images/pokemon-bg.jpeg differ diff --git a/PokeDex/README.md b/PokeDex/README.md new file mode 100644 index 0000000..08b839f --- /dev/null +++ b/PokeDex/README.md @@ -0,0 +1,13 @@ +PokeDex +Welcome to PokeDex, a simple web application that allows you to explore information about different Pokémon! This project utilizes HTML, CSS, and JavaScript to create a user-friendly interface for viewing Pokémon details. + +Features +1)Pokemon Information Display: The main section of the application displays information about a selected Pokémon, including its image, types, and a brief description. +2)Pokemon List: On the right side of the application, you can find a list of Pokémon. Click on any Pokémon in the list to view its details. +3)Type Highlighting: Each Pokémon type is represented by a distinct color, making it easy to identify the types at a glance. + +Customization +You can customize the background image by replacing the URL in the body CSS rule in the style.css file. + +API Integration +This PokeDex fetches data from the PokeAPI, a comprehensive Pokémon database. The JavaScript code in script.js uses the API to retrieve information about each Pokémon. \ No newline at end of file diff --git a/PokeDex/index.html b/PokeDex/index.html new file mode 100644 index 0000000..eaa7460 --- /dev/null +++ b/PokeDex/index.html @@ -0,0 +1,24 @@ + + + + + + PokeDex + + + + +
+
+ +
+ GRASSPOISON +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/PokeDex/script.js b/PokeDex/script.js new file mode 100644 index 0000000..13c3323 --- /dev/null +++ b/PokeDex/script.js @@ -0,0 +1,62 @@ +const pokemonCount = 500; +var pokedex = {}; + +window.onload = async function(){ + getPokemon(1); + for(let i=1; i<=pokemonCount; i++){ + await getPokemon(i); + + let pokemon = document.createElement("div"); + pokemon.id = i; + pokemon.innerText = i.toString() + ". " + pokedex[i]["name"].toUpperCase(); + pokemon.classList.add("pokemon-name"); + pokemon.addEventListener("click", updatePokemon); + document.getElementById("pokemon-list").append(pokemon); + } + + document.getElementById("pokemon-description").innerText = pokedex[1]["desc"]; + + console.log(pokedex) +} + +async function getPokemon(num){ + let url = "https://pokeapi.co/api/v2/pokemon/" + num.toString(); + + let res = await fetch(url); + let pokemon = await res.json(); + + //console.log(pokemon) + + let pokemonName = pokemon["name"]; + let pokemonType = pokemon["types"]; + let pokemonImg = pokemon["sprites"]["front_default"]; + + res = await fetch(pokemon["species"]["url"]); + let pokemonDesc = await res.json(); + + //console.log(pokemonDesc); + + pokemonDesc = pokemonDesc["flavor_text_entries"][5]["flavor_text"] + + pokedex[num] = {"name" : pokemonName, "img" : pokemonImg, "types" : pokemonType, "desc" : pokemonDesc} +} + +function updatePokemon(){ + document.getElementById("pokemon-img").src = pokedex[this.id]["img"]; + + let typesDiv = document.getElementById("pokemon-types"); + while(typesDiv.firstChild){ + typesDiv.firstChild.remove(); + } + + let types = pokedex[this.id]["types"]; + for(let i=0; i