Widget:Test3: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
Linha 7: | Linha 7: | ||
<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; | ||
} | } | ||
.input-group { | .input-group { | ||
margin: 20px 0; | margin: 20px 0; | ||
} | } | ||
.maps__select { | .maps__select, | ||
.input-group input[type="text"], | |||
.input-group button { | |||
width: 100%; | width: 100%; | ||
padding: 10px; | padding: 10px; | ||
margin-top: 5px; | |||
font-size: 16px; | font-size: 16px; | ||
border-radius: 5px; | border-radius: 5px; | ||
border: 1px solid #ccc; | border: 1px solid #ccc; | ||
} | } | ||
. | .image-container { | ||
display: flex; | |||
flex-wrap: wrap; | |||
gap: 10px; | |||
margin-top: 20px; | |||
} | } | ||
. | .image-item { | ||
flex: 1 0 30%; | |||
text-align: center; | |||
} | } | ||
. | .image-item img { | ||
max-width: 100%; | |||
height: auto; | height: auto; | ||
} | } | ||
. | .image-info { | ||
margin- | margin-top: 5px; | ||
} | } | ||
Linha 185: | Linha 61: | ||
.tag-button.selected { | .tag-button.selected { | ||
background-color: #15864e; | background-color: #15864e; | ||
color: | color: #fff; | ||
} | |||
.filter-container { | |||
display: flex; | |||
align-items: center; | |||
margin-bottom: 20px; | |||
} | |||
.filter-container input[type="checkbox"] { | |||
margin-right: 10px; | |||
} | |||
.filter-container label { | |||
font-size: 16px; | |||
} | } | ||
Linha 207: | Linha 97: | ||
</style> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
<form id="mapForm"> | <form id="mapForm"> | ||
<div | <div class="input-group"> | ||
<label for="mapType">Tipo de Mapa</label> | |||
<select id="mapType" class="maps__select"> | <select id="mapType" class="maps__select"> | ||
<option value="">Selecione um mapa</option> | <option value="">Selecione um mapa</option> | ||
Linha 216: | Linha 108: | ||
<option value="3">Mapa Roxo</option> | <option value="3">Mapa Roxo</option> | ||
</select> | </select> | ||
</div> | </div> | ||
<div id="specificOptions" | <div class="input-group hidden" id="specificOptions"> | ||
<label for="specificOption">Local do X</label> | |||
<select id="specificOption" class="maps__select"> | <select id="specificOption" class="maps__select"> | ||
<option value="">Selecione uma opção</option> | <option value="">Selecione uma opção</option> | ||
Linha 230: | Linha 122: | ||
<option value="Pisos">Pisos</option> | <option value="Pisos">Pisos</option> | ||
</select> | </select> | ||
</div> | </div> | ||
<div class="filter-container"> | <div class="filter-container hidden" id="filterSection"> | ||
<input type="checkbox" id="enableFilter"> | <input type="checkbox" id="enableFilter"> | ||
<label for="enableFilter | <label for="enableFilter">Ativar filtro</label> | ||
<div class="input-group hidden" id="filterOptions"> | |||
<label for="filterType">Filtrar Por</label> | |||
<select id="filterType" class="maps__select"> | |||
<label for=" | |||
<select id=" | |||
<option value="">Escolha uma Opção</option> | <option value="">Escolha uma Opção</option> | ||
<option value="number">Filtrar por Número</option> | <option value="number">Filtrar por Número</option> | ||
</select> | </select> | ||
<input type="text" id="searchIds" placeholder="Digite os números ou tags separados por vírgula" | <input type="text" id="searchIds" placeholder="Digite os números ou tags separados por vírgula"> | ||
</div> | </div> | ||
</div> | </div> | ||
<div | <div class="input-group"> | ||
< | <button type="button" id="filterButton">Filtrar</button> | ||
</div> | </div> | ||
<div id="tagButtons" class="hidden"> | <div id="tagButtons" class="hidden"> | ||
<!-- Botões de tag serão exibidos aqui --> | <!-- Botões de tag serão exibidos aqui --> | ||
</div> | |||
<div id="imageContainer" class="image-container"> | |||
<!-- As imagens e suas informações serão exibidas aqui --> | |||
</div> | </div> | ||
</form> | </form> | ||
Linha 266: | Linha 153: | ||
<script> | <script> | ||
const specificOptions = { | const specificOptions = { | ||
1: { | 1: { // Mapa Vermelho | ||
'Areia': [ | '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: '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: 'Desert', coordinates: '4500, 5300, 5', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/55/Mapa_Vermelho_ADV_-_4500%2C_5300%2C_5.webp' } | { id: '102', local: 'Desert', coordinates: '4500, 5300, 5', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/55/Mapa_Vermelho_ADV_-_4500%2C_5300%2C_5.webp' } | ||
Linha 275: | Linha 162: | ||
] | ] | ||
}, | }, | ||
2: { | 2: { // Mapa Verde | ||
'Gelo': [ | 'Gelo': [ | ||
{ id: '201', local: 'Snowy Peak', coordinates: '2050, 4850, 10', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/5/56/Mapa_Verde_ADV_-_2050%2C_4850%2C_10.webp' } | { id: '201', local: 'Snowy Peak', coordinates: '2050, 4850, 10', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/5/56/Mapa_Verde_ADV_-_2050%2C_4850%2C_10.webp' } | ||
] | ] | ||
Linha 289: | Linha 176: | ||
const mapTypeSelect = document.getElementById('mapType'); | const mapTypeSelect = document.getElementById('mapType'); | ||
const filterSection = document.getElementById('filterSection'); | const filterSection = document.getElementById('filterSection'); | ||
const filterOptions = document.getElementById('filterOptions'); | |||
const searchIdsInput = document.getElementById('searchIds'); | const searchIdsInput = document.getElementById('searchIds'); | ||
Linha 317: | Linha 205: | ||
}); | }); | ||
tagButtons.classList.toggle('hidden', tags.length === 0); | |||
} | } | ||
Linha 345: | Linha 231: | ||
img.src = item.imageUrl; | img.src = item.imageUrl; | ||
img.alt = `Mapa ${item.id}`; | img.alt = `Mapa ${item.id}`; | ||
itemDiv.appendChild(img); | itemDiv.appendChild(img); | ||
Linha 369: | Linha 254: | ||
mapTypeSelect.addEventListener('change', () => { | mapTypeSelect.addEventListener('change', () => { | ||
specificOptionSelect.classList.toggle('hidden', !mapTypeSelect.value); | |||
updateTags(); | updateTags(); | ||
filterImages(); | filterImages(); | ||
Linha 388: | Linha 274: | ||
enableFilter.addEventListener('change', () => { | enableFilter.addEventListener('change', () => { | ||
filterSection.classList.toggle('hidden', !enableFilter.checked); | filterSection.classList.toggle('hidden', !enableFilter.checked); | ||
filterOptions.classList.toggle('hidden', !enableFilter.checked); | |||
if (!enableFilter.checked) { | if (!enableFilter.checked) { | ||
filterImages(); | filterImages(); | ||
} | } | ||
}); | }); | ||
function initializePage() { | function initializePage() { | ||
specificOptionSelect.classList.add('hidden'); | |||
filterSection.classList.add('hidden'); | |||
filterOptions.classList.add('hidden'); | |||
updateTags(); | updateTags(); | ||
} | } |
Edição das 23h14min 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> .hidden { display: none; }
.input-group { margin: 20px 0; }
.maps__select, .input-group input[type="text"], .input-group button { width: 100%; padding: 10px; margin-top: 5px; font-size: 16px; border-radius: 5px; border: 1px solid #ccc; }
.image-container { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.image-item { flex: 1 0 30%; text-align: center; }
.image-item img { max-width: 100%; height: auto; }
.image-info { margin-top: 5px; }
.tag-button { display: inline-block; background-color: #f1f1f1; color: #333; padding: 10px 20px; margin: 5px; border: 1px solid #ccc; border-radius: 20px; cursor: pointer; font-size: 16px; }
.tag-button.selected { background-color: #15864e; color: #fff; }
.filter-container { display: flex; align-items: center; margin-bottom: 20px; }
.filter-container input[type="checkbox"] { margin-right: 10px; }
.filter-container label { font-size: 16px; }
.selected-tags { margin: 20px; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 5px; }
.tag-item { display: inline-block; background-color: #007BFF; color: white; padding: 5px 10px; margin-right: 5px; border-radius: 3px; font-size: 14px; } </style>
</head>
<body>
<form id="mapForm">
<label for="mapType">Tipo de Mapa</label> <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>
<button type="button" id="filterButton">Filtrar</button>
</form>
<script> const specificOptions = { 1: { // Mapa Vermelho '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: 'Desert', coordinates: '4500, 5300, 5', tags: ['Areia'], imageUrl: 'https://wiki.pokexgames.com/images/5/55/Mapa_Vermelho_ADV_-_4500%2C_5300%2C_5.webp' } ], 'Grama': [ { id: '103', local: 'Grassland', coordinates: '5600, 4700, 8', tags: ['Grama'], imageUrl: 'https://wiki.pokexgames.com/images/6/67/Mapa_Vermelho_ADV_-_5600%2C_4700%2C_8.webp' } ] }, 2: { // Mapa Verde 'Gelo': [ { id: '201', local: 'Snowy Peak', coordinates: '2050, 4850, 10', tags: ['Gelo'], imageUrl: 'https://wiki.pokexgames.com/images/5/56/Mapa_Verde_ADV_-_2050%2C_4850%2C_10.webp' } ] } };
const imageContainer = document.getElementById('imageContainer'); const tagButtons = document.getElementById('tagButtons'); const filterButton = document.getElementById('filterButton'); const enableFilter = document.getElementById('enableFilter'); const specificOptionSelect = document.getElementById('specificOption'); const mapTypeSelect = document.getElementById('mapType'); const filterSection = document.getElementById('filterSection'); const filterOptions = document.getElementById('filterOptions'); const searchIdsInput = document.getElementById('searchIds');
function updateTags() { const selectedMapType = mapTypeSelect.value; const selectedOption = specificOptionSelect.value;
let tags = []; if (selectedMapType && selectedOption) { const options = specificOptions[selectedMapType]; if (options && options[selectedOption]) { options[selectedOption].forEach(item => { tags = [...new Set([...tags, ...item.tags])]; }); } }
tagButtons.innerHTML = ; tags.forEach(tag => { const button = document.createElement('button'); button.textContent = tag; button.classList.add('tag-button'); button.addEventListener('click', () => { button.classList.toggle('selected'); filterImages(); }); tagButtons.appendChild(button); });
tagButtons.classList.toggle('hidden', tags.length === 0); }
function filterImages() { const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(btn => btn.textContent); const selectedMapType = mapTypeSelect.value; const selectedOption = specificOptionSelect.value; const filterById = searchIdsInput.value.trim();
imageContainer.innerHTML = ; if (selectedMapType && selectedOption) { const options = specificOptions[selectedMapType]; if (options && options[selectedOption]) { const filteredItems = options[selectedOption].filter(item => { const matchesTag = selectedTags.length === 0 || selectedTags.some(tag => item.tags.includes(tag)); const matchesId = filterById === || filterById.split(',').map(id => id.trim()).includes(item.id); return matchesTag && matchesId; });
filteredItems.forEach(item => { const itemDiv = document.createElement('div'); itemDiv.classList.add('image-item');
const img = document.createElement('img'); img.src = item.imageUrl; img.alt = `Mapa ${item.id}`; itemDiv.appendChild(img);
const infoDiv = document.createElement('div'); infoDiv.classList.add('image-info'); infoDiv.innerHTML = ` Número do Mapa: ${item.id}
Local: ${item.local}
Coordenada: ${item.coordinates}
Tag(s): ${item.tags.join(', ')} `; itemDiv.appendChild(infoDiv);
imageContainer.appendChild(itemDiv); });
if (filteredItems.length === 0) {
imageContainer.innerHTML = '
Nenhuma imagem encontrada para os critérios selecionados.
';
} } } }
mapTypeSelect.addEventListener('change', () => { specificOptionSelect.classList.toggle('hidden', !mapTypeSelect.value); updateTags(); filterImages(); });
specificOptionSelect.addEventListener('change', () => { updateTags(); filterImages(); });
filterButton.addEventListener('click', () => { filterImages(); });
searchIdsInput.addEventListener('input', () => { filterImages(); });
enableFilter.addEventListener('change', () => { filterSection.classList.toggle('hidden', !enableFilter.checked); filterOptions.classList.toggle('hidden', !enableFilter.checked); if (!enableFilter.checked) { filterImages(); } });
function initializePage() { specificOptionSelect.classList.add('hidden'); filterSection.classList.add('hidden'); filterOptions.classList.add('hidden'); updateTags(); }
initializePage(); </script>
</body>
</html>