Widget:Test3

De PokeXGames
Revisão de 19h47min de 3 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,
       #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: 340px;
           min-height: 270px;
       }
       .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;
       }
   </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: {
               'Pisos': [
                   { id: '701', local: 'Pewter', coordinates: '3698, 3447, 8', tags: ['Piso', 'Construção'], imageUrl: 'https://wiki.pokexgames.com/images/e/ea/Mapas_de_ADV_VERMELHO_-_3698%2C_3447%2C_8.webp' },
                   { id: '702', local: 'Cemitério de Lavender', coordinates: '4302, 3662, 8', tags: ['Piso', 'Construção', 'Fogo'], imageUrl: 'https://wiki.pokexgames.com/images/f/f7/Mapas_de_ADV_VERMELHO_-_4302%2C_3662%2C_8.webp' },
                   { id: '703', local: 'Cemitério de Lavender', coordinates: '4356, 3641, 9', tags: ['Piso', 'Terra'], imageUrl: 'https://wiki.pokexgames.com/images/1/15/Mapas_de_ADV_VERMELHO_-_4356%2C_3641%2C_9.webp' },
                   { id: '704', local: 'Desert Island', coordinates: '4559, 3656, 9', tags: ['Piso', 'Pirâmide', 'Fogo', 'Construção'], imageUrl: 'https://wiki.pokexgames.com/images/d/dc/Mapas_de_ADV_VERMELHO_-_4559%2C_3656%2C_9.webp' },
                   { id: '715', local: 'Ghost Ship', coordinates: '4673, 5599, 7', tags: ['Piso', 'Construção', 'Água'], imageUrl: 'https://wiki.pokexgames.com/images/c/c7/Mapas_de_ADV_VERMELHO_-_4673%2C_5599%2C_7.webp' },
               ]
           },
           2: {
               'Pedra': [
                   { id: '4001', local: 'Outland Fire', coordinates: '2793, 3029, 7', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/f/fc/Mapa_Verde_ADV_-_2793%2C_3029%2C_7.webp' },
                   { id: '4002', local: 'Outland Water', coordinates: '2808, 2864, 7', tags: ['Pedra', 'Árvore', 'Areia'], imageUrl: 'https://wiki.pokexgames.com/images/0/0a/Mapa_Verde_ADV_-_2808%2C_2864%2C_7.webp' },
                   { id: '4003', local: 'Outland Water', coordinates: '2785, 2866, 6', tags: ['Pedra', 'Árvore', 'Grama'], imageUrl: 'https://wiki.pokexgames.com/images/d/d3/Mapa_Verde_ADV_-_2785%2C_2866%2C_6.webp' },
                   { id: '4004', local: 'Outland Water', coordinates: '2764, 2885, 6', tags: ['Pedra', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/4/4c/Mapa_Verde_ADV_-_2764%2C_2885%2C_6.webp' },
                   { id: '4005', local: 'Outland Water', coordinates: '2751, 2904, 6', tags: ['Pedra', 'Grama'], imageUrl: 'https://wiki.pokexgames.com/images/6/6b/Mapa_Verde_ADV_-_2751%2C_2904%2C_6.webp' },
                   { id: '4006', local: 'Outland Water', coordinates: '2729, 2921, 5', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/c/c2/Mapa_Verde_ADV_-_2729%2C_2921%2C_5.webp' },
               ]
           },
           3: {
               'Areia': [
                   { id: '5007', local: 'Beach Area', coordinates: '5631, 5589, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/9/93/Mapa_Verde_ADV_-_5631%2C_5589%2C_7.webp' },
               ]
           }
       };
       const mapTypeSelect = document.getElementById('mapType');
       const specificOptionSelect = document.getElementById('specificOption');
       const specificOptionsContainer = document.getElementById('specificOptions');
       const enableFilterCheckbox = document.getElementById('enableFilter');
       const filterSection = document.getElementById('filterSection');
       const filterButton = document.getElementById('filterButton');
       const searchIdsInput = document.getElementById('searchIds');
       const imageContainer = document.getElementById('imageContainer');
       // Mostrar opções específicas conforme o tipo de mapa selecionado
       mapTypeSelect.addEventListener('change', function () {
           const selectedMapType = parseInt(mapTypeSelect.value, 10);
           specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>';
           if (selectedMapType && specificOptions[selectedMapType]) {
               specificOptionsContainer.classList.remove('hidden');
               for (const option in specificOptions[selectedMapType]) {
                   if (specificOptions[selectedMapType].hasOwnProperty(option)) {
                       const opt = document.createElement('option');
                       opt.value = option;
                       opt.textContent = option;
                       specificOptionSelect.appendChild(opt);
                   }
               }
           } else {
               specificOptionsContainer.classList.add('hidden');
           }
       });
       // Exibir ou ocultar a seção de filtros conforme a checkbox
       enableFilterCheckbox.addEventListener('change', function () {
           filterSection.classList.toggle('hidden', !enableFilterCheckbox.checked);
       });
       // Filtrar imagens com base nas seleções e no filtro
       filterButton.addEventListener('click', function () {
           const selectedMapType = parseInt(mapTypeSelect.value, 10);
           const selectedSpecificOption = specificOptionSelect.value;
           const searchIds = searchIdsInput.value.split(',').map(id => id.trim());
           imageContainer.innerHTML = ;
           if (selectedMapType && selectedSpecificOption && specificOptions[selectedMapType][selectedSpecificOption]) {
               let filteredMaps = specificOptions[selectedMapType][selectedSpecificOption];
               // Aplicar filtros de número ou tag se o filtro estiver ativado
               if (enableFilterCheckbox.checked) {
                   const filterOption = document.getElementById('filterOption').value;
                   if (filterOption === 'number') {
                       filteredMaps = filteredMaps.filter(map => searchIds.includes(map.id));
                   } else if (filterOption === 'tag') {
                       filteredMaps = filteredMaps.filter(map => searchIds.some(tag => map.tags.includes(tag)));
                   }
               }
               // Exibir imagens filtradas
               if (filteredMaps.length > 0) {
                   imageContainer.classList.remove('hidden');
                   filteredMaps.forEach(map => {
                       const imageItem = document.createElement('div');
                       imageItem.classList.add('image-item');
                       const img = document.createElement('img');
                       img.src = map.imageUrl;
                       img.alt = `${map.local} - ${map.coordinates}`;
                       imageItem.appendChild(img);
                       const info = document.createElement('div');
                       info.classList.add('image-info');
                       info.textContent = `${map.local} - ${map.coordinates} - Tags: ${map.tags.join(', ')}`;
                       imageItem.appendChild(info);
                       imageContainer.appendChild(imageItem);
                   });
               } else {
                   alert('Nenhum mapa encontrado com os filtros aplicados.');
               }
           } else {
               alert('Selecione pelo menos um tipo de mapa e uma opção específica.');
           }
       });
   </script>

</body>

</html>