diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 4edcc16..d969a01 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -1,5 +1,6 @@ // SSE event source let evtSource; +let restartSSEOnErrorTimeoutId; // Table row count, to alternate shading let rowCount = 0; @@ -30,6 +31,9 @@ function loadSpots() { // Start an SSE connection (closing an existing one if it exists). This will then be used to add to the table on the // fly. function startSSEConnection() { + if (evtSource != null) { + evtSource.close(); + } evtSource = new EventSource('/api/v1/spots/stream' + buildQueryString()); evtSource.onmessage = function(event) { @@ -66,8 +70,11 @@ function startSSEConnection() { }; evtSource.onerror = function(err) { - evtSource.close(); - setTimeout(startSSEConnection, 1000); + if (evtSource != null) { + evtSource.close(); + } + clearTimeout(restartSSEOnErrorTimeoutId) + restartSSEOnErrorTimeoutId = setTimeout(startSSEConnection, 1000); }; } diff --git a/webassets/js/spotsbandsandmap.js b/webassets/js/spotsbandsandmap.js index 5a8e1cd..4445592 100644 --- a/webassets/js/spotsbandsandmap.js +++ b/webassets/js/spotsbandsandmap.js @@ -23,8 +23,18 @@ function generateBandsMultiToggleFilterCard(band_options) { var cssFormattedBandName = o['name'] ? o['name'].replace('.', 'p') : "unknown"; $("#band-options").append(` `); }); - // Create All/None buttons - $("#band-options").append(`  `); + // Create All/None/Ham HF buttons + $("#band-options").append(` `); +} + +// Set the band toggles so that only the amateur radio HF bands are selected. This includes 160m and 6m because that's +// widely expected by hams to be included. Special case of toggleFilterButtons(). +function setHamHFBandToggles() { + const hamHFBands = ["160m", "80m", "60m", "40m", "30m", "20m", "17m", "15m", "12m", "10m", "6m"]; + $(".filter-button-band").each(function() { + $(this).prop('checked', hamHFBands.includes($(this).attr('id').replace("filter-button-band-", ""))); + }); + filtersUpdated(); } // Generate SIGs filter card. This one is also a special case.