|
|
|
|
@@ -10,15 +10,25 @@ function saveSettings() {
|
|
|
|
|
if (useLocalStorage) {
|
|
|
|
|
// Find all storeable UI elements, store a key of "element id:property name" mapped to the value of that
|
|
|
|
|
// property. For a checkbox, that's the "checked" property.
|
|
|
|
|
$(".storeable-checkbox").each(function() {
|
|
|
|
|
$(".storeable-checkbox").each(function () {
|
|
|
|
|
localStorage.setItem("#" + $(this)[0].id + ":checked", JSON.stringify($(this)[0].checked));
|
|
|
|
|
});
|
|
|
|
|
$(".storeable-select").each(function() {
|
|
|
|
|
$(".storeable-select").each(function () {
|
|
|
|
|
localStorage.setItem("#" + $(this)[0].id + ":value", JSON.stringify($(this)[0].value));
|
|
|
|
|
});
|
|
|
|
|
$(".storeable-text").each(function() {
|
|
|
|
|
$(".storeable-text").each(function () {
|
|
|
|
|
localStorage.setItem("#" + $(this)[0].id + ":value", JSON.stringify($(this)[0].value));
|
|
|
|
|
});
|
|
|
|
|
// Password fields are only saved if the corresponding "remember password" checkbox is ticked.
|
|
|
|
|
$(".password-field").each(function () {
|
|
|
|
|
var pwKey = "#" + $(this)[0].id + ":value";
|
|
|
|
|
var rememberCheckboxId = $(this).data("remember-checkbox");
|
|
|
|
|
if (rememberCheckboxId && $("#" + rememberCheckboxId)[0] && $("#" + rememberCheckboxId)[0].checked) {
|
|
|
|
|
localStorage.setItem(pwKey, JSON.stringify($(this)[0].value));
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.removeItem(pwKey);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -26,7 +36,7 @@ function saveSettings() {
|
|
|
|
|
function loadSettings() {
|
|
|
|
|
if (useLocalStorage) {
|
|
|
|
|
// Find all local storage entries and push their data to the corresponding UI element
|
|
|
|
|
Object.keys(localStorage).forEach(function(key) {
|
|
|
|
|
Object.keys(localStorage).forEach(function (key) {
|
|
|
|
|
if (key.startsWith("#") && key.includes(":")) {
|
|
|
|
|
// Split the key back into an element ID and a property
|
|
|
|
|
var split = key.split(":");
|
|
|
|
|
@@ -108,9 +118,9 @@ function getQueryStringFor(parameter) {
|
|
|
|
|
|
|
|
|
|
// For a parameter, such as dx_continent, get the filter options that are currently selected in the UI.
|
|
|
|
|
function getSelectedFilterOptions(parameter) {
|
|
|
|
|
return $(".filter-button-" + parameter).filter(function() {
|
|
|
|
|
return $(".filter-button-" + parameter).filter(function () {
|
|
|
|
|
return this.checked;
|
|
|
|
|
}).map(function() {
|
|
|
|
|
}).map(function () {
|
|
|
|
|
return this.value;
|
|
|
|
|
}).get().join(",");
|
|
|
|
|
}
|
|
|
|
|
@@ -118,7 +128,7 @@ function getSelectedFilterOptions(parameter) {
|
|
|
|
|
// For a parameter, such as dx_continent, return true if all possible options are enabled. (In this case, we don't need
|
|
|
|
|
// to bother sending this as one of the query parameters to the API; no parameter provided implies "send everything".)
|
|
|
|
|
function allFilterOptionsSelected(parameter) {
|
|
|
|
|
var filter = $(".filter-button-" + parameter).filter(function() {
|
|
|
|
|
var filter = $(".filter-button-" + parameter).filter(function () {
|
|
|
|
|
return !this.checked;
|
|
|
|
|
}).get();
|
|
|
|
|
return filter.length == 0;
|
|
|
|
|
@@ -137,7 +147,7 @@ function generateMultiToggleFilterCard(elementID, filterQuery, options) {
|
|
|
|
|
|
|
|
|
|
// Method called when "All" or "None" is clicked
|
|
|
|
|
function toggleFilterButtons(filterQuery, state) {
|
|
|
|
|
$(".filter-button-" + filterQuery).each(function() {
|
|
|
|
|
$(".filter-button-" + filterQuery).each(function () {
|
|
|
|
|
$(this).prop('checked', state);
|
|
|
|
|
});
|
|
|
|
|
filtersUpdated();
|
|
|
|
|
@@ -218,8 +228,9 @@ function listenForOSThemeChange() {
|
|
|
|
|
|
|
|
|
|
// Panel toggle functions
|
|
|
|
|
const PANELS = [
|
|
|
|
|
{ area: "#filters-area",button: "#filters-button" },
|
|
|
|
|
{ area: "#display-area", button: "#display-button" },
|
|
|
|
|
{area: "#filters-area", button: "#filters-button"},
|
|
|
|
|
{area: "#display-area", button: "#display-button"},
|
|
|
|
|
{area: "#data-area", button: "#data-button"},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Toggle a panel open or closed. If opening, all other visible panels are closed first.
|
|
|
|
|
@@ -239,18 +250,58 @@ function togglePanel(areaId) {
|
|
|
|
|
// Close a panel and deactivate its toggle button.
|
|
|
|
|
function closePanel(areaId) {
|
|
|
|
|
const panel = PANELS.find(p => p.area === areaId);
|
|
|
|
|
if (panel) { $(panel.button).button("toggle"); }
|
|
|
|
|
if (panel) {
|
|
|
|
|
$(panel.button).button("toggle");
|
|
|
|
|
}
|
|
|
|
|
$(areaId).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleFiltersPanel() { togglePanel("#filters-area"); }
|
|
|
|
|
function closeFiltersPanel() { closePanel("#filters-area"); }
|
|
|
|
|
function toggleDisplayPanel() { togglePanel("#display-area"); }
|
|
|
|
|
function closeDisplayPanel() { closePanel("#display-area"); }
|
|
|
|
|
function toggleFiltersPanel() {
|
|
|
|
|
togglePanel("#filters-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeFiltersPanel() {
|
|
|
|
|
closePanel("#filters-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleDisplayPanel() {
|
|
|
|
|
togglePanel("#display-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDisplayPanel() {
|
|
|
|
|
closePanel("#display-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleDataPanel() {
|
|
|
|
|
togglePanel("#data-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDataPanel() {
|
|
|
|
|
closePanel("#data-area");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build a query string fragment containing any QRZ.com / HamQTH credentials the user has supplied,
|
|
|
|
|
// provided the corresponding "enabled" checkbox is ticked.
|
|
|
|
|
function getCredentialQueryString() {
|
|
|
|
|
var str = "";
|
|
|
|
|
if ($("#qrz-enabled")[0] && $("#qrz-enabled")[0].checked) {
|
|
|
|
|
var qrzUsername = $("#qrz-username").val();
|
|
|
|
|
var qrzPassword = $("#qrz-password").val();
|
|
|
|
|
if (qrzUsername) str += "&qrz_username=" + encodeURIComponent(qrzUsername);
|
|
|
|
|
if (qrzPassword) str += "&qrz_password=" + encodeURIComponent(qrzPassword);
|
|
|
|
|
}
|
|
|
|
|
if ($("#hamqth-enabled")[0] && $("#hamqth-enabled")[0].checked) {
|
|
|
|
|
var hamqthUsername = $("#hamqth-username").val();
|
|
|
|
|
var hamqthPassword = $("#hamqth-password").val();
|
|
|
|
|
if (hamqthUsername) str += "&hamqth_username=" + encodeURIComponent(hamqthUsername);
|
|
|
|
|
if (hamqthPassword) str += "&hamqth_password=" + encodeURIComponent(hamqthPassword);
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Startup
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
usePreferredTheme();
|
|
|
|
|
listenForOSThemeChange();
|
|
|
|
|
});
|
|
|
|
|
|