Widget:Test: mudanças entre as edições

De PokeXGames
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
Linha 53: Linha 53:
             width: 30px;
             width: 30px;
             height: 30px;
             height: 30px;
        }
        .who-drops {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        .who-drops-item {
            display: flex;
            align-items: center;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 8px;
         }
         }
     </style>
     </style>
Linha 77: Linha 91:
                         "name": "Bulbasaur"
                         "name": "Bulbasaur"
                     },
                     },
                     // outros dados omitidos para simplicidade...
                     {
                        "id": 1,
                        "icon": "https://wiki.pokexgames.com/images/5/5c/001-Bulbasaur.png",
                        "link": "https://wiki.pokexgames.com/index.php/Bulbasaur",
                        "name": "Bulbasaur"
                    },
                 ]
                 ]
             },
             },
Linha 99: Linha 118:
                             "quantity": 10,
                             "quantity": 10,
                             "id": 532
                             "id": 532
                         },
                         },                      
                         {
                         {
                             "name": "Lovely Topknot",
                             "name": "Lovely Topknot",
                             "icon": "https://wiki.pokexgames.com/images/e/e9/Lovely_Topknot.png",
                             "icon": "https://wiki.pokexgames.com/images/e/e9/Lovely_Topknot.png",
                             "isNightmare": true,
                             "isNightmare": true,
                             "quantity":20,
                             "quantity": 20,
                             "id": 532
                             "id": 532
                         },
                         },
                        // outros materiais omitidos para simplicidade...
                     ]
                     ]
                 }
                 }
Linha 157: Linha 175:
                         </div>`).join("")}
                         </div>`).join("")}
                     </div>
                     </div>
                </div>`;
            }
            if (data.whoDrops) {
                content.innerHTML += `
                <h3>Quem Droppa</h3>
                <div class="who-drops">
                    ${data.whoDrops.map((drop) => `
                    <div class="who-drops-item">
                        <a href="${drop.link}" target="_blank">
                            <img class="item-name-icon" src="${drop.icon}" />
                            ${drop.name}
                        </a>
                    </div>`).join("")}
                 </div>`;
                 </div>`;
             }
             }

Edição das 02h27min de 23 de agosto de 2024

<!DOCTYPE html> <html lang="pt-BR"> <head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Item Search</title>
   <style>
       .suggest-icon {
           max-width: 20px;
           max-height: 20px;
       }
       #suggest {
           max-height: 300px;
           max-width: 300px;
           overflow-y: scroll;
           overflow-x: hidden;
       }
       .item-name {
           display: flex;
           align-items: center;
       }
       .item-name-icon {
           max-width: 30px;
           margin-right: 8px;
       }
       .craft p {
           margin: 0;
       }
       .materials {
           display: flex;
           align-items: center;
           flex-wrap: wrap;
           gap: 8px;
       }
       .item-from-craft {
           display: flex;
           align-items: center;
           padding: 8px 12px;
           border: 1px solid #ccc;
           border-radius: 8px;
       }
       .material-icon-container {
           display: flex;
           align-items: center;
           justify-content: center;
           width: 30px;
           height: 30px;
       }
       .who-drops {
           display: flex;
           flex-wrap: wrap;
           gap: 8px;
       }
       .who-drops-item {
           display: flex;
           align-items: center;
           padding: 8px;
           border: 1px solid #ccc;
           border-radius: 8px;
       }
   </style>

