Widget:Test3

De PokeXGames
Revisão de 03h27min de 4 de setembro de 2024 por Renee (discussão | contribs)
Ir para navegação Ir para pesquisar

<!DOCTYPE html> <html lang="pt-BR">

<head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Seleção e Exibição de Imagens</title>
   <style>
       .d-flex {
           display: flex;
           justify-content: center;
           align-items: center;
           flex-direction: column;
           margin-top: -15px;
       }
       .hidden {
           display: none;
       }
       .image-container {
           display: flex;
           flex-wrap: wrap;
           justify-content: center;
           gap: 10px;
           margin-top: 5px;
       }
       .image-container .image-item {
           flex: 1 0 30%;
           text-align: center;
       }
       .image-container img {
           object-fit: cover;
           margin-bottom: 5px;
       }
       .image-info {
           margin-top: 5px;
       }
       select,
       input[type="text"],
       button {
           margin: 5px;
       }
       #filterButton {
           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: 20px;
           padding: 5px 15px;
           font-size: 14px;
           cursor: pointer;
           transition: background-color 0.3s, color 0.3s;
           margin: 5px;
       }
       .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>
           <button class="tag-button" data-value="Areia">Areia</button>
           <button class="tag-button" data-value="Gelo">Gelo</button>
           <button class="tag-button" data-value="Grama">Grama</button>
           <button class="tag-button" data-value="Pedra">Pedra</button>
           <button class="tag-button" data-value="Subaquático">Subaquático</button>
           <button class="tag-button" data-value="Terra">Terra</button>
           <button class="tag-button" data-value="Pisos">Pisos</button>
   </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: '3976, 3334, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/6/62/Mapas_de_ADV_VERMELHO_-_3976%2C_3334%2C_7.webp' } 
               ],
               'Gelo': [ 
                   { id: '104', 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' }, 
                   { id: '105', local: 'Ice Palace', coordinates: '3700, 3200, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/8/84/Mapas_de_ADV_VERDE_-_3700%2C_3200%2C_7.webp' } 
               ]
           },
           2: { 
               'Grama': [ 
                   { id: '106', local: 'Green Forest', coordinates: '3000, 3100, 7', tags: ['Grama', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/9/94/Mapas_de_ADV_VERDE_-_3000%2C_3100%2C_7.webp' } 
               ],
               'Pedra': [ 
                   { id: '107', 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' } 
               ]
           }
       };
       const tagButtons = document.querySelectorAll('.tag-button');
       const selectedTagsDiv = document.getElementById('selectedTags');
       const filterButton = document.getElementById('filterButton');
       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 tagButtonsContainer = document.getElementById('tagButtonsContainer');
       const mapTypeSelection = document.getElementById('mapTypeSelection');
       const specificOptionsSection = document.getElementById('specificOptions');
       function filterImages() {
           imageContainer.innerHTML = ;
           const selectedMapType = mapType.value;
           const selectedLocal = specificOption.value;
           const filterByNumber = filterOption.value === 'number';
           const filterByTag = filterOption.value === 'tag';
           let selectedTags = [];
           tagButtons.forEach(button => {
               if (button.classList.contains('selected')) {
                   selectedTags.push(button.dataset.value);
               }
           });
           if (filterByNumber) {
               const ids = searchIds.value.split(',').map(id => id.trim());
               const filteredImages = Object.values(specificOptions)
                   .flatMap(options => Object.values(options))
                   .flat()
                   .filter(item => ids.includes(item.id));
               displayImages(filteredImages);
           } else if (filterByTag) {
               if (!selectedTags.length) return;
               let filteredImages = Object.values(specificOptions)
                   .flatMap(options => Object.values(options))
                   .flat()
                   .filter(item => {
                       return selectedTags.some(tag => item.tags.includes(tag));
                   });
               if (selectedLocal) {
                   filteredImages = filteredImages.filter(item => item.tags.includes(selectedLocal));
               }
               displayImages(filteredImages);
           } else {
               const filteredImages = Object.values(specificOptions)
                   .flatMap(options => Object.values(options))
                   .flat()
                   .filter(item => {
                       return (!selectedMapType || item.mapType === selectedMapType) &&
                              (!selectedLocal || item.local === selectedLocal) &&
                              (!selectedTags.length || selectedTags.some(tag => item.tags.includes(tag)));
                   });
               displayImages(filteredImages);
           }
       }
       function displayImages(images) {
           images.forEach(image => {
               const imageItem = document.createElement('div');
               imageItem.className = 'image-item';
               imageItem.innerHTML = `
                   <img src="${image.imageUrl}" alt="Map Image">

Número do Mapa: ${image.id}

Local: ${image.local}

Coordenada: ${image.coordinates}

Tag(s): ${image.tags.join(', ')}

               `;
               imageContainer.appendChild(imageItem);
           });
           imageContainer.classList.remove('hidden');
       }
       tagButtons.forEach(button => {
           button.addEventListener('click', function() {
               this.classList.toggle('selected');
               updateSelectedTags();
               filterImages();
           });
       });
       function updateSelectedTags() {
           selectedTagsDiv.innerHTML = ;
           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);
               }
           });
       }
       filterButton.addEventListener('click', filterImages);
       enableFilter.addEventListener('change', function() {
           if (this.checked) {
               mapTypeSelection.classList.add('hidden');
               specificOptionsSection.classList.add('hidden');
               filterSection.classList.remove('hidden');
               imageContainer.innerHTML = ;
               imageContainer.classList.remove('hidden');
           } else {
               mapTypeSelection.classList.remove('hidden');
               specificOptionsSection.classList.remove('hidden');
               filterSection.classList.add('hidden');
               imageContainer.classList.add('hidden');
               searchIds.value = ;
               tagButtons.forEach(button => button.classList.remove('selected'));
               selectedTagsDiv.innerHTML = ;
           }
       });
   </script>

</body>

</html>