Widget:Test3

De PokeXGames
Revisão de 22h51min de 3 de setembro de 2024 por Renee (discussão | contribs)
Ir para navegação Ir para pesquisar

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

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Seleção e Exibição de Imagens</title>
   <style>
       .d-flex {
           display: flex;
           justify-content: center;
           align-items: center;
           flex-direction: column;
           margin-top: -15px;
       }
       .hidden {
           display: none;
       }
       .image-container {
           display: flex;
           flex-wrap: wrap;
           justify-content: center;
           gap: 10px;
           margin-top: 5px;
       }
       .image-container .image-item {
           flex: 1 0 30%;
           text-align: center;
       }
       .image-container img {
           object-fit: cover;
           margin-bottom: 5px;
       }
       .image-info {
           margin-top: 5px;
       }
       select,
       input[type="text"],
       button {
           margin: 5px;
       }
       #filterButton,
       #searchButton {
           background: none;
           border: none;
           padding: 0;
           cursor: pointer;
           margin-top: 5px;
       }
       #filterButton img,
       #searchButton img {
           border-radius: 12px;
           width: auto;
           height: auto;
       }
       .mw-body-content {
           display: flex;
       }
       .mw-parser-output {
           display: inline-block;
           padding: .5rem 2rem;
           margin: 0 auto;
           border: 30px solid transparent;
           border-image: url(https://wiki.pokexgames.com/images/3/37/Calculadora-de-Boost.png) 38;
           min-width: 410px;
           min-height: 320px;
       }
       .input-group {
           position: relative;
           margin: 20px 0;
       }
       .input-group label {
           position: absolute;
           top: -18px;
           background: none;
           padding: 0 5px;
           font-size: 14px;
           font-weight: bold;
           color: #0d0d0d;
       }
       .maps__select {
           width: 100%;
           padding: 10px;
           font-size: 16px;
           border-radius: 5px;
           border: 1px solid #ccc;
           appearance: none;
           background-color: #fff;
           box-sizing: border-box;
       }
       .input-group input[type="text"] {
           width: 100%;
           padding: 10px;
           font-size: 16px;
           border-radius: 5px;
           border: 1px solid #ccc;
           box-sizing: border-box;
       }
       .maps__label {
           position: absolute;
           top: -18px;
           background: none;
           padding: 0 5px;
           font-size: 14px;
           font-weight: bold;
           color: #0d0d0d;
       }
       .hover-minimize:hover {
           transform: scale(0.95);
       }
       .filter-container {
           display: flex;
           align-items: center;
       }
       .filter-container input[type="checkbox"] {
           margin: 0;
           padding: 0;
           width: auto;
           height: auto;
           vertical-align: middle;
       }
       .filter-label {
           margin-left: 10px;
           font-size: 14px;
           font-weight: bold;
           color: #0d0d0d;
           line-height: 1.5;
       }
       .tag-button {
           display: inline-block;
           background-color: #f1f1f1;
           color: #333;
           padding: 10px 20px;
           margin: 5px;
           border: 1px solid #ccc;
           border-radius: 20px;
           cursor: pointer;
           font-size: 16px;
       }
       .tag-button.selected {
           background-color: #15864e;
           color: rgb(159, 5, 219);
       }
       .selected-tags {
           margin: 20px;
           padding: 10px;
           background-color: #f9f9f9;
           border: 1px solid #ccc;
           border-radius: 5px;
       }
       .tag-item {
           display: inline-block;
           background-color: #007BFF;
           color: white;
           padding: 5px 10px;
           margin-right: 5px;
           border-radius: 3px;
           font-size: 14px;
       }
   </style>

</head>

<body>

   <form id="mapForm">
           <select id="mapType" class="maps__select">
               <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>
           <label class="maps__label" for="mapType">Tipo de Mapa</label>
   </form>
   <script>
       const specificOptions = {
           1: {
               'Areia': [

{ id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', tags: ['Areia', 'Água', 'Grama', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/4/4c/Mapas_de_ADV_VERMELHO_-_3780%2C_3326%2C_7.webp' },

                   { id: '102', local: 'Wildwind Island', coordinates: '3969, 3300, 7', tags: ['Areia', 'Terra', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/5/58/Mapas_de_ADV_VERMELHO_-_3969%2C_3300%2C_7.webp' },
                   { id: '103', local: 'Wildwind Island', coordinates: '4002, 3320, 7', tags: ['Areia', 'Árvore', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/0/07/Mapas_de_ADV_VERMELHO_-_4002%2C_3320%2C_7.webp' },
                   { id: '104', local: 'Saffron', coordinates: '4009, 3601, 7', tags: ['Areia', 'Árvore', 'Terra', 'Água'], imageUrl: 'https://wiki.pokexgames.com/images/f/f5/Mapas_de_ADV_VERMELHO_-_4009%2C_3601%2C_7.webp' },
                   { id: '105', local: 'Hurricane Island', coordinates: '3750, 3450, 7', tags: ['Areia', 'Grama'], imageUrl: 'https://wiki.pokexgames.com/images/6/6b/Mapas_de_ADV_VERMELHO_-_3750%2C_3450%2C_7.webp' }
               ],
               'Gelo': [
                   { id: '201', local: 'Snowy Hill', coordinates: '3050, 3575, 7', tags: ['Gelo', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/a/aa/Mapas_de_ADV_VERMELHO_-_3050%2C_3575%2C_7.webp' },
                   { id: '202', local: 'Frozen Lake', coordinates: '2900, 3400, 7', tags: ['Gelo', 'Água'], imageUrl: 'https://wiki.pokexgames.com/images/2/2a/Mapas_de_ADV_VERMELHO_-_2900%2C_3400%2C_7.webp' }
               ],
               // Adicione outros tipos de mapas e locais aqui
           }
       };
       // Atualiza o dropdown de tags baseado no Tipo de Mapa e Local do X selecionados
       function updateTagButtons() {
           const mapType = document.getElementById('mapType').value;
           const specificOption = document.getElementById('specificOption').value;
           const tagButtonsContainer = document.getElementById('tagButtons');
           // Limpa os botões existentes
           tagButtonsContainer.innerHTML = ;
           if (mapType && specificOption) {
               const tags = specificOptions[mapType][specificOption].map(option => option.tags).flat();
               const uniqueTags = [...new Set(tags)];
               uniqueTags.forEach(tag => {
                   const button = document.createElement('button');
                   button.classList.add('tag-button');
                   button.textContent = tag;
                   tagButtonsContainer.appendChild(button);
               });
               document.getElementById('tagSection').classList.remove('hidden');
           } else {
               document.getElementById('tagSection').classList.add('hidden');
           }
       }
       // Atualiza as tags selecionadas ao selecionar uma tag
       function toggleTagButton(e) {
           if (e.target.classList.contains('tag-button')) {
               e.target.classList.toggle('selected');
               filterImages();
           }
       }
       // Filtra as imagens baseadas no Tipo de Mapa, Local do X e Tags selecionadas
       function filterImages() {
           const mapType = document.getElementById('mapType').value;
           const specificOption = document.getElementById('specificOption').value;
           const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(button => button.textContent);
           const imageContainer = document.getElementById('imageContainer');
           imageContainer.innerHTML = ; // Limpa imagens existentes
           if (mapType && specificOption) {
               const images = specificOptions[mapType][specificOption] || [];
               const filteredImages = images.filter(image => {
                   // Verifica se as tags selecionadas estão nas tags da imagem
                   if (selectedTags.length > 0) {
                       return selectedTags.some(tag => image.tags.includes(tag));
                   }
                   return true; // Mostra todas as imagens se nenhuma tag estiver selecionada
               });
               filteredImages.forEach(image => {
                   const div = document.createElement('div');
                   div.classList.add('image-item');
                   div.innerHTML = `
                       <img src="${image.imageUrl}" alt="Imagem do Mapa">
                           Número do Mapa: ${image.id} 
Local: ${image.local}
Coordenada: ${image.coordinates}
Tag(s): ${image.tags.join(', ') || 'Nenhuma'}
                   `;
                   imageContainer.appendChild(div);
               });
               imageContainer.classList.remove('hidden');
           } else {
               imageContainer.classList.add('hidden');
           }
       }
       // Habilita o filtro de tags e tipos de mapa
       document.getElementById('mapType').addEventListener('change', updateTagButtons);
       document.getElementById('specificOption').addEventListener('change', updateTagButtons);
       document.getElementById('filterButton').addEventListener('click', filterImages);
       document.getElementById('tagButtons').addEventListener('click', toggleTagButton);
       // Inicia a configuração inicial
       document.getElementById('tagSection').classList.add('hidden');
       document.getElementById('filterSection').classList.add('hidden');
       document.getElementById('imageContainer').classList.add('hidden');
   </script>

</body> </html>