</head> <body>

   <input type="text" id="search" placeholder="Busque um item..." />
   <script>
       // Base de dados local
       const allData = [
           {
               "id": 18,
               "name": "Bag of Pollen",
               "icon": "https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png",
               "link": "https://wiki.pokexgames.com/index.php/Bag_Of_Pollem",
               "isNightmare": false,
               "whoDrops": [
                   {
                       "id": 1,
                       "icon": "https://wiki.pokexgames.com/images/5/5c/001-Bulbasaur.png",
                       "link": "https://wiki.pokexgames.com/index.php/Bulbasaur",
                       "name": "Bulbasaur"
                   },
                   {
                       "id": 1,
                       "icon": "https://wiki.pokexgames.com/images/5/5c/001-Bulbasaur.png",
                       "link": "https://wiki.pokexgames.com/index.php/Bulbasaur",
                       "name": "Bulbasaur"
                   },
               ]
           },
           {
               "id": 1884,
               "name": "Anya Outfit (female)",
               "icon": "https://wiki.pokexgames.com/images/8/8a/Anya_Outfit_Designer.png",
               "link": null,
               "isNightmare": false,
               "craft": {
                   "quantity": 1,
                   "skill": "100",
                   "cooldownText": "5 dias",
                   "rank": "S",
                   "profession": "Stylist",
                   "materials": [
                       {
                           "name": "Lovely Topknot",
                           "icon": "https://wiki.pokexgames.com/images/e/e9/Lovely_Topknot.png",
                           "isNightmare": true,
                           "quantity": 10,
                           "id": 532
                       },                       
                       {
                           "name": "Lovely Topknot",
                           "icon": "https://wiki.pokexgames.com/images/e/e9/Lovely_Topknot.png",
                           "isNightmare": true,
                           "quantity": 20,
                           "id": 532
                       },
                   ]
               }
           },
           {
               "id": 1912,
               "name": "Catcher Token",
               "icon": "https://wiki.pokexgames.com/images/f/fd/Catcher_Token.png",
               "link": "https://wiki.pokexgames.com/index.php/Tokens",
               "isNightmare": false
           }
       ];
       const search = document.getElementById("search");
       const suggest = document.getElementById("suggest");
       const content = document.getElementById("content");
       const clearSuggestions = () => {
           suggest.innerHTML = "";
       };
       const setItem = (id) => {
           const data = allData.find((data) => data.id == id);
           if (!data) return;
           clearSuggestions();
           content.innerHTML = `
               <img class="item-name-icon" src="${data.icon}" />
               ${data.name}

`;

           if (data.craft) {
               content.innerHTML += `

Craft

Quantidade: ${data.craft.quantity}

Skill: ${data.craft.skill} - Rank ${data.craft.rank}

Tempo de Craft: ${data.craft.cooldownText}

Profissão: ${data.craft.profession}

Materiais:

                       ${data.craft.materials.map((material) => `
                               <img class="item-name-icon" src="${material.icon}" />
                           ${material.quantity}x ${material.name}
`).join("")}

`;

           }
           if (data.whoDrops) {
               content.innerHTML += `

Quem Droppa

                   ${data.whoDrops.map((drop) => `
                       <a href="${drop.link}" target="_blank">
                           <img class="item-name-icon" src="${drop.icon}" />
                           ${drop.name}
                       </a>
`).join("")}

`;

           }
           const materialTo = allData.filter((item) => {
               if (!item.craft?.materials) return false;
               return item.craft.materials.some((m) => m.id == id);
           });
           if (materialTo.length) {
               content.innerHTML += `

Usado para craftar

                   ${materialTo.map((material) => `
                           <img class="item-name-icon" src="${material.icon}" />
                       ${material.name}
`).join("")}

`;

           }
       };
       document.addEventListener("click", (e) => {
           if (e.target.classList.contains("suggest-item")) {
               e.preventDefault();
               setItem(e.target.dataset.itemId);
           }
       });
       search.addEventListener("input", () => {
           const value = search.value?.toLowerCase();
           suggest.innerHTML = "";
           allData.forEach((data) => {
               if (data.name.toLowerCase().includes(value)) {
                   const div = document.createElement("div");
                   div.innerHTML = `
                   <img src="${data.icon}" class="suggest-icon" lazy />
                   <a class="suggest-item" href="#" data-item-id="${data.id}">${data.name}</a>`;
                   suggest.appendChild(div);
               }
           });
       });
   </script>

</body> </html>