Widget:Test3
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>Filtro de Mapas</title> <style> .hidden { display: none; } .image-item { margin: 10px 0; } .image-info { margin-top: 5px; } </style>
</head> <body>
<label for="mapType">Tipo de Mapa:</label> <select id="mapType"> <option value="">Selecione o Tipo de Mapa</option> <option value="1">Mapa Vermelho</option> <option value="2">Mapa Verde</option> <option value="3">Mapa Roxo</option> </select>
<label for="specificOption">Local do X:</label> <select id="specificOption"> </select>
<input type="checkbox" id="enableFilter"> <label for="enableFilter">Ativar Filtro</label>
<label for="filterOption">Filtrar por:</label> <select id="filterOption"> <option value="number">Número</option> <option value="tag">Tag</option> </select> <input type="text" id="searchIds" placeholder="Digite os números separados por vírgula"> <button id="filterButton">Filtrar</button>
<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' }, { id: '104', local: 'Saffron', coordinates: '4009, 3601, 7', tags: ['Areia', 'Árvore', 'Terra', 'Água'], imageUrl: 'https://wiki.pokexgames.com/images/f/f5/Mapas_de_ADV_VERMELHO_-_4009%2C_3601%2C_7.webp' }, { id: '105', local: 'Hurricane Island', coordinates: '4166, 3302, 7', tags: ['Areia', 'Pedra', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/a/ab/Mapas_de_ADV_VERMELHO_-_4166%2C_3302%2C_7.webp' }, ], 'Gelo': [ { id: '201', local: 'Frost Peak', coordinates: '4600, 3000, 7', tags: ['Gelo', 'Árvore', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/3/3e/Mapas_de_ADV_VERDE_-_4600%2C_3000%2C_7.webp' }, { id: '202', local: 'Ice Fields', coordinates: '4700, 3100, 7', tags: ['Gelo', 'Pedra', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/1/1e/Mapas_de_ADV_VERDE_-_4700%2C_3100%2C_7.webp' }, ], 'Grama': [ { id: '301', local: 'Green Meadow', coordinates: '5000, 3400, 7', tags: ['Grama', 'Árvore', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/7/76/Mapas_de_ADV_VERDE_-_5000%2C_3400%2C_7.webp' }, { id: '302', local: 'Forest Glade', coordinates: '5100, 3500, 7', tags: ['Grama', 'Árvore', 'Água'], imageUrl: 'https://wiki.pokexgames.com/images/8/89/Mapas_de_ADV_VERDE_-_5100%2C_3500%2C_7.webp' }, ], }, 2: { // Dados para Mapas Verdes }, 3: { // Dados para Mapas Roxos }, };
document.getElementById('mapType').addEventListener('change', updateSpecificOptions); document.getElementById('filterOption').addEventListener('change', toggleSearchInput); document.getElementById('enableFilter').addEventListener('change', toggleFilterSection); document.getElementById('filterButton').addEventListener('click', filterImages);
function updateSpecificOptions() { const mapType = document.getElementById('mapType').value; const specificOption = document.getElementById('specificOption');
specificOption.innerHTML = '<option value="">Selecione uma opção</option>';
if (mapType) { const options = Object.keys(specificOptions[mapType] || {}); options.forEach(option => { specificOption.innerHTML += `<option value="${option}">${option}</option>`; }); } }
function toggleSearchInput() { const filterOption = document.getElementById('filterOption').value; const searchInput = document.getElementById('searchIds'); searchInput.placeholder = filterOption === 'number' ? 'Digite os números separados por vírgula' : 'Digite as tags separadas por vírgula'; }
function toggleFilterSection() { const filterSection = document.getElementById('filterSection'); filterSection.classList.toggle('hidden', !document.getElementById('enableFilter').checked); }
function filterImages() { const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim().toLowerCase()); const filterOption = document.getElementById('filterOption').value; const selectedMapType = document.getElementById('mapType').value; const selectedSpecificOption = document.getElementById('specificOption').value; const imageContainer = document.getElementById('imageContainer'); let imagesHtml = ; let allImages = [];
if (filterOption === 'number') { if (searchIds.length > 0) { Object.keys(specificOptions).forEach(mapType => { if (selectedMapType === || selectedMapType == mapType) { const mapOptions = specificOptions[mapType]; Object.keys(mapOptions).forEach(option => { const images = mapOptions[option].filter(image => searchIds.includes(image.id)); allImages = allImages.concat(images); }); } }); } } else if (filterOption === 'tag' && selectedSpecificOption) { Object.keys(specificOptions).forEach(mapType => { if (selectedMapType === || selectedMapType == mapType) { const mapOptions = specificOptions[mapType]; Object.keys(mapOptions).forEach(option => { const images = mapOptions[option].filter(image => image.tags.includes(selectedSpecificOption)); allImages = allImages.concat(images); }); } }); }
if (allImages.length > 0) { allImages.sort((a, b) => a.local.localeCompare(b.local));
allImages.forEach(image => { imagesHtml += `
<img src="${image.imageUrl}" alt="Imagem ID ${image.id}">
Número do Mapa: ${image.id}
Local: ${image.local}
Coordenada: ${image.coordinates}
Tag(s): ${image.tags.join(', ') || 'Nenhuma'}
`; }); } else { imagesHtml = 'Nenhuma imagem encontrada com os critérios fornecidos.'; }
imageContainer.innerHTML = imagesHtml; imageContainer.classList.toggle('hidden', allImages.length === 0); } </script>
</body> </html>