// Load spots and populate the table. function loadSpots() { $.getJSON('/api/v1/spots' + buildQueryString(), function(jsonData) { // Store last updated time lastUpdateTime = moment.utc(); updateRefreshDisplay(); // Store data spots = jsonData; // Update table updateTable(); }); } // Build a query string for the API, based on the filters that the user has selected. function buildQueryString() { var str = "?"; ["dx_continent", "de_continent", "mode_type", "source", "band"].forEach(fn => { if (!allFilterOptionsSelected(fn)) { str = str + getQueryStringFor(fn) + "&"; } }); str = str + "limit=" + $("#spots-to-fetch option:selected").val(); if ($("#filter-dx-call").val() != "") { str = str + "&dx_call_includes=" + encodeURIComponent($("#filter-dx-call").val()); } return str; } // Update the spots table function updateTable() { // Use local time instead of UTC? var useLocalTime = $("#timeZone")[0].value == "local"; // Get user grid if valid, this will be null if it's not. var userPos = latLonForGridCentre($("#userGrid").val()); // Table data toggles var showTime = $("#tableShowTime")[0].checked; var showDX = $("#tableShowDX")[0].checked; var showFreq = $("#tableShowFreq")[0].checked; var showMode = $("#tableShowMode")[0].checked; var showComment = $("#tableShowComment")[0].checked; var showBearing = $("#tableShowBearing")[0].checked && userPos != null; var showType = $("#tableShowType")[0].checked; var showRef = $("#tableShowRef")[0].checked; var showDE = $("#tableShowDE")[0].checked; // Populate table with headers let table = $('
| ${useLocalTime ? "Local" : "UTC"} | `); } if (showDX) { table.find('thead tr').append(`DX | `); } if (showFreq) { table.find('thead tr').append(`Frequency | `); } if (showMode) { table.find('thead tr').append(`Mode | `); } if (showComment) { table.find('thead tr').append(`Comment | `); } if (showBearing) { table.find('thead tr').append(`Bearing | `); } if (showType) { table.find('thead tr').append(`Type | `); } if (showRef) { table.find('thead tr').append(`Ref. | `); } if (showDE) { table.find('thead tr').append(`DE | `); } if (spots.length == 0) { table.find('tbody').append('|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| No spots match your filters. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ${time_formatted} | `); } if (showDX) { $tr.append(`${dx_call} | `); } if (showFreq) { $tr.append(`${freq_string} | `); } if (showMode) { $tr.append(`${mode_string} | `); } if (showComment) { $tr.append(`${commentText} | `); } if (showBearing) { $tr.append(``); } if (showType) { $tr.append(``); } if (showRef) { $tr.append(`${sig_refs} | `); } if (showDE) { $tr.append(``); } table.find('tbody').append($tr); // Second row for mobile view only, containing type, ref & comment $tr2 = $("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ");
if (showType) {
$td2.append(` ${typeText} `);
}
if (showRef) {
$td2.append(`${sig_refs} `);
}
if (showBearing) {
$td2.append(` Bearing: ${bearingText} `);
}
if (showComment) {
$td2.append(` ${commentText}`); } $tr2.append($td2); table.find('tbody').append($tr2); count++; }); // Update DOM $('#table-container').html(table); } // 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/v1/options', function(jsonData) { // Store options options = jsonData; // Add CSS for band toggle buttons addBandToggleColourCSS(options["bands"]); // Populate the filters panel generateBandsMultiToggleFilterCard(options["bands"]); generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]); generateMultiToggleFilterCard("#mode-options", "mode_type", options["mode_types"]); generateMultiToggleFilterCard("#source-options", "source", options["spot_sources"]); // Populate the Display panel options["web-ui-options"]["spot-count"].forEach(sc => $("#spots-to-fetch").append($(' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||