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
 
(43 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="pt-BR">
<html lang="pt-BR">
<head>
<head>
     <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>
         .d-flex {
         .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;
             display: flex;
            justify-content: center;
             align-items: center;
             align-items: center;
            flex-direction: column;
            margin-top: -15px;
            /* Ajuste este valor conforme necessário para subir o botão */
         }
         }
 
        .dropdown-item img {
         .hidden {
            margin-right: 10px;
             display: none;
        }
         .dropdown-item:hover {
             background-color: #f0f0f0;
         }
         }
         .image-container {
         .image-container {
             display: flex;
             display: flex;
             flex-wrap: wrap;
             flex-direction: column;
            align-items: center;
             justify-content: center;
             justify-content: center;
            gap: 10px;
            margin-top: 5px;
         }
         }
 
         .image-item {  
         .image-container .image-item {
             margin-bottom: 1em;  
             flex: 1 0 30%;
             text-align: center;
             text-align: center;
         }
         }
 
         .image-item img {
         .image-container img {
             display: block;
             object-fit: cover; /* Mantém a proporção da imagem, cortando se necessário */
             margin: 0 auto;
             margin-bottom: 5px;
         }
         }


         .image-info {
         .variations-container {
            margin-top: 5px;
        }
 
        select,
        input[type="text"],
        button {
            margin: 5px;
        }
 
        #filterButton,
        #searchButton {
            background: none;
            /* Remove o fundo do botão */
            border: none;
            /* Remove a borda do botão */
            padding: 0;
            /* Remove o padding do botão */
            cursor: pointer;
            /* Mostra o cursor de ponteiro ao passar sobre o botão */
            margin-top: 5px;
            /* Ajuste a margem superior para subir o botão */
        }
 
        #filterButton img,
        #searchButton img {
            border-radius: 12px;
            width: auto;
            /* Garante que a largura se ajuste ao tamanho original da imagem */
            height: auto;
            /* Garante que a altura se ajuste ao tamanho original da imagem */
        }
 
        .mw-body-content {
             display: flex;
             display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 1em;
         }
         }


         .mw-parser-output {
         .variation-item {
             display: inline-block;
             width: 30%;
            padding: .5rem 2rem;
             box-sizing: border-box;
            margin: 0 auto;
             margin: 10px;
            border: 30px solid transparent;
             text-align: center;
            border-image: url(https://wiki.pokexgames.com/images/3/37/Calculadora-de-Boost.png) 38;
            min-width: 340px;
             min-height: 270px;
        }
 
        .input-group {
            position: relative;
             margin: 20px 0;
            /* Ajuste a margem para mover o campo para cima */
        }
 
        .input-group label {
            position: absolute;
            top: -18px;
            /* Eleva o texto para cima */
            background: none;
            padding: 0 5px;
            font-size: 14px;
            font-weight: bold;
            color: #0d0d0d;
        }
 
        .maps__select {
            width: 100%;
            /* Mantém a largura total disponível */
            padding: 10px;
             font-size: 16px;
            border-radius: 5px;
             border: 1px solid #ccc;
             border: 1px solid #ccc;
            appearance: none;
            background-color: #fff;
            /* Adiciona um fundo branco */
            box-sizing: border-box;
            /* Inclui o padding e a borda na largura total */
        }
        .input-group input[type="text"] {
            width: 100%;
            /* Mantém a largura total disponível */
             padding: 10px;
             padding: 10px;
            font-size: 16px;
            border-radius: 5px;
            border: 1px solid #ccc;
            box-sizing: border-box;
            /* Inclui o padding e a borda na largura total */
        }
        .maps__label {
            position: absolute;
            top: -18px;
            /* Eleva o texto um pouco mais para cima */
            background: none;
            padding: 0 5px;
            font-size: 14px;
            font-weight: bold;
            /* Deixa o texto em negrito */
            color: #0d0d0d;
         }
         }


         .hover-minimize:hover {
         .variation-item img {
             transform: scale(0.95);
            width: 100px;
             /* Adiciona um efeito de minimizar ao passar o mouse */
            height: 100px;
             display: block;
             margin: 0 auto 10px;
         }
         }


         .filter-container {
         .swap-button {
             display: flex;
             margin-top: 10px;
             align-items: center;
             cursor: pointer;
        }
             width: 15px;
 
             height: 15px;
        .filter-container input[type="checkbox"] {
             background: url('https://wiki.pokexgames.com/images/2/2d/Comvip.png') no-repeat center;
             margin: 0;
             background-size: contain;
             padding: 0;
             display: block;
             width: auto;
             margin: 0 auto;
            /* Ajusta o tamanho da checkbox conforme necessário */
            height: auto;
            /* Ajusta o tamanho da checkbox conforme necessário */
            /* Alinha verticalmente a checkbox com o texto */
            vertical-align: middle;
        }
 
        .filter-label {
            margin-left: 10px;
             /* Espaço entre a checkbox e o texto */
            font-size: 14px;
             font-weight: bold;
             color: #0d0d0d;
            line-height: 1.5;
            /* Ajusta a altura da linha para um alinhamento adequado */
         }
         }
     </style>
     </style>
</head>
</head>
<body>
<body>
     <form id="mapForm">
     <form id="imageForm">
        <div id="mapTypeSelection" class="input-group">
         <div class="input-group">
            <select id="mapType" class="maps__select">
             <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
                <option value="">Selecione um mapa</option>
             <div id="dropdown" class="dropdown"></div>
                <option value="1">Mapa Vermelho</option>
                <option value="2">Mapa Verde</option>
                <option value="3">Mapa Roxo</option>
            </select>
            <label class="maps__label" for="mapType">Tipo de Mapa</label>
        </div>
 
        <div id="specificOptions" class="hidden input-group">
            <select id="specificOption" class="maps__select">
                <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>
            <label class="maps__label" for="specificOption">Local do X</label>
        </div>
 
         <div class="filter-container">
            <input type="checkbox" id="enableFilter">
            <label for="enableFilter" class="filter-label">Ativar filtro</label>
        </div>
 
        <div id="filterSection" class="hidden">
            <div id="filterById" class="input-group">
                <label for="searchIds" class="maps__label">Buscar por Nº do Mapa:</label>
                <input type="text" id="searchIds" placeholder="Digite os números separados por vírgula"
                    class="maps__select">
            </div>
 
             <div id="filterByTag" class="hidden input-group">
                <label for="searchTags" class="maps__label">Buscar por Tag:</label>
                <input type="text" id="searchTags" placeholder="Digite a tag desejada" class="maps__select">
             </div>
 
            <div class="d-flex justify-center align-center flex-column">
                <button type="button" id="filterButton" class="hover-minimize">
                    <img src="https://wiki.pokexgames.com/images/8/82/Botao_Filtrar_Mapas_Adv.png"
                        alt="Imagem botão filtrar">
                </button>
            </div>
         </div>
         </div>


Linha 229: Linha 92:


     <script>
     <script>
         const specificOptions = {
         const imageList = {
             1: { // Mapa Vermelho
             'Charmander': {  
                 'Areia': [
                imageUrl: 'https://wiki.pokexgames.com/images/6/65/004-Charmander.png',
                     { id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' },
                 variations: [
                ],
                     {  
                // Outras opções do Mapa Vermelho
                        imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
            },
                        description: 'Charmander XXX',
            2: {
                        obtain: {
                'Areia': [
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                    { id: '1001', local: 'Outland Water', coordinates: '2847, 2827, 6', imageUrl: 'https://wiki.pokexgames.com/images/b/b9/Mapa_Verde_ADV_-_2847%2C_2827%2C_6.webp' },
                            text: 'Estilista'
                    { id: '1002', local: 'Outland Water', coordinates: '2863, 2850, 6', imageUrl: 'https://wiki.pokexgames.com/images/c/c9/Mapa_Verde_ADV_-_2863%2C_2850%2C_6.webp' },
                        },
                    { id: '1003', local: 'Respawn de Baltoy', coordinates: '5575, 5658, 5', imageUrl: 'https://wiki.pokexgames.com/images/3/3f/Mapa_Verde_ADV_-_5575%2C_5658%2C_5.webp' },
                        additionalImages: [
                    { id: '1004', local: 'Respawn de Vibrava', coordinates: '5616, 5555, 8', imageUrl: 'https://wiki.pokexgames.com/images/d/d1/Mapa_Verde_ADV_-_5616%2C_5555%2C_8.webp' },
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png', // Frente
                 ],
                            'https://example.com/left1.png',  // Lado Esquerdo
                // Outras opções do Mapa Verde
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Costas
                            'https://example.com/right1.png'   // Lado Direito
                        ]
                    },
                    { 
                        imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                        description: 'Charmander brabo.',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                            text: 'Estilista'
                        },
                        additionalImages: [
                            'https://example.com/front2.png', // Frente
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',   // Lado Esquerdo
                            'https://example.com/back2.png',   // Costas
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png'   // Lado Direito
                        ]
                    }
                 ]
             },
             },
            3: {
                'Areia': [
                    { id: '10001', local: 'Grotto', coordinates: '3400, 4500, 6', imageUrl: 'https://wiki.pokexgames.com/images/5/56/Mapa_Roxo_ADV_-_3400%2C_4500%2C_6.png' },
                ],
                // Outras opções do Mapa Roxo
            }
         };
         };


         function updateFilterVisibility() {
         const imageSearch = document.getElementById('imageSearch');
            const enableFilter = document.getElementById('enableFilter').checked;
        const dropdown = document.getElementById('dropdown');
            document.getElementById('filterSection').classList.toggle('hidden', !enableFilter);
        const imageContainer = document.getElementById('imageContainer');
            document.getElementById('specificOptions').classList.toggle('hidden', !enableFilter);
        }


         function filterImages() {
         imageSearch.addEventListener('input', function() {
            const mapType = document.getElementById('mapType').value;
             const searchValue = this.value.trim().toLowerCase();
            const specificOption = document.getElementById('specificOption').value;
             dropdown.innerHTML = '';
             const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim()).filter(id => id);
             const searchTags = document.getElementById('searchTags').value.trim().toLowerCase();


             if (!mapType && !searchTags && !searchIds.length) {
             if (searchValue) {
                alert('Selecione pelo menos um tipo de mapa ou insira uma tag ou número.');
                Object.keys(imageList).forEach(imageName => {
                return;
                    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);
                    }
                });


            const images = [];
                dropdown.style.display = dropdown.childNodes.length ? 'block' : 'none';
             if (mapType && specificOption) {
             } else {
                 if (specificOptions[mapType] && specificOptions[mapType][specificOption]) {
                 dropdown.style.display = 'none';
                    images.push(...specificOptions[mapType][specificOption]);
                }
             }
             }
        });


            if (searchIds.length) {
        document.addEventListener('click', function(event) {
                images.push(...Object.values(specificOptions).flatMap(option => option).filter(item => searchIds.includes(item.id)));
            if (!imageSearch.contains(event.target) && !dropdown.contains(event.target)) {
            }
                 dropdown.style.display = 'none';
 
            if (searchTags) {
                 images.push(...Object.values(specificOptions).flatMap(option => option).filter(item => item.tag && item.tag.toLowerCase().includes(searchTags)));
             }
             }
        });


            displayImages(images);
        function showImageInfo(imageName) {
        }
            const imageInfo = imageList[imageName];
            let imagesHtml = `
                <div class="image-item">
                    <img src="${imageInfo.imageUrl}" alt="${imageName}">
                </div>
                <div class="variations-container">
            `;


        function displayImages(images) {
             imageInfo.variations.forEach((variation, index) => {
             const container = document.getElementById('imageContainer');
                 imagesHtml += `
            container.innerHTML = '';
                     <div class="variation-item">
            if (images.length === 0) {
                         <img src="${variation.additionalImages[0]}" alt="Variation Image" class="variation-image" data-variation-index="${index}">
                container.innerHTML = '<p>Nenhuma imagem encontrada.</p>';
                          <div class="swap-button" data-variation-index="${index}"></div>
            } else {
                 images.forEach(image => {
                     const div = document.createElement('div');
                    div.className = 'image-item';
                    div.innerHTML = `
                         <img src="${image.imageUrl}" alt="${image.local}" />
                         <div class="image-info">
                         <div class="image-info">
                             <p>ID: ${image.id}</p>
                             <b>Nome do Addon</b>: ${variation.description}  
                            <p>Local: ${image.local}</p>
                            <b>Como Obter</b>: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
                            <p>Coordenadas: ${image.coordinates}</p>
                         </div>
                         </div>
                     `;
                     </div>
                    container.appendChild(div);
                 `;
                 });
             });
             }
            container.classList.remove('hidden');
        }


        document.getElementById('enableFilter').addEventListener('change', updateFilterVisibility);
            imagesHtml += '</div>';


        document.getElementById('filterButton').addEventListener('click', filterImages);
            imageContainer.innerHTML = imagesHtml;
            imageContainer.classList.remove('hidden');


        document.getElementById('searchIds').addEventListener('input', function () {
            // Alternar imagens ao clicar no botão de troca
             document.getElementById('searchTags').value = '';
             const swapButtons = document.querySelectorAll('.swap-button');
            document.getElementById('filterByTag').classList.add('hidden');
        });


        document.getElementById('searchTags').addEventListener('input', function () {
            swapButtons.forEach(button => {
            document.getElementById('searchIds').value = '';
                const index = button.getAttribute('data-variation-index');
            document.getElementById('filterById').classList.add('hidden');
                const variation = imageInfo.variations[index];
        });
                let currentImageIndex = 0;


        // Inicializa a visibilidade dos filtros ao carregar a página
                button.addEventListener('click', () => {
        updateFilterVisibility();
                    currentImageIndex = (currentImageIndex + 1) % variation.additionalImages.length;
                    const variationImage = button.previousElementSibling;
                    variationImage.src = variation.additionalImages[currentImageIndex];
                });
            });
        }
     </script>
     </script>
</body>
</body>
</html>
</html>

Edição atual tal como às 03h33min de 17 de setembro 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: 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;
       }
       .swap-button {
           margin-top: 10px;
           cursor: pointer;
           width: 15px;
           height: 15px;
           background: url('https://wiki.pokexgames.com/images/2/2d/Comvip.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 = {
           'Charmander': { 
               imageUrl: 'https://wiki.pokexgames.com/images/6/65/004-Charmander.png', 
               variations: [
                   { 
                       imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                       description: 'Charmander XXX',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Frente
                           'https://example.com/left1.png',   // Lado Esquerdo
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',   // Costas
                           'https://example.com/right1.png'   // Lado Direito
                       ]
                   },
                   {  
                       imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                       description: 'Charmander brabo.',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           'https://example.com/front2.png',  // Frente
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',   // Lado Esquerdo
                           'https://example.com/back2.png',   // Costas
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.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]}" alt="Variation Image" class="variation-image" data-variation-index="${index}">
                           Nome do Addon: ${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;
                   variationImage.src = variation.additionalImages[currentImageIndex];
               });
           });
       }
   </script>

</body> </html>