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
 
(48 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 5: Linha 5:
     <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>Busca de Imagens por Nome</title>
    <style>
 
        .input-group { margin-bottom: 1em; position: relative; }
        .dropdown {
            border: 1px solid #ccc;
            display: none;
            position: absolute;
            background-color: #fff;
            z-index: 1000;
            max-height: 150px;
            overflow-y: auto;
            width: 100%;
        }
        .dropdown-item {
            padding: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .dropdown-item img {
            width: 30px;
            height: 30px;
            margin-right: 10px;
        }
        .dropdown-item:hover {
            background-color: #f0f0f0;
        }
        .image-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        .image-item { margin-bottom: 1em; }
        .image-info { margin-top: 0.5em; }
       
        .variations-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 1em;
        }
 
        .variation-item {
            width: 30%;
            box-sizing: border-box;
            margin: 10px;
            text-align: center;
            border: 1px solid #ccc;
            padding: 10px;
        }
 
        .variation-item img {
            width: 100px;
            height: 100px;
            display: block;
            margin: 0 auto 10px;
        }
    </style>
</head>
</head>
<body>
<body>
Linha 77: Linha 20:


     <script>
     <script>
        const imageList = {
            'Charmander': {
                imageUrl: 'https://example.com/charmander.png',
                description: 'Charmander, o Pokémon de fogo inicial.',
                obtain: {
                    url: 'https://wiki.pokexgames.com/index.php/Charmander',
                    text: 'Como capturar Charmander'
                },
                variations: [
                    {
                        description: 'Charmander versão especial de evento.',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Charmander_Event',
                            text: 'Evento especial Charmander'
                        }
                    },
                    {
                        description: 'Charmander com habilidade rara.',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Charmander_Habilidade',
                            text: 'Habilidade Rara de Charmander'
                        }
                    }
                ]
            },
            'Bulbasaur': {
                imageUrl: 'https://example.com/bulbasaur.png',
                description: 'Bulbasaur, o Pokémon de grama inicial.',
                obtain: {
                    url: 'https://wiki.pokexgames.com/index.php/Bulbasaur',
                    text: 'Como capturar Bulbasaur'
                }
            },
            'Squirtle': {
                imageUrl: 'https://example.com/squirtle.png',
                description: 'Squirtle, o Pokémon de água inicial.',
                obtain: {
                    url: 'https://wiki.pokexgames.com/index.php/Squirtle',
                    text: 'Como capturar Squirtle'
                }
            }
        };


         const imageSearch = document.getElementById('imageSearch');
         const imageSearch = document.getElementById('imageSearch');
