`);
- buildBody($body);
- $li.append($body);
- $list.append($li);
-}
-
-// Build the grid of activity checkboxes for a given (already filtered) list of activities.
-function buildActivityFilterGrid(activity_options) {
- const $grid = $('
');
- activity_options.forEach(o => {
- const domSafeName = o["name"].replace(/^[^A-Za-z0-9]+|[^\w]+/gi, "");
- $grid.append(`
`);
- });
- return $grid;
-}
-
-// Generate activities filter card. This one is also a special case. includeGeneralDX controls whether the "General
-// DX" (NO_ACTIVITY) option is offered - this doesn't apply on the alerts page, where every alert has an activity.
-function generateActivitiesMultiToggleFilterCard(activity_options, includeGeneralDX = true) {
- const $list = $('
');
-
- const traditional = activity_options.filter(o => o["activity_type"] === "TRADITIONAL");
- appendActivityFilterSection($list, 'traditional', 'Traditional', true, includeGeneralDX || traditional.length > 0, $body => {
- if (includeGeneralDX) {
- $body.append(``);
- }
- $body.append(buildActivityFilterGrid(traditional));
- });
-
- const adventure = activity_options.filter(o => o["activity_type"] === "ADVENTURE");
- appendActivityFilterSection($list, 'adventure', 'Adventure', true, adventure.length > 0, $body => {
- $body.append(buildActivityFilterGrid(adventure));
- });
-
- const regional = activity_options.filter(o => o["activity_type"] === "REGIONAL");
- appendActivityFilterSection($list, 'regional', 'Regional', false, regional.length > 0, $body => {
- $body.append(buildActivityFilterGrid(regional));
- });
-
- const event = activity_options.filter(o => o["activity_type"] === "EVENT");
- appendActivityFilterSection($list, 'event', 'Event', false, event.length > 0, $body => {
- $body.append(buildActivityFilterGrid(event));
- });
-
- $("#activity-options").append($list);
- $("#activity-options").append(``);
-}
-
// Method called when "All" or "None" is clicked
function toggleFilterButtons(filterQuery, state) {
$(".filter-button-" + filterQuery).each(function () {
@@ -238,8 +167,7 @@ function setColorScheme(mode) {
// Startup function to determine whether to use light or dark mode, or leave as auto
function usePreferredTheme() {
// Work out if we have ever explicitly saved the value of our select box. If so, we set our colour scheme now based
- // on that. If not, we let the select stay with nothing selected, so that the server sets it to whatever the
- // server's default is when the options call is retrieved.
+ // on that. If not, we leave the colour scheme at the server's default, which is set in the page template.
let val = localStorage.getItem("#color_scheme:value");
if (val != null) {
setColorScheme(JSON.parse(val));
diff --git a/static/js/map.js b/static/js/map.js
index fb3857e..d7be8cb 100644
--- a/static/js/map.js
+++ b/static/js/map.js
@@ -322,61 +322,6 @@ function getTooltipText(s) {
return ttt;
}
-// Load server options. Once a successful callback is made from this, we then query spots and set up the timer to query
-// spots repeatedly.
-function loadOptions() {
- $.getJSON('/api/v3/options', function (jsonData) {
- // Store options
- options = jsonData;
-
- // First pass loading settings, so we can load the band colour scheme before the filters that need to use it
- loadSettings();
- setColorScheme($("#color_scheme option:selected").val());
- setBandColorScheme($("#band_color_scheme option:selected").val());
-
- // Add CSS for band toggle buttons
- addBandToggleColourCSS(options["bands"]);
-
- // Populate the filters panel
- generateBandsMultiToggleFilterCard(options["bands"]);
- generateActivitiesMultiToggleFilterCard(options["activities"]);
- generateMultiToggleFilterCard("#dx_continent_options", "dx_continent", options["continents"]);
- generateMultiToggleFilterCard("#de_continent_options", "de_continent", options["continents"]);
- generateModesMultiToggleFilterCard(options["modes"]);
- generateSourcesMultiToggleFilterCard(options["spot_providers"], options["spot_providers_enabled_by_default"]);
-
- // Load URL params. These may select things from the various filter & display options, so the function needs
- // to be called after these are set up, but if the URL params ask for "embedded mode", this will suppress
- // loading settings, so this needs to be called before that.
- loadURLParams();
- loadMapURLParams();
-
- // Load settings from settings storage now all the controls are available
- loadSettings();
-
- // If no basemap has been explicitly saved and the UI is in dark mode, default to dark Mapnik
- if (localStorage.getItem("#basemap:value") === null) {
- if (document.documentElement.getAttribute("data-bs-theme") === "dark") {
- $("#basemap").val("OpenStreetMap.Mapnik.Dark");
- }
- }
-
- // Apply basemap and overlay settings now that controls have their saved values
- setBasemap($("#basemap").val());
- setBasemapOpacity(parseFloat($("#basemapOpacity").val()));
- enableTerminator($("#showTerminator")[0].checked);
- enableMaidenheadGrid($("#showMaidenheadGrid")[0].checked);
- enableCQZones($("#showCQZones")[0].checked);
- enableITUZones($("#showITUZones")[0].checked);
- enableWABWAIGrid($("#showWABWAIGrid")[0].checked);
-
- // Load spots and start SSE for live updates
- loadSpots();
- // Set up spot expiry checker
- setInterval(expireOldSpots, 60 * 1000);
- });
-}
-
// Method called when any display property is changed to reload the map and persist the display settings.
function displayUpdated() {
updateMap();
@@ -639,8 +584,36 @@ $(document).ready(function () {
$(".hideonmap").hide();
// Set up map
setUpMap();
- // Call loadOptions(), this will then trigger loading spots and setting up timers.
- loadOptions();
+ // Load URL params. If these ask for "embedded mode", this will suppress loading settings, so this needs to be
+ // called first.
+ loadURLParams();
+ loadMapURLParams();
+ loadSettings();
+ setColorScheme($("#color_scheme option:selected").val());
+ setBandColorScheme($("#band_color_scheme option:selected").val());
+ addBandToggleColourCSS();
+
+ // If no basemap has been explicitly saved and the UI is in dark mode, default to dark Mapnik
+ if (localStorage.getItem("#basemap:value") === null) {
+ if (document.documentElement.getAttribute("data-bs-theme") === "dark") {
+ $("#basemap").val("OpenStreetMap.Mapnik.Dark");
+ }
+ }
+
+ // Apply basemap and overlay settings now that controls have their saved values
+ setBasemap($("#basemap").val());
+ setBasemapOpacity(parseFloat($("#basemapOpacity").val()));
+ enableTerminator($("#showTerminator")[0].checked);
+ enableMaidenheadGrid($("#showMaidenheadGrid")[0].checked);
+ enableCQZones($("#showCQZones")[0].checked);
+ enableITUZones($("#showITUZones")[0].checked);
+ enableWABWAIGrid($("#showWABWAIGrid")[0].checked);
+
+ // Load spots and start SSE for live updates
+ loadSpots();
+ // Set up spot expiry checker
+ setInterval(expireOldSpots, 60 * 1000);
+
// Display intro box
displayIntroBox();
// Prevent mouse scroll and touch actions in the popup menus being passed through to the map
diff --git a/static/js/spots.js b/static/js/spots.js
index 1f4c1ca..2058c23 100644
--- a/static/js/spots.js
+++ b/static/js/spots.js
@@ -461,52 +461,6 @@ function createNewTableRowsForSpot(s, highlightNew) {
return [$tr, $tr2];
}
-// Load server options. Once a successful callback is made from this, we then query spots and set up the timer to query
-// spots repeatedly.
-function loadOptions() {
- $.getJSON('/api/v3/options', function (jsonData) {
- // Store options
- options = jsonData;
-
- // First pass loading settings, so we can load the band colour scheme before the filters that need to use it
- loadSettings();
- setColorScheme($("#color_scheme option:selected").val());
- setBandColorScheme($("#band_color_scheme option:selected").val());
-
- // Add CSS for band toggle buttons
- addBandToggleColourCSS(options["bands"]);
-
- // Populate the filters panel
- generateBandsMultiToggleFilterCard(options["bands"]);
- generateActivitiesMultiToggleFilterCard(options["activities"]);
- generateMultiToggleFilterCard("#dx_continent_options", "dx_continent", options["continents"]);
- generateMultiToggleFilterCard("#de_continent_options", "de_continent", options["continents"]);
- generateModesMultiToggleFilterCard(options["modes"]);
- generateSourcesMultiToggleFilterCard(options["spot_providers"], options["spot_providers_enabled_by_default"]);
-
- // Load URL params. These may select things from the various filter & display options, so the function needs
- // to be called after these are set up, but if the URL params ask for "embedded mode", this will suppress
- // loading settings, so this needs to be called before that.
- loadURLParams();
-
- // Load settings from settings storage now all the controls are available
- loadSettings();
-
- // Extra setting - the toggle for the "bearing" & "distance" columns are disabled if the user has not entered a
- // valid grid, and normally this logic is handled on user input to the grid field, but we might have just loaded
- // a value direct into the field, so apply the same logic here.
- $("#tableShowBearing").prop('disabled', !isUserGridValid());
- $("#tableShowDistance").prop('disabled', !isUserGridValid());
- if (!isUserGridValid()) {
- $("#tableShowBearing").prop('checked', false);
- $("#tableShowDistance").prop('checked', false);
- }
-
- // Load spots (this will also set up the SSE connection to update them too)
- loadSpots();
- });
-}
-
// Work out if the user's entered grid is a valid Maidenhead grid
function isUserGridValid() {
const userGrid = $("#userGrid").val().toUpperCase();
@@ -572,8 +526,27 @@ function clearWorked() {
// Startup
$(document).ready(function () {
- // Call loadOptions(), this will then trigger loading spots and setting up timers.
- loadOptions();
+ // Load URL params. If these ask for "embedded mode", this will suppress loading settings, so this needs to be
+ // called first.
+ loadURLParams();
+ loadSettings();
+ setColorScheme($("#color_scheme option:selected").val());
+ setBandColorScheme($("#band_color_scheme option:selected").val());
+ addBandToggleColourCSS();
+
+ // Extra setting - the toggle for the "bearing" & "distance" columns are disabled if the user has not entered a
+ // valid grid, and normally this logic is handled on user input to the grid field, but we might have just loaded
+ // a value direct into the field, so apply the same logic here.
+ $("#tableShowBearing").prop('disabled', !isUserGridValid());
+ $("#tableShowDistance").prop('disabled', !isUserGridValid());
+ if (!isUserGridValid()) {
+ $("#tableShowBearing").prop('checked', false);
+ $("#tableShowDistance").prop('checked', false);
+ }
+
+ // Load spots (this will also set up the SSE connection to update them too)
+ loadSpots();
+
// Display intro box
displayIntroBox();
diff --git a/static/js/spotsbandsandmap.js b/static/js/spotsbandsandmap.js
index 8845a88..e09984d 100644
--- a/static/js/spotsbandsandmap.js
+++ b/static/js/spotsbandsandmap.js
@@ -7,80 +7,38 @@ let spots = [];
let worked = []
// Dynamically add CSS code for the band checkboxes to show in the appropriate colour.
-// Some band names contain decimal points which are not allowed in CSS classes, so we text-replace them to "p".
-function addBandToggleColourCSS(band_options) {
+function addBandToggleColourCSS() {
const $style = $('