7 752
edições
Etiqueta: Desfazer |
Sem resumo de edição |
||
Linha 170: | Linha 170: | ||
<body> | <body> | ||
<div class="borda-container"> | <div class="borda-container"> | ||
<div class="input-group"> | <div class="input-group"> | ||
<label for="difficulty"><b>Dificuldade:</b></label> | <label for="difficulty"><b>Dificuldade:</b></label> | ||
Linha 259: | Linha 251: | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
const difficultySelect = document.getElementById("difficulty"); | const difficultySelect = document.getElementById("difficulty"); | ||
const tagButtonsContainer = document.getElementById("tagButtons"); | const tagButtonsContainer = document.getElementById("tagButtons"); | ||
Linha 351: | Linha 342: | ||
searchInput.addEventListener("input", () => { | searchInput.addEventListener("input", () => { | ||
filterHunts(); | filterHunts(); | ||
}); | }); | ||
function filterHunts() { | function filterHunts() { | ||
const selectedDifficulty = difficultySelect.value; | const selectedDifficulty = difficultySelect.value; | ||
const searchTerm = searchInput.value.toLowerCase(); | const searchTerm = searchInput.value.toLowerCase(); | ||
imageContainer.innerHTML = ""; | imageContainer.innerHTML = ""; | ||
const huntList = hunts["NW"]; // Assume que a database é sempre "NW" | |||
const huntList = hunts[ | |||
huntList.forEach(hunt => { | huntList.forEach(hunt => { | ||
const hasAllClasses = hunt.classes.includes("Todos"); | const hasAllClasses = hunt.classes.includes("Todos"); | ||
Linha 419: | Linha 391: | ||
} | } | ||
difficultySelect.addEventListener("change", filterHunts); | difficultySelect.addEventListener("change", filterHunts); | ||
// Preenche as dificuldades disponíveis | |||
const difficulties = new Set(hunts["NW"].map(hunt => hunt.difficulty)); | |||
difficulties.forEach(difficulty => { | |||
const option = document.createElement("option"); | |||
option.value = difficulty; | |||
option.textContent = difficulty; | |||
difficultySelect.appendChild(option); | |||
}); | |||
filterHunts(); // Filtra as hunts ao carregar a página | |||
}); | }); | ||
</script> | </script> |