@@ -40,7 +40,7 @@ document.addEventListener("DOMContentLoaded", async () => {
4040 } ) ;
4141 }
4242
43- const res = await fetch ( "https://pokeapi.co/api/v2/pokemon?limit=1025 " ) ;
43+ const res = await fetch ( "https://pokeapi.co/api/v2/pokemon?limit=2000 " ) ;
4444 const data = await res . json ( ) ;
4545 allPokemon = data . results ;
4646 renderPokemonList ( allPokemon ) ;
@@ -85,7 +85,7 @@ document.addEventListener("DOMContentLoaded", async () => {
8585 const id = pokemon . url . split ( "/" ) . filter ( Boolean ) . pop ( ) ;
8686 card . innerHTML = `
8787 <img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${ id } .png" alt="${ pokemon . name } " loading="lazy" />
88- <h3>${ capitalize ( pokemon . name ) } </h3>
88+ <h3>${ formatName ( pokemon . name ) } </h3>
8989 ` ;
9090 card . onclick = ( ) => {
9191 showPokemonDetails ( id , pokemon . name ) ;
@@ -106,7 +106,7 @@ function renderPokemonList(list) {
106106 <img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${ id } .png" alt="${
107107 pokemon . name
108108 } " />
109- <h3>${ capitalize ( pokemon . name ) } </h3>
109+ <h3>${ formatName ( pokemon . name ) } </h3>
110110 ` ;
111111 card . onclick = ( ) => showPokemonDetails ( id , pokemon . name ) ;
112112 pokemonList . appendChild ( card ) ;
@@ -126,7 +126,7 @@ async function showPokemonDetails(id, name) {
126126 <div class="summary-content">
127127 <div class="summary-left">
128128 <div class="stats-header">
129- <div class="stats-name">${ capitalize ( name ) } </div>
129+ <div class="stats-name">${ formatName ( name ) } </div>
130130 <div class="stats-type">
131131 ${ data . types . map ( t => `<span class="type-pill type-${ t . type . name . toLowerCase ( ) } ">${ t . type . name . toUpperCase ( ) } </span>` ) . join ( " " ) }
132132 </div>
@@ -138,7 +138,7 @@ async function showPokemonDetails(id, name) {
138138 const sName = s . stat . name === 'hp' ? 'HP' :
139139 s . stat . name === 'special-attack' ? 'Sp. Atk' :
140140 s . stat . name === 'special-defense' ? 'Sp. Def' :
141- capitalize ( s . stat . name ) ;
141+ formatName ( s . stat . name ) ;
142142 // Simple color logic based on value
143143 let color = "stat-low" ;
144144 if ( val >= 60 ) color = "stat-mid" ;
@@ -165,7 +165,7 @@ async function showPokemonDetails(id, name) {
165165 <div class="topbar-inner">
166166 <div class="left">
167167 <div class="orange-dot"></div>
168- <span class="name">${ capitalize ( name ) } </span>
168+ <span class="name">${ formatName ( name ) } </span>
169169 </div>
170170 <div class="right">
171171 <span class="gender">♂</span>
@@ -200,6 +200,15 @@ searchInput.addEventListener("input", (e) => {
200200 renderPokemonList ( filtered ) ;
201201} ) ;
202202
203- function capitalize ( str ) {
204- return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) ;
203+ function formatName ( str ) {
204+ let words = str . split ( '-' ) ;
205+ if ( words . includes ( 'mega' ) ) {
206+ words = words . filter ( w => w !== 'mega' ) ;
207+ words . unshift ( 'Mega' ) ;
208+ } else if ( words . includes ( 'gmax' ) ) { // PokeAPI uses 'gmax'
209+ words = words . filter ( w => w !== 'gmax' ) ;
210+ words . unshift ( 'Gigantamax' ) ;
211+ }
212+
213+ return words . map ( w => w . charAt ( 0 ) . toUpperCase ( ) + w . slice ( 1 ) ) . join ( ' ' ) ;
205214}
0 commit comments