mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-13 16:07:30 +00:00
Add distance column for spots
This commit is contained in:
+33
-4
@@ -115,6 +115,7 @@ function updateTable() {
|
||||
const showMode = $("#tableShowMode")[0].checked;
|
||||
const showComment = $("#tableShowComment")[0].checked;
|
||||
const showBearing = $("#tableShowBearing")[0].checked && userPos != null;
|
||||
const showDistance = $("#tableShowDistance")[0].checked && userPos != null;
|
||||
const showType = $("#tableShowType")[0].checked;
|
||||
const showRef = $("#tableShowRef")[0].checked;
|
||||
const showDE = $("#tableShowDE")[0].checked;
|
||||
@@ -141,6 +142,9 @@ function updateTable() {
|
||||
if (showBearing) {
|
||||
table.find('thead tr').append(`<th class='bg-primary-subtle hideonmobile'>Bearing</th>`);
|
||||
}
|
||||
if (showDistance) {
|
||||
table.find('thead tr').append(`<th class='bg-primary-subtle hideonmobile'>Distance</th>`);
|
||||
}
|
||||
if (showType) {
|
||||
table.find('thead tr').append(`<th class='bg-primary-subtle hideonmobile'>Type</th>`);
|
||||
}
|
||||
@@ -191,6 +195,7 @@ function createNewTableRowsForSpot(s, highlightNew) {
|
||||
const showMode = $("#tableShowMode")[0].checked;
|
||||
const showComment = $("#tableShowComment")[0].checked;
|
||||
const showBearing = $("#tableShowBearing")[0].checked && userPos != null;
|
||||
const showDistance = $("#tableShowDistance")[0].checked && userPos != null;
|
||||
const showType = $("#tableShowType")[0].checked;
|
||||
const showRef = $("#tableShowRef")[0].checked;
|
||||
const showDE = $("#tableShowDE")[0].checked;
|
||||
@@ -280,13 +285,27 @@ function createNewTableRowsForSpot(s, highlightNew) {
|
||||
bearingText = bearing.toFixed(0).padStart(3, '0') + "°";
|
||||
if (s["dx_location_good"] == null || s["dx_location_good"] === false) {
|
||||
if (s["dx_location_source"] === "HOME QTH") {
|
||||
bearingText = bearingText + "<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service. We had to fall back to a QRZ \"home\" location for a portable/mobile/alternative spot, so this bearing may not be accurate if the DX is close to you..'></i></span>";
|
||||
bearingText = bearingText + "<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service. We had to fall back to a QRZ \"home\" location for a portable/mobile/alternative spot, so this bearing may not be accurate if the DX is close to you.'></i></span>";
|
||||
} else {
|
||||
bearingText = bearingText + "<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service. We had to fall back to just using the centre of a DXCC entity, so this bearing may not be accurate if the DX is close to you.'></i></span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Format distance text
|
||||
let distanceText = "---<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service, and we could not determine one. A distance to this DX is not available.'></i></span>";
|
||||
if (userPos != null && s["dx_latitude"] != null && s["dx_longitude"] != null) {
|
||||
const distance = calcDistanceKm(userPos[0], userPos[1], s["dx_latitude"], s["dx_longitude"]);
|
||||
distanceText = distance.toFixed(0) + " km";
|
||||
if (s["dx_location_good"] == null || s["dx_location_good"] === false) {
|
||||
if (s["dx_location_source"] === "HOME QTH") {
|
||||
distanceText = distanceText + "<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service. We had to fall back to a QRZ \"home\" location for a portable/mobile/alternative spot, so this distance may not be accurate if the DX is close to you.'></i></span>";
|
||||
} else {
|
||||
distanceText = distanceText + "<span class='bearing-q hideonmobile'><i class='fa-solid fa-circle-question' title='The position was not reported via the spotting service. We had to fall back to just using the centre of a DXCC entity, so this distance may not be accurate if the DX is close to you.'></i></span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Format "type" (Sig or fallback to source)
|
||||
let typeText = s["source"];
|
||||
if (s["sig"]) {
|
||||
@@ -354,6 +373,9 @@ function createNewTableRowsForSpot(s, highlightNew) {
|
||||
if (showBearing) {
|
||||
$tr.append(`<td class='nowrap hideonmobile'>${bearingText}</td>`);
|
||||
}
|
||||
if (showDistance) {
|
||||
$tr.append(`<td class='nowrap hideonmobile'>${distanceText}</td>`);
|
||||
}
|
||||
if (showType) {
|
||||
$tr.append(`<td class='nowrap hideonmobile'><span class='icon-wrapper'><i class='fa-solid ${sigToIcon(s["sig"], "fa-tower-cell")}'></i></span> ${typeText}</td>`);
|
||||
}
|
||||
@@ -394,6 +416,9 @@ function createNewTableRowsForSpot(s, highlightNew) {
|
||||
if (showBearing) {
|
||||
$td2floatright.append(`${bearingText} `);
|
||||
}
|
||||
if (showDistance) {
|
||||
$td2floatright.append(`${distanceText} `);
|
||||
}
|
||||
if (showDE) {
|
||||
$td2floatright.append(` de ${de_call} `);
|
||||
}
|
||||
@@ -443,12 +468,14 @@ function loadOptions() {
|
||||
// Load settings from settings storage now all the controls are available
|
||||
loadSettings();
|
||||
|
||||
// Extra setting - the toggle for the "bearing" column is 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.
|
||||
// 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)
|
||||
@@ -470,8 +497,10 @@ function userGridUpdated() {
|
||||
}
|
||||
// Enable/disable bearing column depending on grid validity
|
||||
$("#tableShowBearing").prop('disabled', !userGridValid);
|
||||
$("#tableShowDistance").prop('disabled', !userGridValid);
|
||||
if (!userGridValid) {
|
||||
$("#tableShowBearing").prop('checked', false);
|
||||
$("#tableShowDistance").prop('checked', false);
|
||||
}
|
||||
// Save settings even if not a valid grid, this allows the user to clear their grid and have it save.
|
||||
saveSettings();
|
||||
|
||||
Reference in New Issue
Block a user