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

De PokeXGames
Ir para navegação Ir para pesquisar
Sem resumo de edição
Etiquetas: Reversão manual Revertido
Sem resumo de edição
Etiqueta: Revertido
Linha 4: Linha 4:
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Busca de Imagens por Nome</title>
     <title>Filtro de Imagens</title>
     <style>
     <style>
         .input-group { margin-bottom: 1em; position: relative; }
         .image-container {
        .dropdown {
             display: flex;
            border: 1px solid #ccc;
             flex-direction: column;
             display: none;
             margin-top: 20px;
             position: absolute;
        }
             background-color: #fff;
 
            z-index: 1000;
        .image-item {
            max-height: 150px;
             margin-bottom: 20px;
             overflow-y: auto;
            width: 100%;
         }
         }
        .image-info {
            margin-top: 10px;
        }
        .dropdown-item img {
            width: 20px;
            height: 20px;
            margin-right: 10px;
            vertical-align: middle;
        }
         .dropdown-item {
         .dropdown-item {
            padding: 8px;
            cursor: pointer;
             display: flex;
             display: flex;
             align-items: center;
             align-items: center;
            cursor: pointer;
            padding: 5px;
            border: 1px solid #ddd;
         }
         }
        .dropdown-item img {
 
            margin-right: 10px;
        }
         .dropdown-item:hover {
         .dropdown-item:hover {
             background-color: #f0f0f0;
             background-color: #f0f0f0;
         }
         }
         .image-item { margin-bottom: 1em; }
 
         .image-info { margin-top: 0.5em; }
         #infoContainer {
            margin-top: 20px;
         }
     </style>
     </style>
</head>
</head>
<body>
<body>
     <form id="imageForm">
     <form id="imageForm">
         <div class="input-group">
         <label for="search">Buscar Imagem:</label>
            <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
        <input type="text" id="search" placeholder="Digite o nome do item">
            <div id="dropdown" class="dropdown"></div>
        <div id="dropdown" class="dropdown"></div>
        </div>
         <div id="infoContainer" class="image-container"></div>
 
         <div id="imageContainer" class="image-container hidden">
            <!-- As imagens e suas informações serão exibidas aqui -->
        </div>
     </form>
     </form>


     <script>
     <script>
         const imageList = {
         const imageOptions = [
            'Charmander': {
            {
                 imageUrl: 'https://wiki.pokexgames.com/images/6/65/004-Charmander.png',  
                name: 'IMG Charmander',
                 description: 'Charmander, o Pokémon de fogo inicial.'  
                 imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Charmander.gif',
                 coordinates: '1234, 5678, 7',
                obtain: '<b>Como Obter: </b> <a href="https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista">Estilista</a>'
             },
             },
            'Bulbasaur': {
             // Adicione mais itens conforme necessário
                imageUrl: 'https://example.com/bulbasaur.png',
         ];
                description: 'Bulbasaur, o Pokémon de grama inicial.'
            },
            'Squirtle': {
                imageUrl: 'https://example.com/squirtle.png',
                description: 'Squirtle, o Pokémon de água inicial.'
            }
             // Adicione mais imagens conforme necessário
         };


         const imageSearch = document.getElementById('imageSearch');
         const searchInput = document.getElementById('search');
         const dropdown = document.getElementById('dropdown');
         const dropdown = document.getElementById('dropdown');
         const imageContainer = document.getElementById('imageContainer');
         const infoContainer = document.getElementById('infoContainer');


         imageSearch.addEventListener('input', function() {
         searchInput.addEventListener('input', function () {
             const searchValue = this.value.trim().toLowerCase();
             const query = searchInput.value.toLowerCase();
             dropdown.innerHTML = '';
             dropdown.innerHTML = '';


             if (searchValue) {
             if (query) {
                 Object.keys(imageList).forEach(imageName => {
                 const filteredOptions = imageOptions.filter(option => option.name.toLowerCase().includes(query));
                    if (imageName.toLowerCase().includes(searchValue)) {
                filteredOptions.forEach(option => {
                        const dropdownItem = document.createElement('div');
                    const item = document.createElement('div');
                        dropdownItem.classList.add('dropdown-item');
                    item.className = 'dropdown-item';
                       
                    item.innerHTML = `<img src="${option.imageUrl}" alt="${option.name}"> ${option.name}`;
                        const imgElement = document.createElement('img');
                    item.addEventListener('click', () => showInfo(option));
                        imgElement.src = imageList[imageName].imageUrl;
                    dropdown.appendChild(item);
                        imgElement.alt = imageName;
                       
                        dropdownItem.appendChild(imgElement);
                        dropdownItem.appendChild(document.createTextNode(imageName));
                       
                        dropdownItem.addEventListener('click', function() {
                            showImageInfo(imageName);
                            dropdown.style.display = 'none';
                        });
                        dropdown.appendChild(dropdownItem);
                    }
                 });
                 });
                dropdown.style.display = dropdown.childNodes.length ? 'block' : 'none';
            } else {
                dropdown.style.display = 'none';
            }
        });
        document.addEventListener('click', function(event) {
            if (!imageSearch.contains(event.target) && !dropdown.contains(event.target)) {
                dropdown.style.display = 'none';
             }
             }
         });
         });


         function showImageInfo(imageName) {
         function showInfo(option) {
             const imageInfo = imageList[imageName];
             infoContainer.innerHTML = `
            const imagesHtml = `
                 <div class="image-item">
                 <div class="image-item">
                     <img src="${imageInfo.imageUrl}" alt="${imageName}">
                     <img src="${option.imageUrl}" alt="${option.name}">
                     <div class="image-info">
                     <div class="image-info">
                         <b>Nome da Imagem</b>: ${imageName} <br>
                         <b>Nome:</b> ${option.name}<br>
                         <b>Descrição</b>: ${imageInfo.description} <br>
                         <b>Coordenada:</b> ${option.coordinates}<br>
                         <b>URL</b>: ${imageInfo.imageUrl}
                         ${option.obtain}
                     </div>
                     </div>
                 </div>
                 </div>
             `;
             `;
            imageContainer.innerHTML = imagesHtml;
            imageContainer.classList.remove('hidden');
         }
         }
     </script>
     </script>
</body>
</body>
</html>
</html>

Edição das 03h54min de 30 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>Filtro de Imagens</title>
   <style>
       .image-container {
           display: flex;
           flex-direction: column;
           margin-top: 20px;
       }
       .image-item {
           margin-bottom: 20px;
       }
       .image-info {
           margin-top: 10px;
       }
       .dropdown-item img {
           width: 20px;
           height: 20px;
           margin-right: 10px;
           vertical-align: middle;
       }
       .dropdown-item {
           display: flex;
           align-items: center;
           cursor: pointer;
           padding: 5px;
           border: 1px solid #ddd;
       }
       .dropdown-item:hover {
           background-color: #f0f0f0;
       }
       #infoContainer {
           margin-top: 20px;
       }
   </style>

</head> <body>

   <form id="imageForm">
       <label for="search">Buscar Imagem:</label>
       <input type="text" id="search" placeholder="Digite o nome do item">
   </form>
   <script>
       const imageOptions = [
           {
               name: 'IMG Charmander',
               imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Charmander.gif',
               coordinates: '1234, 5678, 7',
               obtain: 'Como Obter:  <a href="https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista">Estilista</a>'
           },
           // Adicione mais itens conforme necessário
       ];
       const searchInput = document.getElementById('search');
       const dropdown = document.getElementById('dropdown');
       const infoContainer = document.getElementById('infoContainer');
       searchInput.addEventListener('input', function () {
           const query = searchInput.value.toLowerCase();
           dropdown.innerHTML = ;
           if (query) {
               const filteredOptions = imageOptions.filter(option => option.name.toLowerCase().includes(query));
               filteredOptions.forEach(option => {
                   const item = document.createElement('div');
                   item.className = 'dropdown-item';
                   item.innerHTML = `<img src="${option.imageUrl}" alt="${option.name}"> ${option.name}`;
                   item.addEventListener('click', () => showInfo(option));
                   dropdown.appendChild(item);
               });
           }
       });
       function showInfo(option) {
           infoContainer.innerHTML = `
                   <img src="${option.imageUrl}" alt="${option.name}">
                       Nome: ${option.name}
Coordenada: ${option.coordinates}
${option.obtain}
           `;
       }
   </script>

</body> </html>