Pokémon Guesser
About this app
Guess the Pokémon based on the National Dex number
Pokémon Guesser Pokémon Guesser Enter the National Dex number: Guess
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Pokémon Guesser</title>
<meta name="description" content="Guess the Pokémon based on the National Dex number">
<meta name="keywords" content="Pokémon, National Dex, guess">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
// Function to guess the Pokémon based on the National Dex number
function guessPokemon() {
// Get the user input
const input = document.getElementById("dex-number").value.trim();
// Validate the input
if (input === "") {
alert("Please enter a National Dex number.");
return;
}
const dexNumber = parseInt(input);
if (isNaN(dexNumber)) {
alert("Invalid National Dex number. Please enter a valid number.");
return;
}
// Make a fetch request to the Pokémon API
fetch(`https://pokeapi.co/api/v2/pokemon-species/${dexNumber}`)
.then(response => response.json())
.then(data => {
// Get the Pokémon name
const pokemonName = data.name;
// Display the result
document.getElementById("result").innerHTML = `You are thinking of <strong>${pokemonName}</strong>!`;
})
.catch(error => {
console.log("An error occurred:", error);
alert("An error occurred while fetching the Pokémon data. Please try again later.");
});
}
// Add event listener to the guess button
document.getElementById("guess-button").addEventListener("click", guessPokemon);
});
} catch (error) {
throw error;
}
</script>
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f7f7f7;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.form-group {
margin-bottom: 20px;
}
label {
font-weight: bold;
color: #333;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.btn {
display: block;
width: 100%;
padding: 10px;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn:hover {
background-color: #555;
}
#result {
text-align: center;
margin-top: 20px;
color: #333;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Pokémon Guesser</h1>
<div class="form-group">
<label for="dex-number">Enter the National Dex number:</label>
<input type="text" id="dex-number" placeholder="e.g. 25">
</div>
<button id="guess-button" class="btn">Guess</button>
<div id="result"></div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!