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

Wyświetl plik

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

Wyświetl plik

@ -15,7 +15,20 @@ var g_pota = {
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
}
@ -61,9 +74,10 @@ function togglePota()
function redrawParks()
{
g_layerSources.pota.clear();
if (g_potaEnabled == 1)
{
g_layerSources.pota.clear();
g_pota.mapParks = {};
makeParkFeatures();
}
@ -77,17 +91,17 @@ function makeParkFeatures()
{
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])
{
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.key = park;
parkObj.feature.size = 22;
g_pota.mapParks[park] = parkObj;
g_layerSources.pota.addFeature(parkObj.feature);
break;
@ -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)
{
if (g_potaEnabled == 1)
@ -159,6 +312,25 @@ function getPotaParks()
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)
{
let unique = [];
@ -185,12 +357,15 @@ function processPotaSpots(buffer)
{
if (spots[spot].reference in g_pota.parks)
{
spots[spot].spotTime = Date.parse(spots[spot].spotTime + "Z");
spots[spot].expire = (spots[spot].expire * 1000) + spots[spot].spotTime;
spots[spot].frequency = parseInt(spots[spot].frequency) / 1000;
spots[spot].band = spots[spot].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]);
let newSpot = fillObjectFromTemplate(g_spotTemplate, spots[spot]);
newSpot.spotTime = Date.parse(newSpot.spotTime + "Z");
newSpot.frequency = parseInt(newSpot.frequency) / 1000;
newSpot.band = newSpot.frequency.formatBand();
(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
{
@ -203,11 +378,6 @@ function processPotaSpots(buffer)
{
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();
}
catch (e)
@ -329,10 +499,8 @@ function mouseOverPark(feature)
createParkTipTable(feature);
var positionInfo = myParktip.getBoundingClientRect();
myParktip.style.left = getMouseX() - positionInfo.width / 2 + "px";
myParktip.style.top = getMouseY() - positionInfo.height - 22 + "px";
mouseParkMove();
myParktip.style.zIndex = 499;
myParktip.style.display = "block";
}
@ -346,8 +514,18 @@ function mouseOutPark(mouseEvent)
function mouseParkMove()
{
var positionInfo = myParktip.getBoundingClientRect();
var windowWidth = window.innerWidth;
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)
@ -355,9 +533,8 @@ function createParkTipTable(toolElement)
let worker = "";
let key = toolElement.key;
let parkObj = g_pota.mapParks[key];
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'>" +
key +
" : <font color='cyan'>" + g_pota.parks[key].name + "" +

Wyświetl plik

@ -154,9 +154,9 @@ const ROSTER_COLUMNS = {
}
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.html = `? ${attrs.html} ?`
attrs.html = attrs.html + " +" + String(window.opener.g_zipToCounty[callObj.zipcode].length - 1)
attrs.style = "cursor: pointer; color: cyan;"
}
return attrs
@ -406,7 +406,7 @@ function potaColumnRef(callObj)
let value = callObj.pota[0];
if (callObj.pota.length > 1)
{
value += "...";
value += " +" + String(callObj.pota.length - 1);
}
return value;
}