File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > PokeAPI Sprite Finder</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ </ head >
9+ < body >
10+ < div class ="header ">
11+ < h1 > PokeAPI Sprite Finder</ h1 >
12+ < button id ="themeToggle "> Toggle Theme</ button >
13+ </ div >
14+ < div class ="search-container ">
15+ < div class ="search-wrapper ">
16+ < input type ="text " id ="searchInput " placeholder ="Enter name or ID... " autocomplete ="off ">
17+ < div id ="autocomplete-list " class ="autocomplete-items "> </ div >
18+ </ div >
19+ < div id ="searchId " class ="search-id "> </ div >
20+ < div id ="searchId " class ="search-id "> </ div >
21+ < div class ="search-options ">
22+ < label > < input type ="radio " name ="searchType " value ="pokemon " checked > Pokémon</ label >
23+ < label > < input type ="radio " name ="searchType " value ="item "> Item</ label >
24+ < label > < input type ="radio " name ="searchType " value ="pokemon-form "> Pokémon Form</ label >
25+ < label > < input type ="radio " name ="searchType " value ="type "> Type</ label >
26+ </ div >
27+ < button id ="displayBtn "> Display Sprites</ button >
28+ </ div >
29+ < div id ="results " class ="results-container "> </ div >
30+ < script type ="module " src ="script.js "> </ script >
31+ </ body >
32+ </ html >
Original file line number Diff line number Diff line change 1+ const imgRe = / h t t p s : \/ \/ r a w \. g i t h u b u s e r c o n t e n t \. c o m \/ P o k e A P I \/ s p r i t e s \/ [ \/ - \w\d] + \/ [ \d \w - ] + \. (?: p n g | s v g | g i f ) /
2+ const version = 1
3+
4+ self . addEventListener ( 'fetch' , function ( event ) {
5+ if ( event . request . url . match ( imgRe ) ) {
6+ event . respondWith ( caches . match ( event . request ) . then ( function ( response ) {
7+ if ( response ) {
8+ return response
9+ }
10+
11+ return fetch ( event . request ) . then ( function ( response ) {
12+ if ( event . request . url . match ( imgRe ) ) {
13+ caches . open ( "pokeapi-js-wrapper-images-" + version ) . then ( function ( cache ) {
14+ // The response is opaque, if it fails cache.add() will reject it
15+ cache . add ( event . request . url )
16+ } )
17+ }
18+ return response ;
19+ } ) . catch ( function ( error ) {
20+ console . error ( error )
21+ } )
22+ } ) )
23+ }
24+ } )
25+
26+ self . addEventListener ( 'install' , function ( event ) {
27+ self . skipWaiting ( )
28+ } )
You can’t perform that action at this time.
0 commit comments