Widget:Test: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição Etiqueta: Revertido |
||
Linha 6: | Linha 6: | ||
<title>Seleção e Exibição de Imagens</title> | <title>Seleção e Exibição de Imagens</title> | ||
<style> | <style> | ||
.d-flex { | .mapsCalc__select { | ||
width: 100%; | |||
max-width: 400px; /* Ajuste conforme necessário */ | |||
min-width: 300px; /* Define a largura mínima */ | |||
padding: 10px; | |||
font-size: 16px; | |||
} | border-radius: 5px; | ||
border: 1px solid #ccc; | |||
box-sizing: border-box; | |||
} | |||
.input-group { | |||
position: relative; | |||
margin: 20px 0; | |||
} | |||
.mapsCalc__label { | |||
position: absolute; | |||
top: -18px; | |||
background: none; | |||
padding: 0 5px; | |||
font-size: 14px; | |||
font-weight: bold; | |||
color: #0d0d0d; | |||
} | |||
.d-flex { | |||
display: flex; | |||
justify-content: center; | |||
align-items: center; | |||
flex-direction: column; | |||
margin-top: -20px; | |||
} | |||
#filterButton { | |||
margin-top: 10px; | |||
} | } | ||
#filterButton img { | |||
border-radius: 12px; | |||
width: auto; | |||
height: auto; | |||
} | |||
.image-container { | .image-container { | ||
display: flex; | display: flex; | ||
Linha 24: | Linha 57: | ||
margin-top: 5px; | margin-top: 5px; | ||
} | } | ||
.image-container .image-item { | .image-container .image-item { | ||
flex: 1 0 30%; | flex: 1 0 30%; | ||
text-align: center; | text-align: center; | ||
} | } | ||
.image-container img { | .image-container img { | ||
width: 320px; | width: 320px; | ||
margin-bottom: 5px; | margin-bottom: 5px; | ||
} | } | ||
.image-info { | .image-info { | ||
margin-top: 5px; | margin-top: 5px; | ||
} | } | ||
select, input[type="text"], button { | select, input[type="text"], button { | ||
margin: 5px; | margin: 5px; | ||
} | } | ||
#searchButton, #filterButton { | |||
background: none; | background: none; | ||
border: none; | |||
padding: 0; | |||
cursor: pointer; | |||
} | } | ||
#searchButton img, #filterButton img { | |||
width: 12px; | |||
vertical-align: middle; | |||
} | } | ||
</style> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
<form id="mapForm"> | <form id="mapForm" onsubmit="return false;"> | ||
<div id="mapTypeSelection" class="input-group"> | <div id="mapTypeSelection" class="input-group"> | ||
<select id="mapType" class="mapsCalc__select"> | <select id="mapType" class="mapsCalc__select"> | ||
Linha 135: | Linha 116: | ||
<div id="filterById" class="input-group"> | <div id="filterById" class="input-group"> | ||
<label for="searchIds">Buscar por ID(s):</label> | <label class="mapsCalc__label" for="searchIds">Buscar por ID(s):</label> | ||
<input type="text" id="searchIds" placeholder="Digite os IDs separados por vírgula" class="mapsCalc__select"> | <input type="text" id="searchIds" placeholder="Digite os IDs separados por vírgula" class="mapsCalc__select" maxlength="100"> | ||
</div> | </div> | ||
<div class="d-flex | |||
<div class="d-flex"> | |||
<button type="button" id="filterButton" class="hover-minimize"> | <button type="button" id="filterButton" class="hover-minimize"> | ||
<img src="https://wiki.pokexgames.com/images/ | <img src="https://wiki.pokexgames.com/images/d/d3/Banner_calculadora.png" alt="Imagem botão filtrar"> | ||
</button> | </button> | ||
</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 150: | Linha 133: | ||
<script> | <script> | ||
const specificOptions = { | const specificOptions = { | ||
1: { | 1: { | ||
'Areia': [ | 'Areia': [ | ||
{ id: '1001', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, | { id: '1001', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, | ||
Linha 159: | Linha 142: | ||
{ id: '1006', local: 'Shell Island', coordinates: '4299, 3333, 6', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' } | { id: '1006', local: 'Shell Island', coordinates: '4299, 3333, 6', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' } | ||
], | ], | ||
}, | }, | ||
2: {}, | |||
3: {} | |||
} | |||
}; | }; | ||
Linha 234: | Linha 212: | ||
let allImages = []; | let allImages = []; | ||
Object.keys(specificOptions).forEach(mapType => { | Object.keys(specificOptions).forEach(mapType => { | ||
const mapOptions = specificOptions[mapType]; | const mapOptions = specificOptions[mapType]; | ||
Linha 243: | Linha 220: | ||
}); | }); | ||
allImages.sort((a, b) => a.local.localeCompare(b.local)); | allImages.sort((a, b) => a.local.localeCompare(b.local)); | ||
allImages.forEach(image => { | allImages.forEach(image => { | ||
imagesHtml += ` | imagesHtml += ` | ||
Linha 264: | Linha 239: | ||
} else { | } else { | ||
imageContainer.classList.add('hidden'); | imageContainer.classList.add('hidden'); | ||
} | |||
}); | |||
document.getElementById('mapForm').addEventListener('keydown', function(event) { | |||
if (event.key === 'Enter') { | |||
event.preventDefault(); // Evita o envio do formulário | |||
document.getElementById('filterButton').click(); // Aciona o botão de filtro | |||
} | } | ||
}); | }); |
Edição das 05h37min de 24 de agosto 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> .mapsCalc__select { width: 100%; max-width: 400px; /* Ajuste conforme necessário */ min-width: 300px; /* Define a largura mínima */ padding: 10px; font-size: 16px; border-radius: 5px; border: 1px solid #ccc; box-sizing: border-box; }
.input-group { position: relative; margin: 20px 0; }
.mapsCalc__label { position: absolute; top: -18px; background: none; padding: 0 5px; font-size: 14px; font-weight: bold; color: #0d0d0d; }
.d-flex { display: flex; justify-content: center; align-items: center; flex-direction: column; margin-top: -20px; }
#filterButton { margin-top: 10px; }
#filterButton img { border-radius: 12px; width: auto; height: auto; }
.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 { width: 320px; margin-bottom: 5px; }
.image-info { margin-top: 5px; }
select, input[type="text"], button { margin: 5px; }
#searchButton, #filterButton { background: none; border: none; padding: 0; cursor: pointer; }
#searchButton img, #filterButton img { width: 12px; vertical-align: middle; } </style>
</head> <body>
<form id="mapForm" onsubmit="return false;">
<select id="mapType" class="mapsCalc__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="mapsCalc__label" for="mapType">Tipo de Mapa</label>
<select id="specificOption" class="mapsCalc__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="mapsCalc__label" for="specificOption">Local do X</label>
<label class="mapsCalc__label" for="searchIds">Buscar por ID(s):</label> <input type="text" id="searchIds" placeholder="Digite os IDs separados por vírgula" class="mapsCalc__select" maxlength="100">
<button type="button" id="filterButton" class="hover-minimize"> <img src="https://wiki.pokexgames.com/images/d/d3/Banner_calculadora.png" alt="Imagem botão filtrar"> </button>
</form>
<script> const specificOptions = { 1: { 'Areia': [ { id: '1001', local: 'Green Island', coordinates: '3780, 3326, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, { id: '1002', local: 'Wildwind Island', coordinates: '3969, 3300, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, { id: '1003', local: 'Wildwind Island', coordinates: '4002, 3320, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, { id: '1004', local: 'Hurricane Island', coordinates: '4166, 3302, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, { id: '1005', local: 'Shell Island', coordinates: '4266, 3359, 7', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' }, { id: '1006', local: 'Shell Island', coordinates: '4299, 3333, 6', imageUrl: 'https://wiki.pokexgames.com/images/d/db/3780%2C_3326%2C_7.png' } ], }, 2: {}, 3: {} };
document.getElementById('mapType').addEventListener('change', function() { const selectedMapType = this.value; const specificOptionSelect = document.getElementById('specificOption');
if (selectedMapType) { specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>'; const options = Object.keys(specificOptions[selectedMapType]); options.forEach(option => { specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`; }); document.getElementById('specificOptions').classList.remove('hidden'); } else { document.getElementById('specificOptions').classList.add('hidden'); } });
document.getElementById('specificOption').addEventListener('change', function() { const selectedMapType = document.getElementById('mapType').value; const selectedOption = this.value; const imageContainer = document.getElementById('imageContainer'); if (selectedMapType && selectedOption) { const images = specificOptions[selectedMapType][selectedOption]; let imagesHtml = ;
if (Array.isArray(images)) { images.forEach(image => { imagesHtml += `
<img src="${image.imageUrl}" alt="${selectedOption}">
ID: ${image.id}
Local: ${image.local}
Coordenada: ${image.coordinates}
`; }); } else { imagesHtml = `
<img src="${images.imageUrl}" alt="${selectedOption}">
ID: ${images.id}
Local: ${images.local}
Coordenada: ${images.coordinates}
`; } imageContainer.innerHTML = imagesHtml; imageContainer.classList.remove('hidden'); } else { imageContainer.classList.add('hidden'); } });
document.getElementById('filterButton').addEventListener('click', function() { const searchIds = document.getElementById('searchIds').value.split(',').map(id => id.trim()); const imageContainer = document.getElementById('imageContainer');
if (searchIds.length > 0) { let imagesHtml = ; let allImages = [];
Object.keys(specificOptions).forEach(mapType => { const mapOptions = specificOptions[mapType]; Object.keys(mapOptions).forEach(option => { const images = mapOptions[option].filter(image => searchIds.includes(image.id)); allImages = allImages.concat(images); }); });
allImages.sort((a, b) => a.local.localeCompare(b.local));
allImages.forEach(image => { imagesHtml += `
<img src="${image.imageUrl}" alt="Imagem ID ${image.id}">
ID: ${image.id}
Local: ${image.local}
Coordenada: ${image.coordinates}
`; });
imageContainer.innerHTML = imagesHtml || 'Nenhuma imagem encontrada com os IDs fornecidos.'; imageContainer.classList.remove('hidden'); } else { imageContainer.classList.add('hidden'); } });
document.getElementById('mapForm').addEventListener('keydown', function(event) { if (event.key === 'Enter') { event.preventDefault(); // Evita o envio do formulário document.getElementById('filterButton').click(); // Aciona o botão de filtro } }); </script>
</body> </html>