Widget:Test3: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição Etiqueta: Revertido |
Sem resumo de edição Etiqueta: Revertido |
||
Linha 4: | Linha 4: | ||
<meta charset="UTF-8"> | <meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title> | <title>Filtro de Mapas</title> | ||
<style> | <style> | ||
. | .hidden { display: none; } | ||
.image-item { margin: 10px 0; } | |||
.image-info { margin-top: 5px; } | |||
</style> | |||
</head> | |||
<body> | |||
<div> | |||
<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> | |||
</div> | |||
<div> | |||
<label for="specificOption">Local do X:</label> | |||
<select id="specificOption"> | |||
<!-- Opções serão preenchidas dinamicamente --> | |||
</select> | |||
</div> | |||
<div> | |||
<input type="checkbox" id="enableFilter"> | |||
<label for="enableFilter">Ativar Filtro</label> | |||
</div> | |||
<div id="filterSection" class="hidden"> | |||
<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> | |||
</div> | |||
<div id="imageContainer"></div> | |||
. | <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 += ` | |||
<div class="image-item"> | |||
<img src="${image.imageUrl}" alt="Imagem ID ${image.id}"> | |||
<div class="image-info"> | |||
<b>Número do Mapa</b>: ${image.id} <br> | |||
<b>Local</b>: ${image.local} <br> | |||
<b>Coordenada</b>: ${image.coordinates}<br> | |||
<b>Tag(s)</b>: ${image.tags.join(', ') || 'Nenhuma'} | |||
</div> | |||
</div> | |||
`; | |||
}); | |||
} else { | |||
imagesHtml = 'Nenhuma imagem encontrada com os critérios fornecidos.'; | |||
} | |||
imageContainer.innerHTML = imagesHtml; | |||
imageContainer.classList.toggle('hidden', allImages.length === 0); | |||
} | } | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
Edição das 23h32min 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>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>