// How often to query the server? const REFRESH_INTERVAL_SEC = 60 * 10; // Storage for the alert data that the server gives us. var alerts = [] // Load alerts and populate the table. function loadAlerts() { $.getJSON('/api/v1/alerts' + buildQueryString(), 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() { var str = "?"; ["dx_continent", "source"].forEach(fn => { if (!allFilterOptionsSelected(fn)) { str = str + getQueryStringFor(fn) + "&"; } }); str = str + "limit=" + $("#alerts-to-fetch option:selected").val(); var 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"; } return str; } // Update the alerts table function updateTable() { // Use local time instead of UTC? var useLocalTime = $("#timeZone")[0].value == "local"; // Table data toggles var showStartTime = $("#tableShowStartTime")[0].checked; var showEndTime = $("#tableShowEndTime")[0].checked; var showDX = $("#tableShowDX")[0].checked; var showFreqsModes = $("#tableShowFreqsModes")[0].checked; var showComment = $("#tableShowComment")[0].checked; var showSource = $("#tableShowSource")[0].checked; var showRef = $("#tableShowRef")[0].checked; // Populate table with headers let table = $("#table"); table.find('thead tr').empty(); if (showStartTime) { table.find('thead tr').append(`