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
Linha 200: Linha 200:


     <script>
     <script>
        // Dados de exemplo para filtros
         const specificOptions = {
         const specificOptions = {
             1: {
             1: {
                 'Areia': [
                 'Areia': [
                     { id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' },
                     { id: '101', local: 'Local Verde 1', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }
                 ],
                 ]
             },
             },
             2: {
             2: {
                 'Areia': [
                 '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: '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' },
                     { 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: {
             3: {
Linha 243: Linha 244:
             const specificOptionSelect = document.getElementById('specificOption');
             const specificOptionSelect = document.getElementById('specificOption');


            specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
             if (selectedMapType) {
             if (selectedMapType) {
                specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
                 const options = Object.keys(specificOptions[selectedMapType] || {});
                 const options = Object.keys(specificOptions[selectedMapType] || {});
                 options.forEach(option => {
                 options.forEach(option => {
Linha 256: Linha 257:


         document.getElementById('filterButton').addEventListener('click', function () {
         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 selectedMapType = document.getElementById('mapType').value;
             const selectedOption = document.getElementById('specificOption').value;
             const selectedOption = document.getElementById('specificOption').value;
            const filterMode = document.getElementById('filterMode').value;
            const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim().toLowerCase());
             const imageContainer = document.getElementById('imageContainer');
             const imageContainer = document.getElementById('imageContainer');


Linha 269: Linha 270:
             let imagesHtml = '';
             let imagesHtml = '';
             let allImages = [];
             let allImages = [];
            // Recolhe todas as imagens que correspondem ao tipo de mapa e opção específica
             const mapOptions = specificOptions[selectedMapType] || {};
             const mapOptions = specificOptions[selectedMapType] || {};
             const images = mapOptions[selectedOption] || [];
             const images = mapOptions[selectedOption] || [];
             if (filterMode === 'number') {
             if (filterMode === 'number') {
                 allImages = images.filter(image => searchIds.includes(image.id));
                 allImages = images.filter(image => searchIds.includes(image.id.toLowerCase()));
             } else if (filterMode === 'tag') {
             } else if (filterMode === 'tag') {
                 allImages = images.filter(image => searchIds.includes(image.tag));
                 allImages = images.filter(image => searchIds.includes(image.tag.toLowerCase()));
             }
             }


            // Ordena as imagens pelo nome do local
             allImages.sort((a, b) => a.local.localeCompare(b.local));
             allImages.sort((a, b) => a.local.localeCompare(b.local));


            // Gera o HTML para exibir as imagens ordenadas
             allImages.forEach(image => {
             allImages.forEach(image => {
                 imagesHtml += `
                 imagesHtml += `
Linha 291: Linha 289:
                             <b>Local</b>: ${image.local} <br>
                             <b>Local</b>: ${image.local} <br>
                             <b>Coordenada</b>: ${image.coordinates} <br>
                             <b>Coordenada</b>: ${image.coordinates} <br>
                             <b>Tag</b>: ${image.tag} <br>
                             <b>Tag</b>: ${image.tag || 'Não disponível'} <br>
                         </div>
                         </div>
                     </div>
                     </div>

Edição das 03h18min de 27 de agosto 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>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>
       // Dados de exemplo para filtros
       const specificOptions = {
           1: {
               'Areia': [
                   { id: '101', local: 'Local Verde 1', 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');
           specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
           if (selectedMapType) {
               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 selectedMapType = document.getElementById('mapType').value;
           const selectedOption = document.getElementById('specificOption').value;
           const filterMode = document.getElementById('filterMode').value;
           const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim().toLowerCase());
           const imageContainer = document.getElementById('imageContainer');
           if (!selectedMapType || !selectedOption) {
               alert("Selecione pelo menos um tipo de mapa");
               return;
           }
           let imagesHtml = ;
           let allImages = [];
           const mapOptions = specificOptions[selectedMapType] || {};
           const images = mapOptions[selectedOption] || [];
           if (filterMode === 'number') {
               allImages = images.filter(image => searchIds.includes(image.id.toLowerCase()));
           } else if (filterMode === 'tag') {
               allImages = images.filter(image => searchIds.includes(image.tag.toLowerCase()));
           }
           allImages.sort((a, b) => a.local.localeCompare(b.local));
           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 || 'Não disponível'}
               `;
           });
           imageContainer.innerHTML = imagesHtml || 'Nenhuma imagem encontrada com os parâmetros fornecidos.';
           imageContainer.classList.remove('hidden');
       });
   </script>

</body>

</html>