mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Add max_duration filter for alerts #17
This commit is contained in:
@@ -26,7 +26,10 @@ function buildQueryString() {
|
||||
}
|
||||
});
|
||||
str = str + "limit=" + $("#alerts-to-fetch option:selected").val();
|
||||
str = str + "&max_duration=604800";
|
||||
var maxDur = $("#max-duration option:selected").val();
|
||||
if (maxDur != "") {
|
||||
str = str + "&max_duration=" + maxDur;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -139,8 +142,12 @@ function loadOptions() {
|
||||
options = jsonData;
|
||||
|
||||
// Populate the filters panel
|
||||
$("#settings-container").append(generateFilterCard("DX Continent", "dx_continent", options["continents"]));
|
||||
$("#settings-container").append(generateFilterCard("Sources", "source", options["alert_sources"]));
|
||||
$("#settings-container").append(generateMultiToggleFilterCard("DX Continent", "dx_continent", options["continents"]));
|
||||
$("#settings-container").append(generateMultiToggleFilterCard("Sources", "source", options["alert_sources"]));
|
||||
|
||||
// Options doesn't give us anything for Max Duration as it's a free numeric input, but we generate our own
|
||||
// filter card for this.
|
||||
$("#settings-container").append(generateMaxDurationDropdownFilterCard(options["alert_sources"]));
|
||||
|
||||
// Load settings from settings storage
|
||||
loadSettings();
|
||||
@@ -151,6 +158,30 @@ function loadOptions() {
|
||||
});
|
||||
}
|
||||
|
||||
// Generate maximum duration drop-down filter card. This one is a special case.
|
||||
function generateMaxDurationDropdownFilterCard(band_options) {
|
||||
let $col = $("<div class='col'>")
|
||||
let $card = $("<div class='card'>");
|
||||
let $card_body = $("<div class='card-body'>");
|
||||
$card_body.append(`<h5 class='card-title'>Duration Limit</h5>`);
|
||||
$p = $("<p class='card-text filter-card-text'>");
|
||||
$p.append("Hide any alerts lasting more than:<br/>");
|
||||
$p.append(`<select id="max-duration" class="storeable-select form-select" onclick="filtersUpdated();" style="width: 8em; display: inline-block;">
|
||||
<option value="10800">3 hours</option>
|
||||
<option value="43200">12 hours</option>
|
||||
<option value="86400" selected>24 hours</option>
|
||||
<option value="604800">1 week</option>
|
||||
<option value="2419200">4 weeks</option>
|
||||
<option value="">No limit</option>
|
||||
</select>`);
|
||||
$p.append(" <i class='fa-solid fa-circle-question' title='Some users create long-duration alerts for the period they will be generally in and around xOTA references, not just the times they are specifically on the air. Use this control to restrict the maximum duration of spots that the software will display, and exclude any with a long duration.'></i>");
|
||||
// Compile HTML elements to return
|
||||
$card_body.append($p);
|
||||
$card.append($card_body);
|
||||
$col.append($card);
|
||||
return $col;
|
||||
}
|
||||
|
||||
// Method called when any filter is changed to reload the alerts and persist the filter settings.
|
||||
function filtersUpdated() {
|
||||
loadAlerts();
|
||||
@@ -165,9 +196,6 @@ function setUpEventListeners() {
|
||||
$("#settings-button").button("toggle");
|
||||
$("#settings-area").hide();
|
||||
});
|
||||
$("#alerts-to-fetch").click(function() {
|
||||
filtersUpdated();
|
||||
});
|
||||
}
|
||||
|
||||
// Startup
|
||||
|
||||
Reference in New Issue
Block a user