Saturday commit

merge-requests/203/head
Tag 2022-09-25 00:03:00 -07:00
rodzic 610bd78bef
commit 8ba7d0da46
4 zmienionych plików z 288 dodań i 127 usunięć

Wyświetl plik

@ -744,15 +744,13 @@ function lookupUsCallsign(object, writeState = false)
{ {
g_ulsDatabase.transaction(function (tx) g_ulsDatabase.transaction(function (tx)
{ {
var qry = "SELECT * FROM calls where callsign = \"" + object.DEcall + "\""; let qry = "SELECT * FROM calls where callsign = \"" + object.DEcall + "\"";
tx.executeSql( tx.executeSql(
qry, qry,
[], [],
function (tx, results) function (tx, results)
{ {
var len = results.rows.length, if (results.rows.length == 1)
i;
if (len == 1)
{ {
if (object.state == null) if (object.state == null)
{ {
@ -764,15 +762,16 @@ function lookupUsCallsign(object, writeState = false)
{ {
object.state = "US-" + results.rows[0].state; object.state = "US-" + results.rows[0].state;
} }
if (writeState) setState(object);
if (writeState)
{
setState(object);
}
} }
object.zipcode = String(results.rows[0].zip); object.zipcode = String(results.rows[0].zip);
if (object.cnty == null) if (object.cnty == null)
{ {
let request = g_Idb let request = g_Idb.transaction(["lookups"], "readwrite").objectStore("lookups").get(object.DEcall);
.transaction(["lookups"], "readwrite")
.objectStore("lookups")
.get(object.DEcall);
request.onsuccess = function (event) request.onsuccess = function (event)
{ {
@ -785,21 +784,40 @@ function lookupUsCallsign(object, writeState = false)
if (object.cnty == null && object.zipcode in g_zipToCounty) if (object.cnty == null && object.zipcode in g_zipToCounty)
{ {
var counties = g_zipToCounty[object.zipcode]; var counties = g_zipToCounty[object.zipcode];
if (counties.length > 1) object.qual = false; if (counties.length > 1)
else object.qual = true; {
object.qual = false;
}
else
{
object.qual = true;
}
object.cnty = counties[0]; object.cnty = counties[0];
} }
else object.qual = false; else
if (writeState) setState(object); {
object.qual = false;
}
if (writeState)
{
setState(object);
}
}; };
request.onerror = function (event) request.onerror = function (event)
{ {
object.qual = false; object.qual = false;
if (writeState) setState(object); if (writeState)
{
setState(object);
}
}; };
} }
if (writeState) setState(object); if (writeState)
{
setState(object);
}
} }
}, },
null null

Wyświetl plik

@ -1461,14 +1461,7 @@ function addDeDx(
if (!notQso) if (!notQso)
{ {
if ( if (validateMapBandAndMode(band, mode) && validatePropMode(finalPropMode))
(g_appSettings.gtBandFilter.length == 0 ||
(g_appSettings.gtBandFilter == "auto"
? myBand == band
: g_appSettings.gtBandFilter == band)) &&
validateMapMode(mode) &&
validatePropMode(finalPropMode)
)
{ {
details.rect = qthToQsoBox( details.rect = qthToQsoBox(
finalGrid, finalGrid,
@ -1490,13 +1483,7 @@ function addDeDx(
if (finalDxcc in g_dxccCount) g_dxccCount[finalDxcc]++; if (finalDxcc in g_dxccCount) g_dxccCount[finalDxcc]++;
else g_dxccCount[finalDxcc] = 1; else g_dxccCount[finalDxcc] = 1;
if ( if (validateMapBandAndMode(band, mode))
(g_appSettings.gtBandFilter.length == 0 ||
(g_appSettings.gtBandFilter == "auto"
? myBand == band
: g_appSettings.gtBandFilter == band)) &&
validateMapMode(mode)
)
{ {
rect = qthToBox( rect = qthToBox(
finalGrid, finalGrid,
@ -3532,9 +3519,7 @@ function moonOver(feature)
} }
g_lastMoon = feature; g_lastMoon = feature;
var positionInfo = myMoonTooltip.getBoundingClientRect(); moonMove();
myMoonTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px";
myMoonTooltip.style.top = getMouseY() + 22 + "px";
myMoonTooltip.style.zIndex = 499; myMoonTooltip.style.zIndex = 499;
myMoonTooltip.style.display = "block"; myMoonTooltip.style.display = "block";
} }
@ -3751,9 +3736,8 @@ function trophyOver(feature)
"<div style='font-size:15px;color:cyan;' class='roundBorder'>" + "<div style='font-size:15px;color:cyan;' class='roundBorder'>" +
worker + worker +
"</div>"; "</div>";
var positionInfo = myTrophyTooltip.getBoundingClientRect();
myTrophyTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; trophyMove();
myTrophyTooltip.style.top = getMouseY() - positionInfo.height - 22 + "px";
myTrophyTooltip.style.zIndex = 499; myTrophyTooltip.style.zIndex = 499;
myTrophyTooltip.style.display = "block"; myTrophyTooltip.style.display = "block";
} }
@ -3851,12 +3835,11 @@ function mouseDownGrid(longlat, event)
grid + grid +
"</div>" + "</div>" +
worker; worker;
var positionInfo = myGridTooltip.getBoundingClientRect(); g_MyGridIsUp = true;
myGridTooltip.style.left = event.pixel[0] - positionInfo.width / 2 + "px";
myGridTooltip.style.top = event.pixel[1] - positionInfo.height - 22 + "px"; mouseMoveGrid();
myGridTooltip.style.zIndex = 499; myGridTooltip.style.zIndex = 499;
myGridTooltip.style.display = "block"; myGridTooltip.style.display = "block";
g_MyGridIsUp = true;
} }
function mouseMoveGrid() function mouseMoveGrid()
@ -3894,9 +3877,7 @@ function mouseOverGtFlag(feature)
createFlagTipTable(feature); createFlagTipTable(feature);
var positionInfo = myFlagtip.getBoundingClientRect(); gtFlagMove();
myFlagtip.style.left = getMouseX() + 15 + "px";
myFlagtip.style.top = getMouseY() - positionInfo.height - 5 + "px";
myFlagtip.style.zIndex = 499; myFlagtip.style.zIndex = 499;
myFlagtip.style.display = "block"; myFlagtip.style.display = "block";
@ -3953,17 +3934,14 @@ function mouseOverDataItem(mouseEvent, fromHover)
if (g_mapSettings.mouseOver == false && fromHover == true) return; if (g_mapSettings.mouseOver == false && fromHover == true) return;
g_lastDataGridUp = mouseEvent; g_lastDataGridUp = mouseEvent;
var myTooltip = null;
var callListLength = 0;
var isFlag = false;
myTooltip = document.getElementById("myTooltip"); let isFlag = false;
callListLength = createTooltTipTable(mouseEvent); let callListLength = createTooltTipTable(mouseEvent);
var positionInfo = myTooltip.getBoundingClientRect(); let positionInfo = myTooltip.getBoundingClientRect();
var windowWidth = window.innerWidth; let windowWidth = window.innerWidth;
var top = 0; let top = 0;
var noRoomLeft = false; let noRoomLeft = false;
var noRoomRight = false; let noRoomRight = false;
if ( if (
typeof mouseEvent.spot != "undefined" && typeof mouseEvent.spot != "undefined" &&
g_receptionReports.spots[mouseEvent.spot].bearing > 180 g_receptionReports.spots[mouseEvent.spot].bearing > 180
@ -3993,12 +3971,11 @@ function mouseOverDataItem(mouseEvent, fromHover)
function mouseMoveDataItem(mouseEvent) function mouseMoveDataItem(mouseEvent)
{ {
var myTooltip = document.getElementById("myTooltip"); let positionInfo = myTooltip.getBoundingClientRect();
var positionInfo = myTooltip.getBoundingClientRect(); let windowWidth = window.innerWidth;
var windowWidth = window.innerWidth; let top = 0;
var top = 0; let noRoomLeft = false;
var noRoomLeft = false; let noRoomRight = false;
var noRoomRight = false;
if ( if (
typeof mouseEvent.spot != "undefined" && typeof mouseEvent.spot != "undefined" &&
g_receptionReports.spots[mouseEvent.spot].bearing > 180 g_receptionReports.spots[mouseEvent.spot].bearing > 180
@ -7167,19 +7144,20 @@ function handleWsjtxDecode(newMessage)
if (callsign.DEcall in g_pota.callSpots) if (callsign.DEcall in g_pota.callSpots)
{ {
// copies the entire array // copies the entire array
callsign.pota = g_pota.callSpots[callsign.DEcall]; callsign.pota = [...g_pota.callSpots[callsign.DEcall]];
} }
if (callsign.DEcall in g_pota.callSchedule) else if (callsign.DEcall in g_pota.callSchedule)
{ {
let now = Date.now(); let now = Date.now();
for (let i in g_pota.callSchedule[callsign.DEcall]) for (let i in g_pota.callSchedule[callsign.DEcall])
{ {
if (now < g_pota.callSchedule[callsign.DEcall][i].end && now >= g_pota.callSchedule[callsign.DEcall][i].start && !callsign.pota.includes(g_pota.callSchedule[callsign.DEcall][i].id)) if (now < g_pota.callSchedule[callsign.DEcall][i].end && now >= g_pota.callSchedule[callsign.DEcall][i].start)
{ {
callsign.pota.push(g_pota.callSchedule[callsign.DEcall][i].id); callsign.pota.push(g_pota.callSchedule[callsign.DEcall][i].id);
} }
} }
} }
potaSpotFromDecode(callsign);
} }
if (newMessage.NW) if (newMessage.NW)
@ -10487,7 +10465,9 @@ function validatePropMode(propMode)
return g_appSettings.gtPropFilter == propMode; return g_appSettings.gtPropFilter == propMode;
} }
function validateMapMode(mode) function validateMapBandAndMode(band, mode)
{
if ((g_appSettings.gtBandFilter.length == 0 || (g_appSettings.gtBandFilter == "auto" ? myBand == band : g_appSettings.gtBandFilter == band)))
{ {
if (g_appSettings.gtModeFilter.length == 0) return true; if (g_appSettings.gtModeFilter.length == 0) return true;
@ -10508,6 +10488,11 @@ function validateMapMode(mode)
return g_appSettings.gtModeFilter == mode; return g_appSettings.gtModeFilter == mode;
} }
else
{
return false;
}
}
function redrawGrids() function redrawGrids()
{ {
@ -10528,14 +10513,7 @@ function redrawGrids()
g_QSOcount++; g_QSOcount++;
if (didConfirm) g_QSLcount++; if (didConfirm) g_QSLcount++;
if ( if (validateMapBandAndMode(g_QSOhash[i].band, g_QSOhash[i].mode) && validatePropMode(g_QSOhash[i].propMode))
(g_appSettings.gtBandFilter.length == 0 ||
(g_appSettings.gtBandFilter == "auto"
? myBand == g_QSOhash[i].band
: g_appSettings.gtBandFilter == g_QSOhash[i].band)) &&
validateMapMode(g_QSOhash[i].mode) &&
validatePropMode(g_QSOhash[i].propMode)
)
{ {
if (g_appSettings.gridViewMode > 1) if (g_appSettings.gridViewMode > 1)
{ {
@ -10922,14 +10900,7 @@ function redrawGrids()
for (var i in g_liveCallsigns) for (var i in g_liveCallsigns)
{ {
if ( if (g_appSettings.gridViewMode != 2 && validateMapBandAndMode(g_liveCallsigns[i].band, g_liveCallsigns[i].mode))
g_appSettings.gridViewMode != 2 &&
(g_appSettings.gtBandFilter.length == 0 ||
(g_appSettings.gtBandFilter == "auto"
? myBand == g_liveCallsigns[i].band
: g_appSettings.gtBandFilter == g_liveCallsigns[i].band)) &&
validateMapMode(g_liveCallsigns[i].mode)
)
{ {
if (g_appSettings.gridViewMode == 1 || g_appSettings.gridViewMode == 3) if (g_appSettings.gridViewMode == 1 || g_appSettings.gridViewMode == 3)
{ {
@ -15145,6 +15116,7 @@ function cacheLookupObject(lookup, gridPass, cacheable = false)
{ {
g_liveCallsigns[hash].cnty = lookup.cnty; g_liveCallsigns[hash].cnty = lookup.cnty;
g_liveCallsigns[hash].qual = true; g_liveCallsigns[hash].qual = true;
g_liveCallsigns[hash].cntys = 0;
foundCounty = true; foundCounty = true;
} }
} }
@ -16264,13 +16236,7 @@ function redrawSpots()
continue; continue;
} }
if ( if (validateMapBandAndMode(report.band, report.mode))
(g_appSettings.gtBandFilter.length == 0 ||
(g_appSettings.gtBandFilter == "auto"
? myBand == report.band
: g_appSettings.gtBandFilter == report.band)) &&
validateMapMode(report.mode)
)
{ {
if (now - report.when <= g_receptionSettings.viewHistoryTimeSec) if (now - report.when <= g_receptionSettings.viewHistoryTimeSec)
{ {

Wyświetl plik

@ -15,7 +15,20 @@ var g_pota = {
mapParks: {} mapParks: {}
}; };
var g_defaultPark = { var g_spotTemplate = {
activator: "",
frequency: 0,
mode: "",
reference: "",
spotTime: 0,
spotter: "",
comments: "",
source: "GT",
count: 1,
rbn: false
};
var g_parkTemplate = {
feature: null feature: null
} }
@ -61,9 +74,10 @@ function togglePota()
function redrawParks() function redrawParks()
{ {
g_layerSources.pota.clear();
if (g_potaEnabled == 1) if (g_potaEnabled == 1)
{ {
g_layerSources.pota.clear();
g_pota.mapParks = {}; g_pota.mapParks = {};
makeParkFeatures(); makeParkFeatures();
} }
@ -77,12 +91,12 @@ function makeParkFeatures()
{ {
if (park in g_pota.parks) if (park in g_pota.parks)
{ {
let parkObj = Object.assign({}, g_defaultPark); let parkObj = Object.assign({}, g_parkTemplate);
for (const i in g_pota.parkSpots[park]) for (const i in g_pota.parkSpots[park])
{ {
let report = g_pota.parkSpots[park][i]; let report = g_pota.parkSpots[park][i];
if (parkObj.feature == null && (g_appSettings.gtBandFilter.length == 0 || (g_appSettings.gtBandFilter == "auto" ? myBand == report.band : g_appSettings.gtBandFilter == report.band)) && validateMapMode(report.mode)) if (parkObj.feature == null && validateMapBandAndMode(report.band, report.mode))
{ {
parkObj.feature = iconFeature(ol.proj.fromLonLat([Number(g_pota.parks[park].longitude), Number(g_pota.parks[park].latitude)]), g_gtParkIconActive, 1); parkObj.feature = iconFeature(ol.proj.fromLonLat([Number(g_pota.parks[park].longitude), Number(g_pota.parks[park].latitude)]), g_gtParkIconActive, 1);
parkObj.feature.key = park; parkObj.feature.key = park;
@ -103,6 +117,145 @@ function makeParkFeatures()
} }
} }
var g_potaSpotRedrawTimer = null;
function redrawParkSpotsOnTimeout()
{
if (g_potaSpotRedrawTimer != null)
{
clearTimeout(g_potaSpotRedrawTimer);
g_potaSpotRedrawTimer = null;
}
g_potaSpotRedrawTimer = setTimeout(redrawParks, 250);
}
function potaSpotFromDecode(callObj)
{
let hash = callObj.DEcall + callObj.band + callObj.mode;
for (const i in callObj.pota)
{
let park = callObj.pota[i];
let spotObj = null;
if (!(callObj.DEcall in g_pota.callSpots))
{
// new call and park
g_pota.callSpots[callObj.DEcall] = [park];
}
else if (!g_pota.callSpots[callObj.DEcall].includes(park))
{
// new park
g_pota.callSpots[callObj.DEcall].push(park);
}
if (!(park in g_pota.parkSpots))
{
g_pota.parkSpots[park] = {};
let newSpot = spotFromCallObj(callObj, park);
g_pota.parkSpots[park][hash] = newSpot;
redrawParkSpotsOnTimeout();
}
else if (!(hash in g_pota.parkSpots[park]))
{
let newSpot = spotFromCallObj(callObj, park);
g_pota.parkSpots[park][hash] = newSpot;
redrawParkSpotsOnTimeout();
}
else
{
// update spot
if (!g_pota.parkSpots[park][hash].rbn)
{
g_pota.parkSpots[park][hash].count++;
g_pota.parkSpots[park][hash].spotter = myDEcall;
g_pota.parkSpots[park][hash].spotTime = Date.now();
g_pota.parkSpots[park][hash].source = "GT";
g_pota.parkSpots[park][hash].comments = "RBN " + callObj.RSTsent + " dB " + myDEGrid;
}
}
if (!g_pota.parkSpots[park][hash].rbn)
{
g_pota.parkSpots[park][hash].rbn = true;
reportPotaRBN(g_pota.parkSpots[park][hash]);
}
}
}
function reportPotaRBN(callSpot)
{
let report = {
activator: callSpot.activator,
spotter: myDEcall,
frequency: String(parseInt(callSpot.frequency * 1000)),
reference: callSpot.reference,
mode: callSpot.mode,
source: "GT",
comments: callSpot.comments
}
// console.log(report);
getPostJSONBuffer(
"https://api.pota.app/spot",
rbnReportResult,
null,
"https",
80,
report,
10000,
null,
null
);
}
function rbnReportResult(buffer, flag, cookies)
{
// It worked, but do we take these spots?
// console.log(String(buffer));
}
function spotFromCallObj(callObj, park)
{
let callSpot = {
activator: callObj.DEcall,
spotter: myDEcall,
frequency: Number((g_instances[callObj.instance].status.Frequency / 1000000).toFixed(3)),
reference: park,
mode: callObj.mode,
band: callObj.band,
spotTime: Date.now(),
source: "GT",
count: 1,
rbn: false,
comments: "RBN " + callObj.RSTsent + " dB " + myDEGrid
};
return callSpot;
}
function addParkSpotFeature(park)
{
let parkObj = Object.assign({}, g_parkTemplate);
if (park in g_pota.mapParks)
{
parkObj = g_pota.mapParks[park];
}
else
{
g_pota.mapParks[park] = parkObj;
}
if (parkObj.feature == null && validateMapBandAndMode(report.band, report.mode))
{
parkObj.feature = iconFeature(ol.proj.fromLonLat([Number(g_pota.parks[park].longitude), Number(g_pota.parks[park].latitude)]), g_gtParkIconActive, 1);
parkObj.feature.key = park;
parkObj.feature.size = 22;
g_layerSources.pota.addFeature(parkObj.feature);
}
}
function processPotaParks(buffer) function processPotaParks(buffer)
{ {
if (g_potaEnabled == 1) if (g_potaEnabled == 1)
@ -159,6 +312,25 @@ function getPotaParks()
g_pota.parksTimeout = setTimeout(getPotaParks, 86400000) g_pota.parksTimeout = setTimeout(getPotaParks, 86400000)
} }
// This is a shallow copy, don't use with objects that contain other objects or arrays
function fillObjectFromTemplate(template, input)
{
let object = {};
for (const key in template)
{
if (key in input)
{
object[key] = input[key];
}
else
{
// missing, use the template value
object[key] = template[key];
}
}
return object;
}
function uniqueArrayFromArray(input) function uniqueArrayFromArray(input)
{ {
let unique = []; let unique = [];
@ -185,12 +357,15 @@ function processPotaSpots(buffer)
{ {
if (spots[spot].reference in g_pota.parks) if (spots[spot].reference in g_pota.parks)
{ {
spots[spot].spotTime = Date.parse(spots[spot].spotTime + "Z"); let newSpot = fillObjectFromTemplate(g_spotTemplate, spots[spot]);
spots[spot].expire = (spots[spot].expire * 1000) + spots[spot].spotTime; newSpot.spotTime = Date.parse(newSpot.spotTime + "Z");
spots[spot].frequency = parseInt(spots[spot].frequency) / 1000; newSpot.frequency = parseInt(newSpot.frequency) / 1000;
spots[spot].band = spots[spot].frequency.formatBand(); newSpot.band = newSpot.frequency.formatBand();
(g_pota.callSpots[spots[spot].activator] = g_pota.callSpots[spots[spot].activator] || []).push(spots[spot].reference);
(g_pota.parkSpots[spots[spot].reference] = g_pota.parkSpots[spots[spot].reference] || []).push(spots[spot]); (g_pota.callSpots[newSpot.activator] = g_pota.callSpots[newSpot.activator] || []).push(newSpot.reference);
let hash = newSpot.activator + newSpot.band + newSpot.mode;
(g_pota.parkSpots[newSpot.reference] = g_pota.parkSpots[newSpot.reference] || {})[hash] = newSpot;
} }
else else
{ {
@ -203,11 +378,6 @@ function processPotaSpots(buffer)
{ {
g_pota.callSpots[spot] = uniqueArrayFromArray(g_pota.callSpots[spot]); g_pota.callSpots[spot] = uniqueArrayFromArray(g_pota.callSpots[spot]);
} }
for (const spot in g_pota.parkSpots)
{
g_pota.parkSpots[spot] = uniqueArrayFromArray(g_pota.parkSpots[spot]);
}
redrawParks(); redrawParks();
} }
catch (e) catch (e)
@ -329,10 +499,8 @@ function mouseOverPark(feature)
createParkTipTable(feature); createParkTipTable(feature);
var positionInfo = myParktip.getBoundingClientRect(); mouseParkMove();
myParktip.style.left = getMouseX() - positionInfo.width / 2 + "px";
myParktip.style.top = getMouseY() - positionInfo.height - 22 + "px";
myParktip.style.zIndex = 499; myParktip.style.zIndex = 499;
myParktip.style.display = "block"; myParktip.style.display = "block";
} }
@ -346,8 +514,18 @@ function mouseOutPark(mouseEvent)
function mouseParkMove() function mouseParkMove()
{ {
var positionInfo = myParktip.getBoundingClientRect(); var positionInfo = myParktip.getBoundingClientRect();
var windowWidth = window.innerWidth;
myParktip.style.left = getMouseX() - positionInfo.width / 2 + "px"; myParktip.style.left = getMouseX() - positionInfo.width / 2 + "px";
myParktip.style.top = getMouseY() - positionInfo.height - 22 + "px"; if (windowWidth - getMouseX() < positionInfo.width)
{
myParktip.style.left = getMouseX() - (10 + positionInfo.width) + "px";
}
if (getMouseX() - positionInfo.width < 0)
{
myParktip.style.left = getMouseX() + 10 + "px";
}
myParktip.style.top = getMouseY() - positionInfo.height - 12 + "px";
} }
function createParkTipTable(toolElement) function createParkTipTable(toolElement)
@ -355,7 +533,6 @@ function createParkTipTable(toolElement)
let worker = ""; let worker = "";
let key = toolElement.key; let key = toolElement.key;
let parkObj = g_pota.mapParks[key];
let now = Date.now(); let now = Date.now();
worker += "<div style='background-color:#000;color:lightgreen;font-weight:bold;font-size:12px;border:1px solid gray;margin:0px' class='roundBorder'>" + worker += "<div style='background-color:#000;color:lightgreen;font-weight:bold;font-size:12px;border:1px solid gray;margin:0px' class='roundBorder'>" +

Wyświetl plik

@ -154,9 +154,9 @@ const ROSTER_COLUMNS = {
} }
if (callObj.cnty && callObj.qual == false) if (callObj.cnty && callObj.qual == false)
{ {
attrs.title = "ZIP Code matches multiple counties, click to do a full lookup" attrs.title = "Matches multiple counties, click to do a full lookup"
attrs.onClick = `window.opener.lookupCallsign("${callObj.DEcall}", "${callObj.grid}")` attrs.onClick = `window.opener.lookupCallsign("${callObj.DEcall}", "${callObj.grid}")`
attrs.html = `? ${attrs.html} ?` attrs.html = attrs.html + " +" + String(window.opener.g_zipToCounty[callObj.zipcode].length - 1)
attrs.style = "cursor: pointer; color: cyan;" attrs.style = "cursor: pointer; color: cyan;"
} }
return attrs return attrs
@ -406,7 +406,7 @@ function potaColumnRef(callObj)
let value = callObj.pota[0]; let value = callObj.pota[0];
if (callObj.pota.length > 1) if (callObj.pota.length > 1)
{ {
value += "..."; value += " +" + String(callObj.pota.length - 1);
} }
return value; return value;
} }