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 203: Linha 203:
         </div>
         </div>
     </form>
     </form>


     <script>
     <script>
Linha 211: Linha 210:
             { 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: '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: '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: '4002, 3320, 7', tags:['Areia','Árvore','Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/0/07/Mapas_de_ADV_VERMELHO_-_4002%2C_3320%2C_7.webp' },  
             { id: '103', local: 'Wildwind Island', coordinates: '4002, 3320, 7', tags:['Areia','Árvore','Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/0/07/Mapas_de_ADV_VERMELHO_-_4002%2C_3320%2C_7.webp' }  
             { id: '104', local: 'Desert Oasis', coordinates: '3870, 3120, 7', tags:['Areia','Água'], imageUrl: 'https://wiki.pokexgames.com/images/9/90/Mapas_de_ADV_VERMELHO_-_3870%2C_3120%2C_7.webp' }
        ],  
         ],
        'Gelo': [
             { id: '201', local: 'Ice Cave', coordinates: '3831, 3270, 7', tags:['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/6/67/Mapas_de_ADV_VERDE_-_3831%2C_3270%2C_7.webp' }  
         ],  
         'Grama': [  
         'Grama': [  
             { id: '201', local: 'Forest Area', coordinates: '3590, 2880, 7', tags:['Grama','Árvore','Piso'], imageUrl: 'https://wiki.pokexgames.com/images/6/6a/Mapas_de_ADV_VERMELHO_-_3590%2C_2880%2C_7.webp' },
             { id: '301', local: 'Green Fields', coordinates: '3950, 3200, 7', tags:['Grama','Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/7/7d/Mapas_de_ADV_VERDE_-_3950%2C_3200%2C_7.webp' }  
            { id: '202', local: 'Green Meadow', coordinates: '3650, 2950, 7', tags:['Grama','Árvore','Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/7/7d/Mapas_de_ADV_VERMELHO_-_3650%2C_2950%2C_7.webp' }
         ]  
         ],
        // Adicione mais locais para outras tags conforme necessário
     },
     },
     2: {  
     2: {
         'Gelo': [  
         'Areia': [  
             { id: '301', local: 'Ice Cave', coordinates: '2970, 3580, 7', tags:['Gelo','Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/8/80/Mapas_de_ADV_VERMELHO_-_2970%2C_3580%2C_7.webp' },
             { id: '104', local: 'Tropical Beach', coordinates: '3650, 3280, 7', tags:['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/8/8c/Mapas_de_ADV_VERDE_-_3650%2C_3280%2C_7.webp' }
            { id: '302', local: 'Frozen Lake', coordinates: '3100, 3650, 7', tags:['Gelo','Água'], imageUrl: 'https://wiki.pokexgames.com/images/9/9f/Mapas_de_ADV_VERMELHO_-_3100%2C_3650%2C_7.webp' }
         ]
         ],
     }
        // Adicione mais locais para outras tags conforme necessário
     },
    // Adicione mais tipos de mapa conforme necessário
};
};


Linha 233: Linha 229:
     const mapType = document.getElementById('mapType').value;
     const mapType = document.getElementById('mapType').value;
     const specificOption = document.getElementById('specificOption').value;
     const specificOption = document.getElementById('specificOption').value;
    const selectedTags = Array.from(document.querySelectorAll('#filterByTag input[type="checkbox"]:checked')).map(cb => cb.value);
    const filteredData = [];
    if (mapType && specificOption && specificOptions[mapType] && specificOptions[mapType][specificOption]) {
        filteredData.push(...specificOptions[mapType][specificOption]);
    }
    if (selectedTags.length > 0) {
        filteredData = filteredData.filter(item =>
            item.tags.some(tag => selectedTags.includes(tag))
        );
    }
    displayImages(filteredData);
}
function displayImages(data) {
     const imageContainer = document.getElementById('imageContainer');
     const imageContainer = document.getElementById('imageContainer');
    imageContainer.innerHTML = '';
      
      
     if (data.length === 0) {
    let filteredImages = [];
   
     if (mapType && specificOptions[mapType]) {
        const selectedOptions = specificOptions[mapType];
       
        if (specificOption) {
            filteredImages = selectedOptions[specificOption] || [];
        } else {
            // If no specific option is selected, get all maps for the selected type
            for (const key in selectedOptions) {
                filteredImages = filteredImages.concat(selectedOptions[key]);
            }
        }
       
        imageContainer.innerHTML = '';
        filteredImages.forEach(item => {
            const div = document.createElement('div');
            div.classList.add('image-item');
            div.innerHTML = `
                <img src="${item.imageUrl}" alt="Imagem do Mapa" />
                <div class="image-info">
                    <p>ID: ${item.id}</p>
                    <p>Local: ${item.local}</p>
                    <p>Coordenadas: ${item.coordinates}</p>
                    <p>Tags: ${item.tags.join(', ')}</p>
                </div>
            `;
            imageContainer.appendChild(div);
        });
        imageContainer.classList.remove('hidden');
    } else {
        imageContainer.innerHTML = '';
         imageContainer.classList.add('hidden');
         imageContainer.classList.add('hidden');
        return;
     }
     }
}


    imageContainer.classList.remove('hidden');
document.getElementById('mapType').addEventListener('change', function() {
   
    document.getElementById('specificOptions').classList.remove('hidden');
    data.forEach(item => {
    updateFilters();
        const imageItem = document.createElement('div');
});
        imageItem.className = 'image-item';
       
        const img = document.createElement('img');
        img.src = item.imageUrl;
        img.alt = item.local;
        img.width = 200;  // Ajuste o tamanho conforme necessário
        img.height = 150; // Ajuste o tamanho conforme necessário


        const info = document.createElement('div');
document.getElementById('specificOption').addEventListener('change', function() {
        info.className = 'image-info';
    updateFilters();
        info.innerHTML = `<strong>Local:</strong> ${item.local} <br> <strong>Coordenadas:</strong> ${item.coordinates}`;
});
       
        imageItem.appendChild(img);
        imageItem.appendChild(info);
        imageContainer.appendChild(imageItem);
    });
}


