Widget:Test3

De PokeXGames
Revisão de 02h44min 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;
           /* Ajuste este valor conforme necessário para subir o botão */
       }
       .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,
       #searchButton {
           background: none;
           /* Remove o fundo do botão */
           border: none;
           /* Remove a borda do botão */
           padding: 0;
           /* Remove o padding do botão */
           cursor: pointer;
           /* Mostra o cursor de ponteiro ao passar sobre o botão */
           margin-top: 5px;
           /* Ajuste a margem superior para subir o botão */
       }
       #filterButton img,
       #searchButton img {
           border-radius: 12px;
           width: auto;
           /* Garante que a largura se ajuste ao tamanho original da imagem */
           height: auto;
           /* Garante que a altura se ajuste ao tamanho original da imagem */
       }
       .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;
           /* Ajuste a margem para mover o campo para cima */
       }
       .input-group label {
           position: absolute;
           top: -18px;
           /* Eleva o texto para cima */
           background: none;
           padding: 0 5px;
           font-size: 14px;
           font-weight: bold;
           color: #0d0d0d;
       }
       .maps__select {
           width: 100%;
           /* Mantém a largura total disponível */
           padding: 10px;
           font-size: 16px;
           border-radius: 5px;
           border: 1px solid #ccc;
           appearance: none;
           background-color: #fff;
           /* Adiciona um fundo branco */
           box-sizing: border-box;
           /* Inclui o padding e a borda na largura total */
       }


       .input-group input[type="text"] {
           width: 100%;
           /* Mantém a largura total disponível */
           padding: 10px;
           font-size: 16px;
           border-radius: 5px;
           border: 1px solid #ccc;
           box-sizing: border-box;
           /* Inclui o padding e a borda na largura total */
       }
       .maps__label {
           position: absolute;
           top: -18px;
           /* Eleva o texto um pouco mais para cima */
           background: none;
           padding: 0 5px;
           font-size: 14px;
           font-weight: bold;
           /* Deixa o texto em negrito */
           color: #0d0d0d;
       }
       .hover-minimize:hover {
           transform: scale(0.95);
           /* Adiciona um efeito de minimizar ao passar o mouse */
       }
       .filter-container {
           display: flex;
           align-items: center;
       }
       .filter-container input[type="checkbox"] {
           margin: 0;
           padding: 0;
           width: auto;
           /* Ajusta o tamanho da checkbox conforme necessário */
           height: auto;
           /* Ajusta o tamanho da checkbox conforme necessário */
           /* Alinha verticalmente a checkbox com o texto */
           vertical-align: middle;
       }
       .filter-label {
           margin-left: 10px;
           /* Espaço entre a checkbox e o texto */
           font-size: 14px;
           font-weight: bold;
           color: #0d0d0d;
           line-height: 1.5;
           /* Ajusta a altura da linha para um alinhamento adequado */
       }
       .selected-image {
           border: 2px solid green;
       }
       .unselected-image {
           border: 2px solid red;
       }
       .hidden {
           display: none;
       }
       .map-selection img {
           cursor: pointer;
           width: 20px;
       }
   </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="clearSavedMaps">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' }, 
                   { 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' }, 
                   // Add more images as needed
               ]
           },
           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' },
                   // Add more images as needed
               ],
               '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' },
                   // Add more images as needed
               ]
           }
       };
       let savedMaps = JSON.parse(localStorage.getItem('savedMaps')) || {};
       function renderSavedMaps() {
           const imageContainer = document.getElementById('imageContainer');
           let imagesHtml = ;
           for (const mapId in savedMaps) {
               const map = savedMaps[mapId];
               imagesHtml += `
                       <img src="${map.imageUrl}" alt="Imagem ID ${map.id}" class="selected-image">
                           Número do Mapa: ${map.id} 
Local: ${map.local}
Coordenada: ${map.coordinates}
Tag(s): ${map.tags.join(', ') || 'Nenhuma'}
               `;
           }
           imageContainer.innerHTML = imagesHtml;
           imageContainer.classList.toggle('hidden', !Object.keys(savedMaps).length);
       }
       function toggleMapSelection(mapId, mapData) {
           if (savedMaps[mapId]) {
               delete savedMaps[mapId];
           } else {
               savedMaps[mapId] = mapData;
           }
           localStorage.setItem('savedMaps', JSON.stringify(savedMaps));
           renderSavedMaps();
       }
       function handleImageClick(event) {
           const mapId = event.target.dataset.mapId;
           const mapData = event.target.dataset.mapData;
           if (mapId && mapData) {
               toggleMapSelection(mapId, JSON.parse(mapData));
               event.target.src = savedMaps[mapId] ? 'https://example.com/selected_image.png' : 'https://example.com/unselected_image.png';
           }
       }
       document.getElementById('enableFilter').addEventListener('change', function () {
           const filterSection = document.getElementById('filterSection');
           filterSection.classList.toggle('hidden', !this.checked);
       });
       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="${savedMaps[image.id] ? 'https://example.com/selected_image.png' : 'https://example.com/unselected_image.png'}"
                                    alt="Selecionar/Desmarcar Mapa"
                                    data-map-id="${image.id}"
                                    data-map-data='${JSON.stringify(image)}'
                                    onclick="handleImageClick(event)">
                               <img src="${image.imageUrl}" alt="${selectedOption}">
                                   ID: ${image.id} 
Local: ${image.local}
Coordenadas: ${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 filterOption = document.getElementById('filterOption').value;
           const searchIds = document.getElementById('searchIds').value.trim().toLowerCase().split(',').map(id => id.trim());
           
           if (filterOption === 'tag' && searchIds.length > 0) {
               const images = Object.values(specificOptions).flat().flatMap(option => option.filter(map => map.tags.some(tag => searchIds.includes(tag.toLowerCase()))));
               // Render images based on the tags
           } else if (filterOption === 'number' && searchIds.length > 0) {
               const images = Object.values(specificOptions).flat().flatMap(option => option.filter(map => searchIds.includes(map.id)));
               // Render images based on the numbers
           }
       });
       document.getElementById('clearSavedMaps').addEventListener('click', function () {
           savedMaps = {};
           localStorage.removeItem('savedMaps');
           renderSavedMaps();
       });
       renderSavedMaps();
   </script>

</body> </html>