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 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 6: | Linha 7: | ||
<title>Seleção e Exibição de Imagens</title> | <title>Seleção e Exibição de Imagens</title> | ||
<style> | <style> | ||
.d-flex { | .d-flex { | ||
display: flex; | display: flex; | ||
Linha 159: | Linha 145: | ||
color: #0d0d0d; | color: #0d0d0d; | ||
line-height: 1.5; | line-height: 1.5; | ||
} | |||
.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: rgb(159, 5, 219); | |||
} | |||
.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> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
<form id="mapForm"> | <form id="mapForm"> | ||
<div id="mapTypeSelection" class="input-group"> | <div id="mapTypeSelection" class="input-group"> | ||
<select id="mapType" class="maps__select"> | <select id="mapType" class="maps__select"> | ||
Linha 175: | Linha 196: | ||
</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 189: | Linha 209: | ||
<label class="maps__label" for="specificOption">Local do X</label> | <label class="maps__label" for="specificOption">Local do X</label> | ||
</div> | </div> | ||
<div class="filter-container"> | <div class="filter-container"> | ||
<input type="checkbox" id="enableFilter"> | <input type="checkbox" id="enableFilter"> | ||
<label for="enableFilter" class="filter-label">Ativar filtro</label> | <label for="enableFilter" class="filter-label">Ativar filtro</label> | ||
</div> | </div> | ||
<div class="input-group"> | |||
<label for="tagSelect">Selecione as Tags:</label> | |||
<div id="tagButtons"> | |||
<div class="tag-button" data-value="Areia">Areia</div> | |||
<div class="tag-button" data-value="Grama">Grama</div> | |||
<div class="tag-button" data-value="Gelo">Gelo</div> | |||
<div class="tag-button" data-value="Árvore">Árvore</div> | |||
<div class="tag-button" data-value="Pedra">Pedra</div> | |||
<div class="tag-button" data-value="Terra">Terra</div> | |||
<div class="tag-button" data-value="Piso">Piso</div> | |||
<div class="tag-button" data-value="Construção">Construção</div> | |||
<div class="tag-button" data-value="Pântano">Pântano</div> | |||
<div class="tag-button" data-value="Pirâmide">Pirâmide</div> | |||
<div class="tag-button" data-value="Fogo">Fogo</div> | |||
<div class="tag-button" data-value="Água">Água</div> | |||
</div> | |||
</div> | |||
<div id="filterSection" class="hidden"> | <div id="filterSection" class="hidden"> | ||
<div id=" | <div id="filterById" class="input-group"> | ||
<label for="filterOption" class="maps__label">Filtrar Por | <label for="filterOption" class="maps__label">Filtrar Por</label> | ||
< | <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="mapsCalc__select"> | |||
</div> | </div> | ||
<div class="d-flex justify-center align-center flex-column"> | <div class="d-flex justify-center align-center flex-column"> | ||
<button type="button" id="filterButton" class="hover-minimize"> | <button type="button" id="filterButton" class="hover-minimize"> | ||
Linha 223: | Linha 251: | ||
</div> | </div> | ||
<div id="imageContainer" class="image-container hidden"> | <div id="imageContainer" class="image-container hidden"> | ||
<!-- As imagens e suas informações serão exibidas aqui --> | <!-- As imagens e suas informações serão exibidas aqui --> | ||
Linha 230: | Linha 257: | ||
<script> | <script> | ||
const specificOptions = { | const specificOptions = { | ||
1: { | 1: { | ||
'Areia': [ | 'Areia': [ | ||
{ id: '101', local: 'Green Island', coordinates: '3780, | { 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/9/9b/Mapas_de_ADV_VERDE_-_3969%2C_3300%2C_7.webp' } | ||
], | ], | ||
// | 'Gelo': [ | ||
{ id: '201', local: 'Ice Island', coordinates: '3980, 3326, 7', tags: ['Gelo', 'Subaquático', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/4/42/Mapas_de_ADV_VERDE_-_3980%2C_3326%2C_7.webp' } | |||
] | |||
}, | }, | ||
2: { | 2: { | ||
' | 'Grama': [ | ||
{ id: ' | { id: '301', local: 'Mysterious Forest', coordinates: '4001, 3330, 7', tags: ['Grama', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/a/a4/Mapas_de_ADV_VERDE_-_4001%2C_3330%2C_7.webp' } | ||
] | |||
] | |||
}, | }, | ||
3: { | 3: { | ||
' | 'Pedra': [ | ||
{ id: ' | { id: '401', local: 'Rocky Mountain', coordinates: '3700, 3300, 7', tags: ['Pedra', 'Subaquático'], imageUrl: 'https://wiki.pokexgames.com/images/9/93/Mapas_de_ADV_ROXO_-_3700%2C_3300%2C_7.webp' } | ||
] | |||
] | } | ||
} | |||
}; | }; | ||
document.getElementById('mapType').addEventListener('change', function () { | const enableFilterCheckbox = document.getElementById('enableFilter'); | ||
const filterSection = document.getElementById('filterSection'); | |||
const mapType = document.getElementById('mapType'); | |||
const specificOption = document.getElementById('specificOption'); | |||
const specificOptionsSection = document.getElementById('specificOptions'); | |||
const tagButtons = document.querySelectorAll('.tag-button'); | |||
const filterButton = document.getElementById('filterButton'); | |||
const imageContainer = document.getElementById('imageContainer'); | |||
enableFilterCheckbox.addEventListener('change', function () { | |||
filterSection.classList.toggle('hidden', !this.checked); | |||
}); | |||
mapType.addEventListener('change', function () { | |||
const selectedMapType = parseInt(this.value); | |||
const options = specificOptions[selectedMapType]; | |||
if (options) { | |||
specificOptionsSection.classList.remove('hidden'); | |||
specificOption.innerHTML = '<option value="">Selecione uma opção</option>'; | |||
Object.keys(options).forEach(option => { | |||
specificOption.innerHTML += `<option value="${option}">${option}</option>`; | |||
}); | |||
} else { | } else { | ||
specificOptionsSection.classList.add('hidden'); | |||
specificOption.innerHTML = ''; | |||
} | } | ||
}); | }); | ||
tagButtons.forEach(button => { | |||
button.addEventListener('click', function () { | |||
this.classList.toggle('selected'); | |||
}); | |||
}); | }); | ||
filterButton.addEventListener('click', function () { | |||
const | const selectedMapType = parseInt(mapType.value); | ||
const | const selectedSpecificOption = specificOption.value; | ||
const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(button => button.getAttribute('data-value')); | |||
if (!selectedMapType) { | |||
alert('Selecione um tipo de mapa'); | |||
return; | |||
} | |||
const maps = specificOptions[selectedMapType][selectedSpecificOption] || []; | |||
let filteredMaps = maps; | |||
if ( | if (selectedTags.length > 0) { | ||
filteredMaps = maps.filter(map => selectedTags.every(tag => map.tags.includes(tag))); | |||
} | |||
if (filteredMaps.length > 0) { | |||
imageContainer.innerHTML = ''; | |||
filteredMaps.forEach(map => { | |||
const imageItem = document.createElement('div'); | |||
imageItem.classList.add('image-item'); | |||
imageItem.innerHTML = ` | |||
<img src="${map.imageUrl}" alt="${map.local}" width="120px" height="120px"> | |||
<div class="image-info"> | |||
<p>ID: ${map.id}</p> | |||
<p>Local: ${map.local}</p> | |||
<p>Coordenadas: ${map.coordinates}</p> | |||
<div>Tags: ${map.tags.map(tag => `<span class="tag-item">${tag}</span>`).join(', ')}</div> | |||
</div> | |||
`; | |||
imageContainer.appendChild(imageItem); | |||
}); | |||
imageContainer.classList.remove('hidden'); | |||
} else { | } else { | ||
alert(' | alert('Nenhum mapa corresponde aos critérios selecionados.'); | ||
} | } | ||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
Edição das 21h05min 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> .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-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: rgb(159, 5, 219); }
.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">
<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>
<select id="specificOption" class="maps__select"> <option value="">Selecione uma opção</option> <option value="Areia">Areia</option> <option value="Gelo">Gelo</option> <option value="Grama">Grama</option> <option value="Pedra">Pedra</option> <option value="Subaquático">Subaquático</option> <option value="Terra">Terra</option> <option value="Pisos">Pisos</option> </select> <label class="maps__label" for="specificOption">Local do X</label>
<input type="checkbox" id="enableFilter"> <label for="enableFilter" class="filter-label">Ativar filtro</label>
<label for="tagSelect">Selecione as Tags:</label>
<label for="filterOption" class="maps__label">Filtrar Por</label> <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="mapsCalc__select">
<button type="button" id="filterButton" class="hover-minimize"> <img src="https://wiki.pokexgames.com/images/8/82/Botao_Filtrar_Mapas_Adv.png" alt="Imagem botão filtrar"> </button>
</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/9/9b/Mapas_de_ADV_VERDE_-_3969%2C_3300%2C_7.webp' } ], 'Gelo': [ { id: '201', local: 'Ice Island', coordinates: '3980, 3326, 7', tags: ['Gelo', 'Subaquático', 'Pedra'], imageUrl: 'https://wiki.pokexgames.com/images/4/42/Mapas_de_ADV_VERDE_-_3980%2C_3326%2C_7.webp' } ] }, 2: { 'Grama': [ { id: '301', local: 'Mysterious Forest', coordinates: '4001, 3330, 7', tags: ['Grama', 'Árvore'], imageUrl: 'https://wiki.pokexgames.com/images/a/a4/Mapas_de_ADV_VERDE_-_4001%2C_3330%2C_7.webp' } ] }, 3: { 'Pedra': [ { id: '401', local: 'Rocky Mountain', coordinates: '3700, 3300, 7', tags: ['Pedra', 'Subaquático'], imageUrl: 'https://wiki.pokexgames.com/images/9/93/Mapas_de_ADV_ROXO_-_3700%2C_3300%2C_7.webp' } ] } };
const enableFilterCheckbox = document.getElementById('enableFilter'); const filterSection = document.getElementById('filterSection'); const mapType = document.getElementById('mapType'); const specificOption = document.getElementById('specificOption'); const specificOptionsSection = document.getElementById('specificOptions'); const tagButtons = document.querySelectorAll('.tag-button'); const filterButton = document.getElementById('filterButton'); const imageContainer = document.getElementById('imageContainer');
enableFilterCheckbox.addEventListener('change', function () { filterSection.classList.toggle('hidden', !this.checked); });
mapType.addEventListener('change', function () { const selectedMapType = parseInt(this.value); const options = specificOptions[selectedMapType];
if (options) { specificOptionsSection.classList.remove('hidden'); specificOption.innerHTML = '<option value="">Selecione uma opção</option>';
Object.keys(options).forEach(option => { specificOption.innerHTML += `<option value="${option}">${option}</option>`; }); } else { specificOptionsSection.classList.add('hidden'); specificOption.innerHTML = ; } });
tagButtons.forEach(button => { button.addEventListener('click', function () { this.classList.toggle('selected'); }); });
filterButton.addEventListener('click', function () { const selectedMapType = parseInt(mapType.value); const selectedSpecificOption = specificOption.value; const selectedTags = Array.from(document.querySelectorAll('.tag-button.selected')).map(button => button.getAttribute('data-value'));
if (!selectedMapType) { alert('Selecione um tipo de mapa'); return; }
const maps = specificOptions[selectedMapType][selectedSpecificOption] || []; let filteredMaps = maps;
if (selectedTags.length > 0) { filteredMaps = maps.filter(map => selectedTags.every(tag => map.tags.includes(tag))); }
if (filteredMaps.length > 0) { imageContainer.innerHTML = ; filteredMaps.forEach(map => { const imageItem = document.createElement('div'); imageItem.classList.add('image-item'); imageItem.innerHTML = ` <img src="${map.imageUrl}" alt="${map.local}" width="120px" height="120px">
ID: ${map.id}
Local: ${map.local}
Coordenadas: ${map.coordinates}
Tags: ${map.tags.map(tag => `${tag}`).join(', ')}
`; imageContainer.appendChild(imageItem); }); imageContainer.classList.remove('hidden'); } else { alert('Nenhum mapa corresponde aos critérios selecionados.'); } }); </script>
</body>
</html>