Widget:Test

Revisão de 03h12min de 27 de agosto de 2024 por Renee (discussão | contribs)

<!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: 340px;
           min-height: 270px;
       }
       .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;
       }
   </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>
           <input type="checkbox" id="enableFilter">
           <label for="enableFilter" class="filter-label">Ativar filtro</label>
   </form>
   <script>
       const specificOptions = {
           1: {
               'Areia': [
                   { id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' },
               ],
           },
           2: {
               'Areia': [
                   { id: '1001', local: 'Outland Water', tag: 'agua', coordinates: '2847, 2827, 6', imageUrl: 'https://wiki.pokexgames.com/images/b/b9/Mapa_Verde_ADV_-_2847%2C_2827%2C_6.webp' },
                   { 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' },
               ],
           },
           3: {
               // Adicionar dados para o Mapa Roxo aqui
           }
       };
       document.getElementById('enableFilter').addEventListener('change', function () {
           const filterSection = document.getElementById('filterSection');
           const filterOptions = document.getElementById('filterOptions');
           if (this.checked) {
               filterSection.classList.remove('hidden');
               filterOptions.classList.remove('hidden');
           } else {
               filterSection.classList.add('hidden');
               filterOptions.classList.add('hidden');
           }
       });
       document.getElementById('filterMode').addEventListener('change', function () {
           const filterMode = this.value;
           const searchIds = document.getElementById('searchIds');
           if (filterMode === 'number') {
               searchIds.placeholder = "Digite os números separados por vírgula";
           } else if (filterMode === 'tag') {
               searchIds.placeholder = "Digite as tags separadas por vírgula";
           }
       });
       document.getElementById('mapType').addEventListener('change', function () {
           const selectedMapType = this.value;
           const specificOptionSelect = document.getElementById('specificOption');
           if (selectedMapType) {
               specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
               const options = Object.keys(specificOptions[selectedMapType]);
               options.forEach(option => {
                   specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`;
               });
               document.getElementById('specificOptions').classList.remove('hidden');
           } else {
               document.getElementById('specificOptions').classList.add('hidden');
           }
       });
       document.getElementById('filterButton').addEventListener('click', function () {
           const filterMode = document.getElementById('filterMode').value;
           const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim());
           const selectedMapType = document.getElementById('mapType').value;
           const selectedOption = document.getElementById('specificOption').value;
           const imageContainer = document.getElementById('imageContainer');
           if (!selectedMapType || !selectedOption) {
               alert("Selecione pelo menos um tipo de mapa");
               return;
           }
           if (filterMode === 'number') {
               // Filtrar por número
               if (searchIds.length > 0) {
                   let imagesHtml = ;
                   let allImages = [];
                   // Recolhe todas as imagens que correspondem aos IDs
                   Object.keys(specificOptions).forEach(mapType => {
                       const mapOptions = specificOptions[mapType];
                       Object.keys(mapOptions).forEach(option => {
                           const images = mapOptions[option].filter(image => searchIds.includes(image.id));
                           allImages = allImages.concat(images);
                       });
                   });
                   // Ordena as imagens pelo nome do local
                   allImages.sort((a, b) => a.local.localeCompare(b.local));
                   // Gera o HTML para exibir as imagens ordenadas
                   allImages.forEach(image => {
                       imagesHtml += `
                               <img src="${image.imageUrl}" alt="Imagem ID ${image.id}">
                                   Número do Mapa: ${image.id} 
Local: ${image.local}
Coordenada: ${image.coordinates} Tag: ${image.tag}
                       `;
                   });
                   imageContainer.innerHTML = imagesHtml || 'Nenhuma imagem encontrada com os números fornecidos.';
                   imageContainer.classList.remove('hidden');
               } else {
                   imageContainer.classList.add('hidden');
               }
           } else if (filterMode === 'tag') {
               // Filtrar por tag
               if (searchIds.length > 0) {
                   let imagesHtml = ;
                   let allImages = [];
                   // Recolhe todas as imagens que correspondem às tags
                   Object.keys(specificOptions).forEach(mapType => {
                       const mapOptions = specificOptions[mapType];
                       Object.keys(mapOptions).forEach(option => {
                           const images = mapOptions[option].filter(image => searchIds.includes(image.tag));
                           allImages = allImages.concat(images);
                       });
                   });
                   // Ordena as imagens pelo nome do local
                   allImages.sort((a, b) => a.local.localeCompare(b.local));
                   // Gera o HTML para exibir as imagens ordenadas
                   allImages.forEach(image => {
                       imagesHtml += `
                               <img src="${image.imageUrl}" alt="Imagem Tag ${image.tag}">
                                   Número do Mapa: ${image.id} 
Local: ${image.local}
Coordenada: ${image.coordinates} Tag: ${image.tag}
                       `;
                   });
                   imageContainer.innerHTML = imagesHtml || 'Nenhuma imagem encontrada com as tags fornecidas.';
                   imageContainer.classList.remove('hidden');
               } else {
                   imageContainer.classList.add('hidden');
               }
           }
       });
   </script>

</body>

</html>