// How often to query the server? const REFRESH_INTERVAL_SEC = 60 * 10; // Storage for the alert data that the server gives us. let alerts = []; // Load alerts and populate the table. function loadAlerts() { $.getJSON('/api/v2/alerts' + buildQueryString(false), function (jsonData) { // Store last updated time lastUpdateTime = moment.utc(); updateRefreshDisplay(); // Store data alerts = jsonData; // Update table updateTable(); }); } // Build a query string for the API, based on the filters that the user has selected. function buildQueryString(includeCredentials) { let str = "?"; ["dx_continent", "source"].forEach(fn => { if (!allFilterOptionsSelected(fn)) { str = str + getQueryStringFor(fn) + "&"; } }); str = str + "limit=" + $("#alerts-to-fetch option:selected").val(); const maxDur = $("#max-duration option:selected").val(); if (maxDur !== "9999999999") { str = str + "&max_duration=" + maxDur; } if ($("#dxpeditions_skip_max_duration_check")[0].checked) { str = str + "&dxpeditions_skip_max_duration_check=true"; } if (includeCredentials) { str = str + getCredentialQueryString(); } return str; } // Update the alerts table function updateTable() { // Use local time instead of UTC? const useLocalTime = $("#timeZone")[0].value === "local"; // Table data toggles const showStartTime = $("#tableShowStartTime")[0].checked; const showEndTime = $("#tableShowEndTime")[0].checked; const showDX = $("#tableShowDX")[0].checked; const showFreqsModes = $("#tableShowFreqsModes")[0].checked; const showComment = $("#tableShowComment")[0].checked; const showSource = $("#tableShowSource")[0].checked; const showRef = $("#tableShowRef")[0].checked; // Populate table with headers let table = $("#table"); table.find('thead tr').empty(); if (showStartTime) { table.find('thead tr').append(`