Widget:Test3

De PokeXGames
Revisão de 03h47min 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 Mapas</title>
   <style>
       /* Estilos já fornecidos */
       .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;
           max-width: 100%;
           height: auto;
       }
       .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);
           cursor: pointer;
       }
       .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;
       }
       .selected {
           border: 2px solid #4CAF50;
       }
       .checkbox-item {
           display: flex;
           align-items: center;
           margin-bottom: 10px;
       }
       .checkbox-item input {
           margin-right: 10px;
       }
   </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 type="button" id="saveButton" class="hover-minimize">
               <img src="https://wiki.pokexgames.com/images/6/6f/Save_Icon.png" alt="Salvar Mapas">
               Salvar Mapas Selecionados
           </button>
           <button type="button" id="loadButton" class="hover-minimize">
               <img src="https://wiki.pokexgames.com/images/6/6f/Load_Icon.png" alt="Carregar Mapas">
               Carregar Mapas Selecionados
           </button>
           <button type="button" id="clearButton" class="hover-minimize">
               <img src="https://wiki.pokexgames.com/images/6/6f/Clear_Icon.png" alt="Limpar Mapas">
               Limpar Mapas Salvos
           </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' }
               ],
           },
           3: {
               'Grama': [
                   { id: '30001', local: 'Respawn de Darkrai', coordinates: '30792, 20621, 5', tags: ['Grama', 'Árvore', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/2/23/Mapas_de_ADV_ROXO_-_30792%2C_20621%2C_5.webp' }
               ],
               'Pisos': [
                   { id: '70001', local: 'Respawn de Infernape', coordinates: '30793, 20532, 3', tags: ['Piso', 'Construção', 'Fogo'], imageUrl: 'https://wiki.pokexgames.com/images/6/6f/Mapas_de_ADV_ROXO_-_30793%2C_20532%2C_3.webp' }
               ],
           }
       };
       const enableFilter = document.getElementById('enableFilter');
       const filterSection = document.getElementById('filterSection');
       const filterOption = document.getElementById('filterOption');
       const searchIds = document.getElementById('searchIds');
       const filterButton = document.getElementById('filterButton');
       const imageContainer = document.getElementById('imageContainer');
       const saveButton = document.getElementById('saveButton');
       const loadButton = document.getElementById('loadButton');
       const clearButton = document.getElementById('clearButton');
       const mapType = document.getElementById('mapType');
       const specificOption = document.getElementById('specificOption');
       const specificOptionsContainer = document.getElementById('specificOptions');
       // Ativar/desativar seção de filtro
       enableFilter.addEventListener('change', () => {
           filterSection.classList.toggle('hidden', !enableFilter.checked);
       });
       // Atualizar opções específicas com base no tipo de mapa
       mapType.addEventListener('change', (event) => {
           const selectedMapType = event.target.value;
           specificOption.innerHTML = '<option value="">Selecione uma opção</option>';
           specificOptionsContainer.classList.toggle('hidden', !selectedMapType);
           if (specificOptions[selectedMapType]) {
               Object.keys(specificOptions[selectedMapType]).forEach(key => {
                   specificOption.innerHTML += `<option value="${key}">${key}</option>`;
               });
           }
       });
       // Exibir imagens com base na seleção
       filterButton.addEventListener('click', () => {
           const selectedMapType = mapType.value;
           const selectedOption = specificOption.value;
           const filterValue = searchIds.value.trim().toLowerCase();
           const filterBy = filterOption.value;
           let imagesToDisplay = [];
           if (specificOptions[selectedMapType] && specificOptions[selectedMapType][selectedOption]) {
               imagesToDisplay = specificOptions[selectedMapType][selectedOption];
           }
           // Filtro por tag e número
           if (filterBy === 'tag' && filterValue) {
               imagesToDisplay = imagesToDisplay.filter(item => item.tags.some(tag => tag.toLowerCase().includes(filterValue)));
           } else if (filterBy === 'number' && filterValue) {
               imagesToDisplay = imagesToDisplay.filter(item => filterValue.split(',').map(id => id.trim()).includes(item.id));
           }
           // Mostrar imagens
           imageContainer.innerHTML = ;
           if (imagesToDisplay.length > 0) {
               imageContainer.classList.remove('hidden');
               imagesToDisplay.forEach(item => {
                   imageContainer.innerHTML += `
                           <img src="${item.imageUrl}" alt="Mapa">

ID: ${item.id}

Local: ${item.local}

Coordenadas: ${item.coordinates}

Tags: ${item.tags.join(', ')}

                   `;
               });
           } else {
               imageContainer.classList.add('hidden');
           }
       });
       // Função para salvar mapas
       saveButton.addEventListener('click', () => {
           const selectedMaps = [...document.querySelectorAll('.image-item')].map(item => item.querySelector('img').src);
           localStorage.setItem('savedMaps', JSON.stringify(selectedMaps));
       });
       // Função para carregar mapas salvos
       loadButton.addEventListener('click', () => {
           const savedMaps = JSON.parse(localStorage.getItem('savedMaps')) || [];
           imageContainer.innerHTML = ;
           savedMaps.forEach(mapUrl => {
               imageContainer.innerHTML += `
                       <img src="${mapUrl}" alt="Mapa">
               `;
           });
           imageContainer.classList.remove('hidden');
       });
       // Função para limpar mapas salvos
       clearButton.addEventListener('click', () => {
           localStorage.removeItem('savedMaps');
           imageContainer.innerHTML = ;
           imageContainer.classList.add('hidden');
       });
       // Inicializar seleção
       mapType.dispatchEvent(new Event('change'));
   </script>

</body>

</html>