Browse Source

add show all option

Kirk Trombley 2 years ago
parent
commit
b2e22585b9
2 changed files with 10 additions and 1 deletions
  1. 1 0
      web/index.html
  2. 9 1
      web/main.js

+ 1 - 0
web/index.html

@@ -338,6 +338,7 @@
         />
         <button form="nameSearchForm" type="button" name="random">Random Pokemon</button>
         <button form="nameSearchForm" type="button" name="clear">Clear</button>
+        <button form="nameSearchForm" type="button" name="all">Show All (slow)</button>
       </div>
     </div>
 

+ 9 - 1
web/main.js

@@ -305,10 +305,13 @@ const createPokemonTile = makeTemplate(
       .replace("tapu ", "tapu-")
       .replace("urshifu-gigantamax", "urshifu-gigantamax-single-strike")
       .replace("urshifu-rapid-strike-gigantamax", "urshifu-gigantamax-rapid-strike")
+      .replace("calyrex-shadow", "calyrex-shadow-rider")
+      .replace("calyrex-ice", "calyrex-ice-rider")
       .replace("chienpao", "chien-pao")
       .replace("tinglu", "ting-lu")
       .replace("wochien", "wo-chien")
-      .replace("chiyu", "chi-yu");
+      .replace("chiyu", "chi-yu")
+      .replace(" ", "-");
     if (
       [
         "flabebe",
@@ -563,6 +566,11 @@ nameSearchFormElements.input.addEventListener("input", ({ target: { value } }) =
   );
 });
 
+nameSearchFormElements.all.addEventListener("click", () => {
+  nameSearchFormElements.input.value = "";
+  model.setNameSearchResults(pokemonData.slice(0));
+});
+
 nameSearchFormElements.clear.addEventListener("click", () => {
   nameSearchFormElements.input.value = "";
   model.setNameSearchResults([]);