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 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>Filtro de Mapas</title>
     <style>
     <style>
        .d-flex {
.d-flex {
             display: flex;
             display: flex;
             justify-content: center;
             justify-content: center;
Linha 183: Linha 183:
     </style>
     </style>
</head>
</head>
<body>
<body>
     <form id="mapForm">
     <div>
         <div id="mapTypeSelection" class="input-group">
        <label>
             <select id="mapType" class="maps__select">
            <input type="checkbox" id="filterActive"> Ativar Filtro
                <option value="">Selecione um mapa</option>
        </label>
                <option value="1">Mapa Vermelho</option>
         <div id="mapTypeContainer" class="hidden">
                <option value="2">Mapa Verde</option>
             <label>
                 <option value="3">Mapa Roxo</option>
                Tipo de Mapa:
            </select>
                <select id="mapType">
             <label class="maps__label" for="mapType">Tipo de Mapa</label>
                    <option value="">Selecione</option>
                    <option value="1">Mapa Vermelho</option>
                    <!-- Adicione outras opções de mapa conforme necessário -->
                 </select>
             </label>
         </div>
         </div>
 
         <div id="specificOptionsContainer" class="hidden">
         <div id="specificOptions" class="input-group">
             <label>
             <select id="specificOption" class="maps__select">
                Local do X:
                <option value="">Selecione uma opção</option>
                <select id="specificOption">
                <option value="Areia">Areia</option>
                    <option value="">Selecione</option>
                <option value="Gelo">Gelo</option>
                    <option value="Areia">Areia</option>
                <option value="Grama">Grama</option>
                    <option value="Gelo">Gelo</option>
                <option value="Pedra">Pedra</option>
                    <option value="Grama">Grama</option>
                <option value="Subaquático">Subaquático</option>
                    <option value="Pedra">Pedra</option>
                <option value="Terra">Terra</option>
                    <option value="Subaquático">Subaquático</option>
                <option value="Pisos">Pisos</option>
                    <option value="Terra">Terra</option>
            </select>
                    <option value="Pisos">Pisos</option>
             <label class="maps__label" for="specificOption">Local do X</label>
                </select>
        </div>
             </label>
       
        <div class="filter-container">
            <input type="checkbox" id="enableFilter">
            <label for="enableFilter" class="filter-label">Ativar filtro</label>
        </div>
       
        <div class="input-group">
            <label for="tagSelect">Selecione as Tags:</label>
             <div id="tagButtons" class="hidden">
             <div id="tagButtons" class="hidden">
                 <div class="tag-button" data-value="Areia">Areia</div>
                 <!-- Tags serão adicionadas dinamicamente aqui -->
                <div class="tag-button" data-value="Grama">Grama</div>
                <div class="tag-button" data-value="Gelo">Gelo</div>
                <div class="tag-button" data-value="Árvore">Árvore</div>
                <div class="tag-button" data-value="Pedra">Pedra</div>
                <div class="tag-button" data-value="Terra">Terra</div>
                <div class="tag-button" data-value="Piso">Piso</div>
                <div class="tag-button" data-value="Construção">Construção</div>
                <div class="tag-button" data-value="Pântano">Pântano</div>
                <div class="tag-button" data-value="Pirâmide">Pirâmide</div>
                <div class="tag-button" data-value="Fogo">Fogo</div>
                <div class="tag-button" data-value="Água">Água</div>
             </div>
             </div>
         </div>
         </div>
       
         <button id="filterButton" class="hidden">Filtrar</button>
         <div id="filterSection" class="hidden">
    </div>
            <div id="filterById" class="input-group">
    <div id="imageContainer"></div>
                <label for="filterOption" class="maps__label">Filtrar Por</label>
                <select id="filterOption" class="maps__select">
                    <option value="">Escolha uma Opção</option>
                    <option value="number">Filtrar por Número</option>
                    <option value="tag">Filtrar por Tag</option>
                </select>
                <input type="text" id="searchIds" placeholder="Digite os números ou tags separados por vírgula" class="maps__select">
            </div>
 
            <div class="d-flex">
                <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 id="imageContainer" class="image-container hidden">
            <!-- As imagens e suas informações serão exibidas aqui -->
        </div>
    </form>


     <script>
     <script>
         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: '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: '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: '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: '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: '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' }
                 ]
                 ],
            },
            2: {
                 'Gelo': [
                 'Gelo': [
                     { 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: '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' }
                 ]
                 ],
            },
            3: {
                 'Grama': [
                 'Grama': [
                     { 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: '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' }
                ],
                'Pedra': [
                    { id: '401', local: 'Rocky Ridge', coordinates: '4800, 4600, 7', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/8/80/Mapas_de_ADV_VERMELHO_-_4800%2C_4600%2C_7.webp' }
                ],
                'Subaquático': [
                    { id: '501', local: 'Underwater Cave', coordinates: '5700, 5200, 7', tags: ['Água'], imageUrl: 'https://wiki.pokexgames.com/images/9/90/Mapas_de_ADV_VERMELHO_-_5700%2C_5200%2C_7.webp' }
                ],
                'Terra': [
                    { id: '601', local: 'Mountain Pass', coordinates: '6100, 5300, 7', tags: ['Terra'], imageUrl: 'https://wiki.pokexgames.com/images/a/a0/Mapas_de_ADV_VERMELHO_-_6100%2C_5300%2C_7.webp' }
                ],
                'Pisos': [
                    { id: '701', local: 'Concrete Jungle', coordinates: '6000, 5500, 7', tags: ['Piso'], imageUrl: 'https://wiki.pokexgames.com/images/b/b0/Mapas_de_ADV_VERMELHO_-_6000%2C_5500%2C_7.webp' }
                 ]
                 ]
             }
             }
         };
         };


