All checks were successful
DEPLOY / deploy (push) Successful in 7s
feat: add new project pages for Crazy Space, Pokemon Kreye edition, Pycord, and others fix: update project descriptions for clarity and accuracy style: format JavaScript code for better readability and consistency
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
var pokemons = [6, 26, 260, 282, 297, 380];
|
|
|
|
function chose_random_pokemon() {
|
|
let randnum = Math.floor(Math.random() * pokemons.length);
|
|
let imageToDisplay =
|
|
"/static/assets/images/pokemons/" + pokemons[randnum] + ".png";
|
|
get_name(pokemons[randnum]);
|
|
get_desc(pokemons[randnum]);
|
|
document.getElementById("pokemon_frame").src = imageToDisplay;
|
|
}
|
|
|
|
function get_name(number) {
|
|
fetch("https://pokeapi.co/api/v2/pokemon/" + number)
|
|
.then(function (response) {
|
|
return response.json();
|
|
})
|
|
.then(function (pokemon_data) {
|
|
let name = pokemon_data.name;
|
|
document.getElementById("pokemon_name").textContent = name;
|
|
})
|
|
.catch(function (err) {
|
|
console.log("Fetch Error :-S", err);
|
|
});
|
|
}
|
|
|
|
function get_desc(number) {
|
|
fetch("https://pokeapi.co/api/v2/pokemon-species/" + number)
|
|
.then(function (response) {
|
|
return response.json();
|
|
})
|
|
.then(function (pokemon_data) {
|
|
let desc = pokemon_data.flavor_text_entries[0].flavor_text;
|
|
document.getElementById("pokemon_desc").textContent = desc;
|
|
})
|
|
.catch(function (err) {
|
|
console.log("Fetch Error :-S", err);
|
|
});
|
|
}
|