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
 
(179 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
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>Seleção e Exibição de Imagens</title>
     <title>Busca de Imagens por Nome</title>
     <style>
     <style>
         .hidden {
         .input-group { margin-bottom: 1em; position: relative; }
        .dropdown {
            border: 1px solid #ccc;
             display: none;
             display: none;
            position: absolute;
            background-color: #fff;
            z-index: 1000;
            max-height: 150px;
            overflow-y: auto;
            width: 100%;
         }
         }
         .image-container img {
        .dropdown-item {
             width: 100px;
            padding: 8px;
             height: 100px;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .dropdown-item img {
            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;
            text-align: center;
        }
        .image-item img {
            display: block;
            margin: 0 auto;
        }
 
        .variations-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 1em;
        }
 
        .variation-item {
             width: 35%;
             box-sizing: border-box;
             margin: 5px;
             margin: 5px;
            text-align: center;
            border: 1px solid ;
            padding: 10px;
         }
         }
         select {
 
             margin: 5px;
         .variation-item img {
            display: block;
             margin: 0 auto 10px;
         }
         }
         .image-info {
 
         .swap-button {  
             margin-top: 10px;
             margin-top: 10px;
            cursor: pointer;
            width: 15px;
            height: 15px;
            background: url('https://wiki.pokexgames.com/images/f/fb/SwapButtonAddons.png') no-repeat center;
            background-size: contain;
            display: block;
            margin: 0 auto;
         }
         }
     </style>
     </style>
</head>
</head>
<body>
<body>
    <h1>Selecione o Tipo de Mapa</h1>
     <form id="imageForm">
 
         <div class="input-group">
     <form id="mapForm">
             <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
         <div id="mapTypeSelection">
             <div id="dropdown" class="dropdown"></div>
             <label for="mapType">Tipo de Mapa:</label>
            <select id="mapType">
                <option value="">Selecione um mapa</option>
                <option value="1">Mapa Vermelho</option>
                <option value="2">Mapa Verde</option>
                <option value="3">Mapa Roxo</option>
             </select>
        </div>
 
        <div id="specificOptions" class="hidden">
            <label for="specificOption">Local do X:</label>
            <select id="specificOption">
                <option value="">Selecione uma opção</option>
                <option value="Areia">Areia</option>
                <option value="Gelo">Gelo</option>
                <option value="Grama">Grama</option>
                <option value="Pedra">Pedra</option>
                <option value="Subaquático">Subaquático</option>
                <option value="Terra">Terra</option>
                <option value="Pisos">Pisos</option>
            </select>
         </div>
         </div>


         <div id="imageContainer" class="image-container hidden">
         <div id="imageContainer" class="image-container hidden">
             <!-- A imagem e suas informações serão exibidas aqui -->
             <!-- As imagens e suas informações serão exibidas aqui -->
         </div>
         </div>
     </form>
     </form>


     <script>
     <script>
         const specificOptions = {
         const imageList = {
             1: {
             'Squirtle': {  
                 'Areia': { local: 'Pewter', coordinates: '3467, 3743, 6' },
                 imageUrl: 'https://wiki.pokexgames.com/images/7/7a/007-Squirtle.png',  
                 'Gelo': { local: 'Cerulean', coordinates: '1456, 2345, 4' },
                 variations: [
                'Grama': { local: 'Vermilion', coordinates: '5678, 1234, 5' },
                    {  
                'Pedra': { local: 'Lavender', coordinates: '6789, 2345, 2' },
                        description: 'Squirtle Purple Ninja Pack',
                'Subaquático': { local: 'Celadon', coordinates: '1234, 5678, 3' },
                        descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                'Terra': { local: 'Fuchsia', coordinates: '4567, 6789, 1' },
                        obtain: {
                'Pisos': { local: 'Cinnabar', coordinates: '7890, 1234, 6' }
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
            },
                            text: 'Estilista'
            2: {
                        },
                'Areia': { local: 'Saffron', coordinates: '3456, 7890, 7' },
                        additionalImages: [
                'Gelo': { local: 'Pallet', coordinates: '5678, 1234, 2' },
                            { url: 'https://wiki.pokexgames.com/images/d/dd/Squirtle_Purple_Ninja_Pack_Frente.png'}, // Frente
                'Grama': { local: 'Pewter', coordinates: '6789, 3456, 4' },
                            { url: 'https://wiki.pokexgames.com/images/5/50/Squirtle_Purple_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                'Pedra': { local: 'Cerulean', coordinates: '2345, 6789, 5' },
                            { url: 'https://wiki.pokexgames.com/images/a/af/Squirtle_Purple_Ninja_Pack_Direita.png'}, // Costas
                'Subaquático': { local: 'Vermilion', coordinates: '1234, 4567, 3' },
                            { url: 'https://wiki.pokexgames.com/images/5/5d/Squirtle_Purple_Ninja_Pack_Costas.png'} // Lado Direito
                'Terra': { local: 'Lavender', coordinates: '3456, 7890, 6' },
                        ]
                 'Pisos': { local: 'Celadon', coordinates: '5678, 1234, 2' }
                    },
                    {
                        description: 'Squirtle Red Ninja Pack',
                        descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                            text: 'Estilista'
                        },
                        additionalImages: [
                            { url: 'https://wiki.pokexgames.com/images/1/13/Squirtle_Red_Ninja_Pack_Frente.png'}, // Frente
                            { url: 'https://wiki.pokexgames.com/images/1/1e/Squirtle_Red_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                            { url: 'https://wiki.pokexgames.com/images/0/01/Squirtle_Red_Ninja_Pack_Costas.png'}, // Costas
                            { url: 'https://wiki.pokexgames.com/images/f/fd/Squirtle_Red_Ninja_Pack_Direita.png'} // Lado Direito
                        ]
                    }
                 ]
             },
             },
            3: {
                'Areia': { local: 'Fuchsia', coordinates: '6789, 3456, 4' },
                'Gelo': { local: 'Cinnabar', coordinates: '7890, 1234, 1' },
                'Grama': { local: 'Saffron', coordinates: '4567, 6789, 5' },
                'Pedra': { local: 'Pallet', coordinates: '1234, 5678, 3' },
                'Subaquático': { local: 'Pewter', coordinates: '6789, 2345, 6' },
                'Terra': { local: 'Cerulean', coordinates: '3456, 7890, 2' },
                'Pisos': { local: 'Vermilion', coordinates: '5678, 1234, 4' }
            }
         };
         };


         const images = {
         const imageSearch = document.getElementById('imageSearch');
            'Areia': 'https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png',
        const dropdown = document.getElementById('dropdown');
            'Gelo': 'https://wiki.pokexgames.com/images/4/43/AnotherImage.png',
        const imageContainer = document.getElementById('imageContainer');
            'Grama': 'https://wiki.pokexgames.com/images/3/34/DifferentImage.png',
 
            'Pedra': 'https://wiki.pokexgames.com/images/c/c4/ExampleImage.png',
        imageSearch.addEventListener('input', function() {
             'Subaquático': 'https://wiki.pokexgames.com/images/5/56/AnotherExample.png',
             const searchValue = this.value.trim().toLowerCase();
             'Terra': 'https://wiki.pokexgames.com/images/a/a6/SampleImage.png',
             dropdown.innerHTML = '';
            'Pisos': 'https://wiki.pokexgames.com/images/d/d7/FinalExample.png'
        };


        document.getElementById('mapType').addEventListener('change', function() {
            if (searchValue) {
            const selectedMapType = this.value;
                Object.keys(imageList).forEach(imageName => {
            const specificOptionSelect = document.getElementById('specificOption');
                    if (imageName.toLowerCase().includes(searchValue)) {
            const imageContainer = document.getElementById('imageContainer');
                        const dropdownItem = document.createElement('div');
           
                        dropdownItem.classList.add('dropdown-item');
            specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
                       
            imageContainer.innerHTML = '';
                        const imgElement = document.createElement('img');
           
                        imgElement.src = imageList[imageName].imageUrl;
            if (selectedMapType) {
                        imgElement.alt = imageName;
                const options = Object.keys(specificOptions[selectedMapType]);
                       
                options.forEach(option => {
                        dropdownItem.appendChild(imgElement);
                    specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`;
                        dropdownItem.appendChild(document.createTextNode(imageName));
                       
                        dropdownItem.addEventListener('click', function() {
                            showImageInfo(imageName);
                            dropdown.style.display = 'none';
                        });
                        dropdown.appendChild(dropdownItem);
                    }
                 });
                 });


                 document.getElementById('specificOptions').classList.remove('hidden');
                 dropdown.style.display = dropdown.childNodes.length ? 'block' : 'none';
             } else {
             } else {
                 document.getElementById('specificOptions').classList.add('hidden');
                 dropdown.style.display = 'none';
                document.getElementById('imageContainer').classList.add('hidden');
             }
             }
         });
         });


         document.getElementById('specificOption').addEventListener('change', function() {
         document.addEventListener('click', function(event) {
             const selectedOption = this.value;
             if (!imageSearch.contains(event.target) && !dropdown.contains(event.target)) {
            const imageContainer = document.getElementById('imageContainer');
                 dropdown.style.display = 'none';
            const mapType = document.getElementById('mapType').value;
           
            imageContainer.innerHTML = '';
           
            if (selectedOption) {
                const imageUrl = images[selectedOption];
                const optionInfo = specificOptions[mapType][selectedOption];
                if (imageUrl && optionInfo) {
                    imageContainer.innerHTML = `
                        <img src="${imageUrl}" alt="${selectedOption}">
                        <div class="image-info">
                            Local: ${optionInfo.local} <br>
                            Coordenada: ${optionInfo.coordinates}
                        </div>
                    `;
                    imageContainer.classList.remove('hidden');
                }
            } else {
                 imageContainer.classList.add('hidden');
             }
             }
         });
         });
function showImageInfo(imageName) {
    const imageInfo = imageList[imageName];
    let imagesHtml = `
        <div class="image-item">
            <img src="${imageInfo.imageUrl}" alt="${imageName}">
        </div>
        <div class="variations-container">
    `;
    imageInfo.variations.forEach((variation, index) => {
        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>
        `;
    });
    imagesHtml += '</div>';
    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>
     </script>
</body>
</body>
</html>
</html>

Edição atual tal como às 23h45min de 16 de outubro 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>
   <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 {
           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; 
           text-align: center;
       }
       .image-item img {
           display: block;
           margin: 0 auto;
       }
       .variations-container {
           display: flex;
           flex-wrap: wrap;
           justify-content: center;
           margin-top: 1em;
       }
       .variation-item {
           width: 35%;
           box-sizing: border-box;
           margin: 5px;
           text-align: center;
           border: 1px solid ;
           padding: 10px;
       }
       .variation-item img {
           display: block;
           margin: 0 auto 10px;
       }
       .swap-button { 
           margin-top: 10px;
           cursor: pointer;
           width: 15px;
           height: 15px;
           background: url('https://wiki.pokexgames.com/images/f/fb/SwapButtonAddons.png') no-repeat center;
           background-size: contain;
           display: block;
           margin: 0 auto;
       }
   </style>

</head> <body>

   <form id="imageForm">
           <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
   </form>
   <script>
       const imageList = {
           'Squirtle': { 
               imageUrl: 'https://wiki.pokexgames.com/images/7/7a/007-Squirtle.png', 
               variations: [
                   { 
                       description: 'Squirtle Purple Ninja Pack',
                       descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           { url: 'https://wiki.pokexgames.com/images/d/dd/Squirtle_Purple_Ninja_Pack_Frente.png'}, // Frente
                           { url: 'https://wiki.pokexgames.com/images/5/50/Squirtle_Purple_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                           { url: 'https://wiki.pokexgames.com/images/a/af/Squirtle_Purple_Ninja_Pack_Direita.png'}, // Costas
                           { url: 'https://wiki.pokexgames.com/images/5/5d/Squirtle_Purple_Ninja_Pack_Costas.png'}  // Lado Direito
                       ]
                   },
                   {  
                       description: 'Squirtle Red Ninja Pack',
                       descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           { url: 'https://wiki.pokexgames.com/images/1/13/Squirtle_Red_Ninja_Pack_Frente.png'}, // Frente
                           { url: 'https://wiki.pokexgames.com/images/1/1e/Squirtle_Red_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                           { url: 'https://wiki.pokexgames.com/images/0/01/Squirtle_Red_Ninja_Pack_Costas.png'}, // Costas
                           { url: 'https://wiki.pokexgames.com/images/f/fd/Squirtle_Red_Ninja_Pack_Direita.png'}  // Lado Direito
                       ]
                   }
               ]
           },
       };
       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>