const tagMap = {
        const tagMap = {
        'Areia': 'Areia',
            'Areia': 'Areia',
        'Gelo': 'Gelo',
            'Gelo': 'Gelo',
        'Grama': 'Grama',
            'Grama': 'Grama',
        'Pedra': 'Pedra',
            'Pedra': 'Pedra',
        'Subaquático': 'Água',
            'Subaquático': 'Água',
        'Terra': 'Terra',
            'Terra': 'Terra',
        'Pisos': 'Piso'
            'Pisos': 'Piso'
    };
        };
      function updateTagButtons() {
 
        const specificOption = document.getElementById('specificOption').value;
        function updateTagButtons() {
        const tagButtons = document.querySelectorAll('.tag-button');
            const specificOption = document.getElementById('specificOption').value;
       
            const tagButtons = document.querySelectorAll('.tag-button');
        tagButtons.forEach(button => {
           
            const tagValue = button.getAttribute('data-value');
            tagButtons.forEach(button => {
            if (tagMap[specificOption] === tagValue) {
                const tagValue = button.getAttribute('data-value');
                button.classList.add('selected');
                if (tagMap[specificOption] === tagValue) {
                button.classList.add('disabled');
                    button.classList.add('selected');
                button.setAttribute('disabled', 'true');
                    button.classList.add('disabled');
            } else {
                    button.setAttribute('disabled', 'true');
                button.classList.remove('disabled');
                } else {
                 button.removeAttribute('disabled');
                    button.classList.remove('disabled');
                    button.removeAttribute('disabled');
                 }
            });
        }
 
        function toggleTagButton(e) {
            if (e.target.classList.contains('tag-button')) {
                if (e.target.classList.contains('disabled')) return;
                e.target.classList.toggle('selected');
                filterImages();
             }
             }
         });
         }
    }
 
        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.getAttribute('data-value'));


    function toggleTagButton(e) {
             let filteredMaps = [];
        if (e.target.classList.contains('tag-button')) {
             if (e.target.classList.contains('disabled')) return;
            e.target.classList.toggle('selected');
            filterImages();
        }
    }


    function filterImages() {
            if (mapType && specificOption) {
        const mapType = document.getElementById('mapType').value;
                filteredMaps = specificOptions[mapType][specificOption] || [];
        const specificOption = document.getElementById('specificOption').value;
            }
        const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(button => button.getAttribute('data-value'));


        let filteredMaps = [];
            if (selectedTags.length > 0) {
                filteredMaps = filteredMaps.filter(map => {
                    return selectedTags.some(tag => map.tags.includes(tag));
                });
            }


        if (mapType && specificOption) {
            displayMaps(filteredMaps);
            filteredMaps = specificOptions[mapType][specificOption] || [];
         }
         }


         if (selectedTags.length > 0) {
         function displayMaps(maps) {
             filteredMaps = filteredMaps.filter(map => {
            const container = document.getElementById('imageContainer');
                 return selectedTags.some(tag => map.tags.includes(tag));
             container.innerHTML = ''; // Clear previous results
            });
 
        }
            maps.forEach(map => {
                 const imageItem = document.createElement('div');
                imageItem.className = 'image-item';
 
                const image = document.createElement('img');
                image.src = map.imageUrl;
                image.alt = map.local;
                image.className = 'map-image';


        displayMaps(filteredMaps);
                const info = document.createElement('div');
    }
                info.className = 'image-info';
                info.innerHTML = `
                    <b>Número do Mapa</b>: ${map.id} <br>
                    <b>Local</b>: ${map.local} <br>
                    <b>Coordenada</b>: ${map.coordinates}<br>
                    <b>Tag(s)</b>: ${map.tags.join(', ') || 'Nenhuma'}
                `;


    function displayMaps(maps) {
                imageItem.appendChild(image);
        const container = document.getElementById('imageContainer');
                imageItem.appendChild(info);
        container.innerHTML = ''; // Clear previous results


        maps.forEach(map => {
                container.appendChild(imageItem);
            const imageItem = document.createElement('div');
             });
             imageItem.className = 'image-item';


             const image = document.createElement('img');
             container.classList.remove('hidden');
            image.src = map.imageUrl;
        }
            image.alt = map.local;
            image.className = 'map-image';


             const info = document.createElement('div');
        document.getElementById('filterActive').addEventListener('change', function () {
            info.className = 'image-info';
             const isActive = this.checked;
             info.innerHTML = `
            document.getElementById('mapTypeContainer').classList.toggle('hidden', !isActive);
                <b>Número do Mapa</b>: ${map.id} <br>
             document.getElementById('specificOptionsContainer').classList.toggle('hidden', !isActive);
                <b>Local</b>: ${map.local} <br>
            document.getElementById('filterButton').classList.toggle('hidden', !isActive);
                <b>Coordenada</b>: ${map.coordinates}<br>
        });
                <b>Tag(s)</b>: ${map.tags.join(', ') || 'Nenhuma'}
            `;


             imageItem.appendChild(image);
        document.getElementById('mapType').addEventListener('change', function () {
             imageItem.appendChild(info);
             document.getElementById('specificOptionsContainer').classList.remove('hidden');
            updateTagButtons();
             filterImages();
        });


             container.appendChild(imageItem);
        document.getElementById('specificOption').addEventListener('change', function () {
            updateTagButtons();
             filterImages();
         });
         });


         container.classList.remove('hidden');
         document.getElementById('filterButton').addEventListener('click', filterImages);
    }


    document.getElementById('mapType').addEventListener('change', function () {
        // Dynamically add tag buttons
        document.getElementById('specificOptions').classList.remove('hidden');
        function populateTagButtons() {
        updateTagButtons();
            const tags = Object.keys(tagMap);
        filterImages();
            const container = document.getElementById('tagButtons');
    });
            container.innerHTML = ''; // Clear existing buttons


    document.getElementById('specificOption').addEventListener('change', function () {
            tags.forEach(tag => {
        updateTagButtons();
                const button = document.createElement('div');
        filterImages();
                button.className = 'tag-button';
    });
                button.setAttribute('data-value', tag);
                button.textContent = tag;
                container.appendChild(button);
            });
        }


    document.getElementById('tagButtons').addEventListener('click', toggleTagButton);
        populateTagButtons();


    document.getElementById('filterButton').addEventListener('click', filterImages);
        document.getElementById('tagButtons').addEventListener('click', toggleTagButton);
     </script>
     </script>
</body>
</body>
</html>
</html>

Edição das 22h33min 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>Filtro de Mapas</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>

       <label>
           <input type="checkbox" id="filterActive"> Ativar Filtro
       </label>
       <button id="filterButton" class="hidden">Filtrar</button>
   <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: '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' }
               ],
               'Gelo': [
                   { 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' }
               ],
               'Grama': [
                   { 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' }
               ],
               'Pedra': [
                   { id: '401', local: 'Rocky Ridge', coordinates: '4800, 4600, 7', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/8/80/Mapas_de_ADV_VERMELHO_-_4800%2C_4600%2C_7.webp' }
               ],
               'Subaquático': [
                   { id: '501', local: 'Underwater Cave', coordinates: '5700, 5200, 7', tags: ['Água'], imageUrl: 'https://wiki.pokexgames.com/images/9/90/Mapas_de_ADV_VERMELHO_-_5700%2C_5200%2C_7.webp' }
               ],
               'Terra': [
                   { id: '601', local: 'Mountain Pass', coordinates: '6100, 5300, 7', tags: ['Terra'], imageUrl: 'https://wiki.pokexgames.com/images/a/a0/Mapas_de_ADV_VERMELHO_-_6100%2C_5300%2C_7.webp' }
               ],
               'Pisos': [
                   { id: '701', local: 'Concrete Jungle', coordinates: '6000, 5500, 7', tags: ['Piso'], imageUrl: 'https://wiki.pokexgames.com/images/b/b0/Mapas_de_ADV_VERMELHO_-_6000%2C_5500%2C_7.webp' }
               ]
           }
       };
       const tagMap = {
           'Areia': 'Areia',
           'Gelo': 'Gelo',
           'Grama': 'Grama',
           'Pedra': 'Pedra',
           'Subaquático': 'Água',
           'Terra': 'Terra',
           'Pisos': 'Piso'
       };
       function updateTagButtons() {
           const specificOption = document.getElementById('specificOption').value;
           const tagButtons = document.querySelectorAll('.tag-button');
           
           tagButtons.forEach(button => {
               const tagValue = button.getAttribute('data-value');
               if (tagMap[specificOption] === tagValue) {
                   button.classList.add('selected');
                   button.classList.add('disabled');
                   button.setAttribute('disabled', 'true');
               } else {
                   button.classList.remove('disabled');
                   button.removeAttribute('disabled');
               }
           });
       }
       function toggleTagButton(e) {
           if (e.target.classList.contains('tag-button')) {
               if (e.target.classList.contains('disabled')) return;
               e.target.classList.toggle('selected');
               filterImages();
           }
       }
       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.getAttribute('data-value'));
           let filteredMaps = [];
           if (mapType && specificOption) {
               filteredMaps = specificOptions[mapType][specificOption] || [];
           }
           if (selectedTags.length > 0) {
               filteredMaps = filteredMaps.filter(map => {
                   return selectedTags.some(tag => map.tags.includes(tag));
               });
           }
           displayMaps(filteredMaps);
       }
       function displayMaps(maps) {
           const container = document.getElementById('imageContainer');
           container.innerHTML = ; // Clear previous results
           maps.forEach(map => {
               const imageItem = document.createElement('div');
               imageItem.className = 'image-item';
               const image = document.createElement('img');
               image.src = map.imageUrl;
               image.alt = map.local;
               image.className = 'map-image';
               const info = document.createElement('div');
               info.className = 'image-info';
               info.innerHTML = `
                   Número do Mapa: ${map.id} 
Local: ${map.local}
Coordenada: ${map.coordinates}
Tag(s): ${map.tags.join(', ') || 'Nenhuma'} `;
               imageItem.appendChild(image);
               imageItem.appendChild(info);
               container.appendChild(imageItem);
           });
           container.classList.remove('hidden');
       }
       document.getElementById('filterActive').addEventListener('change', function () {
           const isActive = this.checked;
           document.getElementById('mapTypeContainer').classList.toggle('hidden', !isActive);
           document.getElementById('specificOptionsContainer').classList.toggle('hidden', !isActive);
           document.getElementById('filterButton').classList.toggle('hidden', !isActive);
       });
       document.getElementById('mapType').addEventListener('change', function () {
           document.getElementById('specificOptionsContainer').classList.remove('hidden');
           updateTagButtons();
           filterImages();
       });
       document.getElementById('specificOption').addEventListener('change', function () {
           updateTagButtons();
           filterImages();
       });
       document.getElementById('filterButton').addEventListener('click', filterImages);
       // Dynamically add tag buttons
       function populateTagButtons() {
           const tags = Object.keys(tagMap);
           const container = document.getElementById('tagButtons');
           container.innerHTML = ; // Clear existing buttons
           tags.forEach(tag => {
               const button = document.createElement('div');
               button.className = 'tag-button';
               button.setAttribute('data-value', tag);
               button.textContent = tag;
               container.appendChild(button);
           });
       }
       populateTagButtons();
       document.getElementById('tagButtons').addEventListener('click', toggleTagButton);
   </script>

</body> </html>