mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
IDE inspection fixes and global autoformat
This commit is contained in:
@@ -1696,8 +1696,8 @@ components:
|
||||
items:
|
||||
type: string
|
||||
example:
|
||||
POTA: [POTA]
|
||||
SOTA: [SOTA]
|
||||
POTA: [ POTA ]
|
||||
SOTA: [ SOTA, GMA, ParksNPeaks ]
|
||||
|
||||
CallLookup:
|
||||
type: object
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
// Credentials schema per provider name. Defines the fields to collect and how to label them.
|
||||
var PROVIDER_CREDENTIAL_SCHEMAS = {
|
||||
const PROVIDER_CREDENTIAL_SCHEMAS = {
|
||||
// todo Figure out SOTA authentication
|
||||
// see e.g. https://github.com/ham2k/app-polo/blob/main/src/extensions/activities/sota/SOTAAccount.jsx
|
||||
// https://github.com/ham2k/app-polo/blob/main/src/store/apis/apiSOTA/apiSOTA.js
|
||||
// Refresh token? Way to show user that they need to log in again because cached credentials aren't valid?
|
||||
// todo type: text/password distinction on text boxes so API keys can be obscured
|
||||
"SOTA": [
|
||||
{ key: "access_token", label: "SOTA Access Token", help: "" },
|
||||
{ key: "id_token", label: "SOTA ID Token", help: "TODO SOTA authentication to provide this..." }
|
||||
{key: "access_token", label: "SOTA Access Token", help: ""},
|
||||
{key: "id_token", label: "SOTA ID Token", help: "TODO SOTA authentication to provide this..."}
|
||||
],
|
||||
"ParksNPeaks": [
|
||||
{ key: "user_id", label: "Parks N Peaks User ID", help: "" },
|
||||
{ key: "api_key", label: "Parks N Peaks API Key", help: "Get your API key from your Parks N Peaks account." }
|
||||
{key: "user_id", label: "Parks N Peaks User ID", help: ""},
|
||||
{key: "api_key", label: "Parks N Peaks API Key", help: "Get your API key from your Parks N Peaks account."}
|
||||
],
|
||||
"ZLOTA": [
|
||||
{ key: "user_id", label: "ZLOTA User ID", help: "" },
|
||||
{ key: "api_key", label: "ZLOTA User PIN", help: "Get your PIN from your ZLOTA account." }
|
||||
{key: "user_id", label: "ZLOTA User ID", help: ""},
|
||||
{key: "api_key", label: "ZLOTA User PIN", help: "Get your PIN from your ZLOTA account."}
|
||||
],
|
||||
"Tiles": [
|
||||
{ key: "offline_spot_gateway_pin", label: "Offline Spot Gateway PIN", help: "Get your PIN from your Tiles on the Air account profile." }
|
||||
{
|
||||
key: "offline_spot_gateway_pin",
|
||||
label: "Offline Spot Gateway PIN",
|
||||
help: "Get your PIN from your Tiles on the Air account profile."
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -62,7 +66,7 @@ function loadOptions() {
|
||||
function loadRecaptcha(siteKey) {
|
||||
window._recaptchaSiteKey = siteKey;
|
||||
if (!document.getElementById('recaptcha-script')) {
|
||||
var script = document.createElement('script');
|
||||
const script = document.createElement('script');
|
||||
script.id = 'recaptcha-script';
|
||||
script.src = 'https://www.google.com/recaptcha/api.js?render=explicit&onload=renderRecaptcha';
|
||||
script.async = true;
|
||||
@@ -87,8 +91,8 @@ function updateUpstreamArea() {
|
||||
return;
|
||||
}
|
||||
|
||||
var sig = $("#sig").val();
|
||||
var providers = (sig && options["spot_submit_providers"][sig]) ? options["spot_submit_providers"][sig] : [];
|
||||
const sig = $("#sig").val();
|
||||
const providers = (sig && options["spot_submit_providers"][sig]) ? options["spot_submit_providers"][sig] : [];
|
||||
|
||||
if (providers.length === 0) {
|
||||
$("#upstream-area").hide();
|
||||
@@ -99,8 +103,8 @@ function updateUpstreamArea() {
|
||||
|
||||
// Update the provider selector
|
||||
$("#upstream-provider-select").empty();
|
||||
$.each(providers, function(i, name) {
|
||||
$("#upstream-provider-select").append($('<option>', { value: name, text: name }));
|
||||
$.each(providers, function (i, name) {
|
||||
$("#upstream-provider-select").append($('<option>', {value: name, text: name}));
|
||||
});
|
||||
|
||||
if (providers.length > 1) {
|
||||
@@ -117,7 +121,7 @@ function updateUpstreamArea() {
|
||||
|
||||
// Update the credentials button visibility based on selected provider
|
||||
function updateCredentialsButton() {
|
||||
var providerName = getSelectedUpstreamProvider();
|
||||
const providerName = getSelectedUpstreamProvider();
|
||||
if (providerName && PROVIDER_CREDENTIAL_SCHEMAS[providerName]) {
|
||||
$("#upstream-credentials-btn").show();
|
||||
} else {
|
||||
@@ -127,7 +131,7 @@ function updateCredentialsButton() {
|
||||
|
||||
// Get the currently selected upstream provider name
|
||||
function getSelectedUpstreamProvider() {
|
||||
var providers = (options && options["spot_submit_providers"] && $("#sig").val())
|
||||
const providers = (options && options["spot_submit_providers"] && $("#sig").val())
|
||||
? (options["spot_submit_providers"][$("#sig").val()] || [])
|
||||
: [];
|
||||
if (providers.length === 0) return null;
|
||||
@@ -137,18 +141,18 @@ function getSelectedUpstreamProvider() {
|
||||
|
||||
// Show the credentials modal for the currently selected upstream provider
|
||||
function showCredentialsModal() {
|
||||
var providerName = getSelectedUpstreamProvider();
|
||||
const providerName = getSelectedUpstreamProvider();
|
||||
if (!providerName || !PROVIDER_CREDENTIAL_SCHEMAS[providerName]) return;
|
||||
|
||||
var schema = PROVIDER_CREDENTIAL_SCHEMAS[providerName];
|
||||
var stored = loadCredentials(providerName);
|
||||
const schema = PROVIDER_CREDENTIAL_SCHEMAS[providerName];
|
||||
const stored = loadCredentials(providerName);
|
||||
|
||||
$("#credentials-provider-name").text(providerName);
|
||||
$("#credentials-fields").empty();
|
||||
|
||||
$.each(schema, function(i, field) {
|
||||
var val = stored[field.key] || "";
|
||||
var html = '<div class="mb-3">';
|
||||
$.each(schema, function (i, field) {
|
||||
const val = stored[field.key] || "";
|
||||
let html = '<div class="mb-3">';
|
||||
html += '<label for="cred-' + field.key + '" class="form-label">' + field.label + '</label>';
|
||||
html += '<input type="text" class="form-control" id="cred-' + field.key + '" value="' + $('<div>').text(val).html() + '">';
|
||||
if (field.help) {
|
||||
@@ -165,12 +169,12 @@ function showCredentialsModal() {
|
||||
|
||||
// Save credentials from the modal to local storage
|
||||
function saveCredentials() {
|
||||
var providerName = $("#credentials-modal").data("provider");
|
||||
const providerName = $("#credentials-modal").data("provider");
|
||||
if (!providerName || !PROVIDER_CREDENTIAL_SCHEMAS[providerName]) return;
|
||||
|
||||
var schema = PROVIDER_CREDENTIAL_SCHEMAS[providerName];
|
||||
var creds = {};
|
||||
$.each(schema, function(i, field) {
|
||||
const schema = PROVIDER_CREDENTIAL_SCHEMAS[providerName];
|
||||
const creds = {};
|
||||
$.each(schema, function (i, field) {
|
||||
creds[field.key] = $("#cred-" + field.key).val();
|
||||
});
|
||||
localStorage.setItem("upstream-credentials-" + providerName, JSON.stringify(creds));
|
||||
@@ -179,7 +183,7 @@ function saveCredentials() {
|
||||
|
||||
// Load credentials for a provider from local storage
|
||||
function loadCredentials(providerName) {
|
||||
var stored = localStorage.getItem("upstream-credentials-" + providerName);
|
||||
const stored = localStorage.getItem("upstream-credentials-" + providerName);
|
||||
return stored ? JSON.parse(stored) : {};
|
||||
}
|
||||
|
||||
@@ -237,8 +241,8 @@ function addSpot() {
|
||||
spot["time"] = moment.utc().valueOf() / 1000.0;
|
||||
|
||||
// Upstream submission
|
||||
var submitUpstream = $("#submit-upstream").is(":checked");
|
||||
var upstreamProviderName = getSelectedUpstreamProvider();
|
||||
const submitUpstream = $("#submit-upstream").is(":checked");
|
||||
const upstreamProviderName = getSelectedUpstreamProvider();
|
||||
if (submitUpstream && upstreamProviderName) {
|
||||
if (!sig) {
|
||||
showAddSpotError("A SIG must be selected to submit upstream.");
|
||||
@@ -257,14 +261,14 @@ function addSpot() {
|
||||
return;
|
||||
}
|
||||
|
||||
var creds = loadCredentials(upstreamProviderName);
|
||||
const creds = loadCredentials(upstreamProviderName);
|
||||
spot["submit_upstream"] = true;
|
||||
spot["upstream_provider"] = upstreamProviderName;
|
||||
spot["upstream_credentials"] = creds;
|
||||
|
||||
// Add CAPTCHA token if reCAPTCHA is loaded
|
||||
if (window._recaptchaWidgetId !== undefined) {
|
||||
var token = grecaptcha.getResponse(window._recaptchaWidgetId);
|
||||
const token = grecaptcha.getResponse(window._recaptchaWidgetId);
|
||||
if (!token) {
|
||||
showAddSpotError("Please complete the CAPTCHA to submit upstream.");
|
||||
return;
|
||||
|
||||
@@ -539,7 +539,7 @@ function renderIonosondeData() {
|
||||
ctx.strokeStyle = gridColor;
|
||||
ctx.lineWidth = 1;
|
||||
ctx.setLineDash([]);
|
||||
// Add an extra vertical line for 30MHz, which should correspond to the top of the chart and avoid having
|
||||
// Add an extra horizontal line for 30MHz, which should correspond to the top of the chart and avoid having
|
||||
// no top "border" gridline
|
||||
const y30 = scales.y.getPixelForValue(30);
|
||||
if (y30 >= chartArea.top && y30 <= chartArea.bottom) {
|
||||
|
||||
@@ -366,28 +366,28 @@ const SIG_ICONS = {
|
||||
}
|
||||
|
||||
const SIG_NAMES = {
|
||||
"POTA": "Parks on the Air",
|
||||
"SOTA": "Summits on the Air",
|
||||
"WWFF": "Worldwide Flora & Fauna",
|
||||
"GMA": "Global Mountain Activity",
|
||||
"WWBOTA": "Bunkers on the Air",
|
||||
"HEMA": "Humps Excluding Marilyns Award",
|
||||
"IOTA": "Islands on the Air",
|
||||
"MOTA": "Mills on the Air",
|
||||
"ARLHS": "Amateur Radio Lighthouse Society",
|
||||
"ILLW": "International Lighthouse Lightship Weekend",
|
||||
"SIOTA": "Silos on the Air",
|
||||
"WCA": "World Castles Award",
|
||||
"ZLOTA": "New Zealand on the Air",
|
||||
"WOTA": "Wainwrights on the Air",
|
||||
"BOTA": "Beaches on the Air",
|
||||
"KRMNPA": "Keith Roget Memorial National Parks Award",
|
||||
"LLOTA": "Lagos y Lagunas on the Air",
|
||||
"WWTOTA": "Towers on the Air",
|
||||
"WAB": "Worked All Britain",
|
||||
"WAI": "Worked All Ireland",
|
||||
"Tiles": "Tiles on the Air",
|
||||
"TOTA": "Toilets on the Air"
|
||||
"POTA": "Parks on the Air",
|
||||
"SOTA": "Summits on the Air",
|
||||
"WWFF": "Worldwide Flora & Fauna",
|
||||
"GMA": "Global Mountain Activity",
|
||||
"WWBOTA": "Bunkers on the Air",
|
||||
"HEMA": "Humps Excluding Marilyns Award",
|
||||
"IOTA": "Islands on the Air",
|
||||
"MOTA": "Mills on the Air",
|
||||
"ARLHS": "Amateur Radio Lighthouse Society",
|
||||
"ILLW": "International Lighthouse Lightship Weekend",
|
||||
"SIOTA": "Silos on the Air",
|
||||
"WCA": "World Castles Award",
|
||||
"ZLOTA": "New Zealand on the Air",
|
||||
"WOTA": "Wainwrights on the Air",
|
||||
"BOTA": "Beaches on the Air",
|
||||
"KRMNPA": "Keith Roget Memorial National Parks Award",
|
||||
"LLOTA": "Lagos y Lagunas on the Air",
|
||||
"WWTOTA": "Towers on the Air",
|
||||
"WAB": "Worked All Britain",
|
||||
"WAI": "Worked All Ireland",
|
||||
"Tiles": "Tiles on the Air",
|
||||
"TOTA": "Toilets on the Air"
|
||||
}
|
||||
|
||||
// Get the Font Awesome icon for a given SIG. If the SIG is unknown, the provided default symbol will be returned
|
||||
@@ -407,17 +407,17 @@ function sigToIcon(sig, defaultIcon) {
|
||||
|
||||
// Get the full name for a given SIG abbreviation. If the SIG is unknown, an empty string will be returned.
|
||||
function sigToName(sig) {
|
||||
let col = (sig != null) ? SIG_NAMES[sig] : null;
|
||||
if (col) {
|
||||
return col;
|
||||
} else {
|
||||
let col = (sig != null) ? SIG_NAMES[sig.toUpperCase()] : null;
|
||||
if (col) {
|
||||
return col;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
let col = (sig != null) ? SIG_NAMES[sig] : null;
|
||||
if (col) {
|
||||
return col;
|
||||
} else {
|
||||
let col = (sig != null) ? SIG_NAMES[sig.toUpperCase()] : null;
|
||||
if (col) {
|
||||
return col;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the list of known SIGs
|
||||
@@ -427,12 +427,12 @@ function getKnownSIGs() {
|
||||
|
||||
// Format a Maidenhead grid with alternating alphabetic blocks in lower case
|
||||
function formatGrid(grid) {
|
||||
grid = grid.toUpperCase();
|
||||
if (grid.length >= 6) {
|
||||
grid = grid.substring(0, 4) + grid.substring(4, 6).toLowerCase() + grid.substring(6);
|
||||
}
|
||||
if (grid.length >= 12) {
|
||||
grid = grid.substring(0, 10) + grid.substring(10, 12).toLowerCase() + grid.substring(14);
|
||||
}
|
||||
return grid;
|
||||
grid = grid.toUpperCase();
|
||||
if (grid.length >= 6) {
|
||||
grid = grid.substring(0, 4) + grid.substring(4, 6).toLowerCase() + grid.substring(6);
|
||||
}
|
||||
if (grid.length >= 12) {
|
||||
grid = grid.substring(0, 10) + grid.substring(10, 12).toLowerCase() + grid.substring(14);
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user