Pokedex Test
How do I make an pokedex test?
This was made during a pair programming session with an interviewee using the Poke API (pokeapi.co) and whatever front-end tooling they wanted. . What is a pokedex test? How do you make a pokedex test? This script and codes were developed by Nick Hehr on 15 August 2022, Monday.
Pokedex Test - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pokedex Test</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <main class="pokedex">
</main>
<div class="templates"> <article class="pokemon"> <h2></h2> <img src="" /> <span class="poketype"></span> </article>
</div> <script src="js/index.js"></script>
</body>
</html>
Pokedex Test - Script Codes CSS Codes
.pokedex .pokemon { width: 100%; background: #CCCCCC;
}
.pokedex .pokemon h2 { text-align: center; width: 100%; text-transform: capitalize;
}
.pokedex .pokemon img { width: 100%;
}
.pokedex .pokemon .poketype { display: block; text-align: center; text-transform: capitalize;
}
Pokedex Test - Script Codes JS Codes
(function() { var model = { list : "http://pokeapi.co/api/v2/pokemon/", pokemonList : [] /* pokemon : [{ "name": "", "url": "", "imageSrc": "" }] */ }; var controller = (function() { var pokedexElement = document.querySelector(".pokedex"), pokemonElementPointer = document.querySelector(".templates .pokemon"); function getData(url, callback) { var request = new XMLHttpRequest(); request.open('GET', url, true); request.send(); request.onload = callback; } function parseNames(progressEvent) { if (this.status === 200) { useNames(JSON.parse(this.responseText)['results']); } else { throw new Error("Bad request: " + this.status); } } function loadPokedex() { getData(model.list, parseNames); } function useNames(pokemonList) { pokemonList.forEach(function(pokemon) { getData(pokemon.url, parsePokemon); }); } function parsePokemon() { if (this.status === 200) { insertPokemonOnPage(JSON.parse(this.responseText)); } else { throw new Error("Bad request: " + this.status); } } function insertPokemonOnPage(pokemon) { var name = pokemon.name, sprite = pokemon.sprites.front_default, poketype = pokemon.types[0].type.name, pokemonElement = pokemonElementPointer.cloneNode(true); pokemonElement.querySelector("h2").innerHTML = name; pokemonElement.querySelector("img").src = sprite; pokemonElement.querySelector(".poketype").innerHTML = poketype; pokedexElement.appendChild(pokemonElement); } return { "loadPokedex" : loadPokedex }; })(); controller.loadPokedex();
})();
Developer | Nick Hehr |
Username | HipsterBrown |
Uploaded | August 15, 2022 |
Rating | 3 |
Size | 2,677 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
DogSight.js | 5,766 Kb |
A Sexy Button Hover | 4,752 Kb |
Triangular Pattern Background | 4,393 Kb |
Playing with React-Motion | 3,751 Kb |
SVG Basics | 1,852 Kb |
The CodePen Quiz | 4,944 Kb |
Lettering Pure JS | 3,522 Kb |
ATOM Icon in CSS and Animated | 6,216 Kb |
CSS Icons | 3,516 Kb |
Hexagonal Icon Backgrounds in CSS | 3,896 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Modal Dialog | Gigaleet | 2,251 Kb |
Mostly Fluid | Mccreath | 3,308 Kb |
Example SVGZ Data URI | Joeyhoer | 2,981 Kb |
Free css icon set v2 - one div | Ben_jammin | 0 Kb |
Bootstrap 4 Gridsystem Demo | Rivella50 | 1,535 Kb |
Mega Menu by Joni | Asakasinsky | 3,171 Kb |
Another brick in the wall | Fivera | 1,955 Kb |
Lunar eclipse | Ademilter | 2,056 Kb |
Perspective Origin Demo | Agelber | 3,614 Kb |
Brian The CSS Bee | Jonitrythall | 3,922 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!