mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Continue work on bands display. #48
This commit is contained in:
@@ -30,22 +30,20 @@ function updateBands() {
|
||||
// Stop here if nothing to display
|
||||
var bandsPanel = $("#bands-container");
|
||||
if (spots.length === 0) {
|
||||
// todo bootstrapify
|
||||
bandsPanel.html("<p id='bandPanelNoSpots'>There are no spots matching your filters.</p>");
|
||||
bandsPanel.html("<div class='alert alert-danger' role='alert'>No spots match your filters.</div>");
|
||||
return;
|
||||
}
|
||||
|
||||
// Do some harsher de-duping. Because we only display callsign, frequency and mode here, the previous
|
||||
// de-duplication could have let some through that don't look like dupes on the map, but would do here.
|
||||
// Typically that's a person activating two programs at the same time, e.g. POTA & WWFF.
|
||||
// todo fix from here
|
||||
spotList = removeDuplicatesForBandPanel(spotList);
|
||||
spotList = removeDuplicatesForBandPanel(spots);
|
||||
|
||||
// Convert to a map of band names to the spots on that band. Bands with no
|
||||
// spots in view will not be present.
|
||||
const bandToSpots = new Map();
|
||||
options["bands"].forEach(function (band) {
|
||||
const matchingSpots = spots.filter(function (s) {
|
||||
const matchingSpots = spotList.filter(function (s) {
|
||||
return s.band === band.name;
|
||||
});
|
||||
if (matchingSpots.length > 0) {
|
||||
@@ -60,7 +58,7 @@ function updateBands() {
|
||||
bandToSpots.forEach(function (spotList, bandName) {
|
||||
// Get the colours for the band from the first spot, and prepare the header
|
||||
html += "<div class='bandCol' style='width:" + columnWidthPercent + "%'>";
|
||||
html += "<div class='bandColHeader' style='background-color:" + spotList[0].color + "; color:" + spotList[0].contrast_color + "'>" + spotList[0].band + "</div>";
|
||||
html += "<div class='bandColHeader' style='background-color:" + spotList[0].band_color + "; color:" + spotList[0].band_contrast_color + "'>" + spotList[0].band + "</div>";
|
||||
html += "<div class='bandColMiddle'>";
|
||||
|
||||
// Get the band data to fetch start and end frequencies
|
||||
@@ -68,7 +66,7 @@ function updateBands() {
|
||||
return b.name === bandName;
|
||||
})[0];
|
||||
// Start printing the band
|
||||
const freqStep = (band.stopFreq - band.startFreq) / 40.0;
|
||||
const freqStep = (band.end_freq - band.start_freq) / 40.0;
|
||||
html += "<ul>";
|
||||
html += "<li><span>-</span></li>";
|
||||
|
||||
@@ -76,12 +74,12 @@ function updateBands() {
|
||||
for (let i = 0; i <= 40; i++) {
|
||||
|
||||
// Work out if there are any spots in this step
|
||||
const freqStepStart = band.startFreq + i * freqStep;
|
||||
const freqStepStart = band.start_freq + i * freqStep;
|
||||
const freqStepEnd = freqStepStart + freqStep;
|
||||
const spotsInStep = spotList.filter(function (s) {
|
||||
// Normally we do >= start and < end, but in the special case where this is the last step and there is a spot
|
||||
// right at the end of the band, we include this too
|
||||
return s.freq >= freqStepStart && (s.freq < freqStepEnd || (s.freq === freqStepEnd && freqStepEnd === band.stopFreq));
|
||||
return s.freq >= freqStepStart && (s.freq < freqStepEnd || (s.freq === freqStepEnd && freqStepEnd === band.end_freq));
|
||||
});
|
||||
|
||||
if (spotsInStep.length > 0) {
|
||||
@@ -89,15 +87,7 @@ function updateBands() {
|
||||
html += "<li class='withSpots'><span>";
|
||||
spotsInStep.sort((a, b) => (a.freq > b.freq) ? 1 : ((b.freq > a.freq) ? -1 : 0));
|
||||
spotsInStep.forEach(function (s) {
|
||||
// Figure out the class to use for the spot's div, which defines its colour.
|
||||
let spotDivClass = "bandColSpotCurrent";
|
||||
if (currentPopupSpotUID === s.uid) {
|
||||
spotDivClass = "bandColSpotSelected";
|
||||
} else if (preQSYStatusShouldShowGrey(s.preqsy)) {
|
||||
spotDivClass = "bandColSpotOld";
|
||||
}
|
||||
|
||||
html += "<div class='bandColSpot " + spotDivClass + "' onClick='handleBandPanelSpotClick(\"" + s.uid + "\")'><span class='bandColSpot'>" + s.activator + "<br/><span class='bandColSpotFreq'>" + getFormattedFrequency(s.freq) + "</span>";
|
||||
html += "<div class='bandColSpot'><span class='bandColSpot'>" + s.dx_call + "<br/><span class='bandColSpotFreq'>" + (s.freq/1000000) + "</span>";
|
||||
if (s.mode != null && s.mode.length > 0 && s.mode !== "Unknown") {
|
||||
html += "<span class='bandColSpotMode'>" + s.mode + "</span>";
|
||||
}
|
||||
@@ -108,7 +98,7 @@ function updateBands() {
|
||||
} else {
|
||||
// Step had no spots in it, so just print a marker. This is a frequency on multiples of 4, or a dash otherwise.
|
||||
if (i % 4 === 0) {
|
||||
html += "<li><span>—" + (band.startFreq + i * freqStep).toFixed(3) + "</span></li>";
|
||||
html += "<li><span>—" + ((band.start_freq + i * freqStep)/1000000).toFixed(3) + "</span></li>";
|
||||
} else if (i % 4 === 2) {
|
||||
html += "<li><span>–</span></li>";
|
||||
} else {
|
||||
@@ -128,7 +118,31 @@ function updateBands() {
|
||||
// Desktop mouse wheel to scroll bands horizontally if used on the headers
|
||||
// noinspection JSDeprecatedSymbols
|
||||
$(".bandColHeader").on("wheel", () => bandsPanel.scrollLeft(bandsPanel.scrollLeft() + event.deltaY / 10.0));
|
||||
}
|
||||
|
||||
// Iterate through a temporary list of spots, merging duplicates in a way suitable for the band panel. If two or more
|
||||
// spots with the activator, mode and frequency are found, these will be merged and reduced until only one remains,
|
||||
// with the best data. Note that unlike removeDuplicates(), which operates on the main spot map, this operates only
|
||||
// on the temporary array of spots provided as an argument, and returns the output, for use when constructing the
|
||||
// band panel.
|
||||
function removeDuplicatesForBandPanel(spotList) {
|
||||
const spotsToRemove = [];
|
||||
spotList.forEach(function (check) {
|
||||
spotList.forEach(function (s) {
|
||||
if (s !== check) {
|
||||
if (s.dx_call === check.dx_call && s.freq === check.freq && s.mode === check.mode) {
|
||||
// Find which one to keep and which to delete
|
||||
const checkSpotNewer = check.time > s.time;
|
||||
const keepSpot = checkSpotNewer ? check : s;
|
||||
const deleteSpot = checkSpotNewer ? s : check;
|
||||
// Aggregate list of spots to remove
|
||||
spotsToRemove.push(deleteSpot.uid);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// Perform the removal
|
||||
return spotList.filter(s => !spotsToRemove.includes(s.uid));
|
||||
}
|
||||
|
||||
// Load server options. Once a successful callback is made from this, we then query spots and set up the timer to query
|
||||
|
||||
@@ -23,8 +23,8 @@ function buildQueryString() {
|
||||
}
|
||||
});
|
||||
str = str + "max_age=" + $("#max-spot-age option:selected").val();
|
||||
// Additional filters for the map view: No dupes, no QRT, only spots with locations
|
||||
str = str + "&dedupe=true&allow_qrt=false&needs_location=true";
|
||||
// Additional filters for the map view: No dupes, no QRT, only spots with good locations
|
||||
str = str + "&dedupe=true&allow_qrt=false&needs_good_location=true";
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user