Widget:Test3: 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 259: Linha 259:
         const specificOptions = {
         const specificOptions = {
             1: {
             1: {
    'Areia': [  
                '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: '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: '102', local: 'Desert Area', coordinates: '4891, 2234, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/2/2a/Mapa_Verde_ADV_-_4891%2C_2234%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' },
                'Gelo': [
    { id: '105', local: 'Hurricane Island', coordinates: '4166, 3302, 7',tags:['Areia','Árvore','Água'], imageUrl: 'https://wiki.pokexgames.com/images/0/0d/Mapas_de_ADV_VERMELHO_-_4166%2C_3302%2C_7.webp' },
                    { id: '103', local: 'Snow Land', coordinates: '4881, 4234, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/6/6b/Mapa_Roxo_ADV_-_4881%2C_4234%2C_7.webp' }
]
                ]
             },
             },
             2: {
             2: {
                 'Gelo': [
                 'Areia': [
                     { id: '201', local: 'Frozen Tundra', coordinates: '5600, 5200, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/6/6f/Mapas_de_ADV_VERDE_-_5600%2C_5200%2C_7.webp' }
                     { id: '201', local: 'Sunny Desert', coordinates: '5000, 5000, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/3/36/Mapa_Verde_ADV_-_5000%2C_5000%2C_7.webp' }
                 ]
                 ]
             },
             },
             3: {
             3: {
                 'Grama': [
                 'Gelo': [
                     { id: '301', local: 'Grassland Fields', coordinates: '3300, 2200, 7', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/7/70/Mapas_de_ADV_ROXO_-_3300%2C_2200%2C_7.webp' }
                     { id: '301', local: 'Icy Peaks', coordinates: '3200, 4200, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/9/98/Mapa_Vermelho_ADV_-_3200%2C_4200%2C_7.webp' }
                 ]
                 ]
             }
             }
         };
         };


         function displayMaps(maps) {
         document.getElementById('enableFilter').addEventListener('change', function () {
            const container = document.getElementById('imageContainer');
            const filterSection = document.getElementById('filterSection');
            container.innerHTML = ''; // Clear previous results
            const specificOptionsSection = document.getElementById('specificOptions');
 
            if (this.checked) {
            maps.forEach(map => {
                 filterSection.classList.remove('hidden');
                const imageItem = document.createElement('div');
                 specificOptionsSection.classList.remove('hidden');
                imageItem.className = 'image-item';
            } else {
 
                 filterSection.classList.add('hidden');
                const image = document.createElement('img');
                 specificOptionsSection.classList.add('hidden');
                image.src = map.imageUrl;
                document.getElementById('searchIds').value = '';
                 image.alt = map.local;
                document.getElementById('imageContainer').innerHTML = '';
                image.className = 'map-image';
 
                 const info = document.createElement('div');
                info.className = 'image-info';
                info.innerHTML = `
                    <strong>Local:</strong> ${map.local}<br>
                    <strong>Coordenadas:</strong> ${map.coordinates}<br>
                    <strong>ID:</strong> ${map.id}
                `;
 
                 imageItem.appendChild(image);
                imageItem.appendChild(info);
 
                 container.appendChild(imageItem);
            });
 
            container.classList.remove('hidden');
        }
 
        function filterResults() {
            const mapType = document.getElementById('mapType').value;
            const specificOption = document.getElementById('specificOption').value;
            const tagInput = document.getElementById('searchIds').value.trim();
            const enableFilter = document.getElementById('enableFilter').checked;
 
            if (!enableFilter) {
                return; // If filter is disabled, do nothing
             }
             }
        });


             let filteredMaps = [];
        document.getElementById('mapType').addEventListener('change', function () {
 
             const specificOptionsSelect = document.getElementById('specificOption');
             if (mapType && specificOption) {
            const selectedValue = this.value;
                 filteredMaps = specificOptions[mapType][specificOption] || [];
             if (selectedValue) {
                specificOptionsSelect.classList.remove('hidden');
            } else {
                specificOptionsSelect.classList.add('hidden');
                document.getElementById('specificOption').value = '';
                 document.getElementById('imageContainer').innerHTML = '';
             }
             }
        });


            if (tagInput) {
        document.getElementById('filterOption').addEventListener('change', function () {
                const tags = tagInput.split(',').map(tag => tag.trim().toLowerCase());
            const searchInput = document.getElementById('searchIds');
                filteredMaps = filteredMaps.filter(map => tags.every(tag => map.tags.map(t => t.toLowerCase()).includes(tag)));
            if (this.value === 'number') {
                searchInput.setAttribute('placeholder', 'Digite os números separados por vírgula');
            } else if (this.value === 'tag') {
                searchInput.setAttribute('placeholder', 'Digite as tags separadas por vírgula');
             }
             }
        });


             if (!mapType || !specificOption) {
        document.getElementById('filterButton').addEventListener('click', function () {
                alert('Selecione pelo menos um tipo de mapa e um local do X.');
             const selectedType = document.getElementById('mapType').value;
                return;
            const selectedSpecificOption = document.getElementById('specificOption').value;
             }
            const filterOption = document.getElementById('filterOption').value;
            const searchValue = document.getElementById('searchIds').value.trim().toLowerCase();
             const imageContainer = document.getElementById('imageContainer');


             displayMaps(filteredMaps);
             if (selectedType && selectedSpecificOption) {
        }
                let filteredImages = [];
                const types = specificOptions[selectedType];


        document.getElementById('mapType').addEventListener('change', function () {
                for (const option in types) {
            document.getElementById('specificOptions').classList.remove('hidden');
                    if (types.hasOwnProperty(option) && (selectedSpecificOption === option || selectedSpecificOption === '')) {
            filterResults();
                        const images = types[option];
        });
                        images.forEach(image => {
                            if (filterOption === 'number' && searchValue) {
                                if (image.id.split(',').includes(searchValue)) {
                                    filteredImages.push(image);
                                }
                            } else if (filterOption === 'tag' && searchValue) {
                                const tags = searchValue.split(',').map(tag => tag.trim().toLowerCase());
                                if (tags.some(tag => image.tags.includes(tag))) {
                                    filteredImages.push(image);
                                }
                            } else {
                                filteredImages.push(image);
                            }
                        });
                    }
                }


        document.getElementById('specificOption').addEventListener('change', filterResults);
                imageContainer.innerHTML = '';
 
                if (filteredImages.length > 0) {
        document.getElementById('tagButtons').addEventListener('click', function (e) {
                    filteredImages.forEach(image => {
            if (e.target.classList.contains('tag-button')) {
                        const imageItem = document.createElement('div');
                e.target.classList.toggle('selected');
                        imageItem.className = 'image-item';
                const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(button => button.getAttribute('data-value')).join(',');
                        imageItem.innerHTML = `
                 document.getElementById('searchIds').value = selectedTags;
                            <img src="${image.imageUrl}" alt="Imagem do mapa">
                 filterResults();
                            <div class="image-info">
                                <p>Local: ${image.local}</p>
                                <p>Coordenadas: ${image.coordinates}</p>
                            </div>
                        `;
                        imageContainer.appendChild(imageItem);
                    });
                    imageContainer.classList.remove('hidden');
                 } else {
                    imageContainer.innerHTML = '<p>Nenhuma imagem encontrada.</p>';
                 }
            } else {
                alert('Selecione pelo menos um tipo de mapa e local do X.');
             }
             }
         });
         });


         document.getElementById('enableFilter').addEventListener('change', function () {
         const tagButtons = document.querySelectorAll('.tag-button');
            document.getElementById('filterSection').classList.toggle('hidden', !this.checked);
        tagButtons.forEach(button => {
             filterResults();
            button.addEventListener('click', function () {
                this.classList.toggle('selected');
             });
         });
         });
        document.getElementById('filterButton').addEventListener('click', filterResults);
        document.getElementById('searchIds').addEventListener('input', filterResults);
     </script>
     </script>