document.getElementById('enableFilter').addEventListener('change', function() {
document.getElementById('enableFilter').addEventListener('change', function() {
     const filterSection = document.getElementById('filterSection');
     const isChecked = this.checked;
    filterSection.classList.toggle('hidden', !this.checked);
    document.getElementById('filterSection').classList.toggle('hidden', !isChecked);
});
 
document.getElementById('filterButton').addEventListener('click', function() {
    // Função de filtro por número e tag
});
});


document.getElementById('filterButton').addEventListener('click', updateFilters);
const tags = {
document.getElementById('mapType').addEventListener('change', updateFilters);
    'Areia': 'Areia',
document.getElementById('specificOption').addEventListener('change', updateFilters);
    'Gelo': 'Gelo',
    'Grama': 'Grama',
    'Árvore': 'Árvore',
    'Pedra': 'Pedra',
    'Terra': 'Terra',
    'Piso': 'Piso',
    'Construção': 'Construção',
    'Pântano': 'Pântano',
    'Pirâmide': 'Pirâmide',
    'Fogo': 'Fogo',
    'Água': 'Água'
};
 
function updateTags() {
    const filterByTag = document.getElementById('filterByTag');
    const tagCheckboxes = filterByTag.querySelectorAll('input[type="checkbox"]');
   
    tagCheckboxes.forEach(checkbox => {
        checkbox.addEventListener('change', function() {
            updateFilters();
        });
    });
}


updateFilters(); // Inicializa com os valores padrão
updateTags();
</script>
    </script>
</body>
</body>
</html>
</html>

Edição das 20h16min de 3 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 e Exibição de Imagens</title>
   <style>
       /* Adicione seu estilo aqui */
       .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: 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;
       }
       .tag-checkbox {
           display: flex;
           flex-wrap: wrap;
           gap: 10px;
       }
       .tag-checkbox label {
           display: flex;
           align-items: center;
           font-size: 14px;
       }
       .tag-checkbox input[type="checkbox"] {
           margin-right: 5px;
       }
   </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: { 
       '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: '4002, 3320, 7', tags:['Areia','Árvore','Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/0/07/Mapas_de_ADV_VERMELHO_-_4002%2C_3320%2C_7.webp' } 
       ], 
       'Gelo': [ 
           { id: '201', local: 'Ice Cave', coordinates: '3831, 3270, 7', tags:['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/6/67/Mapas_de_ADV_VERDE_-_3831%2C_3270%2C_7.webp' } 
       ], 
       'Grama': [ 
           { id: '301', local: 'Green Fields', coordinates: '3950, 3200, 7', tags:['Grama','Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/7/7d/Mapas_de_ADV_VERDE_-_3950%2C_3200%2C_7.webp' } 
       ] 
   },
   2: {
       'Areia': [ 
           { id: '104', local: 'Tropical Beach', coordinates: '3650, 3280, 7', tags:['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/8/8c/Mapas_de_ADV_VERDE_-_3650%2C_3280%2C_7.webp' }
       ]
   }

};

function updateFilters() {

   const mapType = document.getElementById('mapType').value;
   const specificOption = document.getElementById('specificOption').value;
   const imageContainer = document.getElementById('imageContainer');
   
   let filteredImages = [];
   
   if (mapType && specificOptions[mapType]) {
       const selectedOptions = specificOptions[mapType];
       
       if (specificOption) {
           filteredImages = selectedOptions[specificOption] || [];
       } else {
           // If no specific option is selected, get all maps for the selected type
           for (const key in selectedOptions) {
               filteredImages = filteredImages.concat(selectedOptions[key]);
           }
       }
       
       imageContainer.innerHTML = ;
       filteredImages.forEach(item => {
           const div = document.createElement('div');
           div.classList.add('image-item');
           div.innerHTML = `
               <img src="${item.imageUrl}" alt="Imagem do Mapa" />

ID: ${item.id}

Local: ${item.local}

Coordenadas: ${item.coordinates}

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

           `;
           imageContainer.appendChild(div);
       });
       imageContainer.classList.remove('hidden');
   } else {
       imageContainer.innerHTML = ;
       imageContainer.classList.add('hidden');
   }

}

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

   document.getElementById('specificOptions').classList.remove('hidden');
   updateFilters();

});

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

   updateFilters();

});

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

   const isChecked = this.checked;
   document.getElementById('filterSection').classList.toggle('hidden', !isChecked);

});

document.getElementById('filterButton').addEventListener('click', function() {

   // Função de filtro por número e tag

});

const tags = {

   'Areia': 'Areia',
   'Gelo': 'Gelo',
   'Grama': 'Grama',
   'Árvore': 'Árvore',
   'Pedra': 'Pedra',
   'Terra': 'Terra',
   'Piso': 'Piso',
   'Construção': 'Construção',
   'Pântano': 'Pântano',
   'Pirâmide': 'Pirâmide',
   'Fogo': 'Fogo',
   'Água': 'Água'

};

function updateTags() {

   const filterByTag = document.getElementById('filterByTag');
   const tagCheckboxes = filterByTag.querySelectorAll('input[type="checkbox"]');
   
   tagCheckboxes.forEach(checkbox => {
       checkbox.addEventListener('change', function() {
           updateFilters();
       });
   });

}

updateTags();

   </script>

</body> </html>