mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-28 18:22:05 +00:00
76 lines
2.7 KiB
JavaScript
76 lines
2.7 KiB
JavaScript
// Storage for the spot data that the server gives us.
|
|
let spots = [];
|
|
// List of people the user has worked. Each entry has the format callsign-band-mode. These can be added to the list by
|
|
// ticking the checkbox on a row of the table, and cleared from the Display menu. Where a row would be added to the
|
|
// table and the callsign-band-mode is in this list, it is shown struck through as already worked. This is persisted
|
|
// to localStorage.
|
|
let worked = []
|
|
|
|
// Dynamically add CSS code for the band checkboxes to show in the appropriate colour.
|
|
function addBandToggleColourCSS() {
|
|
const $style = $('<style>');
|
|
$(".filter-button-band").each(function () {
|
|
$style.append(`label[for="${this.id}"] { padding-left: 0.3em; border-left: 5px solid ${bandToColor(this.value)};}`);
|
|
});
|
|
$('html > head').append($style);
|
|
}
|
|
|
|
// Set the band toggles so that only the amateur radio HF bands are selected. Special case of toggleFilterButtons().
|
|
function setHamHFBandToggles() {
|
|
$(".filter-button-band").each(function () {
|
|
$(this).prop('checked', $(this).data("ham-hf"));
|
|
});
|
|
filtersUpdated();
|
|
}
|
|
|
|
// Set the mode toggles that relate to Analog Voice.
|
|
function setVoiceModeToggles() {
|
|
$(".filter-button-mode").each(function () {
|
|
$(this).prop('checked', $(this).data("mode-type") === "PHONE");
|
|
});
|
|
filtersUpdated();
|
|
}
|
|
|
|
// Set the mode toggles that relate to Digimodes.
|
|
function setDigiModeToggles() {
|
|
$(".filter-button-mode").each(function () {
|
|
$(this).prop('checked', $(this).data("mode-type") === "DATA");
|
|
});
|
|
filtersUpdated();
|
|
}
|
|
|
|
// Method called when any filter is changed to reload the spots and persist the filter settings.
|
|
function filtersUpdated() {
|
|
loadSpots();
|
|
saveSettings();
|
|
}
|
|
|
|
// Function to update the band colour scheme in spots, bands and map pages
|
|
function setBandColorSchemeFromUI() {
|
|
setBandColorScheme($("#band_color_scheme option:selected").val());
|
|
saveSettings();
|
|
// Fudge a full reload because we need to update not just colours in the list/map/bands but also the filters
|
|
window.location.reload();
|
|
}
|
|
|
|
// Query if a callsign-band-mode combination as has already been worked
|
|
function alreadyWorked(callsign, band, mode) {
|
|
return worked.includes(callsign + "-" + band + "-" + mode);
|
|
}
|
|
|
|
// Reload spots on becoming visible. This forces a refresh when used as a PWA and the user switches back to the PWA
|
|
// after some time has passed with it in the background.
|
|
addEventListener("visibilitychange", () => {
|
|
if (!document.hidden) {
|
|
loadSpots();
|
|
}
|
|
});
|
|
|
|
// Startup
|
|
$(document).ready(function () {
|
|
// Load worked list
|
|
const tmpWorked = JSON.parse(localStorage.getItem("worked"));
|
|
if (tmpWorked) {
|
|
worked = tmpWorked;
|
|
}
|
|
}); |