5 805
edições
Sem resumo de edição |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
<!DOCTYPE html> | <!DOCTYPE html> | ||
<html lang="pt-BR"> | <html lang="pt-BR"> | ||
<head> | <head> | ||
<meta charset="UTF-8"> | <meta charset="UTF-8"> | ||
Linha 7: | Linha 6: | ||
<title>Seleção e Exibição de Imagens</title> | <title>Seleção e Exibição de Imagens</title> | ||
<style> | <style> | ||
.hidden { | .hidden { | ||
display: none; | display: none; | ||
} | } | ||
.image-container { | .image-container { | ||
display: flex; | display: flex; | ||
Linha 24: | Linha 14: | ||
justify-content: center; | justify-content: center; | ||
gap: 10px; | gap: 10px; | ||
} | } | ||
.image-item { | |||
flex: 1 0 30%; | flex: 1 0 30%; | ||
text-align: center; | text-align: center; | ||
} | } | ||
.image-item img { | |||
.image- | max-width: 100%; | ||
height: auto; | |||
margin-bottom: 5px; | margin-bottom: 5px; | ||
} | } | ||
.input-group { | .input-group { | ||
margin: 10px 0; | |||
margin: | |||
} | } | ||
.maps__select { | .maps__select { | ||
width: 100%; | width: 100%; | ||
Linha 103: | Linha 33: | ||
border-radius: 5px; | border-radius: 5px; | ||
border: 1px solid #ccc; | border: 1px solid #ccc; | ||
} | } | ||
.tag-button { | .tag-button { | ||
background-color: #f0f0f0; | background-color: #f0f0f0; | ||
Linha 160: | Linha 41: | ||
font-size: 14px; | font-size: 14px; | ||
cursor: pointer; | cursor: pointer; | ||
margin: 5px; | |||
transition: background-color 0.3s, color 0.3s; | transition: background-color 0.3s, color 0.3s; | ||
} | } | ||
.tag-button.selected { | .tag-button.selected { | ||
background-color: #007bff; | background-color: #007bff; | ||
color: #fff; | color: #fff; | ||
} | } | ||
.tag-button.disabled { | .tag-button.disabled { | ||
background-color: #e0e0e0; | background-color: #e0e0e0; | ||
Linha 183: | Linha 56: | ||
</style> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
<form id="mapForm"> | <form id="mapForm"> | ||
Linha 193: | Linha 65: | ||
<option value="3">Mapa Roxo</option> | <option value="3">Mapa Roxo</option> | ||
</select> | </select> | ||
<label | <label for="mapType">Tipo de Mapa</label> | ||
</div> | </div> | ||
<div id="specificOptions" class="hidden input-group"> | <div id="specificOptions" class="hidden input-group"> | ||
<select id="specificOption" class="maps__select"> | <select id="specificOption" class="maps__select"> | ||
Linha 207: | Linha 78: | ||
<option value="Pisos">Pisos</option> | <option value="Pisos">Pisos</option> | ||
</select> | </select> | ||
<label | <label for="specificOption">Local do X</label> | ||
</div> | </div> | ||
<div class="input-group"> | |||
<div class=" | |||
<input type="checkbox" id="enableFilter"> | <input type="checkbox" id="enableFilter"> | ||
<label for="enableFilter | <label for="enableFilter">Ativar filtro</label> | ||
</div> | </div> | ||
<div id="filterSection" class="hidden input-group"> | |||
<div id="filterSection" class="hidden | <select id="filterOption" class="maps__select"> | ||
<option value="">Escolha uma Opção</option> | |||
<option value="number">Filtrar por Número</option> | |||
<option value="tag">Filtrar por Tag</option> | |||
</select> | |||
<input type="text" id="searchIds" placeholder="Digite os números ou tags separados por vírgula" class="maps__select"> | |||
<button type="button" id="filterButton">Filtrar</button> | |||
</div> | </div> | ||
<div id="imageContainer" class="image-container hidden"></div> | |||
<div id="tagButtonsContainer" class="input-group"> | |||
<div id=" | <!-- Botões de tags serão inseridos aqui pelo JavaScript --> | ||
<!-- | |||
</div> | </div> | ||
</form> | </form> | ||
Linha 256: | Linha 103: | ||
1: { | 1: { | ||
'Areia': [ | 'Areia': [ | ||
{ id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', tags: ['Areia | { id: '101', local: 'Green Island', coordinates: '3780, 3326, 7', tags: ['Areia'], 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 | { id: '102', local: 'Wildwind Island', coordinates: '3969, 3300, 7', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/58/Mapas_de_ADV_VERMELHO_-_3969%2C_3300%2C_7.webp' } | ||
], | ], | ||
'Gelo': [ | 'Gelo': [ | ||
{ id: ' | { id: '103', local: 'Snowy Mountain', coordinates: '3500, 3400, 7', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/7/74/Mapas_de_ADV_VERDE_-_3500%2C_3400%2C_7.webp' } | ||
] | ] | ||
}, | }, | ||
2: { | 2: { | ||
'Grama': [ | 'Grama': [ | ||
{ id: ' | { id: '104', local: 'Green Forest', coordinates: '3000, 3100, 7', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/9/94/Mapas_de_ADV_VERDE_-_3000%2C_3100%2C_7.webp' } | ||
], | ], | ||
'Pedra': [ | 'Pedra': [ | ||
{ id: ' | { id: '105', local: 'Rocky Terrain', coordinates: '3200, 3400, 7', tags: ['Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/1/12/Mapas_de_ADV_VERDE_-_3200%2C_3400%2C_7.webp' } | ||
] | ] | ||
} | } | ||
}; | }; | ||
const | const tagButtonsContainer = document.getElementById('tagButtonsContainer'); | ||
const filterButton = document.getElementById('filterButton'); | const filterButton = document.getElementById('filterButton'); | ||
const filterOption = document.getElementById('filterOption'); | const filterOption = document.getElementById('filterOption'); | ||
Linha 285: | Linha 129: | ||
const enableFilter = document.getElementById('enableFilter'); | const enableFilter = document.getElementById('enableFilter'); | ||
const filterSection = document.getElementById('filterSection'); | const filterSection = document.getElementById('filterSection'); | ||
const mapTypeSelection = document.getElementById('mapTypeSelection'); | const mapTypeSelection = document.getElementById('mapTypeSelection'); | ||
const specificOptionsSection = document.getElementById('specificOptions'); | const specificOptionsSection = document.getElementById('specificOptions'); | ||
const tags = ['Areia', 'Gelo', 'Grama', 'Pedra', 'Subaquático', 'Terra', 'Pisos']; | |||
function renderTagButtons() { | |||
tags.forEach(tag => { | |||
const button = document.createElement('button'); | |||
button.className = 'tag-button'; | |||
button.dataset.value = tag; | |||
button.textContent = tag; | |||
button.addEventListener('click', function() { | |||
this.classList.toggle('selected'); | |||
filterImages(); | |||
}); | |||
tagButtonsContainer.appendChild(button); | |||
}); | |||
} | |||
function filterImages() { | function filterImages() { | ||
Linha 297: | Linha 156: | ||
let selectedTags = []; | let selectedTags = []; | ||
document.querySelectorAll('.tag-button.selected').forEach(button => { | |||
selectedTags.push(button.dataset.value); | |||
}); | }); | ||
let filteredImages = []; | |||
for (const [mapTypeKey, locales] of Object.entries(specificOptions)) { | |||
if (selectedMapType && selectedMapType !== mapTypeKey) continue; | |||
if (! | |||
for (const [local, items] of Object.entries(locales)) { | |||
if (selectedLocal && selectedLocal !== local) continue; | |||
items.forEach(item => { | |||
if (filterByNumber && searchIds.value.split(',').map(id => id.trim()).includes(item.id)) { | |||
filteredImages.push(item); | |||
} else if (filterByTag && selectedTags.some(tag => item.tags.includes(tag))) { | |||
filteredImages.push(item); | |||
} else if (!filterByNumber && !filterByTag) { | |||
filteredImages.push(item); | |||
} | |||
}); | }); | ||
} | |||
} | } | ||
displayImages(filteredImages); | |||
} | } | ||
Linha 343: | Linha 188: | ||
imageItem.innerHTML = ` | imageItem.innerHTML = ` | ||
<img src="${image.imageUrl}" alt="Map Image"> | <img src="${image.imageUrl}" alt="Map Image"> | ||
<div | <div> | ||
<p>Número do Mapa: ${image.id}</p> | <p>Número do Mapa: ${image.id}</p> | ||
<p>Local: ${image.local}</p> | <p>Local: ${image.local}</p> | ||
Linha 355: | Linha 200: | ||
} | } | ||
renderTagButtons(); | |||
filterButton.addEventListener('click', filterImages); | filterButton.addEventListener('click', filterImages); | ||
Linha 390: | Linha 217: | ||
imageContainer.classList.add('hidden'); | imageContainer.classList.add('hidden'); | ||
searchIds.value = ''; | searchIds.value = ''; | ||
document.querySelectorAll('.tag-button.selected').forEach(button => button.classList.remove('selected')); | |||
} | } | ||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |