Skip to content

Commit

Permalink
Small improvements to filter description text
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeryfertitta committed Dec 18, 2023
1 parent 35959b6 commit cdc2f52
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ function sortClimbs(climbList, climbStats) {
});
}

function getFilters() {
return {
angle: document.getElementById("select-angle"),
board: document.getElementById("select-board"),
holds: getFilteredHoldCircles(),
maxGrade: document.getElementById("select-max-grade"),
minGrade: document.getElementById("select-min-grade"),
minAscents: document.getElementById("input-min-ascents"),
minRating: document.getElementById("input-min-rating"),
sortBy: document.getElementById("select-sort-by"),
sortOrder: document.getElementById("select-sort-order"),
};
}

function drawResultsPage(
pageNumber,
resultsPerPage,
Expand Down Expand Up @@ -432,19 +446,24 @@ document
matchResults.appendChild(matchCountElement);

let filterListElement = document.createElement("p");
let filters = getFilters();
filterListElement.textContent = `Showing problems with ${
getFilteredHoldCircles().length
} selected holds, at ${
angleFilter == "Any" ? "any angle" : angleFilter + "\xB0"
}, between ${
grades[document.getElementById("select-min-grade").value]
filters.holds.length
} selected hold(s), at ${filters.angle.options[
filters.angle.selectedIndex
].text.toLowerCase()} degrees, between ${
filters.minGrade.options[filters.minGrade.selectedIndex].text
} and ${
grades[document.getElementById("select-max-grade").value]
filters.maxGrade.options[filters.maxGrade.selectedIndex].text
}, with at least ${
document.getElementById("input-min-ascents").value
}+ ascents and ${
document.getElementById("input-min-rating").value
}+ stars.`;
filters.minAscents.value
} ascents and an average rating of ${
filters.minRating.value
} star(s) or more, sorted by ${filters.sortBy.options[
filters.sortBy.selectedIndex
].text.toLowerCase()}, ${filters.sortOrder.options[
filters.sortOrder.selectedIndex
].text.toLowerCase()}.`;
matchResults.appendChild(filterListElement);

sortClimbs(filteredClimbs, climbStats);
Expand Down

0 comments on commit cdc2f52

Please sign in to comment.