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 |
||
Linha 37: | Linha 37: | ||
<div id="specificOptions" class="hidden"> | <div id="specificOptions" class="hidden"> | ||
<label for="specificOption"> | <label for="specificOption">Local do X:</label> | ||
<select id="specificOption"> | <select id="specificOption"> | ||
<option value="">Selecione uma opção</option> | <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> | </select> | ||
</div> | </div> | ||
Linha 50: | Linha 57: | ||
<script> | <script> | ||
const specificOptions = { | const specificOptions = { | ||
1: | 1: { | ||
'Areia': { local: 'Pewter', coordinates: '3467, 3743, 6' }, | |||
{ | 'Gelo': { local: 'Cerulean', coordinates: '1456, 2345, 4' }, | ||
{ | 'Grama': { local: 'Vermilion', coordinates: '5678, 1234, 5' }, | ||
'Pedra': { local: 'Lavender', coordinates: '6789, 2345, 2' }, | |||
2: | 'Subaquático': { local: 'Celadon', coordinates: '1234, 5678, 3' }, | ||
{ | 'Terra': { local: 'Fuchsia', coordinates: '4567, 6789, 1' }, | ||
{ | 'Pisos': { local: 'Cinnabar', coordinates: '7890, 1234, 6' } | ||
{ | }, | ||
{ | 2: { | ||
'Areia': { local: 'Saffron', coordinates: '3456, 7890, 7' }, | |||
'Gelo': { local: 'Pallet', coordinates: '5678, 1234, 2' }, | |||
{ | 'Grama': { local: 'Pewter', coordinates: '6789, 3456, 4' }, | ||
{ | 'Pedra': { local: 'Cerulean', coordinates: '2345, 6789, 5' }, | ||
'Subaquático': { local: 'Vermilion', coordinates: '1234, 4567, 3' }, | |||
'Terra': { local: 'Lavender', coordinates: '3456, 7890, 6' }, | |||
'Pisos': { local: 'Celadon', coordinates: '5678, 1234, 2' } | |||
}, | |||
3: { | |||
'Areia': { local: 'Fuchsia', coordinates: '6789, 3456, 4' }, | |||
'Gelo': { local: 'Cinnabar', coordinates: '7890, 1234, 1' }, | |||
'Grama': { local: 'Saffron', coordinates: '4567, 6789, 5' }, | |||
'Pedra': { local: 'Pallet', coordinates: '1234, 5678, 3' }, | |||
'Subaquático': { local: 'Pewter', coordinates: '6789, 2345, 6' }, | |||
'Terra': { local: 'Cerulean', coordinates: '3456, 7890, 2' }, | |||
'Pisos': { local: 'Vermilion', coordinates: '5678, 1234, 4' } | |||
} | |||
}; | }; | ||
const images = { | const images = { | ||
' | 'Areia': 'https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png', | ||
' | 'Gelo': 'https://wiki.pokexgames.com/images/4/43/AnotherImage.png', | ||
' | 'Grama': 'https://wiki.pokexgames.com/images/3/34/DifferentImage.png', | ||
' | 'Pedra': 'https://wiki.pokexgames.com/images/c/c4/ExampleImage.png', | ||
' | 'Subaquático': 'https://wiki.pokexgames.com/images/5/56/AnotherExample.png', | ||
' | 'Terra': 'https://wiki.pokexgames.com/images/a/a6/SampleImage.png', | ||
' | 'Pisos': 'https://wiki.pokexgames.com/images/d/d7/FinalExample.png' | ||
}; | }; | ||
Linha 88: | Linha 105: | ||
if (selectedMapType) { | if (selectedMapType) { | ||
const options = specificOptions[selectedMapType]; | const options = Object.keys(specificOptions[selectedMapType]); | ||
options.forEach(option => { | options.forEach(option => { | ||
specificOptionSelect.innerHTML += `<option value="${option | specificOptionSelect.innerHTML += `<option value="${option}">${option}</option>`; | ||
}); | }); | ||
Linha 103: | Linha 120: | ||
const selectedOption = this.value; | const selectedOption = this.value; | ||
const imageContainer = document.getElementById('imageContainer'); | const imageContainer = document.getElementById('imageContainer'); | ||
const mapType = document.getElementById('mapType').value; | |||
imageContainer.innerHTML = ''; | imageContainer.innerHTML = ''; | ||
Linha 108: | Linha 126: | ||
if (selectedOption) { | if (selectedOption) { | ||
const imageUrl = images[selectedOption]; | const imageUrl = images[selectedOption]; | ||
const optionInfo = specificOptions[ | const optionInfo = specificOptions[mapType][selectedOption]; | ||
if (imageUrl && optionInfo) { | if (imageUrl && optionInfo) { | ||
imageContainer.innerHTML = ` | imageContainer.innerHTML = ` |
Edição das 03h29min de 23 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> .hidden { display: none; } .image-container img { width: 100px; height: 100px; margin: 5px; } select { margin: 5px; } .image-info { margin-top: 10px; } </style>
</head> <body>
Selecione o Tipo de Mapa
<form id="mapForm">
<label for="mapType">Tipo de Mapa:</label> <select id="mapType"> <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 for="specificOption">Local do X:</label> <select id="specificOption"> <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>
</form>
<script> const specificOptions = { 1: { 'Areia': { local: 'Pewter', coordinates: '3467, 3743, 6' }, 'Gelo': { local: 'Cerulean', coordinates: '1456, 2345, 4' }, 'Grama': { local: 'Vermilion', coordinates: '5678, 1234, 5' }, 'Pedra': { local: 'Lavender', coordinates: '6789, 2345, 2' }, 'Subaquático': { local: 'Celadon', coordinates: '1234, 5678, 3' }, 'Terra': { local: 'Fuchsia', coordinates: '4567, 6789, 1' }, 'Pisos': { local: 'Cinnabar', coordinates: '7890, 1234, 6' } }, 2: { 'Areia': { local: 'Saffron', coordinates: '3456, 7890, 7' }, 'Gelo': { local: 'Pallet', coordinates: '5678, 1234, 2' }, 'Grama': { local: 'Pewter', coordinates: '6789, 3456, 4' }, 'Pedra': { local: 'Cerulean', coordinates: '2345, 6789, 5' }, 'Subaquático': { local: 'Vermilion', coordinates: '1234, 4567, 3' }, 'Terra': { local: 'Lavender', coordinates: '3456, 7890, 6' }, 'Pisos': { local: 'Celadon', coordinates: '5678, 1234, 2' } }, 3: { 'Areia': { local: 'Fuchsia', coordinates: '6789, 3456, 4' }, 'Gelo': { local: 'Cinnabar', coordinates: '7890, 1234, 1' }, 'Grama': { local: 'Saffron', coordinates: '4567, 6789, 5' }, 'Pedra': { local: 'Pallet', coordinates: '1234, 5678, 3' }, 'Subaquático': { local: 'Pewter', coordinates: '6789, 2345, 6' }, 'Terra': { local: 'Cerulean', coordinates: '3456, 7890, 2' }, 'Pisos': { local: 'Vermilion', coordinates: '5678, 1234, 4' } } };
const images = { 'Areia': 'https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png', 'Gelo': 'https://wiki.pokexgames.com/images/4/43/AnotherImage.png', 'Grama': 'https://wiki.pokexgames.com/images/3/34/DifferentImage.png', 'Pedra': 'https://wiki.pokexgames.com/images/c/c4/ExampleImage.png', 'Subaquático': 'https://wiki.pokexgames.com/images/5/56/AnotherExample.png', 'Terra': 'https://wiki.pokexgames.com/images/a/a6/SampleImage.png', 'Pisos': 'https://wiki.pokexgames.com/images/d/d7/FinalExample.png' };
document.getElementById('mapType').addEventListener('change', function() { const selectedMapType = this.value; const specificOptionSelect = document.getElementById('specificOption'); const imageContainer = document.getElementById('imageContainer'); specificOptionSelect.innerHTML = '<option value="">Selecione uma opção</option>'; imageContainer.innerHTML = ; if (selectedMapType) { 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('imageContainer').classList.add('hidden'); } });
document.getElementById('specificOption').addEventListener('change', function() { const selectedOption = this.value; const imageContainer = document.getElementById('imageContainer'); const mapType = document.getElementById('mapType').value; imageContainer.innerHTML = ; if (selectedOption) { const imageUrl = images[selectedOption]; const optionInfo = specificOptions[mapType][selectedOption]; if (imageUrl && optionInfo) { imageContainer.innerHTML = ` <img src="${imageUrl}" alt="${selectedOption}">
Local: ${optionInfo.local}
Coordenada: ${optionInfo.coordinates}
`; imageContainer.classList.remove('hidden'); } } else { imageContainer.classList.add('hidden'); } }); </script>
</body> </html>