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"> <head>
<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>
        .hidden {
            display: none;
        }
        .image-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
        }
        .image-item {
            flex: 1 0 30%;
            text-align: center;
        }
        .image-item img {
            max-width: 100%;
            height: auto;
            margin-bottom: 5px;
        }
        .input-group {
            margin: 10px 0;
        }
        .maps__select {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            border-radius: 5px;
            border: 1px solid #ccc;
        }
        .tag-button {
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 20px;
            padding: 5px 15px;
            font-size: 14px;
            cursor: pointer;
            margin: 5px;
            transition: background-color 0.3s, color 0.3s;
        }
        .tag-button.selected {
            background-color: #007bff;
            color: #fff;
        }
        .tag-button.disabled {
            background-color: #e0e0e0;
            color: #a0a0a0;
            border-color: #d0d0d0;
            cursor: not-allowed;
        }
    </style>
</head>
<body>
    <form id="mapForm">
        <div id="mapTypeSelection" class="input-group">
            <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 for="mapType">Tipo de Mapa</label>
        </div>
        <div id="specificOptions" class="hidden input-group">
            <select id="specificOption" class="maps__select">
                <option value="">Selecione uma opção</option>
                <option value="Areia">Areia</option>
                <option value="Gelo">Gelo</option>
                <option value="Grama">Grama</option>
                <option value="Pedra">Pedra</option>
                <option value="Subaquático">Subaquático</option>
                <option value="Terra">Terra</option>
                <option value="Pisos">Pisos</option>
            </select>
            <label for="specificOption">Local do X</label>
        </div>
        <div class="input-group">
            <input type="checkbox" id="enableFilter">
            <label for="enableFilter">Ativar filtro</label>
        </div>
        <div id="filterSection" class="hidden input-group">
            <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">
            <button type="button" id="filterButton">Filtrar</button>
        </div>
        <div id="imageContainer" class="image-container hidden"></div>
        <div id="tagButtonsContainer" class="input-group">
            <!-- Botões de tags serão inseridos aqui pelo JavaScript -->
        </div>
    </form>


    <script>
  <meta charset="UTF-8">
        const specificOptions = {
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
            1: {
  <title>Seleção de Mapas</title>
                'Areia': [
    <style>
                    { id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/4/4c/Mapas_de_ADV_VERMELHO_-_3780%2C_3326%2C_7.webp' },
      .d-flex {
                    { id: '102', local: 'Wildwind Island', coordinates: '3969, 3300, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/58/Mapas_de_ADV_VERMELHO_-_3969%2C_3300%2C_7.webp' }
          display: flex;
                ],
          justify-content: center;
                'Gelo': [
          align-items: center;
                    { id: '103', local: 'Snowy Mountain', coordinates: '3500, 3400, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/7/74/Mapas_de_ADV_VERDE_-_3500%2C_3400%2C_7.webp' }
          flex-direction: column;
                ]
          margin-top: -15px;
            },
      }
            2: {  
      .hidden {
                'Grama': [
          display: none;
                    { id: '104', local: 'Green Forest', coordinates: '3000, 3100, 7', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/9/94/Mapas_de_ADV_VERDE_-_3000%2C_3100%2C_7.webp' }
      }
                ],
      .image-container {
                'Pedra': [
          display: flex;
                    { id: '105', local: 'Rocky Terrain', coordinates: '3200, 3400, 7', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/1/12/Mapas_de_ADV_VERDE_-_3200%2C_3400%2C_7.webp' }
          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 {


        const tagButtonsContainer = document.getElementById('tagButtonsContainer');
  object-fit: cover; /* Mantém a proporção da imagem, cortando se necessário */
        const filterButton = document.getElementById('filterButton');
  margin-bottom: 5px;
        const filterOption = document.getElementById('filterOption');
}
        const searchIds = document.getElementById('searchIds');
        const imageContainer = document.getElementById('imageContainer');
        const mapType = document.getElementById('mapType');
        const specificOption = document.getElementById('specificOption');
        const enableFilter = document.getElementById('enableFilter');
        const filterSection = document.getElementById('filterSection');
        const mapTypeSelection = document.getElementById('mapTypeSelection');
        const specificOptionsSection = document.getElementById('specificOptions');


        const tags = ['Areia', 'Gelo', 'Grama', 'Pedra', 'Subaquático', 'Terra', 'Pisos'];
      .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;
      }
filterOptions {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
}


        function renderTagButtons() {
      .mw-body-content {
            tags.forEach(tag => {
          display: flex;
                const button = document.createElement('button');
      }
                button.className = 'tag-button';
      .mw-parser-output {
                button.dataset.value = tag;
          display: inline-block;
                button.textContent = tag;
          padding: .5rem 2rem;
                button.addEventListener('click', function() {
          margin: 0 auto;
                    this.classList.toggle('selected');
          border: 30px solid transparent;
                    filterImages();
          border-image: url(https://wiki.pokexgames.com/images/3/37/Calculadora-de-Boost.png) 38;
                });
          min-width: 410px;
                tagButtonsContainer.appendChild(button);
          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-buttons {
          display: flex;
          flex-wrap: wrap;
          gap: 10px;
          justify-content: center;
          margin-top: 10px;
      }
      .tag-buttons 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-buttons button:hover {
          background-color: #ddd;
          color: #333;
      }
      .tag-buttons button.selected {
          background-color: #007bff;
          color: #fff;
          border-color: #007bff;
      }
      .tag-buttons button.disabled {
          background-color: #e0e0e0;
          color: #a0a0a0;
          border-color: #d0d0d0;
          cursor: not-allowed;
      }
  </style>
</head> <body>


        function filterImages() {
      <label for="mapType">Tipo de Mapa</label>
            imageContainer.innerHTML = '';
      <select id="mapType" class="maps__select">
            const selectedMapType = mapType.value;
          <option value="">Selecione um mapa</option>
            const selectedLocal = specificOption.value;
          <option value="1">Mapa Vermelho</option>
            const filterByNumber = filterOption.value === 'number';
          <option value="2">Mapa Verde</option>
            const filterByTag = filterOption.value === 'tag';
          <option value="3">Mapa Roxo</option>
      </select>
      <label for="specificOption">Local do X</label>
      <select id="specificOption" class="maps__select">
          <option value="">Selecione uma opção</option>
          <option value="Areia">Areia</option>
          <option value="Gelo">Gelo</option>
          <option value="Grama">Grama</option>
          <option value="Pedra">Pedra</option>
          <option value="Subaquático">Subaquático</option>
          <option value="Terra">Terra</option>
          <option value="Pisos">Pisos</option>
      </select>
      <input type="checkbox" id="enableFilter">
      <label for="enableFilter">Ativar filtro</label>
      <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">


            let selectedTags = [];
  <img src="https://wiki.pokexgames.com/images/8/82/Botao_Filtrar_Mapas_Adv.png" alt="Filtrar">  
            document.querySelectorAll('.tag-button.selected').forEach(button => {
</button>
                selectedTags.push(button.dataset.value);
            });


            let filteredImages = [];
<script>
            for (const [mapTypeKey, locales] of Object.entries(specificOptions)) {
                if (selectedMapType && selectedMapType !== mapTypeKey) continue;


                for (const [local, items] of Object.entries(locales)) {
  const specificOptions = {
                    if (selectedLocal && selectedLocal !== local) continue;
      1: { // Mapa Vermelho
          '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', coordinates: '4500, 5300, 5', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/55/Mapa_Vermelho_ADV_-_4500%2C_5300%2C_5.webp' }
          ],
          'Grama': [
              { id: '103', local: 'Grassland', coordinates: '5600, 4700, 8', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/6/67/Mapa_Vermelho_ADV_-_5600%2C_4700%2C_8.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');
  const specificOptionSelect = document.getElementById('specificOption');
  const filterOptions = document.getElementById('filterOptions');
  const tagButtons = document.getElementById('tagButtons');
  const imageContainer = document.getElementById('imageContainer');
  const enableFilter = document.getElementById('enableFilter');
  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 = [];
      if (selectedMapType && selectedOption) {
          const options = specificOptions[selectedMapType];
          if (options && options[selectedOption]) {
              options[selectedOption].forEach(item => {
                  tags = [...new Set([...tags, ...item.tags])];
              });
          }
      }
      tagButtons.innerHTML = ;
      const disabledTags = {
          'Areia': 'Areia',
          'Gelo': 'Gelo',
          'Grama': 'Grama',
          'Pedra': 'Pedra',
          'Subaquático': 'Água',
          'Terra': 'Terra',
          'Pisos': 'Piso'
      };
      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);
  }
  function filterImages() {
      const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(btn => btn.textContent);
      const selectedMapType = mapTypeSelect.value;
      const selectedOption = specificOptionSelect.value;
      const filterById = searchIdsInput.value.trim();
      imageContainer.innerHTML = ;
      let itemsToFilter = [];
      if (selectedMapType) {
          const options = specificOptions[selectedMapType];
          if (options) {
              if (selectedOption && options[selectedOption]) {
                  itemsToFilter = options[selectedOption];
              }
          }
      } else {
          // Se nenhum tipo de mapa for selecionado, reunir itens de todos os tipos de mapa
          for (const mapType in specificOptions) {
              for (const local in specificOptions[mapType]) {
                  itemsToFilter = itemsToFilter.concat(specificOptions[mapType][local]);
              }
          }
      }
      if (itemsToFilter.length > 0) {
          const filteredItems = itemsToFilter.filter(item => {
              const matchesTag = selectedTags.length === 0 || selectedTags.some(tag => item.tags.includes(tag));
              const matchesId = filterById ===  || filterById.split(',').map(id => id.trim()).includes(item.id);
              const matchesLocal = selectedOption ===  || item.tags.includes(selectedOption);
             
              return matchesTag && matchesId && matchesLocal;
          });
          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 = `
                  Número do Mapa: ${item.id}


                    items.forEach(item => {
                  Local: ${item.local}
                        if (filterByNumber && searchIds.value.split(',').map(id => id.trim()).includes(item.id)) {
                            filteredImages.push(item);
                        } else if (filterByTag && selectedTags.some(tag => item.tags.includes(tag))) {
                            filteredImages.push(item);
                        } else if (!filterByNumber && !filterByTag) {
                            filteredImages.push(item);
                        }
                    });
                }
            }


            displayImages(filteredImages);
                  Coordenada: ${item.coordinates}
        }


        function displayImages(images) {
                  Tag(s): ${item.tags.join(', ')}
            images.forEach(image => {
              `;
                const imageItem = document.createElement('div');
              itemDiv.appendChild(infoDiv);
                imageItem.className = 'image-item';
              imageContainer.appendChild(itemDiv);
                imageItem.innerHTML = `
          });
                    <img src="${image.imageUrl}" alt="Map Image">
          if (filteredItems.length === 0) {
                    <div>
imageContainer.innerHTML = '
                        <p>Número do Mapa: ${image.id}</p>
                        <p>Local: ${image.local}</p>
                        <p>Coordenada: ${image.coordinates}</p>
                        <p>Tag(s): ${image.tags.join(', ')}</p>
                    </div>
                `;
                imageContainer.appendChild(imageItem);
            });
            imageContainer.classList.remove('hidden');
        }


        renderTagButtons();
Nenhuma imagem encontrada para os critérios selecionados.


        filterButton.addEventListener('click', filterImages);
';


        enableFilter.addEventListener('change', function() {
          }
            if (this.checked) {
      }
                mapTypeSelection.classList.add('hidden');
  }
                specificOptionsSection.classList.add('hidden');
document.getElementById('enableFilter').addEventListener('change', function() {
                filterSection.classList.remove('hidden');
 
                imageContainer.innerHTML = '';
  const filterOptions = document.getElementById('filterOptions');
                imageContainer.classList.remove('hidden');
  if (this.checked) {
            } else {
      filterOptions.classList.remove('hidden');
                mapTypeSelection.classList.remove('hidden');
  } else {
                specificOptionsSection.classList.remove('hidden');
      filterOptions.classList.add('hidden');
                filterSection.classList.add('hidden');
  }
                imageContainer.classList.add('hidden');
});
                searchIds.value = '';
 
                document.querySelectorAll('.tag-button.selected').forEach(button => button.classList.remove('selected'));
  function handleFilterChange() {
            }
      const isFilterEnabled = enableFilter.checked;
        });
      if (isFilterEnabled) {
    </script>
          mapTypeSelect.disabled = true;
</body>
          specificOptionSelect.disabled = true;
</html>
          filterOptions.classList.remove('hidden');
          tagButtons.classList.add('hidden');  
          filterTypeSelect.value = 'number';
          filterButton.addEventListener('click', () => {
              // Desmarcar todas as tags ao ativar o filtro
              document.querySelectorAll('.tag-button.selected').forEach(btn => btn.classList.remove('selected'));
              filterImages();
          });
          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>
 
</body> </html>

Edição das 03h34min 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 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; /* 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;
      }

filterOptions {

  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;

}

      .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-buttons {
          display: flex;
          flex-wrap: wrap;
          gap: 10px;
          justify-content: center;
          margin-top: 10px;
      }
      .tag-buttons 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-buttons button:hover {
          background-color: #ddd;
          color: #333;
      }
      .tag-buttons button.selected {
          background-color: #007bff;
          color: #fff;
          border-color: #007bff;
      }
      .tag-buttons button.disabled {
          background-color: #e0e0e0;
          color: #a0a0a0;
          border-color: #d0d0d0;
          cursor: not-allowed;
      }
  </style> 

</head> <body>

      <label for="mapType">Tipo de Mapa</label>
      <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 for="specificOption">Local do X</label>
      <select id="specificOption" class="maps__select">
          <option value="">Selecione uma opção</option>
          <option value="Areia">Areia</option>
          <option value="Gelo">Gelo</option>
          <option value="Grama">Grama</option>
          <option value="Pedra">Pedra</option>
          <option value="Subaquático">Subaquático</option>
          <option value="Terra">Terra</option>
          <option value="Pisos">Pisos</option>
      </select>
      <input type="checkbox" id="enableFilter">
      <label for="enableFilter">Ativar filtro</label>
      <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>

<script>

  const specificOptions = {
      1: { // Mapa Vermelho
          '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', coordinates: '4500, 5300, 5', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/55/Mapa_Vermelho_ADV_-_4500%2C_5300%2C_5.webp' }
          ],
          'Grama': [
              { id: '103', local: 'Grassland', coordinates: '5600, 4700, 8', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/6/67/Mapa_Vermelho_ADV_-_5600%2C_4700%2C_8.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');
  const specificOptionSelect = document.getElementById('specificOption');
  const filterOptions = document.getElementById('filterOptions');
  const tagButtons = document.getElementById('tagButtons');
  const imageContainer = document.getElementById('imageContainer');
  const enableFilter = document.getElementById('enableFilter');
  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 = [];
      if (selectedMapType && selectedOption) {
          const options = specificOptions[selectedMapType];
          if (options && options[selectedOption]) {
              options[selectedOption].forEach(item => {
                  tags = [...new Set([...tags, ...item.tags])];
              });
          }
      }
      tagButtons.innerHTML = ;
      const disabledTags = {
          'Areia': 'Areia',
          'Gelo': 'Gelo',
          'Grama': 'Grama',
          'Pedra': 'Pedra',
          'Subaquático': 'Água',
          'Terra': 'Terra',
          'Pisos': 'Piso'
      };
      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);
  }
  function filterImages() {
      const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(btn => btn.textContent);
      const selectedMapType = mapTypeSelect.value;
      const selectedOption = specificOptionSelect.value;
      const filterById = searchIdsInput.value.trim();
      imageContainer.innerHTML = ;
      let itemsToFilter = [];
      if (selectedMapType) {
          const options = specificOptions[selectedMapType];
          if (options) {
              if (selectedOption && options[selectedOption]) {
                  itemsToFilter = options[selectedOption];
              }
          }
      } else {
          // Se nenhum tipo de mapa for selecionado, reunir itens de todos os tipos de mapa
          for (const mapType in specificOptions) {
              for (const local in specificOptions[mapType]) {
                  itemsToFilter = itemsToFilter.concat(specificOptions[mapType][local]);
              }
          }
      }
      if (itemsToFilter.length > 0) {
          const filteredItems = itemsToFilter.filter(item => {
              const matchesTag = selectedTags.length === 0 || selectedTags.some(tag => item.tags.includes(tag));
              const matchesId = filterById ===  || filterById.split(',').map(id => id.trim()).includes(item.id);
              const matchesLocal = selectedOption ===  || item.tags.includes(selectedOption);
              
              return matchesTag && matchesId && matchesLocal;
          });
          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 = `
                  Número do Mapa: ${item.id}
                  Local: ${item.local}
                  Coordenada: ${item.coordinates}
                  Tag(s): ${item.tags.join(', ')}
              `;
              itemDiv.appendChild(infoDiv);
              imageContainer.appendChild(itemDiv);
          });
          if (filteredItems.length === 0) {

imageContainer.innerHTML = '

Nenhuma imagem encontrada para os critérios selecionados.

';

          }
      }
  }

document.getElementById('enableFilter').addEventListener('change', function() {

  const filterOptions = document.getElementById('filterOptions');
  if (this.checked) {
      filterOptions.classList.remove('hidden');
  } else {
      filterOptions.classList.add('hidden');
  }

});

  function handleFilterChange() {
      const isFilterEnabled = enableFilter.checked;
      if (isFilterEnabled) {
          mapTypeSelect.disabled = true;
          specificOptionSelect.disabled = true;
          filterOptions.classList.remove('hidden');
          tagButtons.classList.add('hidden'); 
          filterTypeSelect.value = 'number'; 
          filterButton.addEventListener('click', () => {
              // Desmarcar todas as tags ao ativar o filtro
              document.querySelectorAll('.tag-button.selected').forEach(btn => btn.classList.remove('selected'));
              filterImages();
          });
          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>

</body> </html>