From 7735a9f97b849c6392f7e113ea3a25cdfab8ac92 Mon Sep 17 00:00:00 2001 From: csharpen Date: Fri, 29 Jul 2022 09:06:01 +0000 Subject: [PATCH 1/4] If treating RR73/73 as CQ, soften highlighting to help differentiate foreshadow from an actual CQ --- package.nw/lib/roster/processRosterHunting.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package.nw/lib/roster/processRosterHunting.js b/package.nw/lib/roster/processRosterHunting.js index 3f218d63..a5116c8e 100644 --- a/package.nw/lib/roster/processRosterHunting.js +++ b/package.nw/lib/roster/processRosterHunting.js @@ -786,6 +786,13 @@ function processRosterHunting(callRoster, rosterSettings) { callingBg = calling + inversionAlpha; calling = bold; + // If treating RR73/73 as CQ, soften highlighting to help differentiate foreshadow from an actual CQ + if (callObj.DXcall == "RR73" || callObj.DXcall == "73") + { + callingConf = `${unconf}#90EE90${inversionAlpha};`; + calling = `#90EE90${inversionAlpha};` + callingBg = "#000000" + } } // Assemble all styles From 85ca5399c3a7b5c791e1a023a3b70fd247894513 Mon Sep 17 00:00:00 2001 From: csharpen Date: Fri, 29 Jul 2022 09:13:58 +0000 Subject: [PATCH 2/4] Trailing whitespace fallin' on my head... --- package.nw/lib/roster/processRosterHunting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.nw/lib/roster/processRosterHunting.js b/package.nw/lib/roster/processRosterHunting.js index a5116c8e..e901ea52 100644 --- a/package.nw/lib/roster/processRosterHunting.js +++ b/package.nw/lib/roster/processRosterHunting.js @@ -786,8 +786,8 @@ function processRosterHunting(callRoster, rosterSettings) { callingBg = calling + inversionAlpha; calling = bold; - // If treating RR73/73 as CQ, soften highlighting to help differentiate foreshadow from an actual CQ - if (callObj.DXcall == "RR73" || callObj.DXcall == "73") + // If treating RR73/73 as CQ, soften highlighting to help differentiate foreshadow from an actual CQ + if (callObj.DXcall == "RR73" || callObj.DXcall == "73") { callingConf = `${unconf}#90EE90${inversionAlpha};`; calling = `#90EE90${inversionAlpha};` From 5eb937e646a7a2cce6c76937a6bd6fa657dfb4e5 Mon Sep 17 00:00:00 2001 From: Tag Date: Sun, 7 Aug 2022 10:43:20 -0700 Subject: [PATCH 3/4] Initial commit --- package.nw/lib/gt.js | 224 ++++++++++------------------------------- package.nw/lib/gtws.js | 15 ++- 2 files changed, 67 insertions(+), 172 deletions(-) diff --git a/package.nw/lib/gt.js b/package.nw/lib/gt.js index 30c41121..7d91c4f4 100644 --- a/package.nw/lib/gt.js +++ b/package.nw/lib/gt.js @@ -4665,6 +4665,7 @@ function setStrikesButton() { strikesImg.style.webkitFilter = "grayscale(1)"; } + g_gtLiveStatusUpdate = true; } function toggleStrikesValue() @@ -5210,8 +5211,6 @@ function displayTime() if (g_mapSettings.strikes && g_mapSettings.offlineMode == false) { - if (g_strikeWebSocket == null) loadStrikes(); - var now = Date.now(); for (var time in g_bolts) { @@ -5225,17 +5224,6 @@ function displayTime() else { g_layerSources.strikes.clear(); - if (g_strikeWebSocket != null) - { - try - { - g_strikeWebSocket.close(); - } - catch (e) - { - g_strikeWebSocket = null; - } - } } if (g_currentNightState != g_nightTime) @@ -5382,20 +5370,17 @@ g_lightningGlobal[1] = new ol.style.Icon({ }); var g_bolts = {}; -var g_strikeWebSocket = null; -var g_strikeInterval = null; var g_strikeRange = 0.4; function toggleStrikeGlobal() { - g_mapSettings.strikesGlobal = - g_mapSettings.strikesGlobal == false; + g_mapSettings.strikesGlobal = g_mapSettings.strikesGlobal == false; saveMapSettings(); - var msg = "Local Strikes"; + let msg = "Local Strikes"; if (g_mapSettings.strikesGlobal == true) msg = "Global Strikes"; - var worker = + let worker = "Strike Distance Changed
" + msg + "
"; if (g_mapSettings.strikes == false) { worker += "
Detection is not enabled!"; } addLastTraffic(worker); @@ -5403,169 +5388,68 @@ function toggleStrikeGlobal() g_layerSources.strikes.clear(); } -function setStrikeDistance() +function handleStrike( strike ) { + let index = Date.now(); + while (index in g_bolts) index++; + + let inRange = true; + + if (Math.abs(strike.o - g_myLon) > g_strikeRange) inRange = false; + + if (Math.abs(strike.a - g_myLat) > g_strikeRange) inRange = false; + if ( - g_mapSettings.offlineMode == true && - g_strikeWebSocket != null && - g_strikeWebSocket.readyState != 3 + g_mapSettings.strikesGlobal || + (g_mapSettings.strikesGlobal == false && inRange) ) { - g_strikeWebSocket.close(); - return; + g_bolts[index] = iconFeature( + ol.proj.fromLonLat([strike.o, strike.a]), + inRange ? g_lightningBolt : g_lightningGlobal[0], + 1 + ); + + g_layerSources.strikes.addFeature(g_bolts[index]); } - if (g_strikeWebSocket != null) + if (inRange == true) { - var distance = g_strikeRange; - if (g_mapSettings.strikesGlobal == true) distance = 1000; + playStrikeAlert(); - var send = "{\"west\":-180,\"east\":180,\"north\":-90,\"south\":-90}"; + let dist = + parseInt( + MyCircle.distance( + g_myLat, + g_myLon, + strikes.a, + strikes.o, + distanceUnit.value + ) * MyCircle.validateRadius(distanceUnit.value) + ).toLocaleString() + + " " + + distanceUnit.value.toLowerCase(); + let azim = + parseInt( + MyCircle.bearing(g_myLat, g_myLon, strike.a, strike.o) + ).toLocaleString() + "°"; - if (g_strikeInterval == null) { g_strikeInterval = setInterval(setStrikeDistance, 300000); } + let worker = + "Lighting Strike Detected!
"; + worker += + "" + userTimeString(null) + "
"; + worker += + "Distance: " + + dist + + "
"; + worker += + "Bearing: " + + azim + + ""; - try - { - g_strikeWebSocket.send(send); - } - catch (e) - { - g_strikeWebSocket = null; - } - } - else - { - if (g_strikeInterval != null) - { - clearInterval(g_strikeInterval); - g_strikeInterval = null; - } - } -} - -var g_strikeCount = 0; -function loadStrikes() -{ - if (g_strikeWebSocket) return; - - var rnd = parseInt(Math.random() * 4); - var ws_server = ""; - if (rnd < 1) - { - ws_server = "ws7.blitzortung.org"; - } - else if (rnd < 2) - { - ws_server = "ws6.blitzortung.org"; - } - else if (rnd < 3) - { - ws_server = "ws5.blitzortung.org"; - } - else - { - ws_server = "ws1.blitzortung.org"; + addLastTraffic(worker); } - try - { - g_strikeWebSocket = new WebSocket("wss:///" + ws_server + ":3000"); - } - catch (e) - { - g_strikeWebSocket = null; - return; - } - - g_strikeWebSocket.onopen = function () - { - setStrikeDistance(); - }; - - g_strikeWebSocket.onmessage = function (evt) - { - var Strikes = JSON.parse(evt.data); - Strikes.sig = null; - - if ( - "delay" in Strikes && - "time" in Strikes && - "lat" in Strikes && - "lon" in Strikes - ) - { - var index = Date.now(); - while (index in g_bolts) index++; - - var inRange = true; - - if (Math.abs(Strikes.lon - g_myLon) > g_strikeRange) inRange = false; - - if (Math.abs(Strikes.lat - g_myLat) > g_strikeRange) inRange = false; - - if ( - g_mapSettings.strikesGlobal || - (g_mapSettings.strikesGlobal == false && inRange) - ) - { - g_bolts[index] = iconFeature( - ol.proj.fromLonLat([Strikes.lon, Strikes.lat]), - inRange ? g_lightningBolt : g_lightningGlobal[0], - 1 - ); - - g_layerSources.strikes.addFeature(g_bolts[index]); - } - - if (inRange == true) - { - playStrikeAlert(); - - var dist = - parseInt( - MyCircle.distance( - g_myLat, - g_myLon, - Strikes.lat, - Strikes.lon, - distanceUnit.value - ) * MyCircle.validateRadius(distanceUnit.value) - ).toLocaleString() + - " " + - distanceUnit.value.toLowerCase(); - var azim = - parseInt( - MyCircle.bearing(g_myLat, g_myLon, Strikes.lat, Strikes.lon) - ).toLocaleString() + "°"; - - var worker = - "Lighting Strike Detected!
"; - worker += - "" + userTimeString(null) + "
"; - worker += - "Distance: " + - dist + - "
"; - worker += - "Bearing: " + - azim + - ""; - - addLastTraffic(worker); - } - } - delete evt.data; - }; - - g_strikeWebSocket.onerror = function () - { - g_strikeWebSocket = null; - }; - - g_strikeWebSocket.onclose = function () - { - g_strikeWebSocket = null; - }; } function toggleMouseTrack() diff --git a/package.nw/lib/gtws.js b/package.nw/lib/gtws.js index d98ee678..f6a0a382 100644 --- a/package.nw/lib/gtws.js +++ b/package.nw/lib/gtws.js @@ -9,7 +9,8 @@ var g_chatRecvFunctions = { info: gtChatUpdateCall, drop: gtChatRemoveCall, mesg: gtChatMessage, - o: gtSpotMessage + o: gtSpotMessage, + l: gtLightningStrike }; var ChatState = Object(); @@ -235,8 +236,9 @@ function gtChatSendStatus() msg.mode = myMode; msg.band = myBand; msg.src = "GT"; - msg.canmsg = g_appSettings.gtMsgEnable == true; + msg.canmsg = g_appSettings.gtMsgEnable; msg.o = g_appSettings.gtSpotEnable == true ? 1 : 0; + msg.l = g_mapSettings.strikes == true ? 1 : 0; msg = JSON.stringify(msg); if (msg != g_lastGtStatus) @@ -595,6 +597,15 @@ function gtSpotMessage(jsmesg) addNewOAMSSpot(jsmesg.cid, jsmesg.db); } +function gtLightningStrike(jsmesg) +{ + // Saftey check + if (g_mapSettings.strikes) + { + handleStrike(jsmesg); + } +} + function gtChatSystemInit() { g_gtEngineInterval = setInterval(gtChatStateMachine, 1000); From 3f2a0bbb1a465543bf63f448d21cd519c78177fd Mon Sep 17 00:00:00 2001 From: Tag Date: Sun, 7 Aug 2022 10:48:57 -0700 Subject: [PATCH 4/4] Lint fix --- package.nw/lib/gt.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.nw/lib/gt.js b/package.nw/lib/gt.js index 7d91c4f4..459001d2 100644 --- a/package.nw/lib/gt.js +++ b/package.nw/lib/gt.js @@ -5388,7 +5388,7 @@ function toggleStrikeGlobal() g_layerSources.strikes.clear(); } -function handleStrike( strike ) +function handleStrike(strike) { let index = Date.now(); while (index in g_bolts) index++; @@ -5449,7 +5449,6 @@ function handleStrike( strike ) addLastTraffic(worker); } - } function toggleMouseTrack()