Linha 161: Linha 62:
         });
         });


        function showImageInfo(imageName) {
function showImageInfo(imageName) {
            const imageInfo = imageList[imageName];
    const imageInfo = imageList[imageName];
            let imagesHtml = `
    let imagesHtml = `
                <div class="image-item">
        <div class="image-item">
                    <img src="${imageInfo.imageUrl}" alt="${imageName}">
            <img src="${imageInfo.imageUrl}" alt="${imageName}">
                    <div class="image-info">
        </div>
                        <b>Nome da Imagem</b>: ${imageName} <br>
        <div class="variations-container">
                        <b>Descrição</b>: ${imageInfo.description} <br>
    `;
                        <b>URL</b>: ${imageInfo.imageUrl} <br>
 
                        <b>Como Obter</b>: <a href="${imageInfo.obtain.url}" target="_blank">${imageInfo.obtain.text}</a>
    imageInfo.variations.forEach((variation, index) => {
                    </div>
        imagesHtml += `
            <div class="variation-item">
                <img src="${variation.additionalImages[0].url}" alt="Variation Image" class="variation-image" data-variation-index="${index}" style="width: ${variation.additionalImages[0].width}px;">
                <div class="swap-button" data-variation-index="${index}"></div><br>
                <div class="image-info">
                    <img src="${variation.descriptionIMG}" alt="Description Image" style="margin-right: 5px; display: inline-block;"> <!-- Exibe a imagem antes da descrição -->
                    <br> ${variation.description} <br> <!-- Descrição após a imagem -->
                    <b>Como Obter</b>: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
                 </div>
                 </div>
             `;
             </div>
        `;
    });


            if (imageInfo.variations) {
    imagesHtml += `</div>`;
                imagesHtml += '<div class="variations-container">';
 
                imageInfo.variations.forEach(variation => {
    imageContainer.innerHTML = imagesHtml;
                    imagesHtml += `
    imageContainer.classList.remove('hidden');
                        <div class="variation-item">
 
                            <img src="https://via.placeholder.com/100" alt="Variation Image">
    // Alternar imagens ao clicar no botão de troca
                            <div class="image-info">
    const swapButtons = document.querySelectorAll('.swap-button');
                                <b>Descrição</b>: ${variation.description} <br>
 
                                <b>Como Obter</b>: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
    swapButtons.forEach(button => {
                            </div>
        const index = button.getAttribute('data-variation-index');
                        </div>
        const variation = imageInfo.variations[index];
                    `;
        let currentImageIndex = 0;
                });
 
                imagesHtml += '</div>';
        button.addEventListener('click', () => {
            }
            currentImageIndex = (currentImageIndex + 1) % variation.additionalImages.length;
            const variationImage = button.previousElementSibling; // Atualiza a imagem da variação
            variationImage.src = variation.additionalImages[currentImageIndex].url;
            variationImage.style.width = `${variation.additionalImages[currentImageIndex].width}px`;
        });
    });
}


            imageContainer.innerHTML = imagesHtml;
            imageContainer.classList.remove('hidden');
        }
     </script>
     </script>
</body>
</body>
</html>
</html>

Edição atual tal como às 19h22min de 22 de dezembro 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>Busca de Imagens por Nome</title>
 

</head> <body>

   <form id="imageForm">
           <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
   </form>
   <script>
       const imageSearch = document.getElementById('imageSearch');
       const dropdown = document.getElementById('dropdown');
       const imageContainer = document.getElementById('imageContainer');
       imageSearch.addEventListener('input', function() {
           const searchValue = this.value.trim().toLowerCase();
           dropdown.innerHTML = ;
           if (searchValue) {
               Object.keys(imageList).forEach(imageName => {
                   if (imageName.toLowerCase().includes(searchValue)) {
                       const dropdownItem = document.createElement('div');
                       dropdownItem.classList.add('dropdown-item');
                       
                       const imgElement = document.createElement('img');
                       imgElement.src = imageList[imageName].imageUrl;
                       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) {

   const imageInfo = imageList[imageName];
   let imagesHtml = `
           <img src="${imageInfo.imageUrl}" alt="${imageName}">
   `;
   imageInfo.variations.forEach((variation, index) => {
       imagesHtml += `
                <img src="${variation.additionalImages[0].url}" alt="Variation Image" class="variation-image" data-variation-index="${index}" style="width: ${variation.additionalImages[0].width}px;">

                   <img src="${variation.descriptionIMG}" alt="Description Image" style="margin-right: 5px; display: inline-block;"> 
                   
${variation.description}
Como Obter: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
       `;
   });
imagesHtml += `

`;

   imageContainer.innerHTML = imagesHtml;
   imageContainer.classList.remove('hidden');
   // Alternar imagens ao clicar no botão de troca
   const swapButtons = document.querySelectorAll('.swap-button');
   swapButtons.forEach(button => {
       const index = button.getAttribute('data-variation-index');
       const variation = imageInfo.variations[index];
       let currentImageIndex = 0;
       button.addEventListener('click', () => {
           currentImageIndex = (currentImageIndex + 1) % variation.additionalImages.length;
           const variationImage = button.previousElementSibling; // Atualiza a imagem da variação
           variationImage.src = variation.additionalImages[currentImageIndex].url;
           variationImage.style.width = `${variation.additionalImages[currentImageIndex].width}px`;
       });
   });

}

   </script>

</body> </html>