File size: 1,114 Bytes
7a095ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Sample Pokémon data (extend to #251 in practice)
const pokemonData = [
    { id: "001", name_jp: "フシギダネ", name_en: "bulbasaur" },
    { id: "002", name_jp: "フシギソウ", name_en: "ivysaur" },
    { id: "003", name_jp: "フシギバナ", name_en: "venusaur" },
    { id: "152", name_jp: "チコリータ", name_en: "chikorita" },
    { id: "251", name_jp: "セレビィ", name_en: "celebi" }
    // Add all Pokémon #1 to #251 here
];

// Populate the Pokémon list
const pokemonList = document.getElementById("pokemon-list");
pokemonData.forEach(pokemon => {
    const li = document.createElement("li");
    li.textContent = `${pokemon.id} ${pokemon.name_jp}`;
    li.setAttribute("data-name-en", pokemon.name_en);
    pokemonList.appendChild(li);

    // Add click event listener
    li.addEventListener("click", () => {
        const spriteUrl = `https://play.pokemonshowdown.com/sprites/ani/${pokemon.name_en}.gif`;
        document.getElementById("pokemon-sprite").src = spriteUrl;
        document.getElementById("pokemon-info").textContent = `${pokemon.id} ${pokemon.name_jp}`;
    });
});