mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 16:59:25 +00:00
Don't supply query parameters to the API unless they are required
This commit is contained in:
@@ -24,8 +24,12 @@ function loadSpots() {
|
||||
// Build a query string for the API, based on the filters that the user has selected.
|
||||
function buildQueryString() {
|
||||
var str = "?";
|
||||
var filterNames = ["dx_continent", "de_continent", "mode_type", "source", "band"];
|
||||
str = str + filterNames.map(n => { return getQueryStringFor(n); }).join("&");
|
||||
["dx_continent", "de_continent", "mode_type", "source", "band"].forEach(fn => {
|
||||
if (!allFilterOptionsSelected(fn)) {
|
||||
str = str + getQueryStringFor(fn) + "&";
|
||||
}
|
||||
});
|
||||
str = str + "limit=50";
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -43,6 +47,15 @@ function getSelectedFilterOptions(parameter) {
|
||||
}).get().join(",");
|
||||
}
|
||||
|
||||
// For a parameter, such as dx_continent, return true if all possible options are enabled. (In this case, we don't need
|
||||
// to bother sending this as one of the query parameters to the API; no parameter provided implies "send everything".)
|
||||
function allFilterOptionsSelected(parameter) {
|
||||
var filter = $(".filter-button-" + parameter).filter(function() {
|
||||
return !this.checked;
|
||||
}).get();
|
||||
return filter.length == 0;
|
||||
}
|
||||
|
||||
// Update the spots table
|
||||
function updateTable() {
|
||||
// Populate table with headers
|
||||
|
||||
Reference in New Issue
Block a user