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 de Mapas</title>
     <title>Seleção e Exibição de Imagens</title>
      <style>
    <style>
         .d-flex {
         .d-flex {
             display: flex;
             display: flex;
Linha 175: Linha 176:
         }
         }


         .tag-buttons button.disabled {
         .tag-button.disabled {
             background-color: #e0e0e0;
             background-color: #e0e0e0;
             color: #a0a0a0;
             color: #a0a0a0;
Linha 184: Linha 185:
</head>
</head>
<body>
<body>
     <div class="input-group">
     <form id="mapForm">
         <label for="mapType">Tipo de Mapa</label>
         <div id="mapTypeSelection" class="input-group">
        <select id="mapType" class="maps__select">
            <select id="mapType" class="maps__select">
            <option value="">Selecione um mapa</option>
                <option value="">Selecione um mapa</option>
            <option value="1">Mapa Vermelho</option>
                <option value="1">Mapa Vermelho</option>
            <option value="2">Mapa Verde</option>
                <option value="2">Mapa Verde</option>
            <option value="3">Mapa Roxo</option>
                <option value="3">Mapa Roxo</option>
        </select>
            </select>
    </div>
            <label class="maps__label" for="mapType">Tipo de Mapa</label>
        </div>


    <div class="input-group">
        <div id="specificOptions" class="hidden input-group">
        <label for="specificOption">Local do X</label>
            <select id="specificOption" class="maps__select">
        <select id="specificOption" class="maps__select">
                <option value="">Selecione uma opção</option>
            <option value="">Selecione uma opção</option>
                <option value="Areia">Areia</option>
            <option value="Areia">Areia</option>
                <option value="Gelo">Gelo</option>
            <option value="Gelo">Gelo</option>
                <option value="Grama">Grama</option>
            <option value="Grama">Grama</option>
                <option value="Pedra">Pedra</option>
            <option value="Pedra">Pedra</option>
                <option value="Subaquático">Subaquático</option>
            <option value="Subaquático">Subaquático</option>
                <option value="Terra">Terra</option>
            <option value="Terra">Terra</option>
                <option value="Pisos">Pisos</option>
            <option value="Pisos">Pisos</option>
            </select>
        </select>
            <label class="maps__label" for="specificOption">Local do X</label>
    </div>
        </div>
 
       
    <div class="filter-container">
        <div class="filter-container">
        <input type="checkbox" id="enableFilter">
            <input type="checkbox" id="enableFilter">
        <label for="enableFilter">Ativar filtro</label>
            <label for="enableFilter" class="filter-label">Ativar filtro</label>
    </div>
        </div>
       
        <div id="filterSection" class="hidden">
            <div id="filterById" class="input-group">
                <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="mapsCalc__select">
            </div>


    <div id="filterOptions" class="input-group hidden">
        <label for="filterType">Filtrar Por</label>
        <select id="filterType" class="maps__select">
            <option value="number">Filtrar por Número</option>
        </select>
        <input type="text" id="searchIds" placeholder="Digite os números separados por vírgula">
       
<button id="filterButton">
    <img src="https://wiki.pokexgames.com/images/8/82/Botao_Filtrar_Mapas_Adv.png" alt="Filtrar">
</button>
    </div>


    <div id="tagButtons" class="hidden">
            <div class="d-flex justify-center align-center flex-column">
        <!-- Botões de tag serão exibidos aqui -->
                <button type="button" id="filterButton" class="hover-minimize">
    </div>
                    <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">
        <div id="imageContainer" class="image-container hidden">
        <!-- As imagens e suas informações serão exibidas aqui -->
            <!-- As imagens e suas informações serão exibidas aqui -->
     </div>
        </div>
     </form>


<script>
    <script>
    const specificOptions = {
const specificOptions = {
        1: { // Mapa Vermelho
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' },  
Linha 243: Linha 249:
     { 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: { // Mapa Verde
};
             'Gelo': [
                { id: '201', local: 'Frozen Lake', coordinates: '5100, 3300, 6', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/7/7b/Mapa_Verde_ADV_-_5100%2C_3300%2C_6.webp' }
            ],
            'Pedra': [
                { id: '202', local: 'Rocky Mountains', coordinates: '4700, 5600, 5', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/8/8e/Mapa_Verde_ADV_-_4700%2C_5600%2C_5.webp' }
            ]
        },
        3: { // Mapa Roxo
            'Subaquático': [
                { id: '301', local: 'Underwater Cave', coordinates: '3000, 2900, 4', tags: ['Água', 'Subaquático'], imageUrl: 'https://wiki.pokexgames.com/images/9/93/Mapa_Roxo_ADV_-_3000%2C_2900%2C_4.webp' }
            ],
            'Terra': [
                { id: '302', local: 'Earth Plains', coordinates: '3400, 4400, 6', tags: ['Terra'], imageUrl: 'https://wiki.pokexgames.com/images/a/a1/Mapa_Roxo_ADV_-_3400%2C_4400%2C_6.webp' }
            ]
        }
    };


    const mapTypeSelect = document.getElementById('mapType');
        document.getElementById('enableFilter').addEventListener('change', function () {
    const specificOptionSelect = document.getElementById('specificOption');
            const filterSection = document.getElementById('filterSection');
    const filterOptions = document.getElementById('filterOptions');
            if (this.checked) {
    const tagButtons = document.getElementById('tagButtons');
                filterSection.classList.remove('hidden');
    const imageContainer = document.getElementById('imageContainer');
            } else {
    const enableFilter = document.getElementById('enableFilter');
                filterSection.classList.add('hidden');
    const filterTypeSelect = document.getElementById('filterType');
            }
    const searchIdsInput = document.getElementById('searchIds');
        });  
    const filterButton = document.getElementById('filterButton');
 
    function updateTags() {
        const selectedMapType = mapTypeSelect.value;
        const selectedOption = specificOptionSelect.value;


         let tags = [];
         document.getElementById('searchIds').addEventListener('keypress', function (event) {
        if (selectedMapType && selectedOption) {
             if (event.key === 'Enter') {
            const options = specificOptions[selectedMapType];
                 event.preventDefault();
             if (options && options[selectedOption]) {
                document.getElementById('filterButton').click();
                 options[selectedOption].forEach(item => {
                    tags = [...new Set([...tags, ...item.tags])];
                });
             }
             }
         }
         });


         tagButtons.innerHTML = '';
         document.getElementById('mapType').addEventListener('change', function () {
            const selectedMapType = this.value;
            const specificOptionSelect = document.getElementById('specificOption');


        const disabledTags = {
            if (selectedMapType) {
            'Areia': 'Areia',
                specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
            'Gelo': 'Gelo',
                const options = Object.keys(specificOptions[selectedMapType]);
            'Grama': 'Grama',
                options.forEach(option => {
            'Pedra': 'Pedra',
                    specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`;
            'Subaquático': 'Água',
                });
            'Terra': 'Terra',
                document.getElementById('specificOptions').classList.remove('hidden');
            'Pisos': 'Piso'
             } else {
        };
                 document.getElementById('specificOptions').classList.add('hidden');
 
        tags.forEach(tag => {
            const button = document.createElement('button');
            button.textContent = tag;
            button.classList.add('tag-button');
             if (disabledTags[selectedOption] === tag) {
                 button.disabled = true; // Desabilitar a tag correspondente ao Local do X
                button.classList.add('disabled');
             }
             }
            button.addEventListener('click', () => {
                if (!button.disabled) {
                    button.classList.toggle('selected');
                }
            });
            tagButtons.appendChild(button);
         });
         });


         tagButtons.classList.toggle('hidden', tags.length === 0);
         document.getElementById('specificOption').addEventListener('change', function () {
    }
            const selectedMapType = document.getElementById('mapType').value;
            const selectedOption = this.value;
            const imageContainer = document.getElementById('imageContainer');


function filterImages() {
            if (selectedMapType && selectedOption) {
    const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(btn => btn.textContent);
                const images = specificOptions[selectedMapType][selectedOption];
    const selectedMapType = mapTypeSelect.value;
                let imagesHtml = '';
    const selectedOption = specificOptionSelect.value;
    const filterById = searchIdsInput.value.trim();


    imageContainer.innerHTML = '';
                if (Array.isArray(images)) {
                    images.forEach(image => {
                        imagesHtml += `
                            <div class="image-item">
                                <img src="${image.imageUrl}" alt="${selectedOption}">
                                <div class="image-info">
                        <b>Número do Mapa</b>: ${image.id} <br>
                        <b>Local</b>: ${image.local} <br>
                        <b>Coordenada</b>: ${image.coordinates}<br>
                        <b>Tag(s)</b>: ${image.tags.join(', ') || 'Nenhuma'}
                                </div>
                            </div>
                        `;
                    });
                }


    let itemsToFilter = [];
                imageContainer.innerHTML = imagesHtml;
                imageContainer.classList.remove('hidden');
            } else {
                imageContainer.classList.add('hidden');
            }
        });


     // Verifica se tanto o Tipo de Mapa quanto o Local do X estão selecionados
document.getElementById('filterButton').addEventListener('click', function () {
     if (selectedMapType && selectedOption) {
     const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim().toLowerCase());
        const options = specificOptions[selectedMapType];
     const filterOption = document.getElementById('filterOption').value;
         if (options && options[selectedOption]) {
    const selectedMapType = document.getElementById('mapType').value;
            itemsToFilter = options[selectedOption];
    const selectedSpecificOption = document.getElementById('specificOption').value;
    const imageContainer = document.getElementById('imageContainer');
    let imagesHtml = '';
    let allImages = [];
if (filterOption === 'number') {
         if (searchIds.length > 0) {
            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);
                });
            });
         }
         }
    }


        // Remove a tag correspondente ao Local do X das tags selecionadas
    if (allImages.length > 0) {
         const tagsToFilter = selectedTags.filter(tag => tag !== selectedOption);
         allImages.sort((a, b) => a.local.localeCompare(b.local));


         // Se houver itens a serem filtrados, aplica os filtros
         allImages.forEach(image => {
        if (itemsToFilter.length > 0) {
            imagesHtml += `
            const filteredItems = itemsToFilter.filter(item => {
                 <div class="image-item">
                const matchesTag = tagsToFilter.length === 0 || tagsToFilter.every(tag => item.tags.includes(tag));
                     <img src="${image.imageUrl}" alt="Imagem ID ${image.id}">
                 const matchesId = filterById === '' || filterById.split(',').map(id => id.trim()).includes(item.id);
                     <div class="image-info">
 
                         <b>Número do Mapa</b>: ${image.id} <br>
                return matchesTag && matchesId;
                         <b>Local</b>: ${image.local} <br>
            });
                         <b>Coordenada</b>: ${image.coordinates}<br>
 
                         <b>Tag(s)</b>: ${image.tags.join(', ') || 'Nenhuma'}  
            // Exibe os itens filtrados
                     </div>
            if (filteredItems.length > 0) {
                 </div>
                filteredItems.forEach(item => {
             `;
                    const itemDiv = document.createElement('div');
         });
                    itemDiv.classList.add('image-item');
 
                    const img = document.createElement('img');
                     img.src = item.imageUrl;
                    img.alt = `Mapa ${item.id}`;
                     itemDiv.appendChild(img);
 
                    const infoDiv = document.createElement('div');
                    infoDiv.classList.add('image-info');
                    infoDiv.innerHTML = `
                         <strong>Número do Mapa:</strong> ${item.id}<br>
                         <strong>Local:</strong> ${item.local}<br>
                         <strong>Coordenada:</strong> ${item.coordinates}<br>
                         <strong>Tag(s):</strong> ${item.tags.join(', ')}
                     `;
                    itemDiv.appendChild(infoDiv);
 
                    imageContainer.appendChild(itemDiv);
                });
            } else {
                 imageContainer.innerHTML = '<p>Nenhuma imagem encontrada para os critérios selecionados.</p>';
             }
         } else {
            imageContainer.innerHTML = '<p>Nenhum item disponível para o tipo de mapa e local selecionados.</p>';
        }
     } else {
     } else {
         imageContainer.innerHTML = '<p>Por favor, selecione um Tipo de Mapa e um Local do X.</p>';
         imagesHtml = 'Nenhuma imagem encontrada com os critérios fornecidos.';
     }
     }
}


    imageContainer.innerHTML = imagesHtml;
    imageContainer.classList.toggle('hidden', allImages.length === 0);
});


    function handleFilterChange() {
const tagButtons = document.querySelectorAll('.tag-button');
         const isFilterEnabled = enableFilter.checked;
         const selectedTagsDiv = document.getElementById('selectedTags');


         if (isFilterEnabled) {
         // Função para atualizar as tags selecionadas
            mapTypeSelect.disabled = true;
        function updateSelectedTags() {
            specificOptionSelect.disabled = true;
            filterOptions.classList.remove('hidden');
            tagButtons.classList.add('hidden');


             filterTypeSelect.value = 'number';
             // Adiciona as novas tags selecionadas
            filterButton.addEventListener('click', () => {
            tagButtons.forEach(button => {
                // Desmarcar todas as tags ao ativar o filtro
                if (button.classList.contains('selected')) {
                document.querySelectorAll('.tag-button.selected').forEach(btn => btn.classList.remove('selected'));
                    const tagItem = document.createElement('span');
                 filterImages();
                    tagItem.className = 'tag-item';
                    tagItem.textContent = button.dataset.value;
                    selectedTagsDiv.appendChild(tagItem);
                 }
             });
             });
            mapTypeSelect.value = '';
            specificOptionSelect.value = '';
            searchIdsInput.value = '';
            imageContainer.innerHTML = '';
        } else {
            mapTypeSelect.disabled = false;
            specificOptionSelect.disabled = false;
            filterOptions.classList.add('hidden');
            tagButtons.classList.remove('hidden');
            searchIdsInput.value = '';
            imageContainer.innerHTML = '';
            updateTags();
         }
         }
    }
    enableFilter.addEventListener('change', handleFilterChange);
    mapTypeSelect.addEventListener('change', () => {
        updateTags();
        filterImages();
    });
    specificOptionSelect.addEventListener('change', () => {
        updateTags();
        filterImages();
    });
    // Inicializa a exibição das tags e imagens
    updateTags();
</script>


        // Adiciona o listener para detectar cliques nos botões
        tagButtons.forEach(button => {
            button.addEventListener('click', function() {
                // Alterna a classe 'selected' para selecionar/deselecionar a tag
                button.classList.toggle('selected');
                updateSelectedTags();
            });
        });
    </script>
</body>
</body>
</html>
</html>

Edição das 03h19min de 4 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; /* Mantém a proporção da imagem, cortando se necessário */
   margin-bottom: 5px;

}

       .image-info {
           margin-top: 5px;
       }
       select,
       input[type="text"],
       button {
           margin: 5px;
       }
       #filterButton {
           background: none;
           border: none;
           padding: 0;
           cursor: pointer;
           margin-top: 5px;
           display: flex;
           align-items: center;
       }
       #filterButton img {
           border-radius: 12px;
           margin-right: 5px;
           align-items: center;
       }
       #filterButton span {
           font-size: 16px;
           color: #0d0d0d;
       }
       .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;
       }
       /* Estilo para os botões de tags */


       .tag-button {
           background-color: #f0f0f0;
           border: 1px solid #ccc;
           border-radius: 5px;
           padding: 5px 10px;
           font-size: 14px;
           cursor: pointer;
           transition: background-color 0.3s, color 0.3s;
       }
       .tag-button:hover {
           background-color: #ddd;
           color: #333;
       }
       .tag-button.selected {
           background-color: #007bff;
           color: #fff;
           border-color: #007bff;
       }
       .tag-button.disabled {
           background-color: #e0e0e0;
           color: #a0a0a0;
           border-color: #d0d0d0;
           cursor: not-allowed;
       }
   </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',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' }, 

]

           },

};

       document.getElementById('enableFilter').addEventListener('change', function () {
           const filterSection = document.getElementById('filterSection');
           if (this.checked) {
               filterSection.classList.remove('hidden');
           } else {
               filterSection.classList.add('hidden');
           }
       }); 
       document.getElementById('searchIds').addEventListener('keypress', function (event) {
           if (event.key === 'Enter') {
               event.preventDefault();
               document.getElementById('filterButton').click();
           }
       });
       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('specificOption').addEventListener('change', function () {
           const selectedMapType = document.getElementById('mapType').value;
           const selectedOption = this.value;
           const imageContainer = document.getElementById('imageContainer');
           if (selectedMapType && selectedOption) {
               const images = specificOptions[selectedMapType][selectedOption];
               let imagesHtml = ;
               if (Array.isArray(images)) {
                   images.forEach(image => {
                       imagesHtml += `
                               <img src="${image.imageUrl}" alt="${selectedOption}">
                       Número do Mapa: ${image.id} 
Local: ${image.local}
Coordenada: ${image.coordinates}
Tag(s): ${image.tags.join(', ') || 'Nenhuma'}
                       `;
                   });
               }
               imageContainer.innerHTML = imagesHtml;
               imageContainer.classList.remove('hidden');
           } else {
               imageContainer.classList.add('hidden');
           }
       });

document.getElementById('filterButton').addEventListener('click', function () {

   const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim().toLowerCase());
   const filterOption = document.getElementById('filterOption').value;
   const selectedMapType = document.getElementById('mapType').value;
   const selectedSpecificOption = document.getElementById('specificOption').value;
   const imageContainer = document.getElementById('imageContainer');
   let imagesHtml = ;
   let allImages = [];
if (filterOption === 'number') {
       if (searchIds.length > 0) {
           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);
               });
           });
       }
   }
   if (allImages.length > 0) {
       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(s): ${image.tags.join(', ') || 'Nenhuma'}
           `;
       });
   } else {
       imagesHtml = 'Nenhuma imagem encontrada com os critérios fornecidos.';
   }
   imageContainer.innerHTML = imagesHtml;
   imageContainer.classList.toggle('hidden', allImages.length === 0);

});

const tagButtons = document.querySelectorAll('.tag-button');

       const selectedTagsDiv = document.getElementById('selectedTags');
       // Função para atualizar as tags selecionadas
       function updateSelectedTags() {
           // Adiciona as novas tags selecionadas
           tagButtons.forEach(button => {
               if (button.classList.contains('selected')) {
                   const tagItem = document.createElement('span');
                   tagItem.className = 'tag-item';
                   tagItem.textContent = button.dataset.value;
                   selectedTagsDiv.appendChild(tagItem);
               }
           });
       }
       // Adiciona o listener para detectar cliques nos botões
       tagButtons.forEach(button => {
           button.addEventListener('click', function() {
               // Alterna a classe 'selected' para selecionar/deselecionar a tag
               button.classList.toggle('selected');
               updateSelectedTags();
           });
       });
   </script>

</body> </html>