</body>
</body>


</html>
</html>

Edição das 21h44min de 3 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>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>
           <input type="checkbox" id="enableFilter">
           <label for="enableFilter" class="filter-label">Ativar filtro</label>
           <label for="tagSelect">Selecione as Tags:</label>
Areia
Grama
Gelo
Árvore
Pedra
Terra
Piso
Construção
Pântano
Pirâmide
Fogo
Água
   </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: 'Desert Area', coordinates: '4891, 2234, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/2/2a/Mapa_Verde_ADV_-_4891%2C_2234%2C_7.webp' }
               ],
               'Gelo': [
                   { id: '103', local: 'Snow Land', coordinates: '4881, 4234, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/6/6b/Mapa_Roxo_ADV_-_4881%2C_4234%2C_7.webp' }
               ]
           },
           2: {
               'Areia': [
                   { id: '201', local: 'Sunny Desert', coordinates: '5000, 5000, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/3/36/Mapa_Verde_ADV_-_5000%2C_5000%2C_7.webp' }
               ]
           },
           3: {
               'Gelo': [
                   { id: '301', local: 'Icy Peaks', coordinates: '3200, 4200, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/9/98/Mapa_Vermelho_ADV_-_3200%2C_4200%2C_7.webp' }
               ]
           }
       };
       document.getElementById('enableFilter').addEventListener('change', function () {
           const filterSection = document.getElementById('filterSection');
           const specificOptionsSection = document.getElementById('specificOptions');
           if (this.checked) {
               filterSection.classList.remove('hidden');
               specificOptionsSection.classList.remove('hidden');
           } else {
               filterSection.classList.add('hidden');
               specificOptionsSection.classList.add('hidden');
               document.getElementById('searchIds').value = ;
               document.getElementById('imageContainer').innerHTML = ;
           }
       });
       document.getElementById('mapType').addEventListener('change', function () {
           const specificOptionsSelect = document.getElementById('specificOption');
           const selectedValue = this.value;
           if (selectedValue) {
               specificOptionsSelect.classList.remove('hidden');
           } else {
               specificOptionsSelect.classList.add('hidden');
               document.getElementById('specificOption').value = ;
               document.getElementById('imageContainer').innerHTML = ;
           }
       });
       document.getElementById('filterOption').addEventListener('change', function () {
           const searchInput = document.getElementById('searchIds');
           if (this.value === 'number') {
               searchInput.setAttribute('placeholder', 'Digite os números separados por vírgula');
           } else if (this.value === 'tag') {
               searchInput.setAttribute('placeholder', 'Digite as tags separadas por vírgula');
           }
       });
       document.getElementById('filterButton').addEventListener('click', function () {
           const selectedType = document.getElementById('mapType').value;
           const selectedSpecificOption = document.getElementById('specificOption').value;
           const filterOption = document.getElementById('filterOption').value;
           const searchValue = document.getElementById('searchIds').value.trim().toLowerCase();
           const imageContainer = document.getElementById('imageContainer');
           if (selectedType && selectedSpecificOption) {
               let filteredImages = [];
               const types = specificOptions[selectedType];
               for (const option in types) {
                   if (types.hasOwnProperty(option) && (selectedSpecificOption === option || selectedSpecificOption === )) {
                       const images = types[option];
                       images.forEach(image => {
                           if (filterOption === 'number' && searchValue) {
                               if (image.id.split(',').includes(searchValue)) {
                                   filteredImages.push(image);
                               }
                           } else if (filterOption === 'tag' && searchValue) {
                               const tags = searchValue.split(',').map(tag => tag.trim().toLowerCase());
                               if (tags.some(tag => image.tags.includes(tag))) {
                                   filteredImages.push(image);
                               }
                           } else {
                               filteredImages.push(image);
                           }
                       });
                   }
               }
               imageContainer.innerHTML = ;
               if (filteredImages.length > 0) {
                   filteredImages.forEach(image => {
                       const imageItem = document.createElement('div');
                       imageItem.className = 'image-item';
                       imageItem.innerHTML = `
                           <img src="${image.imageUrl}" alt="Imagem do mapa">

Local: ${image.local}

Coordenadas: ${image.coordinates}

                       `;
                       imageContainer.appendChild(imageItem);
                   });
                   imageContainer.classList.remove('hidden');
               } else {

imageContainer.innerHTML = '

Nenhuma imagem encontrada.

';

               }
           } else {
               alert('Selecione pelo menos um tipo de mapa e local do X.');
           }
       });
       const tagButtons = document.querySelectorAll('.tag-button');
       tagButtons.forEach(button => {
           button.addEventListener('click', function () {
               this.classList.toggle('selected');
           });
       });
   </script>

</body>

</html>