From 813ed47a70e52dab9d278e321959c1c29321bdb4 Mon Sep 17 00:00:00 2001 From: Sebastian Delmont Date: Sun, 13 Dec 2020 21:10:27 -0500 Subject: [PATCH] `npm run lint-fix` --- package.nw/lib/adif.js | 1372 ++++--- package.nw/lib/alerts.js | 545 ++- package.nw/lib/arc.js | 158 +- package.nw/lib/callsigns.js | 415 +- package.nw/lib/datepicker.js | 157 +- package.nw/lib/defaults.js | 38 +- package.nw/lib/fw.js | 94 +- package.nw/lib/gt.js | 6940 ++++++++++++++++++++++------------ package.nw/lib/gtws.js | 378 +- package.nw/lib/protos.js | 41 +- package.nw/lib/roster.js | 2229 +++++++---- package.nw/lib/screens.js | 73 +- package.nw/lib/shadow.js | 168 +- package.nw/lib/stats.js | 136 +- 14 files changed, 8387 insertions(+), 4357 deletions(-) diff --git a/package.nw/lib/adif.js b/package.nw/lib/adif.js index 478fb9a4..738d2954 100644 --- a/package.nw/lib/adif.js +++ b/package.nw/lib/adif.js @@ -4,32 +4,36 @@ var selectStartupLink = null; -function dragOverHandler(ev) { +function dragOverHandler(ev) +{ // Prevent default behavior (Prevent file from being opened) ev.preventDefault(); } -function dropHandler(ev) { +function dropHandler(ev) +{ // Prevent default behavior (Prevent file from being opened) ev.preventDefault(); - if (ev.dataTransfer.items) { + if (ev.dataTransfer.items) + { // Use DataTransferItemList interface to access the file(s) - for (var i = 0; i < ev.dataTransfer.items.length; i++) { + for (var i = 0; i < ev.dataTransfer.items.length; i++) + { // If dropped items aren't files, reject them Entry = ev.dataTransfer.items[i].webkitGetAsEntry(); - if (Entry && typeof Entry.isFile != "undefined" && Entry.isFile == true) { + if (Entry && typeof Entry.isFile != "undefined" && Entry.isFile == true) + { var filename = ev.dataTransfer.items[i].getAsFile().path; var test = filename.toLowerCase(); var valid = test.endsWith(".adi") ? true : test.endsWith(".adif") - ? true - : test.endsWith(".log") - ? true - : test.endsWith(".txt") - ? true - : false; - if (valid && fs.existsSync(filename)) { + ? true + : test.endsWith(".log") + ? true + : !!test.endsWith(".txt"); + if (valid && fs.existsSync(filename)) + { onAdiLoadComplete(fs.readFileSync(filename, "UTF-8"), false); } } @@ -37,13 +41,16 @@ function dropHandler(ev) { } } -function findAdiField(row, field) { +function findAdiField(row, field) +{ var value = ""; var regex = new RegExp("<" + field + ":", "i"); var firstSplitArray = row.split(regex); - if (firstSplitArray && firstSplitArray.length == 2) { + if (firstSplitArray && firstSplitArray.length == 2) + { var secondSplitArray = firstSplitArray[1].split(">"); - if (secondSplitArray.length > 1) { + if (secondSplitArray.length > 1) + { var newLenSearch = secondSplitArray[0].split(":"); var newLen = newLenSearch[0]; value = secondSplitArray[1].slice(0, newLen); @@ -52,7 +59,8 @@ function findAdiField(row, field) { return value; } -function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { +function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) +{ let rawAdiBuffer = ""; if (typeof adiBuffer == "object") rawAdiBuffer = String(adiBuffer); else rawAdiBuffer = adiBuffer; @@ -62,7 +70,8 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { if (rawAdiBuffer.indexOf("PSKReporter") > -1) activeAdifLogMode = false; - if (rawAdiBuffer.length > 1) { + if (rawAdiBuffer.length > 1) + { let regex = new RegExp("", "i"); activeAdifArray = rawAdiBuffer.split(regex); } @@ -70,11 +79,14 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { let dateTime = new Date(); let dupes = 0; - for (let x = 0; x < activeAdifArray.length; x++) { + for (let x = 0; x < activeAdifArray.length; x++) + { let finalMode = ""; - if (activeAdifArray[x].length > 3) { - if (activeAdifLogMode) { + if (activeAdifArray[x].length > 3) + { + if (activeAdifLogMode) + { let confirmed = false; let finalGrid = findAdiField( activeAdifArray[x], @@ -99,7 +111,7 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { g_appSettings.workingCallsignEnable && !(finalDEcall in g_appSettings.workingCallsigns) ) - continue; + { continue; } let finalRSTsent = findAdiField(activeAdifArray[x], "RST_SENT"); let finalRSTrecv = findAdiField(activeAdifArray[x], "RST_RCVD"); let finalBand = findAdiField(activeAdifArray[x], "BAND").toLowerCase(); @@ -122,16 +134,18 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { if (finalCont.length == 0) finalCont = null; let finalCnty = findAdiField(activeAdifArray[x], "CNTY").toUpperCase(); if (finalCnty.length == 0) finalCnty = null; - else { + else + { finalCnty = finalCnty.replaceAll(" ", ""); } let finalMode = findAdiField(activeAdifArray[x], "MODE").toUpperCase(); let subMode = findAdiField(activeAdifArray[x], "SUBMODE"); if (subMode == "FT4" && (finalMode == "MFSK" || finalMode == "DATA")) - finalMode = "FT4"; + { finalMode = "FT4"; } if (subMode == "JS8" && finalMode == "MFSK") finalMode = "JS8"; - if (finalBand == "oob" || finalBand == "") { + if (finalBand == "oob" || finalBand == "") + { finalBand = Number( findAdiField(activeAdifArray[x], "FREQ") ).formatBand(); @@ -142,13 +156,13 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { let finalQslMsgIntl = findAdiField(activeAdifArray[x], "QSLMSG_INTL"); if (finalQslMsg.length > 1) finalMsg = finalQslMsg; if (finalQslMsgIntl.length > 1 && finalMsg == "") - finalMsg = finalQslMsgIntl; + { finalMsg = finalQslMsgIntl; } let finalDxcc = Number(findAdiField(activeAdifArray[x], "DXCC")); if (finalDxcc == 0) finalDxcc = Number(callsignToDxcc(finalDXcall)); if (!(finalDxcc in g_dxccToGeoData)) - finalDxcc = Number(callsignToDxcc(finalDXcall)); + { finalDxcc = Number(callsignToDxcc(finalDXcall)); } // If my callsign isn't present, it must be for me anyway @@ -156,13 +170,13 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { if (finalCqZone.length == 1) finalCqZone = "0" + finalCqZone; if (parseInt(finalCqZone) < 1 || parseInt(finalCqZone) > 40) - finalCqZone = ""; + { finalCqZone = ""; } finalCqZone = String(finalCqZone); let finalItuZone = findAdiField(activeAdifArray[x], "ITUZ"); if (finalItuZone.length == 1) finalItuZone = "0" + finalItuZone; if (parseInt(finalItuZone) < 1 || parseInt(finalItuZone) > 90) - finalItuZone = ""; + { finalItuZone = ""; } finalItuZone = String(finalItuZone); let finalIOTA = findAdiField(activeAdifArray[x], "IOTA").toUpperCase(); @@ -186,7 +200,7 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { lotw_qsl_rcvd == "V" || lotwConfirmed1 == "Y" ) - confirmed = true; + { confirmed = true; } let dateTime = new Date( Date.UTC( @@ -205,24 +219,28 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { g_appSettings.workingDateEnable && finalTime < g_appSettings.workingDate ) - continue; + { continue; } finalGrid = finalGrid.substr(0, 6); if (!validateGridFromString(finalGrid)) finalGrid = ""; - if (finalGrid == "" && vuccGrids != "") { + if (finalGrid == "" && vuccGrids != "") + { finalVucc = vuccGrids.split(","); finalGrid = finalVucc[0]; finalVucc.shift(); } let isDigital = false; let isPhone = false; - if (finalMode in g_modes) { + if (finalMode in g_modes) + { isDigital = g_modes[finalMode]; } - if (finalMode in g_modes_phone) { + if (finalMode in g_modes_phone) + { isPhone = g_modes_phone[finalMode]; } if (finalDXcall != "") + { addDeDx( finalGrid, finalDXcall, @@ -251,7 +269,10 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { finalIOTA, finalSatName ); - } else { + } + } + else + { let finalMyGrid = findAdiField( activeAdifArray[x], "MY_GRIDSQUARE" @@ -271,7 +292,8 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { ).formatBand(); let finalMsg = "-"; let finalDxcc = Number(findAdiField(activeAdifArray[x], "DXCC")); - if (finalDxcc == 0) { + if (finalDxcc == 0) + { if (finalDXcall == myDEcall) finalDxcc = callsignToDxcc(finalDEcall); else finalDxcc = callsignToDxcc(finalDXcall); } @@ -293,8 +315,10 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { finalGrid != "" && finalDXcall != "" && validateGridFromString(finalGrid) - ) { + ) + { if (finalDXcall == myDEcall) + { addDeDx( finalMyGrid, finalDEcall, @@ -317,7 +341,9 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { null, null ); + } else if (finalDEcall == myDEcall) + { addDeDx( finalGrid, finalDXcall, @@ -340,7 +366,9 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { null, null ); + } else + { addDeDx( finalGrid, finalDXcall, @@ -363,6 +391,7 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { null, null ); + } } } } @@ -372,7 +401,8 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { updateCountStats(); updateLogbook(); - if (g_fromDirectCallNoFileDialog == false) { + if (g_fromDirectCallNoFileDialog == false) + { fileSelector.setAttribute("type", ""); fileSelector.setAttribute("type", "file"); fileSelector.setAttribute("accept", ".adi,"); @@ -384,15 +414,22 @@ function onAdiLoadComplete(adiBuffer, saveAdifFile, adifFileName, newFile) { goProcessRoster(); } -function clubLogCallback(buffer, flag, cookie) { +function clubLogCallback(buffer, flag, cookie) +{ var rawAdiBuffer = String(buffer); - if (rawAdiBuffer.indexOf("Invalid login") > -1) { + if (rawAdiBuffer.indexOf("Invalid login") > -1) + { if (flag) clubTestResult.innerHTML = "Invalid"; - } else if (buffer == null) { + } + else if (buffer == null) + { if (flag) clubTestResult.innerHTML = "Unknown Error"; - } else { + } + else + { if (flag) clubTestResult.innerHTML = "Passed"; - else { + else + { g_fromDirectCallNoFileDialog = true; rawAdiBuffer = cleanAndPrepADIF("clublog.adif", rawAdiBuffer); @@ -405,14 +442,16 @@ function clubLogCallback(buffer, flag, cookie) { } var g_isGettingClub = false; -function grabClubLog(test) { - if (g_isGettingClub == false) { +function grabClubLog(test) +{ + if (g_isGettingClub == false) + { if (test) clubTestResult.innerHTML = "Testing"; var postData = { email: clubEmail.value, password: clubPassword.value, - call: clubCall.value, + call: clubCall.value }; getAPostBuffer( "https://clublog.org/getadif.php", @@ -427,22 +466,30 @@ function grabClubLog(test) { } } -function tryToWriteAdifToDocFolder(filename, buffer, append = false) { +function tryToWriteAdifToDocFolder(filename, buffer, append = false) +{ var finalFile = g_appData + g_dirSeperator + filename; - try { - if (append == false) { + try + { + if (append == false) + { fs.writeFileSync(finalFile, buffer); return buffer; - } else { + } + else + { fs.appendFileSync(finalFile, buffer); return fs.readFileSync(finalFile); } - } catch (e) { + } + catch (e) + { return false; } } -function cleanAndPrepADIF(name, adiBuffer, reverse = false, noheader = false) { +function cleanAndPrepADIF(name, adiBuffer, reverse = false, noheader = false) +{ var rawAdiBuffer = adiBuffer; var regex = new RegExp("", "i"); rawAdiBuffer = rawAdiBuffer.replace(regex, ""); @@ -454,17 +501,23 @@ function cleanAndPrepADIF(name, adiBuffer, reverse = false, noheader = false) { if (noheader == false) finalBuffer = name + "\r\n"; - if (adiArray.length > 1) { + if (adiArray.length > 1) + { regex = new RegExp("", "i"); activeAdifArray = adiArray[1].split(regex); - if (reverse == false) { - for (var x = 0; x < activeAdifArray.length - 1; x++) { + if (reverse == false) + { + for (var x = 0; x < activeAdifArray.length - 1; x++) + { var row = activeAdifArray[x].replace(/[\n\r]/g, ""); if (row.length > 0) finalBuffer += row + "\r\n"; } - } else { - for (var x = activeAdifArray.length - 1; x > -1; x--) { + } + else + { + for (var x = activeAdifArray.length - 1; x > -1; x--) + { var row = activeAdifArray[x].replace(/[\n\r]/g, ""); if (row.length > 0) finalBuffer += row + "\r\n"; } @@ -474,14 +527,17 @@ function cleanAndPrepADIF(name, adiBuffer, reverse = false, noheader = false) { return finalBuffer; } -function addZero(i) { - if (i < 10) { +function addZero(i) +{ + if (i < 10) + { i = "0" + i; } return i; } -function getUTCString(d) { +function getUTCString(d) +{ var Y = d.getUTCFullYear(); var M = addZero(d.getUTCMonth() + 1); var D = addZero(d.getUTCDate()); @@ -491,13 +547,18 @@ function getUTCString(d) { return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s; } -function lotwCallback(buffer, flag) { +function lotwCallback(buffer, flag) +{ var rawAdiBuffer = String(buffer); - if (rawAdiBuffer.indexOf("password incorrect") > -1) { + if (rawAdiBuffer.indexOf("password incorrect") > -1) + { if (flag) lotwTestResult.innerHTML = "Invalid"; - } else { + } + else + { if (flag) lotwTestResult.innerHTML = "Passed"; - else { + else + { var shouldAppend = false; g_fromDirectCallNoFileDialog = true; @@ -519,34 +580,45 @@ function lotwCallback(buffer, flag) { } } -function shouldWeAppendInsteadOfCreate(filename) { +function shouldWeAppendInsteadOfCreate(filename) +{ var finalFile = g_appData + g_dirSeperator + filename; - try { + try + { if (fs.existsSync(finalFile)) return true; else return false; - } catch (e) { + } + catch (e) + { return false; } } -function tryToDeleteLog(filename) { +function tryToDeleteLog(filename) +{ var finalFile = g_appData + g_dirSeperator + filename; - try { - if (fs.existsSync(finalFile)) { + try + { + if (fs.existsSync(finalFile)) + { fs.unlinkSync(finalFile); } - } catch (e) {} + } + catch (e) {} } var g_lotwCount = 0; var g_isGettingLOTW = false; -function grabLOtWLog(test) { - if (g_isGettingLOTW == false) { +function grabLOtWLog(test) +{ + if (g_isGettingLOTW == false) + { var lastQSLDateString = "&qso_qsorxsince=1945-01-01&qso_qslsince=1945-01-01"; - if (test == true) { + if (test == true) + { lotwTestResult.innerHTML = "Testing"; lastQSLDateString = "&qso_qsosince=2100-01-01"; } @@ -569,13 +641,20 @@ function grabLOtWLog(test) { } } -function qrzCallback(buffer, flag) { - if (buffer.indexOf("invalid api key") > -1) { +function qrzCallback(buffer, flag) +{ + if (buffer.indexOf("invalid api key") > -1) + { if (flag) qrzTestResult.innerHTML = "Invalid"; - } else { - if (flag) { + } + else + { + if (flag) + { qrzTestResult.innerHTML = "Passed"; - } else { + } + else + { g_fromDirectCallNoFileDialog = true; var htmlString = String(buffer).replace(/</g, "<"); htmlString = htmlString.replace(/>/g, ">"); @@ -591,10 +670,13 @@ function qrzCallback(buffer, flag) { } var g_isGettingQRZCom = false; -function grabQrzComLog(test) { - if (g_isGettingQRZCom == false) { +function grabQrzComLog(test) +{ + if (g_isGettingQRZCom == false) + { var action = "FETCH"; - if (test) { + if (test) + { qrzTestResult.innerHTML = "Testing"; action = "STATUS"; } @@ -615,28 +697,37 @@ function grabQrzComLog(test) { } } -function ValidateQrzApi(inputText) { +function ValidateQrzApi(inputText) +{ inputText.value = inputText.value.toUpperCase(); - if (inputText.value.length == 19) { + if (inputText.value.length == 19) + { var passed = false; var dashcount = 0; - for (var i = 0; i < inputText.value.length; i++) { + for (var i = 0; i < inputText.value.length; i++) + { if (inputText.value[i] == "-") dashcount++; } - if (dashcount == 3) { + if (dashcount == 3) + { passed = true; } - if (passed) { + if (passed) + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; return true; - } else { + } + else + { inputText.style.color = "white"; inputText.style.backgroundColor = "red"; return false; } - } else { + } + else + { inputText.style.color = "white"; inputText.style.backgroundColor = "red"; @@ -644,19 +735,24 @@ function ValidateQrzApi(inputText) { } } -function ValidateText(inputText) { - if (inputText.value.length > 0) { +function ValidateText(inputText) +{ + if (inputText.value.length > 0) + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; return true; - } else { + } + else + { inputText.style.color = "white"; inputText.style.backgroundColor = "red"; return false; } } -function pskCallback(buffer, flag) { +function pskCallback(buffer, flag) +{ g_fromDirectCallNoFileDialog = true; var rawAdiBuffer = String(buffer); @@ -665,10 +761,12 @@ function pskCallback(buffer, flag) { var g_isGettingPsk = false; -function grabPsk24() { +function grabPsk24() +{ if (g_isGettingPsk == true) return; - if (myDEcall.length > 0 && myDEcall != "NOCALL") { + if (myDEcall.length > 0 && myDEcall != "NOCALL") + { var days = 1; if (pskImg.src == 1) days = 7; getABuffer( @@ -686,12 +784,16 @@ function grabPsk24() { } } -function adifMenuCheckBoxChanged(what) { - g_adifLogSettings["menu"][what.id] = what.checked; +function adifMenuCheckBoxChanged(what) +{ + g_adifLogSettings.menu[what.id] = what.checked; var menuItem = what.id + "Div"; - if (what.checked == true) { + if (what.checked == true) + { document.getElementById(menuItem).style.display = "inline-block"; - } else { + } + else + { document.getElementById(menuItem).style.display = "none"; } @@ -700,20 +802,26 @@ function adifMenuCheckBoxChanged(what) { if (what == buttonAdifCheckBox) setAdifStartup(loadAdifCheckBox); } -function adifStartupCheckBoxChanged(what) { - g_adifLogSettings["startup"][what.id] = what.checked; +function adifStartupCheckBoxChanged(what) +{ + g_adifLogSettings.startup[what.id] = what.checked; localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); if (what == loadAdifCheckBox) setAdifStartup(loadAdifCheckBox); } -function adifLogQsoCheckBoxChanged(what) { - g_adifLogSettings["qsolog"][what.id] = what.checked; - if (what.id == "logLOTWqsoCheckBox") { - if (what.checked == true) { +function adifLogQsoCheckBoxChanged(what) +{ + g_adifLogSettings.qsolog[what.id] = what.checked; + if (what.id == "logLOTWqsoCheckBox") + { + if (what.checked == true) + { lotwUpload.style.display = "inline-block"; trustedTestButton.style.display = "inline-block"; - } else { + } + else + { lotwUpload.style.display = "none"; trustedTestButton.style.display = "none"; } @@ -721,34 +829,44 @@ function adifLogQsoCheckBoxChanged(what) { localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); } -function adifNicknameCheckBoxChanged(what) { - g_adifLogSettings["nickname"][what.id] = what.checked; - if (what.id == "nicknameeQSLCheckBox") { - if (what.checked == true) { +function adifNicknameCheckBoxChanged(what) +{ + g_adifLogSettings.nickname[what.id] = what.checked; + if (what.id == "nicknameeQSLCheckBox") + { + if (what.checked == true) + { eQSLNickname.style.display = "inline-block"; - } else { + } + else + { eQSLNickname.style.display = "none"; } } localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); } -function adifTextValueChange(what) { - g_adifLogSettings["text"][what.id] = what.value; +function adifTextValueChange(what) +{ + g_adifLogSettings.text[what.id] = what.value; localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); } var fileSelector = document.createElement("input"); fileSelector.setAttribute("type", "file"); fileSelector.setAttribute("accept", ".adi,.adif"); -fileSelector.onchange = function () { - if (this.files && this.files[0]) { +fileSelector.onchange = function () +{ + if (this.files && this.files[0]) + { path = this.value.replace(this.files[0].name, ""); fileSelector.setAttribute("nwworkingdir", path); var reader = new FileReader(); - reader.onload = function (e) { - if (e.target.error == null) { + reader.onload = function (e) + { + if (e.target.error == null) + { onAdiLoadComplete(e.target.result, false); } }; @@ -757,7 +875,8 @@ fileSelector.onchange = function () { } }; -function adifLoadDialog() { +function adifLoadDialog() +{ var exists = fileSelector.getAttribute("nwworkingdir"); fileSelector.setAttribute("nwworkingdir", g_appData); @@ -770,9 +889,12 @@ function adifLoadDialog() { var startupFileSelector = document.createElement("input"); startupFileSelector.setAttribute("type", "file"); startupFileSelector.setAttribute("accept", ".adi,.adif"); -startupFileSelector.onchange = function () { - if (this.files && this.files[0]) { - for (var i in g_startupLogs) { +startupFileSelector.onchange = function () +{ + if (this.files && this.files[0]) + { + for (var i in g_startupLogs) + { if (this.value == g_startupLogs[i].file) return; } var newObject = Object(); @@ -788,8 +910,10 @@ startupFileSelector.onchange = function () { } }; -function start_and_end(str) { - if (str.length > 31) { +function start_and_end(str) +{ + if (str.length > 31) + { return ( str.substr(0, 16) + " ... " + str.substr(str.length - 15, str.length) ); @@ -797,13 +921,16 @@ function start_and_end(str) { return str; } -function setFileSelectors() { +function setFileSelectors() +{ selectStartupLink = document.getElementById("selectAdifButton"); - selectStartupLink.onclick = function () { + selectStartupLink.onclick = function () + { var exists = startupFileSelector.getAttribute("nwworkingdir"); - if (exists == null) { + if (exists == null) + { if (g_workingIniPath.length > 1) - startupFileSelector.setAttribute("nwworkingdir", g_appData); + { startupFileSelector.setAttribute("nwworkingdir", g_appData); } } startupFileSelector.click(); @@ -811,7 +938,8 @@ function setFileSelectors() { }; selectTqsl = document.getElementById("selectTQSLButton"); - selectTqsl.onclick = function () { + selectTqsl.onclick = function () + { tqslFileSelector.click(); return false; }; @@ -821,8 +949,10 @@ function setFileSelectors() { var tqslFileSelector = document.createElement("input"); tqslFileSelector.setAttribute("type", "file"); tqslFileSelector.setAttribute("accept", "*"); -tqslFileSelector.onchange = function () { - if (this.files && this.files[0]) { +tqslFileSelector.onchange = function () +{ + if (this.files && this.files[0]) + { g_trustedQslSettings.binaryFile = this.files[0].path; var fs = require("fs"); @@ -830,13 +960,18 @@ tqslFileSelector.onchange = function () { fs.existsSync(g_trustedQslSettings.binaryFile) && (g_trustedQslSettings.binaryFile.endsWith("tqsl.exe") || g_trustedQslSettings.binaryFile.endsWith("tqsl")) - ) { + ) + { g_trustedQslSettings.binaryFileValid = true; - } else g_trustedQslSettings.binaryFileValid = false; + } + else g_trustedQslSettings.binaryFileValid = false; - if (g_trustedQslSettings.binaryFileValid == true) { + if (g_trustedQslSettings.binaryFileValid == true) + { tqslFileDiv.style.backgroundColor = "blue"; - } else { + } + else + { tqslFileDiv.style.backgroundColor = "red"; } @@ -845,10 +980,12 @@ tqslFileSelector.onchange = function () { } }; -function loadGtQSOLogFile() { +function loadGtQSOLogFile() +{ var fs = require("fs"); - if (fs.existsSync(g_qsoLogFile)) { + if (fs.existsSync(g_qsoLogFile)) + { var rawAdiBuffer = fs.readFileSync(g_qsoLogFile); g_fromDirectCallNoFileDialog = true; @@ -857,47 +994,62 @@ function loadGtQSOLogFile() { } } -function loadWsjtLogFile() { +function loadWsjtLogFile() +{ var fs = require("fs"); - if (fs.existsSync(g_workingIniPath + "wsjtx_log.adi")) { + if (fs.existsSync(g_workingIniPath + "wsjtx_log.adi")) + { var rawAdiBuffer = fs.readFileSync(g_workingIniPath + "wsjtx_log.adi"); g_fromDirectCallNoFileDialog = true; onAdiLoadComplete(rawAdiBuffer, false); } } -function findTrustedQSLPaths() { +function findTrustedQSLPaths() +{ var process = require("process"); var base = null; - if (g_trustedQslSettings.stationFileValid == true) { + if (g_trustedQslSettings.stationFileValid == true) + { // double check the presence of the station_data; - if (!fs.existsSync(g_trustedQslSettings.stationFile)) { + if (!fs.existsSync(g_trustedQslSettings.stationFile)) + { g_trustedQslSettings.stationFileValid = false; } } - if (g_trustedQslSettings.stationFileValid == false) { - if (g_platform == "windows") { + if (g_trustedQslSettings.stationFileValid == false) + { + if (g_platform == "windows") + { base = process.env.APPDATA + "\\TrustedQSL\\station_data"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.stationFile = base; g_trustedQslSettings.stationFileValid = true; - } else { + } + else + { base = process.env.LOCALAPPDATA + "\\TrustedQSL\\station_data"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.stationFile = base; g_trustedQslSettings.stationFileValid = true; } } - } else { + } + else + { base = process.env.HOME + "/.tqsl/station_data"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.stationFile = base; g_trustedQslSettings.stationFileValid = true; } } } - if (g_trustedQslSettings.stationFileValid == true) { + if (g_trustedQslSettings.stationFileValid == true) + { var validate = false; var option = document.createElement("option"); option.value = ""; @@ -908,69 +1060,95 @@ function findTrustedQSLPaths() { parser = new DOMParser(); xmlDoc = parser.parseFromString(buffer, "text/xml"); var x = xmlDoc.getElementsByTagName("StationData"); - for (var i = 0; i < x.length; i++) { + for (var i = 0; i < x.length; i++) + { option = document.createElement("option"); option.value = x[i].getAttribute("name"); option.text = x[i].getAttribute("name"); - if (option.value == g_adifLogSettings.text.lotwStation) { + if (option.value == g_adifLogSettings.text.lotwStation) + { option.selected = true; validate = true; } lotwStation.appendChild(option); } - if (validate) { + if (validate) + { ValidateText(lotwStation); } } - if (g_trustedQslSettings.binaryFileValid == true) { + if (g_trustedQslSettings.binaryFileValid == true) + { // double check the presence of the TrustedQSL binary; - if (!fs.existsSync(g_trustedQslSettings.binaryFile)) { + if (!fs.existsSync(g_trustedQslSettings.binaryFile)) + { g_trustedQslSettings.binaryFileValid = false; } } - if (g_trustedQslSettings.binaryFileValid == false || g_platform == "mac") { - if (g_platform == "windows") { + if (g_trustedQslSettings.binaryFileValid == false || g_platform == "mac") + { + if (g_platform == "windows") + { base = process.env["ProgramFiles(x86)"] + "\\TrustedQSL\\tqsl.exe"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; } - } else if (g_platform == "mac") { + } + else if (g_platform == "mac") + { base = "/Applications/TrustedQSL/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = process.env.HOME + "/Applications/TrustedQSL/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = process.env.HOME + "/Applications/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = "/Applications/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = process.env.HOME + "/Desktop/TrustedQSL/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = process.env.HOME + "/Applications/Ham Radio/tqsl.app/Contents/MacOS/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; } @@ -979,14 +1157,20 @@ function findTrustedQSLPaths() { } } } - } else if (g_platform == "linux") { + } + else if (g_platform == "linux") + { base = "/usr/bin/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; - } else { + } + else + { base = "/usr/local/bin/tqsl"; - if (fs.existsSync(base)) { + if (fs.existsSync(base)) + { g_trustedQslSettings.binaryFile = base; g_trustedQslSettings.binaryFileValid = true; } @@ -996,44 +1180,58 @@ function findTrustedQSLPaths() { localStorage.trustedQslSettings = JSON.stringify(g_trustedQslSettings); } -function startupAdifLoadFunction() { +function startupAdifLoadFunction() +{ var fs = require("fs"); - for (var i in g_startupLogs) { - try { - if (fs.existsSync(g_startupLogs[i].file)) { + for (var i in g_startupLogs) + { + try + { + if (fs.existsSync(g_startupLogs[i].file)) + { var rawAdiBuffer = fs.readFileSync(g_startupLogs[i].file); g_fromDirectCallNoFileDialog = true; onAdiLoadComplete(rawAdiBuffer, false); } - } catch (e) {} + } + catch (e) {} } } -function setAdifStartup(checkbox) { +function setAdifStartup(checkbox) +{ if (g_trustedQslSettings.binaryFile == null) - g_trustedQslSettings.binaryFile = ""; + { g_trustedQslSettings.binaryFile = ""; } if ( g_trustedQslSettings.binaryFile.endsWith("tqsl.exe") || g_trustedQslSettings.binaryFile.endsWith("tqsl") - ) { + ) + { g_trustedQslSettings.binaryFileValid = true; - } else g_trustedQslSettings.binaryFileValid = false; + } + else g_trustedQslSettings.binaryFileValid = false; - if (g_trustedQslSettings.binaryFileValid == true) { + if (g_trustedQslSettings.binaryFileValid == true) + { tqslFileDiv.style.backgroundColor = "blue"; - } else { + } + else + { tqslFileDiv.style.backgroundColor = "red"; } tqslFileDiv.innerHTML = "" + start_and_end(g_trustedQslSettings.binaryFile) + ""; - if (buttonAdifCheckBox.checked || loadAdifCheckBox.checked) { + if (buttonAdifCheckBox.checked || loadAdifCheckBox.checked) + { var worker = ""; - if (g_startupLogs.length > 0) { + if (g_startupLogs.length > 0) + { worker += ""; - for (var i in g_startupLogs) { + for (var i in g_startupLogs) + { worker += ""; } worker += "
"; - } else { + } + else + { worker = "No file(s) selected"; } startupLogFileDiv.innerHTML = worker; selectFileOnStartupDiv.style.display = "block"; - } else { + } + else + { startupLogFileDiv.innerHTML = "No file(s) selected"; startupFileSelector.setAttribute("type", ""); startupFileSelector.setAttribute("type", "file"); @@ -1059,15 +1261,18 @@ function setAdifStartup(checkbox) { } } -function removeStartupLog(i) { - if (i in g_startupLogs) { +function removeStartupLog(i) +{ + if (i in g_startupLogs) + { g_startupLogs.splice(i, 1); localStorage.startupLogs = JSON.stringify(g_startupLogs); setAdifStartup(loadAdifCheckBox); } } -function startupAdifLoadCheck() { +function startupAdifLoadCheck() +{ logEventMedia.value = g_alertSettings.logEventMedia; loadWsjtLogFile(); @@ -1075,9 +1280,10 @@ function startupAdifLoadCheck() { if (loadGTCheckBox.checked == true) loadGtQSOLogFile(); if (loadAdifCheckBox.checked == true && g_startupLogs.length > 0) - startupAdifLoadFunction(); + { startupAdifLoadFunction(); } - if (g_mapSettings.offlineMode == false) { + if (g_mapSettings.offlineMode == false) + { if (g_appSettings.gtFlagImgSrc == 1) showGtFlags(); if (loadLOTWCheckBox.checked == true) grabLOtWLog(false); @@ -1099,7 +1305,8 @@ function getABuffer( imgToGray, stringOfFlag, timeoutX -) { +) +{ let url = require("url"); let http = require(mode); let fileBuffer = null; @@ -1113,24 +1320,28 @@ function getABuffer( }; if (typeof stringOfFlag != "undefined") window[stringOfFlag] = true; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = "linear-gradient(grey 0%, black 0% 100% )"; imgToGray.style.webkitFilter = "invert(100%) grayscale(1)"; } - let req = http.request(options, function (res) { + let req = http.request(options, function (res) + { let fsize = res.headers["content-length"]; let cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { let percent = 0; if (fsize > 0) percent = parseInt((fileBuffer.length / fsize) * 100); else percent = parseInt(((fileBuffer.length / 100000) * 100) % 100); @@ -1142,41 +1353,53 @@ function getABuffer( "% 100% )"; } }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cookies); } - if (typeof stringOfFlag != "undefined") { + if (typeof stringOfFlag != "undefined") + { window[stringOfFlag] = false; } - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } }) - .on("error", function () { - if (typeof stringOfFlag != "undefined") { + .on("error", function () + { + if (typeof stringOfFlag != "undefined") + { window[stringOfFlag] = false; } - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } }); }); - req.on("socket", function (socket) { - socket.on("timeout", function () { + req.on("socket", function (socket) + { + socket.on("timeout", function () + { req.abort(); }); }); - req.on("error", function () { - if (typeof stringOfFlag != "undefined") { + req.on("error", function () + { + if (typeof stringOfFlag != "undefined") + { window[stringOfFlag] = false; } - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } @@ -1194,7 +1417,8 @@ function getAPostBuffer( theData, imgToGray, stringOfFlag -) { +) +{ var querystring = require("querystring"); var postData = querystring.stringify(theData); var url = require("url"); @@ -1208,30 +1432,34 @@ function getAPostBuffer( method: "post", headers: { "Content-Type": "application/x-www-form-urlencoded", - "Content-Length": postData.length, - }, + "Content-Length": postData.length + } }; window[stringOfFlag] = true; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = "linear-gradient(grey 0%, black 0% 100% )"; imgToGray.style.webkitFilter = "invert(100%) grayscale(1)"; } - var req = http.request(options, function (res) { + var req = http.request(options, function (res) + { var fsize = res.headers["content-length"]; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { var percent = 0; if (fsize > 0) percent = parseInt((fileBuffer.length / fsize) * 100); else percent = parseInt(((fileBuffer.length / 100000) * 100) % 100); @@ -1244,35 +1472,44 @@ function getAPostBuffer( "% 100% )"; } }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cookies); window[stringOfFlag] = false; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } } }) - .on("error", function () { + .on("error", function () + { window[stringOfFlag] = false; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } }); }); - req.on("socket", function (socket) { - socket.on("timeout", function () { + req.on("socket", function (socket) + { + socket.on("timeout", function () + { req.abort(); }); }); - req.on("error", function (err) { // eslint-disable-line node/handle-callback-err + req.on("error", function (err) // eslint-disable-line node/handle-callback-err + { window[stringOfFlag] = false; - if (typeof imgToGray != "undefined") { + if (typeof imgToGray != "undefined") + { imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } @@ -1282,41 +1519,51 @@ function getAPostBuffer( req.end(); } -function sendUdpMessage(msg, length, port, address) { +function sendUdpMessage(msg, length, port, address) +{ var dgram = require("dgram"); var socket = dgram.createSocket({ type: "udp4", reuseAddr: true }); - socket.send(msg, 0, length, port, address, (err) => { // eslint-disable-line node/handle-callback-err + socket.send(msg, 0, length, port, address, (err) => // eslint-disable-line node/handle-callback-err + { socket.close(); }); } -function sendTcpMessage(msg, length, port, address) { +function sendTcpMessage(msg, length, port, address) +{ var net = require("net"); var client = new net.Socket(); client.setTimeout(30000); - client.connect(port, address, function () { + client.connect(port, address, function () + { client.write(msg); }); client.on("close", function () {}); } -function valueToAdiField(field, value) { +function valueToAdiField(field, value) +{ var adi = "<" + field + ":"; adi += String(value).length + ">"; adi += String(value) + " "; return adi; } -function pad(value) { - if (value < 10) { +function pad(value) +{ + if (value < 10) + { return "0" + value; - } else { + } + else + { return value; } } -function HMSfromMilli(milli) { +function HMSfromMilli(milli) +{ var seconds = parseInt(milli / 1000); var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -1329,7 +1576,8 @@ function HMSfromMilli(milli) { return String(val); } -function colonHMSfromMilli(milli) { +function colonHMSfromMilli(milli) +{ var seconds = parseInt(milli / 1000); var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -1342,7 +1590,8 @@ function colonHMSfromMilli(milli) { return String(val); } -function colonHMSfromSeconds(secondsIn) { +function colonHMSfromSeconds(secondsIn) +{ var seconds = secondsIn; var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -1355,7 +1604,8 @@ function colonHMSfromSeconds(secondsIn) { return String(val); } -function convertToDate(julian) { +function convertToDate(julian) +{ var DAY = 86400000; var HALF_DAY = DAY / 2; var UNIX_EPOCH_JULIAN_DATE = 2440587.5; @@ -1369,7 +1619,8 @@ var lastReportHash = null; var g_oldStyleLogMessage = null; -function oldSendToLogger() { +function oldSendToLogger() +{ var newMessage = Object.assign({}, g_oldStyleLogMessage); var band = Number(newMessage.Frequency / 1000000).formatBand(); @@ -1377,7 +1628,8 @@ function oldSendToLogger() { if ( newMessage.DXGrid.length == 0 && newMessage.DXCall + band + newMessage.MO in g_liveCallsigns - ) { + ) + { newMessage.DXGrid = g_liveCallsigns[ newMessage.DXCall + band + newMessage.MO ].grid.substr(0, 4); @@ -1417,24 +1669,29 @@ function oldSendToLogger() { report += valueToAdiField("GRIDSQUARE", newMessage.DXGrid); if (newMessage.Comments.length > 0) - report += valueToAdiField("COMMENT", newMessage.Comments); + { report += valueToAdiField("COMMENT", newMessage.Comments); } if (newMessage.Name.length > 0) - report += valueToAdiField("NAME", newMessage.Name); + { report += valueToAdiField("NAME", newMessage.Name); } - if (newMessage.Operatorcall.length > 0) { + if (newMessage.Operatorcall.length > 0) + { report += valueToAdiField("OPERATOR", newMessage.Operatorcall); } - if (newMessage.Mycall.length > 0) { + if (newMessage.Mycall.length > 0) + { report += valueToAdiField("STATION_CALLSIGN", newMessage.Mycall); - } else if (myDEcall != "NOCALL" && myDEcall.length > 0) - report += valueToAdiField("STATION_CALLSIGN", myDEcall); + } + else if (myDEcall != "NOCALL" && myDEcall.length > 0) + { report += valueToAdiField("STATION_CALLSIGN", myDEcall); } - if (newMessage.Mygrid.length > 0) { + if (newMessage.Mygrid.length > 0) + { report += valueToAdiField("MY_GRIDSQUARE", newMessage.Mygrid); - } else if (myDEGrid.length > 1) - report += valueToAdiField("MY_GRIDSQUARE", myDEGrid); + } + else if (myDEGrid.length > 1) + { report += valueToAdiField("MY_GRIDSQUARE", myDEGrid); } report += ""; @@ -1449,115 +1706,138 @@ var g_adifLookupMap = { cqzone: "CQZ", ituzone: "ITUZ", email: "EMAIL", - county: "CNTY", + county: "CNTY" }; -function sendToLogger(ADIF) { +function sendToLogger(ADIF) +{ let regex = new RegExp("", "i"); let record = parseADIFRecord(ADIF.split(regex)[1]); - let localMode = record["MODE"]; + let localMode = record.MODE; - if (localMode == "MFSK" && "SUBMODE" in record) { - localMode = record["SUBMODE"]; + if (localMode == "MFSK" && "SUBMODE" in record) + { + localMode = record.SUBMODE; } if ( - (!("GRIDSQUARE" in record) || record["GRIDSQUARE"].length == 0) && - record["CALL"] + record["BAND"] + localMode in g_liveCallsigns - ) { - record["GRIDSQUARE"] = g_liveCallsigns[ - record["CALL"] + record["BAND"] + localMode + (!("GRIDSQUARE" in record) || record.GRIDSQUARE.length == 0) && + record.CALL + record.BAND + localMode in g_liveCallsigns + ) + { + record.GRIDSQUARE = g_liveCallsigns[ + record.CALL + record.BAND + localMode ].grid.substr(0, 4); } - if ("TX_PWR" in record) { - record["TX_PWR"] = String(parseInt(record["TX_PWR"])); + if ("TX_PWR" in record) + { + record.TX_PWR = String(parseInt(record.TX_PWR)); } if ( (!("STATION_CALLSIGN" in record) || - record["STATION_CALLSIGN"].length == 0) && + record.STATION_CALLSIGN.length == 0) && myDEcall != "NOCALL" && myDEcall.length > 0 - ) { - record["STATION_CALLSIGN"] = myDEcall; + ) + { + record.STATION_CALLSIGN = myDEcall; } if ( - (!("MY_GRIDSQUARE" in record) || record["MY_GRIDSQUARE"].length == 0) && + (!("MY_GRIDSQUARE" in record) || record.MY_GRIDSQUARE.length == 0) && myDEGrid.length > 1 - ) { - record["MY_GRIDSQUARE"] = myDEGrid; + ) + { + record.MY_GRIDSQUARE = myDEGrid; } - if (!("DXCC" in record)) { - let dxcc = callsignToDxcc(record["CALL"]); + if (!("DXCC" in record)) + { + let dxcc = callsignToDxcc(record.CALL); if (dxcc == -1) dxcc = 0; - record["DXCC"] = String(dxcc); + record.DXCC = String(dxcc); } - if (!("COUNTRY" in record) && Number(record["DXCC"]) > 0) { - record["COUNTRY"] = g_dxccToADIFName[Number(record["DXCC"])]; + if (!("COUNTRY" in record) && Number(record.DXCC) > 0) + { + record.COUNTRY = g_dxccToADIFName[Number(record.DXCC)]; } - if (g_appSettings.lookupMerge == true) { + if (g_appSettings.lookupMerge == true) + { let request = g_Idb .transaction(["lookups"], "readwrite") .objectStore("lookups") - .get(record["CALL"]); + .get(record.CALL); - request.onsuccess = function (event) { - if (request.result) { + request.onsuccess = function (event) + { + if (request.result) + { let lookup = request.result; - for (let key in lookup) { - if (key in g_adifLookupMap) { + for (let key in lookup) + { + if (key in g_adifLookupMap) + { record[g_adifLookupMap[key]] = lookup[key]; } } - if ("GRIDSQUARE" in record && "grid" in lookup) { + if ("GRIDSQUARE" in record && "grid" in lookup) + { if ( - record["GRIDSQUARE"].substr(0, 4) == lookup["grid"].substr(0, 4) - ) { - record["GRIDSQUARE"] = lookup["grid"]; + record.GRIDSQUARE.substr(0, 4) == lookup.grid.substr(0, 4) + ) + { + record.GRIDSQUARE = lookup.grid; } } if ( g_appSettings.lookupMissingGrid && "grid" in lookup && - (!("GRIDSQUARE" in record) || record["GRIDSQUARE"].length == 0) - ) { - record["GRIDSQUARE"] = lookup["grid"]; + (!("GRIDSQUARE" in record) || record.GRIDSQUARE.length == 0) + ) + { + record.GRIDSQUARE = lookup.grid; } } finishSendingReport(record, localMode); }; - request.onerror = function (event) { + request.onerror = function (event) + { finishSendingReport(record, localMode); }; - } else { + } + else + { finishSendingReport(record, localMode); } } -function finishSendingReport(record, localMode) { +function finishSendingReport(record, localMode) +{ let report = ""; - let reportHash = record["CALL"] + record["MODE"] + localMode; + let reportHash = record.CALL + record.MODE + localMode; - for (let key in record) { + for (let key in record) + { report += "<" + key + ":" + record[key].length + ">" + record[key] + " "; } report += ""; - if (reportHash != lastReportHash) { + if (reportHash != lastReportHash) + { lastReportHash = reportHash; if ( g_N1MMSettings.enable == true && g_N1MMSettings.port > 1024 && g_N1MMSettings.ip.length > 4 - ) { + ) + { sendUdpMessage( report, report.length, @@ -1571,7 +1851,8 @@ function finishSendingReport(record, localMode) { g_log4OMSettings.enable == true && g_log4OMSettings.port > 1024 && g_log4OMSettings.ip.length > 4 - ) { + ) + { sendUdpMessage( "ADD " + report, report.length + 4, @@ -1581,47 +1862,66 @@ function finishSendingReport(record, localMode) { addLastTraffic("Logged to Log4OM"); } - try { + try + { onAdiLoadComplete("GT" + report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception Internal Log"); } - try { + try + { // Log worthy - if (logGTqsoCheckBox.checked == true) { + if (logGTqsoCheckBox.checked == true) + { var fs = require("fs"); fs.appendFileSync(g_qsoLogFile, report + "\r\n"); addLastTraffic( "Logged to GridTracker backup" ); } - } catch (e) { + } + catch (e) + { addLastTraffic( "Exception GridTracker backup" ); } - try { + try + { sendQrzLogEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception QRZ Log"); } - try { + try + { sendClubLogEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception ClubLog Log"); } - try { + try + { sendHrdLogEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception HrdLog.net Log"); } - try { + try + { sendCloudlogEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception Cloudlog Log"); } @@ -1629,11 +1929,15 @@ function finishSendingReport(record, localMode) { g_acLogSettings.enable == true && g_acLogSettings.port > 0 && g_acLogSettings.ip.length > 4 - ) { - try { + ) + { + try + { sendACLogMessage(record, g_acLogSettings.port, g_acLogSettings.ip); addLastTraffic("Logged to N3FJP"); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception N3FJP Log"); } } @@ -1642,15 +1946,19 @@ function finishSendingReport(record, localMode) { g_dxkLogSettings.enable == true && g_dxkLogSettings.port > 0 && g_dxkLogSettings.ip.length > 4 - ) { - try { + ) + { + try + { sendDXKeeperLogMessage( report, g_dxkLogSettings.port, g_dxkLogSettings.ip ); addLastTraffic("Logged to DXKeeper"); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception DXKeeper Log"); } } @@ -1659,8 +1967,10 @@ function finishSendingReport(record, localMode) { g_HRDLogbookLogSettings.enable == true && g_HRDLogbookLogSettings.port > 0 && g_HRDLogbookLogSettings.ip.length > 4 - ) { - try { + ) + { + try + { sendHRDLogbookEntry( record, g_HRDLogbookLogSettings.port, @@ -1669,14 +1979,19 @@ function finishSendingReport(record, localMode) { addLastTraffic( "Logged to HRD Logbook" ); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception HRD Log"); } } - try { + try + { sendLotwLogEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception LoTW Log"); } @@ -1684,32 +1999,44 @@ function finishSendingReport(record, localMode) { logeQSLQSOCheckBox.checked == true && nicknameeQSLCheckBox.checked == true && eQSLNickname.value.trim().length > 0 - ) { - record["APP_EQSL_QTH_NICKNAME"] = eQSLNickname.value.trim(); + ) + { + record.APP_EQSL_QTH_NICKNAME = eQSLNickname.value.trim(); report = ""; - for (var key in record) { + for (var key in record) + { report += "<" + key + ":" + record[key].length + ">" + record[key] + " "; } report += ""; } - try { + try + { sendeQSLEntry(report); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception LoTW Log"); } - try { + try + { alertLogMessage(); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception Alert Log"); } - if (lookupCloseLog.checked == true) { - try { + if (lookupCloseLog.checked == true) + { + try + { openLookupWindow(false); - } catch (e) { + } + catch (e) + { addLastTraffic("Exception Hide Lookup"); } } @@ -1718,57 +2045,81 @@ function finishSendingReport(record, localMode) { return report; } -function alertLogMessage() { - if (logEventMedia.value != "none") { +function alertLogMessage() +{ + if (logEventMedia.value != "none") + { playAlertMediaFile(logEventMedia.value); } } -function eqslCallback(buffer, flag) { +function eqslCallback(buffer, flag) +{ var result = String(buffer); - if (flag) { - if (result.indexOf("No such Username/Password found") != -1) { + if (flag) + { + if (result.indexOf("No such Username/Password found") != -1) + { eQSLTestResult.innerHTML = "Bad
Password
or
Nickname"; logeQSLQSOCheckBox.checked = false; adifLogQsoCheckBoxChanged(logeQSLQSOCheckBox); - } else if (result.indexOf("No such Callsign found") != -1) { + } + else if (result.indexOf("No such Callsign found") != -1) + { eQSLTestResult.innerHTML = "Unknown
Callsign"; logeQSLQSOCheckBox.checked = false; adifLogQsoCheckBoxChanged(logeQSLQSOCheckBox); - } else if (result.indexOf("Your ADIF log file has been built") != -1) { + } + else if (result.indexOf("Your ADIF log file has been built") != -1) + { eQSLTestResult.innerHTML = "Passed"; - } else if ( + } + else if ( result.indexOf("specify the desired User by using the QTHNickname") != -1 - ) { + ) + { eQSLTestResult.innerHTML = "QTH Nickname
Needed"; - } else { + } + else + { eQSLTestResult.innerHTML = "Unknown
Error"; logeQSLQSOCheckBox.checked = false; adifLogQsoCheckBoxChanged(logeQSLQSOCheckBox); } - } else { - if (result.indexOf("Error: No match on eQSL_User/eQSL_Pswd") != -1) { + } + else + { + if (result.indexOf("Error: No match on eQSL_User/eQSL_Pswd") != -1) + { addLastTraffic( "Fail log eQSL.cc (credentials)" ); } if ( result.indexOf("specify the desired User by using the QTHNickname") != -1 - ) { + ) + { addLastTraffic( "Fail log eQSL.cc (nickname)" ); - } else if (result.indexOf("Result: 0 out of 1 records") != -1) { + } + else if (result.indexOf("Result: 0 out of 1 records") != -1) + { addLastTraffic("Fail log eQSL.cc (dupe)"); - } else if (result.indexOf("Result: 1 out of 1 records added") != -1) { + } + else if (result.indexOf("Result: 1 out of 1 records added") != -1) + { addLastTraffic("Logged to eQSL.cc"); - } else { + } + else + { addLastTraffic("Fail log eQSL.cc (?)"); } } } -function eQSLTest(test) { +function eQSLTest(test) +{ if (g_mapSettings.offlineMode == true) return; eQSLTestResult.innerHTML = "Testing"; @@ -1781,14 +2132,16 @@ function eQSLTest(test) { "&RcvdSince=2020101"; if (nicknameeQSLCheckBox.checked == true) - fUrl += "&QTHNickname=" + encodeURIComponent(eQSLNickname.value); + { fUrl += "&QTHNickname=" + encodeURIComponent(eQSLNickname.value); } getABuffer(fUrl, eqslCallback, true, "https", 443); } -function sendeQSLEntry(report) { +function sendeQSLEntry(report) +{ if (g_mapSettings.offlineMode == true) return; - if (logeQSLQSOCheckBox.checked == true) { + if (logeQSLQSOCheckBox.checked == true) + { var pid = "GridTracker"; var pver = String(gtVersion); var header = "" + pid + "\r\n"; @@ -1806,8 +2159,10 @@ function sendeQSLEntry(report) { } } -function testTrustedQSL(test) { - if (g_mapSettings.offlineMode == true) { +function testTrustedQSL(test) +{ + if (g_mapSettings.offlineMode == true) + { lotwTestResult.innerHTML = "Currently
offline"; return; } @@ -1817,7 +2172,8 @@ function testTrustedQSL(test) { g_trustedQslSettings.binaryFileValid == true && g_trustedQslSettings.stationFileValid == true && lotwStation.value.length > 0 - ) { + ) + { lotwTestResult.innerHTML = "Testing Upload"; var child_process = require("child_process"); @@ -1828,29 +2184,32 @@ function testTrustedQSL(test) { child_process.execFile( g_trustedQslSettings.binaryFile, options, - (error, stdout, stderr) => { - if (error) { + (error, stdout, stderr) => + { + if (error) + { lotwTestResult.innerHTML = "Error encountered"; } lotwTestResult.innerHTML = stderr; } ); - return; - } else { + } + else + { var worker = ""; if (g_trustedQslSettings.binaryFileValid == false) - worker += "Invalid tqsl executable
"; + { worker += "Invalid tqsl executable
"; } if (g_trustedQslSettings.stationFileValid == false) - worker += "TrustQSL not installed
"; + { worker += "TrustQSL not installed
"; } if (!ValidateText(lotwTrusted)) worker += "TQSL Password missing
"; if (!ValidateText(lotwStation)) worker += "Select Station
"; lotwTestResult.innerHTML = worker; - return; } } var g_trustTempPath = ""; -function sendLotwLogEntry(report) { +function sendLotwLogEntry(report) +{ if (g_mapSettings.offlineMode == true) return; if ( @@ -1858,7 +2217,8 @@ function sendLotwLogEntry(report) { g_trustedQslSettings.binaryFileValid == true && g_trustedQslSettings.stationFileValid == true && lotwStation.value.length > 0 - ) { + ) + { var header = "Generated " + userTimeString(null) + " for " + myDEcall + "\r\n\r\n"; var pid = "GridTracker"; @@ -1877,7 +2237,8 @@ function sendLotwLogEntry(report) { options.push("all"); options.push("-l"); options.push(lotwStation.value); - if (lotwTrusted.value.length > 0) { + if (lotwTrusted.value.length > 0) + { options.push("-p"); options.push(lotwTrusted.value); } @@ -1890,11 +2251,15 @@ function sendLotwLogEntry(report) { child_process.execFile( g_trustedQslSettings.binaryFile, options, - (error, stdout, stderr) => { // eslint-disable-line node/handle-callback-err - if (stderr.indexOf("Final Status: Success") < 0) { + (error, stdout, stderr) => // eslint-disable-line node/handle-callback-err + { + if (stderr.indexOf("Final Status: Success") < 0) + { alert(stderr); addLastTraffic("Fail log to TQSL"); - } else { + } + else + { addLastTraffic("Logged to TQSL"); } fs.unlinkSync(g_trustTempPath); @@ -1903,7 +2268,8 @@ function sendLotwLogEntry(report) { } } -function n1mmLoggerChanged() { +function n1mmLoggerChanged() +{ g_N1MMSettings.enable = buttonN1MMCheckBox.checked; g_N1MMSettings.ip = N1MMIpInput.value; g_N1MMSettings.port = N1MMPortInput.value; @@ -1911,7 +2277,8 @@ function n1mmLoggerChanged() { localStorage.N1MMSettings = JSON.stringify(g_N1MMSettings); } -function log4OMLoggerChanged() { +function log4OMLoggerChanged() +{ g_log4OMSettings.enable = buttonLog4OMCheckBox.checked; g_log4OMSettings.ip = log4OMIpInput.value; g_log4OMSettings.port = log4OMPortInput.value; @@ -1919,7 +2286,8 @@ function log4OMLoggerChanged() { localStorage.log4OMSettings = JSON.stringify(g_log4OMSettings); } -function acLogLoggerChanged() { +function acLogLoggerChanged() +{ g_acLogSettings.enable = buttonacLogCheckBox.checked; g_acLogSettings.ip = acLogIpInput.value; g_acLogSettings.port = acLogPortInput.value; @@ -1927,7 +2295,8 @@ function acLogLoggerChanged() { localStorage.acLogSettings = JSON.stringify(g_acLogSettings); } -function dxkLogLoggerChanged() { +function dxkLogLoggerChanged() +{ g_dxkLogSettings.enable = buttondxkLogCheckBox.checked; g_dxkLogSettings.ip = dxkLogIpInput.value; g_dxkLogSettings.port = dxkLogPortInput.value; @@ -1935,7 +2304,8 @@ function dxkLogLoggerChanged() { localStorage.dxkLogSettings = JSON.stringify(g_dxkLogSettings); } -function hrdLogbookLoggerChanged() { +function hrdLogbookLoggerChanged() +{ g_HRDLogbookLogSettings.enable = buttonHrdLogbookCheckBox.checked; g_HRDLogbookLogSettings.ip = hrdLogbookIpInput.value; g_HRDLogbookLogSettings.port = hrdLogbookPortInput.value; @@ -1953,54 +2323,74 @@ function CloudUrlErrorCallback( timeoutMs, timeoutCallback, message -) { +) +{ CloudlogTestResult.innerHTML = message; } -function CloudlogSendLogResult(buffer, flag) { - if (flag && flag == true) { - if (buffer) { - if (buffer.indexOf("missing api key") > -1) { +function CloudlogSendLogResult(buffer, flag) +{ + if (flag && flag == true) + { + if (buffer) + { + if (buffer.indexOf("missing api key") > -1) + { CloudlogTestResult.innerHTML = "API Key Invalid"; - } else if (buffer.indexOf("created") > -1) { + } + else if (buffer.indexOf("created") > -1) + { CloudlogTestResult.innerHTML = "Passed"; - } else { + } + else + { CloudlogTestResult.innerHTML = "Invalid Response"; } - } else { + } + else + { CloudlogTestResult.innerHTML = "Invalid Response"; } - } else { + } + else + { if (buffer && buffer.indexOf("created") > -1) - addLastTraffic("Logged to Cloudlog"); + { addLastTraffic("Logged to Cloudlog"); } else addLastTraffic("Fail log to Cloudlog"); } } -function qrzSendLogResult(buffer, flag) { - if (typeof buffer != "undefined" && buffer != null) { +function qrzSendLogResult(buffer, flag) +{ + if (typeof buffer != "undefined" && buffer != null) + { var data = String(buffer); var kv = data.split("&"); - if (kv.length > 0) { + if (kv.length > 0) + { var arrData = Object(); - for (var x in kv) { + for (var x in kv) + { var split = kv[x].split("="); arrData[split[0]] = split[1]; } if ( - typeof arrData["RESULT"] == "undefined" || - arrData["RESULT"] != "OK" - ) { + typeof arrData.RESULT == "undefined" || + arrData.RESULT != "OK" + ) + { alert( "Error uploading QSO to QRZ.com (" + - (arrData["REASON"] || "Unknown error") + + (arrData.REASON || "Unknown error") + ")" ); addLastTraffic("Fail log to QRZ.com"); - } else - addLastTraffic("Logged to QRZ.com"); + } + else + { addLastTraffic("Logged to QRZ.com"); } } - } else alert("Error uploading QSO to QRZ.com (No response)"); + } + else alert("Error uploading QSO to QRZ.com (No response)"); } function postDialogRetryCallback( @@ -2013,8 +2403,10 @@ function postDialogRetryCallback( timeoutMs, timeoutCallback, who -) { - if (window.confirm("Error sending QSO to " + who + ", retry?")) { +) +{ + if (window.confirm("Error sending QSO to " + who + ", retry?")) + { getPostBuffer( file_url, callback, @@ -2039,7 +2431,8 @@ function postRetryErrorCallaback( timeoutMs, timeoutCallback, who -) { +) +{ getPostBuffer( file_url, callback, @@ -2053,15 +2446,18 @@ function postRetryErrorCallaback( ); } -function sendQrzLogEntry(report) { +function sendQrzLogEntry(report) +{ if (g_mapSettings.offlineMode == true) return; - if (logQRZqsoCheckBox.checked == true && ValidateQrzApi(qrzApiKey)) { - if (typeof nw != "undefined") { + if (logQRZqsoCheckBox.checked == true && ValidateQrzApi(qrzApiKey)) + { + if (typeof nw != "undefined") + { var postData = { KEY: qrzApiKey.value, ACTION: "INSERT", - ADIF: report, + ADIF: report }; getPostBuffer( "https://logbook.qrz.com/api", @@ -2078,21 +2474,25 @@ function sendQrzLogEntry(report) { } } -function clubLogQsoResult(buffer, flag) { +function clubLogQsoResult(buffer, flag) +{ addLastTraffic("Logged to ClubLog.org"); } -function sendClubLogEntry(report) { +function sendClubLogEntry(report) +{ if (g_mapSettings.offlineMode == true) return; - if (logClubqsoCheckBox.checked == true) { - if (typeof nw != "undefined") { + if (logClubqsoCheckBox.checked == true) + { + if (typeof nw != "undefined") + { var postData = { email: clubEmail.value, password: clubPassword.value, callsign: clubCall.value, adif: report, - api: CLk, + api: CLk }; getPostBuffer( @@ -2110,11 +2510,14 @@ function sendClubLogEntry(report) { } } -function sendCloudlogEntry(report) { +function sendCloudlogEntry(report) +{ if (g_mapSettings.offlineMode == true) return; - if (logCloudlogQSOCheckBox.checked == true) { - if (typeof nw != "undefined") { + if (logCloudlogQSOCheckBox.checked == true) + { + if (typeof nw != "undefined") + { var postData = { key: CloudlogAPI.value, type: "adif", string: report }; getPostJSONBuffer( CloudlogURL.value, @@ -2131,31 +2534,40 @@ function sendCloudlogEntry(report) { } } -function hrdSendLogResult(buffer, flag) { - if (flag && flag == true) { - if (buffer.indexOf("Unknown user") > -1) { +function hrdSendLogResult(buffer, flag) +{ + if (flag && flag == true) + { + if (buffer.indexOf("Unknown user") > -1) + { HRDLogTestResult.innerHTML = "Failed"; logHRDLOGqsoCheckBox.checked = false; adifLogQsoCheckBoxChanged(logHRDLOGqsoCheckBox); - } else HRDLogTestResult.innerHTML = "Passed"; - } else { + } + else HRDLogTestResult.innerHTML = "Passed"; + } + else + { if (buffer.indexOf("Unknown user") == -1) - addLastTraffic("Logged to HRDLOG.net"); + { addLastTraffic("Logged to HRDLOG.net"); } else - addLastTraffic("Fail log to HRDLOG.net"); + { addLastTraffic("Fail log to HRDLOG.net"); } } } -function sendHrdLogEntry(report) { +function sendHrdLogEntry(report) +{ if (g_mapSettings.offlineMode == true) return; - if (logHRDLOGqsoCheckBox.checked == true) { - if (typeof nw != "undefined") { + if (logHRDLOGqsoCheckBox.checked == true) + { + if (typeof nw != "undefined") + { var postData = { Callsign: HRDLOGCallsign.value, Code: HRDLOGUploadCode.value, App: "GridTracker " + gtVersion, - ADIFData: report, + ADIFData: report }; getPostBuffer( "https://www.hrdlog.net/NewEntry.aspx", @@ -2172,14 +2584,17 @@ function sendHrdLogEntry(report) { } } -function hrdCredentialTest(test) { - if (test && test == true) { +function hrdCredentialTest(test) +{ + if (test && test == true) + { HRDLogTestResult.innerHTML = "Testing"; - if (typeof nw != "undefined") { + if (typeof nw != "undefined") + { var postData = { Callsign: HRDLOGCallsign.value, - Code: HRDLOGUploadCode.value, + Code: HRDLOGUploadCode.value }; getPostBuffer( "https://www.hrdlog.net/NewEntry.aspx", @@ -2193,11 +2608,14 @@ function hrdCredentialTest(test) { } } -function ClublogTest(test) { - if (test && test == true) { +function ClublogTest(test) +{ + if (test && test == true) + { CloudlogTestResult.innerHTML = "Testing"; - if (typeof nw != "undefined") { + if (typeof nw != "undefined") + { var postData = { key: CloudlogAPI.value, type: "adif", string: "" }; getPostJSONBuffer( CloudlogURL.value, @@ -2224,8 +2642,10 @@ function getPostJSONBuffer( timeoutMs, timeoutCallback, who -) { - try { +) +{ + try + { var postData = JSON.stringify(theData); var url = require("url"); var protocol = url.parse(file_url).protocol; // eslint-disable-line node/no-deprecated-api @@ -2238,36 +2658,45 @@ function getPostJSONBuffer( method: "post", headers: { "Content-Type": "application/json", - "Content-Length": postData.length, - }, + "Content-Length": postData.length + } }; - var req = http.request(options, function (res) { + var req = http.request(options, function (res) + { var fsize = res.headers["content-length"]; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cookies); } }) .on("error", function () {}); }); - if (typeof timeoutMs == "number" && timeoutMs > 0) { - req.on("socket", function (socket) { + if (typeof timeoutMs == "number" && timeoutMs > 0) + { + req.on("socket", function (socket) + { socket.setTimeout(timeoutMs); - socket.on("timeout", function () { + socket.on("timeout", function () + { req.abort(); }); }); - req.on("error", function (err) { // eslint-disable-line node/handle-callback-err + req.on("error", function (err) // eslint-disable-line node/handle-callback-err + { if (typeof timeoutCallback != "undefined") + { timeoutCallback( file_url, callback, @@ -2279,12 +2708,16 @@ function getPostJSONBuffer( timeoutCallback, who ); + } }); } req.write(postData); req.end(); - } catch (e) { + } + catch (e) + { if (typeof timeoutCallback != "undefined") + { timeoutCallback( file_url, callback, @@ -2296,17 +2729,20 @@ function getPostJSONBuffer( timeoutCallback, "Invalid Url" ); + } } } -function valueToXmlField(field, value) { +function valueToXmlField(field, value) +{ var adi = "<" + field + ">"; adi += String(value); adi += ""; return adi; } -function aclUpdateControlValue(control, value) { +function aclUpdateControlValue(control, value) +{ return ( valueToXmlField( "CMD", @@ -2317,18 +2753,21 @@ function aclUpdateControlValue(control, value) { ); } -function aclAction(action) { +function aclAction(action) +{ return ( valueToXmlField("CMD", "" + valueToXmlField("VALUE", action)) + "\r\n" ); } -function adifField(record, key) { +function adifField(record, key) +{ if (key in record) return record[key]; else return ""; } -function sendACLogMessage(record, port, address) { +function sendACLogMessage(record, port, address) +{ var report = ""; report += aclAction("CLEAR"); @@ -2340,12 +2779,14 @@ function sendACLogMessage(record, port, address) { adifField(record, "FREQ") ); if (adifField(record, "SUBMODE").length > 0) + { report += aclUpdateControlValue( "TXTENTRYMODE", adifField(record, "SUBMODE") ); + } else - report += aclUpdateControlValue("TXTENTRYMODE", adifField(record, "MODE")); + { report += aclUpdateControlValue("TXTENTRYMODE", adifField(record, "MODE")); } var date = adifField(record, "QSO_DATE"); var dataString = @@ -2399,12 +2840,15 @@ function sendACLogMessage(record, port, address) { report += aclUpdateControlValue("TXTENTRYCOUNTYR", adifField(record, "CNTY")); var sentSpcNum = false; - if (adifField(record, "SRX").length > 0) { + if (adifField(record, "SRX").length > 0) + { report += aclUpdateControlValue( "TXTENTRYSERIALNOR", adifField(record, "SRX") ); - } else if (adifField(record, "CONTEST_ID").length > 0) { + } + else if (adifField(record, "CONTEST_ID").length > 0) + { report += aclUpdateControlValue( "TXTENTRYSPCNUM", adifField(record, "SRX_STRING") @@ -2420,16 +2864,19 @@ function sendACLogMessage(record, port, address) { ); } - if (adifField(record, "STATE").length > 0) { + if (adifField(record, "STATE").length > 0) + { report += aclUpdateControlValue( "TXTENTRYSTATE", adifField(record, "STATE") ); if (sentSpcNum == false) + { report += aclUpdateControlValue( "TXTENTRYSPCNUM", adifField(record, "STATE") ); + } } report += aclAction("ENTER"); @@ -2437,7 +2884,8 @@ function sendACLogMessage(record, port, address) { sendTcpMessage(report, report.length, port, address); } -function sendDXKeeperLogMessage(newMessage, port, address) { +function sendDXKeeperLogMessage(newMessage, port, address) +{ var report = ""; report += valueToAdiField("command", "log"); @@ -2447,7 +2895,8 @@ function sendDXKeeperLogMessage(newMessage, port, address) { sendTcpMessage(report, report.length, Number(port) + 1, address); } -function parseADIFRecord(adif) { +function parseADIFRecord(adif) +{ var regex = new RegExp("", "i"); var newLine = adif.split(regex); var line = newLine[0].trim(); // Catch the naughty case of someone sending two records at the same time @@ -2456,19 +2905,24 @@ function parseADIFRecord(adif) { // because strings are not escaped for adif.. ie: :'s and <'s .. we have to walk from left to right // cheesy, but damn i'm tired of parsing things var x = 0; - while (line.length > 0) { - while (line.charAt(0) != "<" && line.length > 0) { + while (line.length > 0) + { + while (line.charAt(0) != "<" && line.length > 0) + { line = line.substr(1); } - if (line.length > 0) { + if (line.length > 0) + { line = line.substr(1); var where = line.indexOf(":"); - if (where != -1) { + if (where != -1) + { var fieldName = line.substr(0, where).toUpperCase(); line = line.substr(fieldName.length + 1); var fieldLength = parseInt(line); var end = line.indexOf(">"); - if (end > 0) { + if (end > 0) + { line = line.substr(end + 1); var fieldValue = line.substr(0, fieldLength); line = line.substr(fieldLength); @@ -2481,14 +2935,16 @@ function parseADIFRecord(adif) { return record; } -function sendHRDLogbookEntry(report, port, address) { +function sendHRDLogbookEntry(report, port, address) +{ var command = "ver\rdb add {"; var items = Object.assign({}, report); - items["FREQ"] = items["FREQ"].split(".").join(""); + items.FREQ = items.FREQ.split(".").join(""); - for (var item in items) { - command += item + '="' + items[item] + '" '; + for (var item in items) + { + command += item + "=\"" + items[item] + "\" "; } command += "}\rexit\r"; diff --git a/package.nw/lib/alerts.js b/package.nw/lib/alerts.js index 7cfb1f01..2cfdb193 100644 --- a/package.nw/lib/alerts.js +++ b/package.nw/lib/alerts.js @@ -11,8 +11,10 @@ var g_audioSettings = Object(); var g_speechAvailable = false; var g_alertSettings = Object(); -function loadAlerts() { - if (typeof localStorage.classicAlertsVersion == "undefined") { +function loadAlerts() +{ + if (typeof localStorage.classicAlertsVersion == "undefined") + { g_classicAlerts = { huntCallsign: false, huntGrid: false, @@ -43,7 +45,7 @@ function loadAlerts() { huntDXCCNotifyMedia: "none", huntCQzNotifyMedia: "none", huntITUzNotifyMedia: "none", - huntStatesNotifyMedia: "none", + huntStatesNotifyMedia: "none" }; localStorage.classicAlerts = JSON.stringify(g_classicAlerts); @@ -69,23 +71,28 @@ function loadAlerts() { localStorage.alertSettings = JSON.stringify(g_alertSettings); localStorage.classicAlertsVersion = gtVersion; - } else { + } + else + { g_classicAlerts = JSON.parse(localStorage.classicAlerts); g_alertSettings = JSON.parse(localStorage.alertSettings); } - if (typeof g_alertSettings.reference == "undefined") { + if (typeof g_alertSettings.reference == "undefined") + { g_alertSettings.reference = 0; localStorage.alertSettings = JSON.stringify(g_alertSettings); } - if (typeof g_alertSettings.logEventMedia == "undefined") { + if (typeof g_alertSettings.logEventMedia == "undefined") + { g_alertSettings.logEventMedia = "Ping-coin.mp3"; localStorage.alertSettings = JSON.stringify(g_alertSettings); } - if (typeof g_classicAlerts.huntRoster == "undefined") { + if (typeof g_classicAlerts.huntRoster == "undefined") + { g_classicAlerts.huntRoster = false; g_classicAlerts.huntRosterNotify = 1; g_classicAlerts.huntRosterNotifyWord = "New hit"; @@ -96,7 +103,8 @@ function loadAlerts() { loadClassicAlertView(); - if (typeof localStorage.savedAlerts == "undefined") { + if (typeof localStorage.savedAlerts == "undefined") + { g_alerts = { popup: { value: "QRZ", @@ -108,8 +116,8 @@ function loadAlerts() { lastMessage: "", lastTime: 0, fired: 0, - needAck: 0, - }, + needAck: 0 + } }; g_speechSettings = Object(); @@ -121,9 +129,12 @@ function loadAlerts() { g_speechSettings.phonetics = true; g_audioSettings.volume = 1; saveAlerts(); - } else { + } + else + { g_alerts = JSON.parse(localStorage.savedAlerts); - for (var key in g_alerts) { + for (var key in g_alerts) + { if ( g_alerts[key].type != 0 && g_alerts[key].type != 2 && @@ -131,14 +142,15 @@ function loadAlerts() { g_alerts[key].type != 5 && g_alerts[key].type != 6 ) - delete g_alerts[key]; + { delete g_alerts[key]; } if (g_alerts[key].repeat == 3) delete g_alerts[key]; } g_speechSettings = JSON.parse(localStorage.speechSettings); g_audioSettings = JSON.parse(localStorage.audioSettings); } - if (g_speechSettings.voice > 0) { + if (g_speechSettings.voice > 0) + { alertVoiceInput.value = g_speechSettings.voice - 1; } @@ -179,12 +191,14 @@ function loadAlerts() { setAlertVisual(); } -function newLogEventSetting(obj) { +function newLogEventSetting(obj) +{ g_alertSettings.logEventMedia = obj.value; localStorage.alertSettings = JSON.stringify(g_alertSettings); } -function exceptionValuesChanged() { +function exceptionValuesChanged() +{ setAlertVisual(); g_alertSettings.requireGrid = wantGrid.checked; @@ -212,71 +226,87 @@ function exceptionValuesChanged() { localStorage.alertSettings = JSON.stringify(g_alertSettings); } -function hashMaker(band, mode) { - //"Current Band & Mode" +function hashMaker(band, mode) +{ + // "Current Band & Mode" if (g_alertSettings.reference == 0) return band + mode; - //"Current Band, Any Mode" + // "Current Band, Any Mode" if (g_alertSettings.reference == 1) return band; - //"Current Band, Any Digi Mode" + // "Current Band, Any Digi Mode" if (g_alertSettings.reference == 2) return band + "dg"; - //"Current Mode, Any Band" + // "Current Mode, Any Band" if (g_alertSettings.reference == 3) return mode; - //"Any Band, Any Mode" + // "Any Band, Any Mode" if (g_alertSettings.reference == 4) return ""; - //"Any Band, Any Digit Mode" + // "Any Band, Any Digit Mode" if (g_alertSettings.reference == 5) return "dg"; } -function setAlertVisual() { - if (wantMaxDT.checked == true) { +function setAlertVisual() +{ + if (wantMaxDT.checked == true) + { maxDT.style.display = "block"; maxDTView.style.display = "block"; - } else { + } + else + { maxDT.style.display = "none"; maxDTView.style.display = "none"; } - if (wantMinDB.checked == true) { + if (wantMinDB.checked == true) + { minDb.style.display = "block"; minDbView.style.display = "block"; - } else { + } + else + { minDb.style.display = "none"; minDbView.style.display = "none"; } - if (wantMinFreq.checked == true) { + if (wantMinFreq.checked == true) + { minFreq.style.display = "block"; minFreqView.style.display = "block"; - } else { + } + else + { minFreq.style.display = "none"; minFreqView.style.display = "none"; } - if (wantMaxFreq.checked == true) { + if (wantMaxFreq.checked == true) + { maxFreq.style.display = "block"; maxFreqView.style.display = "block"; - } else { + } + else + { maxFreq.style.display = "none"; maxFreqView.style.display = "none"; } if (g_callsignLookups.lotwUseEnable == true) - usesLoTWDiv.style.display = "block"; + { usesLoTWDiv.style.display = "block"; } else usesLoTWDiv.style.display = "none"; if (g_callsignLookups.eqslUseEnable == true) - useseQSLDiv.style.display = "block"; + { useseQSLDiv.style.display = "block"; } else useseQSLDiv.style.display = "none"; } -function saveAlertSettings() { +function saveAlertSettings() +{ localStorage.speechSettings = JSON.stringify(g_speechSettings); localStorage.audioSettings = JSON.stringify(g_audioSettings); } -function saveAlerts() { +function saveAlerts() +{ localStorage.savedAlerts = JSON.stringify(g_alerts); saveAlertSettings(); @@ -284,7 +314,8 @@ function saveAlerts() { var g_testAudioTimer = null; -function changeAudioValues() { +function changeAudioValues() +{ if (g_testAudioTimer) clearTimeout(g_testAudioTimer); g_audioSettings.volume = audioVolume.value; @@ -294,11 +325,13 @@ function changeAudioValues() { saveAlertSettings(); } -function playTestFile() { +function playTestFile() +{ playAlertMediaFile("Sysenter-7.mp3"); } -function changeSpeechValues() { +function changeSpeechValues() +{ chrome.tts.stop(); g_speechSettings.volume = speechVolume.value; @@ -313,29 +346,38 @@ function changeSpeechValues() { saveAlertSettings(); } -function addNewAlert() { +function addNewAlert() +{ var error = "Added"; var valid = true; var filename = ""; var shortname = ""; - if (alertNotifySelect.value == 0) { - if (alertMediaSelect.value == "none") { + if (alertNotifySelect.value == 0) + { + if (alertMediaSelect.value == "none") + { valid = false; error = "Select File!"; - } else { + } + else + { filename = alertMediaSelect.value; shortname = alertMediaSelect.selectedOptions[0].innerText; } } - if (valid) { - if (alertTypeSelect.value == 0 || alertTypeSelect.value == 5) { + if (valid) + { + if (alertTypeSelect.value == 0 || alertTypeSelect.value == 5) + { valid = ValidateCallsign(alertValueInput, null); - if (!valid) { + if (!valid) + { error = "Invalid Callsign"; } } } - if (valid) { + if (valid) + { valid = addAlert( alertValueInput.value, alertTypeSelect.value, @@ -344,7 +386,8 @@ function addNewAlert() { filename, shortname ); - if (!valid) { + if (!valid) + { error = "Duplicate!"; } } @@ -352,10 +395,12 @@ function addNewAlert() { displayAlerts(); } -function addAlert(value, type, notify, repeat, filename, shortname) { +function addAlert(value, type, notify, repeat, filename, shortname) +{ var newKey = unique(value + type + notify + repeat + filename); - if (!g_alerts.hasOwnProperty(newKey)) { + if (!g_alerts.hasOwnProperty(newKey)) + { var alertItem = Object(); alertItem.value = value; alertItem.type = type; @@ -375,13 +420,15 @@ function addAlert(value, type, notify, repeat, filename, shortname) { return false; // we have this alert already } -function deleteAlert(key) { +function deleteAlert(key) +{ delete g_alerts[key]; saveAlerts(); displayAlerts(); } -function resetAlert(key) { +function resetAlert(key) +{ g_alerts[key].lastMessage = ""; g_alerts[key].lastTime = 0; g_alerts[key].fired = 0; @@ -389,8 +436,10 @@ function resetAlert(key) { displayAlerts(); } -function processAlertMessage(decodeWords, message, band, mode) { - if (Object.keys(g_alerts).length == 0) { +function processAlertMessage(decodeWords, message, band, mode) +{ + if (Object.keys(g_alerts).length == 0) + { // no alerts, don't bother return false; } @@ -404,17 +453,22 @@ function processAlertMessage(decodeWords, message, band, mode) { // Grab the last word in the decoded message var grid = decodeWords[decodeWords.length - 1].trim(); - if (grid.length == 4) { + if (grid.length == 4) + { // maybe it's a grid var LETTERS = grid.substr(0, 2); var NUMBERS = grid.substr(2, 2); - if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) { + if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) + { theirGrid = LETTERS + NUMBERS; - if (theirGrid != "RR73") { + if (theirGrid != "RR73") + { validQTH = true; - } else { + } + else + { theirGrid = null; validQTH = false; } @@ -423,29 +477,32 @@ function processAlertMessage(decodeWords, message, band, mode) { if (validQTH) msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); if (validQTH == false && decodeWords.length == 3) - msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); + { msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); } if (validQTH == false && decodeWords.length == 2) - msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); - if (decodeWords[0] == "CQ") { + { msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); } + if (decodeWords[0] == "CQ") + { CQ = true; } - if (decodeWords.length >= 3 && CQ == true && validQTH == false) { + if (decodeWords.length >= 3 && CQ == true && validQTH == false) + { if (validateNumAndLetter(decodeWords[decodeWords.length - 1].trim())) - msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); + { msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); } else msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); } - if (decodeWords.length >= 4 && CQ == false) { + if (decodeWords.length >= 4 && CQ == false) + { msgDEcallsign = decodeWords[1]; } - var okayToAlert = true; + var okayToAlert = true; if (msgDEcallsign + band + mode in g_liveCallsigns) - found_callsign = g_liveCallsigns[msgDEcallsign + band + mode]; + { found_callsign = g_liveCallsigns[msgDEcallsign + band + mode]; } if (okayToAlert == true) - return checkAlerts(msgDEcallsign, theirGrid, message, found_callsign); + { return checkAlerts(msgDEcallsign, theirGrid, message, found_callsign); } } return false; } @@ -457,61 +514,81 @@ function checkAlerts( callsignRecord, band, mode -) { +) +{ var hadAlert = false; - for (var key in g_alerts) { + for (var key in g_alerts) + { var nalert = g_alerts[key]; - if (nalert.type == 0) { + if (nalert.type == 0) + { // callsign exatch match - if (DEcallsign == nalert.value) { + if (DEcallsign == nalert.value) + { handleAlert(nalert, DEcallsign, originalMessage, callsignRecord); hadAlert = true; } - } else if (grid && nalert.type == 2) { + } + else if (grid && nalert.type == 2) + { // gridsquare if ( !(DEcallsign + band + mode in g_tracker.worked.call) && grid.indexOf(nalert.value) == 0 - ) { + ) + { handleAlert(nalert, DEcallsign, originalMessage, callsignRecord, grid); hadAlert = true; } - } else if (nalert.type == 4) { + } + else if (nalert.type == 4) + { // QRZ - if (myDEcall.length > 0 && originalMessage.indexOf(myDEcall + " ") == 0) { + if (myDEcall.length > 0 && originalMessage.indexOf(myDEcall + " ") == 0) + { handleAlert(nalert, DEcallsign, originalMessage, callsignRecord); hadAlert = true; } - } else if (nalert.type == 5) { + } + else if (nalert.type == 5) + { // callsign partial if ( !(DEcallsign + band + mode in g_tracker.worked.call) && DEcallsign.indexOf(nalert.value) == 0 - ) { + ) + { handleAlert(nalert, DEcallsign, originalMessage, callsignRecord); hadAlert = true; } - } else if (nalert.type == 6) { + } + else if (nalert.type == 6) + { // callsign regex - try { + try + { if ( !(DEcallsign + band + mode in g_tracker.worked.call) && DEcallsign.match(nalert.value) - ) { + ) + { handleAlert(nalert, DEcallsign, originalMessage, callsignRecord); hadAlert = true; } - } catch (e) {} + } + catch (e) {} } } - if (hadAlert) { + if (hadAlert) + { displayAlerts(); return true; } return false; } -function handleAlert(nAlert, target, lastMessage, callsignRecord, grid) { +function handleAlert(nAlert, target, lastMessage, callsignRecord, grid) +{ if (nAlert.fired > 0 && nAlert.repeat == 0) return; if (nAlert.fired == 1 && nAlert.repeat == 1) return; @@ -519,12 +596,14 @@ function handleAlert(nAlert, target, lastMessage, callsignRecord, grid) { nAlert.lastMessage = lastMessage; nAlert.lastTime = timeNowSec(); - if (callsignRecord != null) { + if (callsignRecord != null) + { if ( typeof callsignRecord.rect != "undefined" && callsignRecord.rect != null && nAlert.notify == 3 - ) { + ) + { // Fix me g_map .getView() @@ -536,19 +615,22 @@ function handleAlert(nAlert, target, lastMessage, callsignRecord, grid) { if (nAlert.notify == 2) nAlert.needAck = 1; - if (nAlert.type == 0 || nAlert.type == 5 || nAlert.type == 6) { + if (nAlert.type == 0 || nAlert.type == 5 || nAlert.type == 6) + { if (nAlert.notify == 0) playAlertMediaFile(nAlert.filename); if (nAlert.notify == 1) speakAlertString("Callsign", target, null); if (nAlert.notify == 2) displayAlertPopUp("Seeking", target, null); } - if (nAlert.type == 2) { + if (nAlert.type == 2) + { if (nAlert.notify == 0) playAlertMediaFile(nAlert.filename); if (nAlert.notify == 1) speakAlertString("Grid square", grid, null); if (nAlert.notify == 2) displayAlertPopUp("Gridsquare", grid, target); } - if (nAlert.type == 4) { + if (nAlert.type == 4) + { if (nAlert.notify == 0) playAlertMediaFile(nAlert.filename); if (nAlert.notify == 1) speakQRZString(target, "Calling", myDEcall); if (nAlert.notify == 2) displayAlertPopUp("QRZ", null, null); @@ -556,7 +638,8 @@ function handleAlert(nAlert, target, lastMessage, callsignRecord, grid) { nAlert.fired++; } -function playAlertMediaFile(filename, overrideMute) { +function playAlertMediaFile(filename, overrideMute) +{ if (g_appSettings.alertMute && !overrideMute) return; var fpath = path.join(g_userMediaDir, filename); @@ -569,12 +652,15 @@ function playAlertMediaFile(filename, overrideMute) { audio.play(); } -function stringToPhonetics(string) { +function stringToPhonetics(string) +{ var newMsg = ""; - for (var x = 0; x < string.length; x++) { + for (var x = 0; x < string.length; x++) + { if (g_speechSettings.phonetics == true) - newMsg += g_phonetics[string.substr(x, 1)]; - else { + { newMsg += g_phonetics[string.substr(x, 1)]; } + else + { if (string.substr(x, 1) == " ") newMsg += ", "; else newMsg += string.substr(x, 1); } @@ -584,19 +670,22 @@ function stringToPhonetics(string) { return newMsg; } -function speakQRZString(caller, words, you) { - if (g_appSettings.alertMute == 0) { +function speakQRZString(caller, words, you) +{ + if (g_appSettings.alertMute == 0) + { var sCaller = ""; var sYou = ""; if (caller) sCaller = stringToPhonetics(caller); if (you) sYou = stringToPhonetics(you); - if (g_speechAvailable) { + if (g_speechAvailable) + { var speak = sCaller.trim() + ", " + words.trim() + ", " + sYou.trim(); var msg = new SpeechSynthesisUtterance(speak); msg.lang = g_localeString; if (g_speechSettings.voice > 0) - msg.voice = g_voices[g_speechSettings.voice - 1]; + { msg.voice = g_voices[g_speechSettings.voice - 1]; } msg.rate = g_speechSettings.rate; msg.pitch = g_speechSettings.pitch; msg.volume = g_speechSettings.volume; @@ -605,19 +694,22 @@ function speakQRZString(caller, words, you) { } } -function speakAlertString(what, message, target) { - if (g_appSettings.alertMute == 0) { +function speakAlertString(what, message, target) +{ + if (g_appSettings.alertMute == 0) + { var sMsg = ""; var sTarget = ""; if (message) sMsg = stringToPhonetics(message); if (target) sTarget = stringToPhonetics(target); - if (g_speechAvailable) { + if (g_speechAvailable) + { var speak = what.trim() + ", " + sMsg.trim() + ", " + sTarget.trim(); var msg = new SpeechSynthesisUtterance(speak); msg.lang = g_localeString; if (g_speechSettings.voice > 0) - msg.voice = g_voices[g_speechSettings.voice - 1]; + { msg.voice = g_voices[g_speechSettings.voice - 1]; } msg.rate = g_speechSettings.rate; msg.pitch = g_speechSettings.pitch; msg.volume = g_speechSettings.volume; @@ -628,13 +720,16 @@ function speakAlertString(what, message, target) { var g_alertFlasher = null; -function unflashAlertPopUp() { +function unflashAlertPopUp() +{ var worker = ""; var acount = 0; alertsPopDiv.style.backgroundColor = "#000"; - if (Object.keys(g_alerts).length > 0) { - for (var key in g_alerts) { + if (Object.keys(g_alerts).length > 0) + { + for (var key in g_alerts) + { if (g_alerts[key].needAck) acount++; } @@ -656,21 +751,25 @@ function unflashAlertPopUp() { worker += "When"; worker += ""; - for (var key in g_alerts) { - if (g_alerts[key].needAck) { + for (var key in g_alerts) + { + if (g_alerts[key].needAck) + { worker += ""; worker += "" + g_alertTypeOptions[g_alerts[key].type] + ""; if (g_alerts[key].type == 0) - worker += "" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } if (g_alerts[key].type == 2) - worker += "" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } if (g_alerts[key].type == 4) - worker += "" + myDEcall + ""; + { worker += "" + myDEcall + ""; } if (g_alerts[key].type == 5) + { worker += "" + g_alerts[key].value + "*"; + } if (g_alerts[key].type == 6) - worker += "" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } worker += "" + g_alertValueOptions[g_alerts[key].notify] + ""; worker += "" + g_alertRepeatOptions[g_alerts[key].repeat] + ""; @@ -699,7 +798,8 @@ function unflashAlertPopUp() { g_alertFlasher = null; } -function displayAlertPopUp(what, message, target) { +function displayAlertPopUp(what, message, target) +{ if (g_alertFlasher) clearTimeout(g_alertFlasher); alertPopListDiv.innerHTML = @@ -709,48 +809,63 @@ function displayAlertPopUp(what, message, target) { g_alertFlasher = setTimeout(unflashAlertPopUp, 100); } -function ackAlerts() { +function ackAlerts() +{ alertsPopDiv.style.display = "none"; - for (var key in g_alerts) { + for (var key in g_alerts) + { g_alerts[key].needAck = 0; } } -function alertTypeChanged() { +function alertTypeChanged() +{ addError.innerHTML = ""; - if (alertTypeSelect.value == 0 || alertTypeSelect.value == 5) { + if (alertTypeSelect.value == 0 || alertTypeSelect.value == 5) + { alertValueSelect.innerHTML = ""; alertValueSelect.innerHTML = - ''; + ""; ValidateCallsign(alertValueInput, null); - } else if (alertTypeSelect.value == 2) { + } + else if (alertTypeSelect.value == 2) + { alertValueSelect.innerHTML = ""; alertValueSelect.innerHTML = - ''; + ""; ValidateGridsquareOnly4(alertValueInput, null); - } else if (alertTypeSelect.value == 4) { + } + else if (alertTypeSelect.value == 4) + { alertValueSelect.innerHTML = - ''; + "\" maxlength=\"12\" size=\"5\" oninput=\"ValidateCallsign(this,null);\" / >"; ValidateCallsign(alertValueInput, null); - } else if (alertTypeSelect.value == 6) { + } + else if (alertTypeSelect.value == 6) + { alertValueSelect.innerHTML = ""; alertValueSelect.innerHTML = - ''; + ""; ValidateText(alertValueInput); } } -function alertNotifyChanged(who = "") { +function alertNotifyChanged(who = "") +{ addError.innerHTML = ""; - if (alertNotifySelect.value == 0) { + if (alertNotifySelect.value == 0) + { alertMediaSelect.style.display = "block"; - if (who == "media") { + if (who == "media") + { playAlertMediaFile(alertMediaSelect.value); } - } else { + } + else + { alertMediaSelect.style.display = "none"; } } @@ -779,10 +894,12 @@ g_alertRepeatOptions["1"] = "Once"; g_alertRepeatOptions["2"] = "Inf"; g_alertRepeatOptions["3"] = "Inf(Session)"; -function displayAlerts() { +function displayAlerts() +{ var worker = ""; - if (Object.keys(g_alerts).length > 0) { + if (Object.keys(g_alerts).length > 0) + { worker += "
" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } if (g_alerts[key].type == 2) - worker += "" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } if (g_alerts[key].type == 4) - worker += "" + myDEcall + ""; + { worker += "" + myDEcall + ""; } if (g_alerts[key].type == 5) + { worker += "" + g_alerts[key].value + "*"; + } if (g_alerts[key].type == 6) - worker += "" + g_alerts[key].value + ""; + { worker += "" + g_alerts[key].value + ""; } worker += "" + g_alertValueOptions[g_alerts[key].notify] + ""; worker += "" + g_alertRepeatOptions[g_alerts[key].repeat] + ""; @@ -850,51 +970,71 @@ function displayAlerts() { alertListDiv.innerHTML = worker; } -function loadClassicAlertView() { - for (node in g_classicAlerts) { +function loadClassicAlertView() +{ + for (node in g_classicAlerts) + { what = document.getElementById(node); - if (what != null) { - if (what.type == "select-one" || what.type == "text") { + if (what != null) + { + if (what.type == "select-one" || what.type == "text") + { what.value = g_classicAlerts[node]; - if (what.id.endsWith("Notify")) { + if (what.id.endsWith("Notify")) + { var mediaNode = document.getElementById(what.id + "Media"); var wordNode = document.getElementById(what.id + "Word"); - if (what.value == "0") { + if (what.value == "0") + { mediaNode.style.display = "block"; wordNode.style.display = "none"; - } else { + } + else + { mediaNode.style.display = "none"; wordNode.style.display = "block"; } } - if (what.type == "text") { + if (what.type == "text") + { ValidateText(what); } - } else if (what.type == "checkbox") { + } + else if (what.type == "checkbox") + { what.checked = g_classicAlerts[node]; } } } } -function wantedChanged(what) { - if (what.type == "select-one" || what.type == "text") { +function wantedChanged(what) +{ + if (what.type == "select-one" || what.type == "text") + { g_classicAlerts[what.id] = what.value; - if (what.id.endsWith("Notify")) { + if (what.id.endsWith("Notify")) + { var mediaNode = document.getElementById(what.id + "Media"); var wordNode = document.getElementById(what.id + "Word"); - if (what.value == "0") { + if (what.value == "0") + { mediaNode.style.display = "block"; wordNode.style.display = "none"; - } else { + } + else + { mediaNode.style.display = "none"; wordNode.style.display = "block"; } } - if (what.id.endsWith("Media")) { + if (what.id.endsWith("Media")) + { if (what.value != "none") playAlertMediaFile(what.value); } - } else if (what.type == "checkbox") { + } + else if (what.type == "checkbox") + { g_classicAlerts[what.id] = what.checked; } localStorage.classicAlerts = JSON.stringify(g_classicAlerts); @@ -906,7 +1046,7 @@ var g_classic_alert_count_template = { huntDXCC: 0, huntCQz: 0, huntITUz: 0, - huntStates: 0, + huntStates: 0 }; var g_classic_alert_counts = Object.assign({}, g_classic_alert_count_template); @@ -917,7 +1057,7 @@ var g_classic_alert_functions = { huntDXCC: alertCheckDXCC, huntCQz: alertCheckCQz, huntITUz: alertCheckITUz, - huntStates: alertCheckStates, + huntStates: alertCheckStates }; var g_classic_alert_words = { @@ -926,20 +1066,26 @@ var g_classic_alert_words = { huntDXCC: "DXCC", huntCQz: "CQ Zone", huntITUz: "I-T-U Zone", - huntStates: "State", + huntStates: "State" }; -function processClassicAlerts() { - for (key in g_classic_alert_counts) { +function processClassicAlerts() +{ + for (key in g_classic_alert_counts) + { if ( document.getElementById(key).checked == true && g_classic_alert_counts[key] > 0 - ) { + ) + { var notify = document.getElementById(key + "Notify").value; - if (notify == "0") { + if (notify == "0") + { var media = document.getElementById(key + "Notify" + "Media").value; if (media != "none") playAlertMediaFile(media); - } else if (notify == "1") { + } + else if (notify == "1") + { speakAlertString( document.getElementById(key + "Notify" + "Word").value ); @@ -949,57 +1095,66 @@ function processClassicAlerts() { g_classic_alert_counts = Object.assign({}, g_classic_alert_count_template); } -function checkClassicAlerts(CQ, callObj, message, DXcall) { +function checkClassicAlerts(CQ, callObj, message, DXcall) +{ var didAlert = false; if (g_alertSettings.cqOnly == true && CQ == false) return didAlert; if (g_alertSettings.requireGrid == true && callObj.grid.length != 4) - return didAlert; + { return didAlert; } if (g_alertSettings.wantMinDB == true && message.SR < g_alertSettings.minDb) - return didAlert; + { return didAlert; } if ( g_alertSettings.wantMaxDT == true && Math.abs(message.DT) > g_alertSettings.maxDT ) - return didAlert; + { return didAlert; } if ( g_alertSettings.wantMinFreq == true && message.DF < g_alertSettings.minFreq ) - return didAlert; + { return didAlert; } if ( g_alertSettings.wantMaxFreq == true && message.DF > g_alertSettings.maxFreq ) - return didAlert; + { return didAlert; } - if (DXcall == "CQ RU") { + if (DXcall == "CQ RU") + { if (g_alertSettings.noRoundUp == true) return didAlert; - } else { + } + else + { if (g_alertSettings.onlyRoundUp == true) return didAlert; } - if (callObj.dxcc == g_myDXCC) { + if (callObj.dxcc == g_myDXCC) + { if (g_alertSettings.noMyDxcc == true) return didAlert; - } else { + } + else + { if (g_alertSettings.onlyMyDxcc == true) return didAlert; } if ( g_callsignLookups.lotwUseEnable == true && g_alertSettings.usesLoTW == true - ) { + ) + { if (!(callObj.DEcall in g_lotwCallsigns)) return didAlert; } if ( g_callsignLookups.eqslUseEnable == true && g_alertSettings.useseQSL == true - ) { + ) + { if (!(callObj.DEcall in g_eqslCallsigns)) return didAlert; } @@ -1009,10 +1164,12 @@ function checkClassicAlerts(CQ, callObj, message, DXcall) { callObj.DEcall + hashMaker(callObj.band, callObj.mode) in g_tracker.worked.call ) - return didAlert; + { return didAlert; } - for (key in g_classic_alert_functions) { - if (document.getElementById(key).checked == true) { + for (key in g_classic_alert_functions) + { + if (document.getElementById(key).checked == true) + { var alerted = g_classic_alert_functions[key](key, callObj); if (alerted == true) didAlert = true; g_classic_alert_counts[key] += alerted; @@ -1022,7 +1179,8 @@ function checkClassicAlerts(CQ, callObj, message, DXcall) { return didAlert; } -function alertCheckCallsign(key, callObj) { +function alertCheckCallsign(key, callObj) +{ var status = document.getElementById(key + "Need").value; if ( @@ -1030,18 +1188,19 @@ function alertCheckCallsign(key, callObj) { callObj.DEcall + hashMaker(callObj.band, callObj.mode) in g_tracker.worked.call ) - return 0; + { return 0; } if ( status == "confirmed" && callObj.DEcall + hashMaker(callObj.band, callObj.mode) in g_tracker.confirmed.call ) - return 0; + { return 0; } return 1; } -function alertCheckGrid(key, callObj) { +function alertCheckGrid(key, callObj) +{ var status = document.getElementById(key + "Need").value; if (callObj.grid.length == 0) return 0; @@ -1050,18 +1209,19 @@ function alertCheckGrid(key, callObj) { callObj.grid + hashMaker(callObj.band, callObj.mode) in g_tracker.worked.grid ) - return 0; + { return 0; } if ( status == "confirmed" && callObj.grid + hashMaker(callObj.band, callObj.mode) in g_tracker.confirmed.grid ) - return 0; + { return 0; } return 1; } -function alertCheckDXCC(key, callObj) { +function alertCheckDXCC(key, callObj) +{ var status = document.getElementById(key + "Need").value; if ( @@ -1069,23 +1229,25 @@ function alertCheckDXCC(key, callObj) { String(callObj.dxcc) + hashMaker(callObj.band, callObj.mode) in g_tracker.worked.dxcc ) - return 0; + { return 0; } if ( status == "confirmed" && String(callObj.dxcc) + hashMaker(callObj.band, callObj.mode) in g_tracker.confirmed.dxcc ) - return 0; + { return 0; } return 1; } -function alertCheckCQz(key, callObj) { +function alertCheckCQz(key, callObj) +{ var workedTotal = (confirmedTotal = callObj.cqza.length); if (workedTotal == 0) return 0; var workedFound = (confirmedFound = 0); - for (index in callObj.cqza) { + for (index in callObj.cqza) + { var hash = callObj.cqza[index] + hashMaker(callObj.band, callObj.mode); if (hash in g_tracker.worked.cqz) workedFound++; @@ -1100,12 +1262,14 @@ function alertCheckCQz(key, callObj) { return 1; } -function alertCheckITUz(key, callObj) { +function alertCheckITUz(key, callObj) +{ var workedTotal = (confirmedTotal = callObj.ituza.length); if (workedTotal == 0) return 0; var workedFound = (confirmedFound = 0); - for (index in callObj.ituza) { + for (index in callObj.ituza) + { var hash = callObj.ituza[index] + hashMaker(callObj.band, callObj.mode); if (hash in g_tracker.worked.ituz) workedFound++; @@ -1120,9 +1284,12 @@ function alertCheckITUz(key, callObj) { return 1; } -function alertCheckStates(key, callObj) { - if (callObj.dxcc == 291 || callObj.dxcc == 110 || callObj.dxcc == 6) { - if (callObj.state in g_StateData) { +function alertCheckStates(key, callObj) +{ + if (callObj.dxcc == 291 || callObj.dxcc == 110 || callObj.dxcc == 6) + { + if (callObj.state in g_StateData) + { var hash = callObj.state + hashMaker(callObj.band, callObj.mode); var status = document.getElementById(key + "Need").value; diff --git a/package.nw/lib/arc.js b/package.nw/lib/arc.js index df563424..4c6d30c3 100644 --- a/package.nw/lib/arc.js +++ b/package.nw/lib/arc.js @@ -3,75 +3,94 @@ var D2R = Math.PI / 180; var R2D = 180 / Math.PI; -var Coord = function (lon, lat) { +var Coord = function (lon, lat) +{ this.lon = lon; this.lat = lat; this.x = D2R * lon; this.y = D2R * lat; }; -Coord.prototype.view = function () { +Coord.prototype.view = function () +{ return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4); }; -Coord.prototype.antipode = function () { +Coord.prototype.antipode = function () +{ var anti_lat = -1 * this.lat; var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1; return new Coord(anti_lon, anti_lat); }; -var LineString = function () { +var LineString = function () +{ this.coords = []; this.length = 0; }; -LineString.prototype.move_to = function (coord) { +LineString.prototype.move_to = function (coord) +{ this.length++; this.coords.push(coord); }; -var Arc = function (properties) { +var Arc = function (properties) +{ this.properties = properties || {}; this.geometries = []; }; -Arc.prototype.json = function () { - if (this.geometries.length <= 0) { +Arc.prototype.json = function () +{ + if (this.geometries.length <= 0) + { return { geometry: { type: "LineString", coordinates: null }, type: "Feature", - properties: this.properties, + properties: this.properties }; - } else if (this.geometries.length == 1) { + } + else if (this.geometries.length == 1) + { return { geometry: { type: "LineString", coordinates: this.geometries[0].coords }, type: "Feature", - properties: this.properties, + properties: this.properties }; - } else { + } + else + { var multiline = []; - for (var i = 0; i < this.geometries.length; i++) { + for (var i = 0; i < this.geometries.length; i++) + { multiline.push(this.geometries[i].coords); } return { geometry: { type: "MultiLineString", coordinates: multiline }, type: "Feature", - properties: this.properties, + properties: this.properties }; } }; // TODO - output proper multilinestring -Arc.prototype.wkt = function () { +Arc.prototype.wkt = function () +{ var wkt_string = ""; var wkt = "LINESTRING("; - var collect = function (c) { + var collect = function (c) + { wkt += c[0] + " " + c[1] + ","; }; - for (var i = 0; i < this.geometries.length; i++) { - if (this.geometries[i].coords.length === 0) { + for (var i = 0; i < this.geometries.length; i++) + { + if (this.geometries[i].coords.length === 0) + { return "LINESTRING(empty)"; - } else { + } + else + { var coords = this.geometries[i].coords; coords.forEach(collect); wkt_string += wkt.substring(0, wkt.length - 1) + ")"; @@ -84,13 +103,16 @@ Arc.prototype.wkt = function () { * http://en.wikipedia.org/wiki/Great-circle_distance * */ -var GreatCircle = function (start, end, properties) { - if (!start || start.x === undefined || start.y === undefined) { +var GreatCircle = function (start, end, properties) +{ + if (!start || start.x === undefined || start.y === undefined) + { throw new Error( "GreatCircle constructor expects two args: start and end objects with x and y properties" ); } - if (!end || end.x === undefined || end.y === undefined) { + if (!end || end.x === undefined || end.y === undefined) + { throw new Error( "GreatCircle constructor expects two args: start and end objects with x and y properties" ); @@ -108,7 +130,8 @@ var GreatCircle = function (start, end, properties) { Math.pow(Math.sin(w / 2.0), 2); this.g = 2.0 * Math.asin(Math.sqrt(z)); - if (this.g == Math.PI) { + if (this.g == Math.PI) + { throw new Error( "it appears " + start.view() + @@ -116,7 +139,9 @@ var GreatCircle = function (start, end, properties) { end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite" ); - } else if (isNaN(this.g)) { + } + else if (isNaN(this.g)) + { throw new Error( "could not calculate great circle between " + start + " and " + end ); @@ -126,7 +151,8 @@ var GreatCircle = function (start, end, properties) { /* * http://williams.best.vwh.net/avform.htm#Intermediate */ -GreatCircle.prototype.interpolate = function (f) { +GreatCircle.prototype.interpolate = function (f) +{ var A = Math.sin((1 - f) * this.g) / Math.sin(this.g); var B = Math.sin(f * this.g) / Math.sin(this.g); var x = @@ -144,14 +170,19 @@ GreatCircle.prototype.interpolate = function (f) { /* * Generate points along the great circle */ -GreatCircle.prototype.Arc = function (npoints, options) { +GreatCircle.prototype.Arc = function (npoints, options) +{ var first_pass = []; - if (!npoints || npoints <= 2) { + if (!npoints || npoints <= 2) + { first_pass.push([this.start.lon, this.start.lat]); first_pass.push([this.end.lon, this.end.lat]); - } else { + } + else + { var delta = 1.0 / (npoints - 1); - for (var i = 0; i < npoints; ++i) { + for (var i = 0; i < npoints; ++i) + { var step = delta * i; var pair = this.interpolate(step); first_pass.push(pair); @@ -173,7 +204,8 @@ GreatCircle.prototype.Arc = function (npoints, options) { var dfDiffSpace = 360 - dfDateLineOffset; // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342 - for (var j = 1; j < first_pass.length; ++j) { + for (var j = 1; j < first_pass.length; ++j) + { var dfPrevX = first_pass[j - 1][0]; var dfX = first_pass[j][0]; var dfDiffLong = Math.abs(dfX - dfPrevX); @@ -181,20 +213,26 @@ GreatCircle.prototype.Arc = function (npoints, options) { dfDiffLong > dfDiffSpace && ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) || (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) - ) { + ) + { bHasBigDiff = true; - } else if (dfDiffLong > dfMaxSmallDiffLong) { + } + else if (dfDiffLong > dfMaxSmallDiffLong) + { dfMaxSmallDiffLong = dfDiffLong; } } var poMulti = []; - if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) { + if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) + { var poNewLS = []; poMulti.push(poNewLS); - for (var k = 0; k < first_pass.length; ++k) { + for (var k = 0; k < first_pass.length; ++k) + { var dfX0 = parseFloat(first_pass[k][0]); - if (k > 0 && Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) { + if (k > 0 && Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) + { var dfX1 = parseFloat(first_pass[k - 1][0]); var dfY1 = parseFloat(first_pass[k - 1][1]); var dfX2 = parseFloat(first_pass[k][0]); @@ -206,26 +244,30 @@ GreatCircle.prototype.Arc = function (npoints, options) { k + 1 < first_pass.length && first_pass[k - 1][0] > -180 && first_pass[k - 1][0] < dfRightBorderX - ) { + ) + { poNewLS.push([-180, first_pass[k][1]]); k++; poNewLS.push([first_pass[k][0], first_pass[k][1]]); continue; - } else if ( + } + else if ( dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 == -180 && k + 1 < first_pass.length && first_pass[k - 1][0] > dfLeftBorderX && first_pass[k - 1][0] < 180 - ) { + ) + { poNewLS.push([180, first_pass[k][1]]); k++; poNewLS.push([first_pass[k][0], first_pass[k][1]]); continue; } - if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) { + if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) + { // swap dfX1, dfX2 var tmpX = dfX1; dfX1 = dfX2; @@ -235,59 +277,73 @@ GreatCircle.prototype.Arc = function (npoints, options) { dfY1 = dfY2; dfY2 = tmpY; } - if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) { + if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) + { dfX2 += 360; } - if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) { + if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) + { var dfRatio = (180 - dfX1) / (dfX2 - dfX1); var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1; poNewLS.push([ first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180, - dfY, + dfY ]); poNewLS = []; poNewLS.push([ first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180, - dfY, + dfY ]); poMulti.push(poNewLS); - } else { + } + else + { poNewLS = []; poMulti.push(poNewLS); } poNewLS.push([dfX0, first_pass[k][1]]); - } else { + } + else + { poNewLS.push([first_pass[k][0], first_pass[k][1]]); } } - } else { + } + else + { // add normally var poNewLS0 = []; poMulti.push(poNewLS0); - for (var l = 0; l < first_pass.length; ++l) { + for (var l = 0; l < first_pass.length; ++l) + { poNewLS0.push([first_pass[l][0], first_pass[l][1]]); } } var arc = new Arc(this.properties); - for (var m = 0; m < poMulti.length; ++m) { + for (var m = 0; m < poMulti.length; ++m) + { var line = new LineString(); arc.geometries.push(line); var points = poMulti[m]; - for (var j0 = 0; j0 < points.length; ++j0) { + for (var j0 = 0; j0 < points.length; ++j0) + { line.move_to(points[j0]); } } return arc; }; -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { +if (typeof module !== "undefined" && typeof module.exports !== "undefined") +{ // nodejs module.exports.Coord = Coord; module.exports.Arc = Arc; module.exports.GreatCircle = GreatCircle; -} else { +} +else +{ // browser var arc = {}; arc.Coord = Coord; diff --git a/package.nw/lib/callsigns.js b/package.nw/lib/callsigns.js index fcb0ec82..b2566324 100644 --- a/package.nw/lib/callsigns.js +++ b/package.nw/lib/callsigns.js @@ -20,19 +20,26 @@ var g_oqrsFile = ""; var g_oqrsWhenDate = 0; var g_oqrsLoadTimer = null; -function dumpFile(file) { - try { +function dumpFile(file) +{ + try + { if (fs.existsSync(file)) fs.unlinkSync(file); - } catch (e) {} + } + catch (e) {} } -function dumpDir(dir) { - try { +function dumpDir(dir) +{ + try + { if (fs.existsSync(dir)) fs.rmdirSync(dir); - } catch (e) {} + } + catch (e) {} } -function callsignServicesInit() { +function callsignServicesInit() +{ // Dump old data files we no longer reference dumpFile(g_jsonDir + "uls-callsigns.json"); dumpFile(g_jsonDir + "us-callsigns.json"); @@ -48,16 +55,20 @@ function callsignServicesInit() { g_eqslFile = g_NWappData + "eqsl-callsigns.json"; g_oqrsFile = g_NWappData + "cloqrs-callsigns.json"; - if (g_callsignLookups.lotwUseEnable) { + if (g_callsignLookups.lotwUseEnable) + { lotwLoadCallsigns(); } - if (g_callsignLookups.eqslUseEnable) { + if (g_callsignLookups.eqslUseEnable) + { eqslLoadCallsigns(); } - if (g_callsignLookups.ulsUseEnable) { + if (g_callsignLookups.ulsUseEnable) + { ulsLoadCallsigns(); } - if (g_callsignLookups.oqrsUseEnable) { + if (g_callsignLookups.oqrsUseEnable) + { oqrsLoadCallsigns(); } @@ -67,46 +78,59 @@ function callsignServicesInit() { oqrsSettingsDisplay(); } -function saveCallsignSettings() { +function saveCallsignSettings() +{ localStorage.callsignLookups = JSON.stringify(g_callsignLookups); } -function lotwLoadCallsigns() { +function lotwLoadCallsigns() +{ var now = timeNowSec(); if (now - g_callsignLookups.lotwLastUpdate > 86400 * 7) - g_callsignLookups.lotwLastUpdate = 0; - else { + { g_callsignLookups.lotwLastUpdate = 0; } + else + { var lotwWhenTimer = 86400 * 7 - (now - g_callsignLookups.lotwLastUpdate); g_lotwWhenDate = now + lotwWhenTimer; g_lotwLoadTimer = setTimeout(lotwDownload, lotwWhenTimer * 1000); } - if (!fs.existsSync(g_lotwFile)) { + if (!fs.existsSync(g_lotwFile)) + { g_callsignLookups.lotwLastUpdate = 0; - } else { + } + else + { var data = fs.readFileSync(g_lotwFile); g_lotwCallsigns = JSON.parse(data); - if (Object.keys(g_lotwCallsigns).length < 100) { + if (Object.keys(g_lotwCallsigns).length < 100) + { lotwDownload(); } } - if (g_callsignLookups.lotwLastUpdate == 0) { + if (g_callsignLookups.lotwLastUpdate == 0) + { lotwDownload(); } } -function lotwSettingsDisplay() { +function lotwSettingsDisplay() +{ lotwUseEnable.checked = g_callsignLookups.lotwUseEnable; - if (g_callsignLookups.lotwLastUpdate == 0) { + if (g_callsignLookups.lotwLastUpdate == 0) + { lotwUpdatedTd.innerHTML = "Never"; - } else { + } + else + { lotwUpdatedTd.innerHTML = userTimeString( g_callsignLookups.lotwLastUpdate * 1000 ); } - if (!g_callsignLookups.lotwUseEnable) { + if (!g_callsignLookups.lotwUseEnable) + { if (g_lotwLoadTimer != null) clearTimeout(g_lotwLoadTimer); g_lotwLoadTimer = null; g_lotwCallsigns = Object(); @@ -114,10 +138,12 @@ function lotwSettingsDisplay() { lotwCountTd.innerHTML = Object.keys(g_lotwCallsigns).length; } -function lotwValuesChanged() { +function lotwValuesChanged() +{ g_callsignLookups.lotwUseEnable = lotwUseEnable.checked; saveCallsignSettings(); - if (g_callsignLookups.lotwUseEnable == true) { + if (g_callsignLookups.lotwUseEnable == true) + { lotwLoadCallsigns(); } lotwSettingsDisplay(); @@ -127,7 +153,8 @@ function lotwValuesChanged() { if (g_callRosterWindowHandle) g_callRosterWindowHandle.window.resize(); } -function lotwDownload(fromSettings) { +function lotwDownload(fromSettings) +{ lotwUpdatedTd.innerHTML = "Downloading..."; getBuffer( "https://lotw.arrl.org/lotw-user-activity.csv", @@ -138,15 +165,18 @@ function lotwDownload(fromSettings) { ); } -function processLotwCallsigns(result, flag) { - //var result = String(buffer); +function processLotwCallsigns(result, flag) +{ + // var result = String(buffer); var lines = Array(); lines = result.split("\n"); var lotwCallsigns = Object(); - for (x in lines) { + for (x in lines) + { var breakout = lines[x].split(","); - if (breakout.length == 3) { + if (breakout.length == 3) + { var dateTime = new Date( Date.UTC( breakout[1].substr(0, 4), @@ -170,7 +200,8 @@ function processLotwCallsigns(result, flag) { g_lotwWhenDate = now + lotwWhenTimer; g_lotwLoadTimer = setTimeout(lotwDownload, lotwWhenTimer * 1000); - if (Object.keys(lotwCallsigns).length > 100) { + if (Object.keys(lotwCallsigns).length > 100) + { g_lotwCallsigns = lotwCallsigns; fs.writeFileSync(g_lotwFile, JSON.stringify(g_lotwCallsigns)); } @@ -178,39 +209,50 @@ function processLotwCallsigns(result, flag) { lotwSettingsDisplay(); } -function oqrsLoadCallsigns() { +function oqrsLoadCallsigns() +{ var now = timeNowSec(); if (now - g_callsignLookups.oqrsLastUpdate > 86400 * 7) - g_callsignLookups.oqrsLastUpdate = 0; - else { + { g_callsignLookups.oqrsLastUpdate = 0; } + else + { var oqrsWhenTimer = 86400 * 7 - (now - g_callsignLookups.oqrsLastUpdate); g_oqrsWhenDate = now + oqrsWhenTimer; g_oqrsLoadTimer = setTimeout(oqrsDownload, oqrsWhenTimer * 1000); } - if (!fs.existsSync(g_oqrsFile)) { + if (!fs.existsSync(g_oqrsFile)) + { g_callsignLookups.oqrsLastUpdate = 0; - } else { + } + else + { var data = fs.readFileSync(g_oqrsFile); g_oqrsCallsigns = JSON.parse(data); } - if (g_callsignLookups.oqrsLastUpdate == 0) { + if (g_callsignLookups.oqrsLastUpdate == 0) + { oqrsDownload(); } } -function oqrsSettingsDisplay() { +function oqrsSettingsDisplay() +{ oqrsUseEnable.checked = g_callsignLookups.oqrsUseEnable; - if (g_callsignLookups.oqrsLastUpdate == 0) { + if (g_callsignLookups.oqrsLastUpdate == 0) + { oqrsUpdatedTd.innerHTML = "Never"; - } else { + } + else + { oqrsUpdatedTd.innerHTML = userTimeString( g_callsignLookups.oqrsLastUpdate * 1000 ); } - if (!g_callsignLookups.oqrsUseEnable) { + if (!g_callsignLookups.oqrsUseEnable) + { if (g_oqrsLoadTimer != null) clearTimeout(g_oqrsLoadTimer); g_oqrsLoadTimer = null; g_oqrsCallsigns = Object(); @@ -218,10 +260,12 @@ function oqrsSettingsDisplay() { oqrsCountTd.innerHTML = Object.keys(g_oqrsCallsigns).length; } -function oqrsValuesChanged() { +function oqrsValuesChanged() +{ g_callsignLookups.oqrsUseEnable = oqrsUseEnable.checked; saveCallsignSettings(); - if (g_callsignLookups.oqrsUseEnable == true) { + if (g_callsignLookups.oqrsUseEnable == true) + { oqrsLoadCallsigns(); } oqrsSettingsDisplay(); @@ -231,7 +275,8 @@ function oqrsValuesChanged() { if (g_callRosterWindowHandle) g_callRosterWindowHandle.window.resize(); } -function oqrsDownload(fromSettings) { +function oqrsDownload(fromSettings) +{ oqrsUpdatedTd.innerHTML = "Downloading..."; getBuffer( "http://app.gridtracker.org/callsigns/clublog.json", @@ -242,7 +287,8 @@ function oqrsDownload(fromSettings) { ); } -function processoqrsCallsigns(buffer, flag) { +function processoqrsCallsigns(buffer, flag) +{ g_oqrsCallsigns = JSON.parse(buffer); g_callsignLookups.oqrsLastUpdate = timeNowSec(); @@ -258,39 +304,50 @@ function processoqrsCallsigns(buffer, flag) { oqrsSettingsDisplay(); } -function eqslLoadCallsigns() { +function eqslLoadCallsigns() +{ var now = timeNowSec(); if (now - g_callsignLookups.eqslLastUpdate > 86400 * 7) - g_callsignLookups.eqslLastUpdate = 0; - else { + { g_callsignLookups.eqslLastUpdate = 0; } + else + { var eqslWhenTimer = 86400 * 7 - (now - g_callsignLookups.eqslLastUpdate); g_eqslWhenDate = now + eqslWhenTimer; g_eqslLoadTimer = setTimeout(eqslDownload, eqslWhenTimer * 1000); } - if (!fs.existsSync(g_eqslFile)) { + if (!fs.existsSync(g_eqslFile)) + { g_callsignLookups.eqslLastUpdate = 0; - } else { + } + else + { var data = fs.readFileSync(g_eqslFile); g_eqslCallsigns = JSON.parse(data); } - if (g_callsignLookups.eqslLastUpdate == 0) { + if (g_callsignLookups.eqslLastUpdate == 0) + { eqslDownload(); } } -function eqslSettingsDisplay() { +function eqslSettingsDisplay() +{ eqslUseEnable.checked = g_callsignLookups.eqslUseEnable; - if (g_callsignLookups.eqslLastUpdate == 0) { + if (g_callsignLookups.eqslLastUpdate == 0) + { eqslUpdatedTd.innerHTML = "Never"; - } else { + } + else + { eqslUpdatedTd.innerHTML = userTimeString( g_callsignLookups.eqslLastUpdate * 1000 ); } - if (!g_callsignLookups.eqslUseEnable) { + if (!g_callsignLookups.eqslUseEnable) + { if (g_eqslLoadTimer != null) clearTimeout(g_eqslLoadTimer); g_eqslLoadTimer = null; g_eqslCallsigns = Object(); @@ -298,10 +355,12 @@ function eqslSettingsDisplay() { eqslCountTd.innerHTML = Object.keys(g_eqslCallsigns).length; } -function eqslValuesChanged() { +function eqslValuesChanged() +{ g_callsignLookups.eqslUseEnable = eqslUseEnable.checked; saveCallsignSettings(); - if (g_callsignLookups.eqslUseEnable == true) { + if (g_callsignLookups.eqslUseEnable == true) + { eqslLoadCallsigns(); } eqslSettingsDisplay(); @@ -311,7 +370,8 @@ function eqslValuesChanged() { if (g_callRosterWindowHandle) g_callRosterWindowHandle.window.resize(); } -function eqslDownload(fromSettings) { +function eqslDownload(fromSettings) +{ eqslUpdatedTd.innerHTML = "Downloading..."; getBuffer( "https://www.eqsl.cc/qslcard/DownloadedFiles/AGMemberList.txt", @@ -322,12 +382,14 @@ function eqslDownload(fromSettings) { ); } -function processeqslCallsigns(buffer, flag) { +function processeqslCallsigns(buffer, flag) +{ var result = String(buffer); var lines = Array(); lines = result.split("\n"); g_eqslCallsigns = Object(); - for (x in lines) { + for (x in lines) + { g_eqslCallsigns[lines[x].trim()] = true; } g_callsignLookups.eqslLastUpdate = timeNowSec(); @@ -340,20 +402,23 @@ function processeqslCallsigns(buffer, flag) { g_eqslLoadTimer = setTimeout(eqslDownload, eqslWhenTimer * 1000); if (Object.keys(g_eqslCallsigns).length > 10000) - fs.writeFileSync(g_eqslFile, JSON.stringify(g_eqslCallsigns)); + { fs.writeFileSync(g_eqslFile, JSON.stringify(g_eqslCallsigns)); } eqslSettingsDisplay(); } -function ulsLoadCallsigns() { - if (g_ulsLoadTimer != null) { +function ulsLoadCallsigns() +{ + if (g_ulsLoadTimer != null) + { clearTimeout(g_ulsLoadTimer); g_ulsLoadTimer = null; } var now = timeNowSec(); if (now - g_callsignLookups.ulsLastUpdate > 86400 * 7) ulsDownload(); - else { + else + { var ulsWhenTimer = 86400 * 7 - (now - g_callsignLookups.ulsLastUpdate); g_ulsWhenDate = now + ulsWhenTimer; g_ulsLoadTimer = setTimeout(ulsDownload, ulsWhenTimer * 1000); @@ -361,28 +426,39 @@ function ulsLoadCallsigns() { } } -function updateQSO() { - if (g_ulsCallsignsCount > 0) { - for (hash in g_QSOhash) { +function updateQSO() +{ + if (g_ulsCallsignsCount > 0) + { + for (hash in g_QSOhash) + { var details = g_QSOhash[hash]; var lookupCall = false; if ( (details.cnty == null || details.state == null) && isKnownCallsignDXCC(details.dxcc) - ) { + ) + { // Do County Lookup lookupCall = true; - } else if (details.cnty != null && isKnownCallsignUSplus(details.dxcc)) { - if (!(details.cnty in g_cntyToCounty)) { - if (details.cnty.indexOf(",") == -1) { + } + else if (details.cnty != null && isKnownCallsignUSplus(details.dxcc)) + { + if (!(details.cnty in g_cntyToCounty)) + { + if (details.cnty.indexOf(",") == -1) + { if (!(details.state + "," + details.cnty in g_cntyToCounty)) - lookupCall = true; - } else lookupCall = true; + { lookupCall = true; } + } + else lookupCall = true; } } - if (lookupCall) { - if (g_callsignLookups.ulsUseEnable) { + if (lookupCall) + { + if (g_callsignLookups.ulsUseEnable) + { lookupUsCallsign(details, true); } } @@ -390,16 +466,20 @@ function updateQSO() { } } -function updateCallsignCount() { - g_ulsDatabase.transaction(function (tx) { +function updateCallsignCount() +{ + g_ulsDatabase.transaction(function (tx) + { tx.executeSql( "SELECT count(*) as cnt FROM calls", [], - function (tx, results) { + function (tx, results) + { var len = results.rows.length, i; - if (len == 1) { - g_ulsCallsignsCount = results.rows[0]["cnt"]; + if (len == 1) + { + g_ulsCallsignsCount = results.rows[0].cnt; ulsCountTd.innerHTML = g_ulsCallsignsCount; updateQSO(); @@ -410,18 +490,23 @@ function updateCallsignCount() { }); } -function ulsSettingsDisplay() { +function ulsSettingsDisplay() +{ ulsUseEnable.checked = g_callsignLookups.ulsUseEnable; - if (g_callsignLookups.ulsLastUpdate == 0) { + if (g_callsignLookups.ulsLastUpdate == 0) + { ulsUpdatedTd.innerHTML = "Never"; - } else { + } + else + { ulsUpdatedTd.innerHTML = userTimeString( g_callsignLookups.ulsLastUpdate * 1000 ); } - if (!g_callsignLookups.ulsUseEnable) { + if (!g_callsignLookups.ulsUseEnable) + { if (g_ulsLoadTimer != null) clearTimeout(g_ulsLoadTimer); g_ulsLoadTimer = null; g_ulsCallsignsCount = 0; @@ -429,12 +514,16 @@ function ulsSettingsDisplay() { } } -function ulsValuesChanged() { +function ulsValuesChanged() +{ g_callsignLookups.ulsUseEnable = ulsUseEnable.checked; - if (g_callsignLookups.ulsUseEnable == true) { + if (g_callsignLookups.ulsUseEnable == true) + { ulsLoadCallsigns(); - } else { + } + else + { resetULSDatabase(); ulsCountTd.innerHTML = 0; } @@ -445,7 +534,8 @@ function ulsValuesChanged() { if (g_callRosterWindowHandle) g_callRosterWindowHandle.window.resize(); } -function ulsDownload() { +function ulsDownload() +{ ulsUpdatedTd.innerHTML = "Downloading..."; ulsCountTd.innerHTML = 0; getChunkedBuffer( @@ -465,48 +555,58 @@ function getChunkedBuffer( port, cookie, errorHandler -) { +) +{ var url = require("url"); var http = require(mode); var fileBuffer = null; var options = null; - if (cookie != null) { + if (cookie != null) + { options = { host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api port: port, followAllRedirects: true, path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api headers: { - Cookie: cookie, - }, + Cookie: cookie + } }; - } else { + } + else + { options = { host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api port: port, followAllRedirects: true, - path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api + path: url.parse(file_url).path // eslint-disable-line node/no-deprecated-api }; } - http.get(options, function (res) { + http.get(options, function (res) + { var fsize = res.headers["content-length"]; var fread = 0; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { var isEnd = false; fread += data.length; if (fread == fsize) isEnd = true; - if (fileBuffer == null) { + if (fileBuffer == null) + { fileBuffer = callback(data, flag, cookies, true, isEnd); - } else { + } + else + { fileBuffer = callback(fileBuffer + data, flag, cookies, false, isEnd); // eslint-disable-line node/no-callback-literal } }) .on("end", function () {}) - .on("error", function (e) { + .on("error", function (e) + { console.error("Got error: " + e.message); }); }); @@ -519,35 +619,45 @@ var g_ulsDatabase = openDatabase( 50 * 1024 * 1024 ); -g_ulsDatabase.transaction(function (tx) { +g_ulsDatabase.transaction(function (tx) +{ tx.executeSql( "CREATE TABLE IF NOT EXISTS calls ( callsign TEXT PRIMARY KEY, zip, state)" ); }); -function resetULSDatabase() { +function resetULSDatabase() +{ g_callsignLookups.ulsLastUpdate = 0; g_ulsCallsignsCount = 0; } -function processulsCallsigns(data, flag, cookies, starting, finished) { +function processulsCallsigns(data, flag, cookies, starting, finished) +{ var buffer = String(data); var returnBuffer = ""; - if (buffer && buffer.length > 0) { + if (buffer && buffer.length > 0) + { var lines = null; - if (buffer[buffer.length - 1] == "\n") { + if (buffer[buffer.length - 1] == "\n") + { lines = buffer.split("\n"); - } else { + } + else + { var lastIndex = buffer.lastIndexOf("\n"); returnBuffer = buffer.substring(lastIndex); lines = buffer.substring(0, lastIndex).split("\n"); } - if (lines.length > 0) { - g_ulsDatabase.transaction(function (tx) { - if (starting == true) { + if (lines.length > 0) + { + g_ulsDatabase.transaction(function (tx) + { + if (starting == true) + { if (g_ulsLoadTimer != null) clearTimeout(g_ulsLoadTimer); g_ulsLoadTimer = null; g_ulsWhenDate = 0; @@ -555,29 +665,34 @@ function processulsCallsigns(data, flag, cookies, starting, finished) { ulsUpdatedTd.innerHTML = "Processing..."; tx.executeSql("delete from calls"); } - for (var x in lines) { - if (lines[x].length) { + for (var x in lines) + { + if (lines[x].length) + { ++g_ulsCallsignsCount; tx.executeSql( "INSERT INTO calls (rowid, callsign, zip, state) VALUES (" + g_ulsCallsignsCount + - ',"' + + ",\"" + lines[x].substr(7) + - '","' + + "\",\"" + lines[x].substr(0, 5) + - '","' + + "\",\"" + lines[x].substr(5, 2) + - '")' + "\")" ); - if (g_ulsCallsignsCount % 10000 == 0) { + if (g_ulsCallsignsCount % 10000 == 0) + { tx.executeSql( "SELECT count(*) as cnt FROM calls", [], - function (rx, results) { + function (rx, results) + { var len = results.rows.length, i; - if (len == 1) { - ulsCountTd.innerHTML = results.rows[0]["cnt"]; + if (len == 1) + { + ulsCountTd.innerHTML = results.rows[0].cnt; } } ); @@ -589,7 +704,8 @@ function processulsCallsigns(data, flag, cookies, starting, finished) { } } - if (finished == true) { + if (finished == true) + { var now = timeNowSec(); if (g_ulsLoadTimer != null) clearTimeout(g_ulsLoadTimer); @@ -598,15 +714,18 @@ function processulsCallsigns(data, flag, cookies, starting, finished) { g_ulsWhenDate = ulsWhenTimer + now; g_ulsLoadTimer = setTimeout(ulsDownload, ulsWhenTimer * 1000); - g_ulsDatabase.transaction(function (tx) { + g_ulsDatabase.transaction(function (tx) + { tx.executeSql( "SELECT count(*) as cnt FROM calls", [], - function (rx, results) { + function (rx, results) + { var len = results.rows.length, i; - if (len == 1) { - g_ulsCallsignsCount = results.rows[0]["cnt"]; + if (len == 1) + { + g_ulsCallsignsCount = results.rows[0].cnt; ulsCountTd.innerHTML = g_ulsCallsignsCount; g_callsignLookups.ulsLastUpdate = timeNowSec(); saveCallsignSettings(); @@ -621,47 +740,61 @@ function processulsCallsigns(data, flag, cookies, starting, finished) { return Buffer(returnBuffer); // eslint-disable-line node/no-deprecated-api } -function lookupUsCallsign(object, writeState = false) { - g_ulsDatabase.transaction(function (tx) { - var qry = 'SELECT * FROM calls where callsign = "' + object.DEcall + '"'; +function lookupUsCallsign(object, writeState = false) +{ + g_ulsDatabase.transaction(function (tx) + { + var qry = "SELECT * FROM calls where callsign = \"" + object.DEcall + "\""; tx.executeSql( qry, [], - function (tx, results) { + function (tx, results) + { var len = results.rows.length, i; - if (len == 1) { - if (object.state == null) { - if (object.dxcc == 1) { - object.state = "CA-" + results.rows[0]["state"]; - } else { - object.state = "US-" + results.rows[0]["state"]; + if (len == 1) + { + if (object.state == null) + { + if (object.dxcc == 1) + { + object.state = "CA-" + results.rows[0].state; + } + else + { + object.state = "US-" + results.rows[0].state; } if (writeState) setState(object); } - object.zipcode = String(results.rows[0]["zip"]); - if (object.cnty == null) { + object.zipcode = String(results.rows[0].zip); + if (object.cnty == null) + { let request = g_Idb .transaction(["lookups"], "readwrite") .objectStore("lookups") .get(object.DEcall); - request.onsuccess = function (event) { - if (request.result) { + request.onsuccess = function (event) + { + if (request.result) + { object.cnty = request.result.cnty; object.qual = true; } - if (object.cnty == null && object.zipcode in g_zipToCounty) { + 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; object.cnty = counties[0]; - } else object.qual = false; + } + else object.qual = false; if (writeState) setState(object); }; - request.onerror = function (event) { + request.onerror = function (event) + { object.qual = false; if (writeState) setState(object); }; diff --git a/package.nw/lib/datepicker.js b/package.nw/lib/datepicker.js index d507c57a..0c871f5a 100644 --- a/package.nw/lib/datepicker.js +++ b/package.nw/lib/datepicker.js @@ -1,5 +1,6 @@ var picker = { - attach : function (opt) { + attach: function (opt) + { // attach() : attach datepicker to target // opt : options (object) // target : datepicker will populate this field @@ -10,47 +11,50 @@ var picker = { // (A) Create new datepicker var dp = document.createElement("div"); dp.dataset.target = opt.target; - dp.dataset.fire = opt.fire; + dp.dataset.fire = opt.fire; dp.dataset.startmon = opt.startmon ? "1" : "0"; dp.classList.add("picker"); - if (opt.disableday) { + if (opt.disableday) + { dp.dataset.disableday = JSON.stringify(opt.disableday); } // (B) Default to current month + year // ! NOTE: UTC+0 ! var today = new Date(), - thisMonth = today.getUTCMonth(), // Note: Jan is 0 - thisYear = today.getUTCFullYear(), - months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + thisMonth = today.getUTCMonth(), // Note: Jan is 0 + thisYear = today.getUTCFullYear(), + months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; // (C) Month select var select = document.createElement("select"), - option = null; + option = null; select.classList.add("picker-m"); - for (var mth in months) { + for (var mth in months) + { option = document.createElement("option"); option.value = parseInt(mth) + 1; option.text = months[mth]; select.appendChild(option); } select.selectedIndex = thisMonth; - select.addEventListener("change", function(){ picker.draw(this); }); + select.addEventListener("change", function() { picker.draw(this); }); dp.appendChild(select); // (D) Year select var yRange = 100; // Year range to show, I.E. from thisYear-yRange to thisYear+yRange select = document.createElement("select"); select.classList.add("picker-y"); - for (var y = thisYear-yRange; y < thisYear+20; y++) { + for (var y = thisYear - yRange; y < thisYear + 20; y++) + { option = document.createElement("option"); option.value = y; option.text = y; select.appendChild(option); } select.selectedIndex = yRange; - select.addEventListener("change", function(){ picker.draw(this); }); + select.addEventListener("change", function() { picker.draw(this); }); dp.appendChild(select); // (E) Day select @@ -62,10 +66,12 @@ var picker = { picker.draw(select); // (F1) Popup datepicker - if (opt.container==1) { + if (opt.container == 1) + { // Mark this as a "popup" var uniqueID = 0; - while (document.getElementById("picker-" + uniqueID) != null) { + while (document.getElementById("picker-" + uniqueID) != null) + { uniqueID = Math.floor(Math.random() * (100 - 2)) + 1; } dp.dataset.popup = "1"; @@ -80,11 +86,14 @@ var picker = { // Attach onclick to show/hide datepicker var target = document.getElementById(opt.target); target.dataset.dp = uniqueID; - target.onfocus = function () { + target.onfocus = function () + { document.getElementById("picker-" + this.dataset.dp).classList.add("show"); }; - wrapper.addEventListener("click", function (evt) { - if (evt.target.classList.contains("picker-wrap")) { + wrapper.addEventListener("click", function (evt) + { + if (evt.target.classList.contains("picker-wrap")) + { this.classList.remove("show"); } }); @@ -94,82 +103,93 @@ var picker = { } // (F2) Inline datepicker - else { + else + { document.getElementById(opt.container).appendChild(dp); } }, - draw : function (el) { + draw: function (el) + { // draw() : draw the days in month // el : HTML reference to either year or month selector // (A) Get date picker components var parent = el.parentElement, - year = parent.getElementsByClassName("picker-y")[0].value, - month = parent.getElementsByClassName("picker-m")[0].value, - days = parent.getElementsByClassName("picker-d")[0]; + year = parent.getElementsByClassName("picker-y")[0].value, + month = parent.getElementsByClassName("picker-m")[0].value, + days = parent.getElementsByClassName("picker-d")[0]; // (B) Date range calculation // ! NOTE: UTC+0 ! var daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate(), - startDay = new Date(Date.UTC(year, month-1, 1)).getUTCDay(), // Note: Sun = 0 - endDay = new Date(Date.UTC(year, month-1, daysInMonth)).getUTCDay(), - startDay = startDay==0 ? 7 : startDay, - endDay = endDay==0 ? 7 : endDay; + startDay = new Date(Date.UTC(year, month - 1, 1)).getUTCDay(), // Note: Sun = 0 + endDay = new Date(Date.UTC(year, month - 1, daysInMonth)).getUTCDay(), + startDay = startDay == 0 ? 7 : startDay, + endDay = endDay == 0 ? 7 : endDay; // (C) Generate date squares (in array first) var squares = [], - disableday = null; - if (parent.dataset.disableday) { + disableday = null; + if (parent.dataset.disableday) + { disableday = JSON.parse(parent.dataset.disableday); } // (C1) Empty squares before first day of month - if (parent.dataset.startmon=="1" && startDay!=1) { - for (var i=1; i 0 ) - { - window[parent.dataset.fire](); - } + if (parent.dataset.fire.length > 0) + { + window[parent.dataset.fire](); + } // (D) Popup only - close the popup - if (parent.dataset.popup == "1") { + if (parent.dataset.popup == "1") + { document.getElementById("picker-" + parent.dataset.dpid).classList.remove("show"); } } -}; \ No newline at end of file +}; diff --git a/package.nw/lib/defaults.js b/package.nw/lib/defaults.js index f59a3bd3..f386dfde 100644 --- a/package.nw/lib/defaults.js +++ b/package.nw/lib/defaults.js @@ -26,7 +26,7 @@ var validSettings = [ "speechSettings", "startupLogs", "trustedQslSettings", - "screenSettings", + "screenSettings" ]; var def_appSettings = { @@ -88,7 +88,7 @@ var def_appSettings = { workingCallsigns: {}, workingDateEnable: false, workingDate: 0, - gtSpotEnable: true, + gtSpotEnable: true }; var def_mapSettings = { @@ -125,7 +125,7 @@ var def_mapSettings = { trafficDecode: true, usNexrad: false, zoom: 4, - mapTrans: 0.5, + mapTrans: 0.5 }; var def_adifLogSettings = { @@ -134,7 +134,7 @@ var def_adifLogSettings = { buttonClubCheckBox: false, buttonLOTWCheckBox: false, buttonQRZCheckBox: false, - buttonPsk24CheckBox: true, + buttonPsk24CheckBox: true }, startup: { loadAdifCheckBox: false, @@ -142,7 +142,7 @@ var def_adifLogSettings = { loadQRZCheckBox: false, loadLOTWCheckBox: false, loadClubCheckBox: false, - loadGTCheckBox: true, + loadGTCheckBox: true }, qsolog: { logQRZqsoCheckBox: false, @@ -151,10 +151,10 @@ var def_adifLogSettings = { logHRDLOGqsoCheckBox: false, logClubqsoCheckBox: false, logCloudlogQSOCheckBox: false, - logeQSLQSOCheckBox: false, + logeQSLQSOCheckBox: false }, nickname: { - nicknameeQSLCheckBox: false, + nicknameeQSLCheckBox: false }, text: { lotwLogin: "", @@ -171,9 +171,9 @@ var def_adifLogSettings = { CloudlogAPI: "", eQSLUser: "", eQSLPassword: "", - eQSLNickname: "", + eQSLNickname: "" }, - downloads: {}, + downloads: {} }; var def_msgSettings = { @@ -183,7 +183,7 @@ var def_msgSettings = { msgFrequencySelect: 0, msgActionSelect: 0, msgAwaySelect: 0, - msgAwayText: "I am away from the shack at the moment", + msgAwayText: "I am away from the shack at the moment" }; var def_receptionSettings = { @@ -194,39 +194,39 @@ var def_receptionSettings = { pathColor: -1, pathNightColor: 361, spotWidth: 0.8, - mergeSpots: false, + mergeSpots: false }; var def_N1MMSettings = { enable: false, port: 2333, - ip: "127.0.0.1", + ip: "127.0.0.1" }; var def_log4OMSettings = { enable: false, port: 2236, - ip: "127.0.0.1", + ip: "127.0.0.1" }; var def_dxkLogSettings = { enable: false, port: 52000, - ip: "127.0.0.1", + ip: "127.0.0.1" }; var def_HRDLogbookLogSettings = { enable: false, port: 7826, - ip: "127.0.0.1", + ip: "127.0.0.1" }; var def_acLogSettings = { enable: false, port: 1100, - ip: "127.0.0.1", + ip: "127.0.0.1" }; var def_trustedQslSettings = { stationFile: "", stationFileValid: false, binaryFile: "", - binaryFileValid: false, + binaryFileValid: false }; var def_callsignLookups = { lotwUseEnable: true, @@ -240,10 +240,10 @@ var def_callsignLookups = { ulsLastUpdate: 0, oqrsUseEnable: false, oqrsWeeklyEnable: false, - oqrsLastUpdate: 0, + oqrsLastUpdate: 0 }; var def_bandActivity = { lastUpdate: {}, - lines: {}, + lines: {} }; diff --git a/package.nw/lib/fw.js b/package.nw/lib/fw.js index 63303031..5bca8f89 100644 --- a/package.nw/lib/fw.js +++ b/package.nw/lib/fw.js @@ -1,9 +1,10 @@ -function hooray() { +function hooray() +{ var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight, mousePos = { x: 400, - y: 300, + y: 300 }, // create canvas canvas = document.createElement("canvas"), @@ -14,7 +15,8 @@ function hooray() { colorCode = 0; // init - $(document).ready(function () { + $(document).ready(function () + { document.body.appendChild(canvas); canvas.width = SCREEN_WIDTH; canvas.height = SCREEN_HEIGHT; @@ -23,27 +25,33 @@ function hooray() { }); // update mouse position - $(document).mousemove(function (e) { + $(document).mousemove(function (e) + { e.preventDefault(); mousePos = { x: e.clientX, - y: e.clientY, + y: e.clientY }; }); // launch more rockets!!! - $(document).mousedown(function (e) { - for (var i = 0; i < 5; i++) { + $(document).mousedown(function (e) + { + for (var i = 0; i < 5; i++) + { launchFrom((Math.random() * SCREEN_WIDTH * 2) / 3 + SCREEN_WIDTH / 6); } }); - function launch() { + function launch() + { launchFrom(mousePos.x); } - function launchFrom(x) { - if (rockets.length < 10) { + function launchFrom(x) + { + if (rockets.length < 10) + { var rocket = new Rocket(x); rocket.explosionColor = Math.floor((Math.random() * 360) / 10) * 10; rocket.vel.y = Math.random() * -3 - 4; @@ -55,12 +63,15 @@ function hooray() { } } - function loop() { + function loop() + { // update screen size - if (SCREEN_WIDTH != window.innerWidth) { + if (SCREEN_WIDTH != window.innerWidth) + { canvas.width = SCREEN_WIDTH = window.innerWidth; } - if (SCREEN_HEIGHT != window.innerHeight) { + if (SCREEN_HEIGHT != window.innerHeight) + { canvas.height = SCREEN_HEIGHT = window.innerHeight; } @@ -70,7 +81,8 @@ function hooray() { var existingRockets = []; - for (var i = 0; i < rockets.length; i++) { + for (var i = 0; i < rockets.length; i++) + { // update and render rockets[i].update(); rockets[i].render(context); @@ -98,9 +110,12 @@ function hooray() { rockets[i].vel.y >= 0 || distance < 50 || randomChance - ) { + ) + { rockets[i].explode(); - } else { + } + else + { existingRockets.push(rockets[i]); } } @@ -109,11 +124,13 @@ function hooray() { var existingParticles = []; - for (var i = 0; i < particles.length; i++) { + for (var i = 0; i < particles.length; i++) + { particles[i].update(); // render and save particles that can be rendered - if (particles[i].exists()) { + if (particles[i].exists()) + { particles[i].render(context); existingParticles.push(particles[i]); } @@ -122,19 +139,21 @@ function hooray() { // update array with existing particles - old particles should be garbage collected particles = existingParticles; - while (particles.length > MAX_PARTICLES) { + while (particles.length > MAX_PARTICLES) + { particles.shift(); } } - function Particle(pos) { + function Particle(pos) + { this.pos = { x: pos ? pos.x : 0, - y: pos ? pos.y : 0, + y: pos ? pos.y : 0 }; this.vel = { x: 0, - y: 0, + y: 0 }; this.shrink = 0.97; this.size = 2; @@ -149,7 +168,8 @@ function hooray() { this.color = 0; } - Particle.prototype.update = function () { + Particle.prototype.update = function () + { // apply resistance this.vel.x *= this.resistance; this.vel.y *= this.resistance; @@ -168,8 +188,10 @@ function hooray() { this.alpha -= this.fade; }; - Particle.prototype.render = function (c) { - if (!this.exists()) { + Particle.prototype.render = function (c) + { + if (!this.exists()) + { return; } @@ -206,16 +228,18 @@ function hooray() { c.restore(); }; - Particle.prototype.exists = function () { + Particle.prototype.exists = function () + { return this.alpha >= 0.1 && this.size >= 1; }; - function Rocket(x) { + function Rocket(x) + { Particle.apply(this, [ { x: x, - y: SCREEN_HEIGHT, - }, + y: SCREEN_HEIGHT + } ]); this.explosionColor = 0; @@ -224,10 +248,12 @@ function hooray() { Rocket.prototype = new Particle(); Rocket.prototype.constructor = Rocket; - Rocket.prototype.explode = function () { + Rocket.prototype.explode = function () + { var count = Math.random() * 10 + 80; - for (var i = 0; i < count; i++) { + for (var i = 0; i < count; i++) + { var particle = new Particle(this.pos); var angle = Math.random() * Math.PI * 2; @@ -250,8 +276,10 @@ function hooray() { } }; - Rocket.prototype.render = function (c) { - if (!this.exists()) { + Rocket.prototype.render = function (c) + { + if (!this.exists()) + { return; } diff --git a/package.nw/lib/gt.js b/package.nw/lib/gt.js index 18eeadea..fad91be9 100644 --- a/package.nw/lib/gt.js +++ b/package.nw/lib/gt.js @@ -7,12 +7,13 @@ var gtBeta = pjson.betaVersion; var g_startVersion = 0; if (typeof localStorage.currentVersion != "undefined") - g_startVersion = localStorage.currentVersion; +{ g_startVersion = localStorage.currentVersion; } if ( typeof localStorage.currentVersion == "undefined" || localStorage.currentVersion != String(gtVersion) -) { +) +{ localStorage.currentVersion = String(gtVersion); var gui = require("nw.gui"); gui.App.clearCache(); @@ -38,7 +39,8 @@ const path = require("path"); const g_dirSeperator = path.sep; var g_platform = os.platform(); -if (g_platform.indexOf("win") == 0 || g_platform.indexOf("Win") == 0) { +if (g_platform.indexOf("win") == 0 || g_platform.indexOf("Win") == 0) +{ g_platform = "windows"; } if (g_platform.indexOf("inux") > -1) g_platform = "linux"; @@ -78,25 +80,28 @@ var g_callsignDatabaseDXCC = { 1: true, 6: true, 110: true, - 202: true, + 202: true }; var g_callsignDatabaseUS = { 291: true, 6: true, - 110: true, + 110: true }; var g_callsignDatabaseUSplus = { 291: true, 6: true, 110: true, - 202: true, + 202: true }; -function loadAllSettings() { - for (var x in localStorage) { - if (!validSettings.includes(x) && typeof localStorage[x] == "string") { +function loadAllSettings() +{ + for (var x in localStorage) + { + if (!validSettings.includes(x) && typeof localStorage[x] == "string") + { delete localStorage[x]; } } @@ -134,9 +139,11 @@ function loadAllSettings() { g_startupLogs = loadArrayIfExists("startupLogs"); g_mapMemory = loadArrayIfExists("mapMemory"); - if (g_mapMemory.length != 7) { + if (g_mapMemory.length != 7) + { g_mapMemory = []; - for (var x = 0; x < 7; x++) { + for (var x = 0; x < 7; x++) + { g_mapMemory[x] = {}; g_mapMemory[x].zoom = -1; g_mapMemory[x].LoLa = [0, 0]; @@ -164,14 +171,18 @@ var g_heatEnabled = g_appSettings.heatEnabled; var g_myLat = g_mapSettings.latitude; var g_myLon = g_mapSettings.longitude; -function loadDefaultsAndMerge(key, def) { +function loadDefaultsAndMerge(key, def) +{ var settings = {}; - if (typeof localStorage[key] != "undefined") { + if (typeof localStorage[key] != "undefined") + { settings = JSON.parse(localStorage[key]); } var merged = deepmerge(def, settings); - for (var x in merged) { - if (!(x in def)) { + for (var x in merged) + { + if (!(x in def)) + { delete merged[x]; } } @@ -179,35 +190,43 @@ function loadDefaultsAndMerge(key, def) { return merged; } -function loadArrayIfExists(key) { +function loadArrayIfExists(key) +{ var data = []; - if (typeof localStorage[key] != "undefined") { + if (typeof localStorage[key] != "undefined") + { data = JSON.parse(localStorage[key]); } return data; } -function loadObjectIfExists(key) { +function loadObjectIfExists(key) +{ var data = {}; - if (typeof localStorage[key] != "undefined") { + if (typeof localStorage[key] != "undefined") + { data = JSON.parse(localStorage[key]); } return data; } -function saveAppSettings() { +function saveAppSettings() +{ localStorage.appSettings = JSON.stringify(g_appSettings); } -function saveMapSettings() { +function saveMapSettings() +{ localStorage.mapSettings = JSON.stringify(g_mapSettings); } -function saveStartupLogs() { +function saveStartupLogs() +{ localStorage.startupLogs = JSON.stringify(g_startupLogs); } -function saveLogSettings() { +function saveLogSettings() +{ localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); localStorage.N1MMSettings = JSON.stringify(g_N1MMSettings); localStorage.log4OMSettings = JSON.stringify(g_log4OMSettings); @@ -217,12 +236,14 @@ function saveLogSettings() { localStorage.trustedQslSettings = JSON.stringify(g_trustedQslSettings); } -function saveAndCloseApp() { +function saveAndCloseApp() +{ g_closing = true; saveReceptionReports(); - try { + try + { var data = {}; data.tracker = g_tracker; @@ -233,36 +254,47 @@ function saveAndCloseApp() { data.version = gtVersion; fs.writeFileSync(g_NWappData + "internal_qso.json", JSON.stringify(data)); - } catch (e) { + } + catch (e) + { console.log(e); } - if (g_map) { + if (g_map) + { mapMemory(6, true, true); g_mapSettings.zoom = g_map.getView().getZoom(); saveMapSettings(); } - if (g_wsjtUdpServer != null) { - try { - if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") { + if (g_wsjtUdpServer != null) + { + try + { + if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") + { g_wsjtUdpServer.dropMembership(g_appSettings.wsjtIP); } g_wsjtUdpServer.close(); - } catch (e) { + } + catch (e) + { console.log(e); } } - if (g_forwardUdpServer != null) { + if (g_forwardUdpServer != null) + { g_forwardUdpServer.close(); } saveAppSettings(); saveMapSettings(); - try { - if (g_callRosterWindowHandle) { + try + { + if (g_callRosterWindowHandle) + { g_callRosterWindowHandle.window.writeRosterSettings(); } if (g_popupWindowHandle != null) g_popupWindowHandle.window.close(true); @@ -273,13 +305,16 @@ function saveAndCloseApp() { g_lookupWindowHandle.window.close(true); g_baWindowHandle.window.close(true); g_callRosterWindowHandle.window.close(true); - } catch (e) {} + } + catch (e) {} nw.App.quit(); } -function clearAndReload() { +function clearAndReload() +{ g_closing = true; - if (g_wsjtUdpServer != null) { + if (g_wsjtUdpServer != null) + { g_wsjtUdpServer.close(); g_wsjtUdpServer = null; } @@ -290,7 +325,8 @@ function clearAndReload() { win.hide(); -win.on("close", function () { +win.on("close", function () +{ saveAndCloseApp(); }); win.show(); @@ -342,19 +378,19 @@ var g_colorBands = [ "2m", "1.25m", "70cm", - "23cm", + "23cm" ]; var g_pathIgnore = {}; -g_pathIgnore["RU"] = true; -g_pathIgnore["FTRU"] = true; -g_pathIgnore["FD"] = true; -g_pathIgnore["TEST"] = true; -g_pathIgnore["DX"] = true; -g_pathIgnore["CQ"] = true; +g_pathIgnore.RU = true; +g_pathIgnore.FTRU = true; +g_pathIgnore.FD = true; +g_pathIgnore.TEST = true; +g_pathIgnore.DX = true; +g_pathIgnore.CQ = true; var g_replaceCQ = {}; -g_replaceCQ["ASIA"] = "AS"; +g_replaceCQ.ASIA = "AS"; var g_searchBand = "dummy"; @@ -392,7 +428,8 @@ var g_tracker = {}; initQSOdata(); -function initQSOdata() { +function initQSOdata() +{ g_tracker.worked = {}; g_tracker.confirmed = {}; @@ -430,10 +467,10 @@ var g_layerVectors = {}; var g_scaleLine = null; var g_scaleUnits = {}; -g_scaleUnits["MI"] = "us"; -g_scaleUnits["KM"] = "metric"; -g_scaleUnits["NM"] = "nautical"; -g_scaleUnits["DG"] = "degrees"; +g_scaleUnits.MI = "us"; +g_scaleUnits.KM = "metric"; +g_scaleUnits.NM = "nautical"; +g_scaleUnits.DG = "degrees"; var g_passingToolTipTableString = ""; var g_mouseX = 0; @@ -463,7 +500,7 @@ var g_us48Data = {}; var g_startupFunctions = Array(); var g_pskColors = {}; -g_pskColors["OOB"] = "888888"; +g_pskColors.OOB = "888888"; g_pskColors["4000m"] = "45E0FF"; g_pskColors["2200m"] = "FF4500"; g_pskColors["630m"] = "1E90FF"; @@ -498,7 +535,7 @@ var g_UTCoptions = { minute: "2-digit", second: "2-digit", timeZone: "UTC", - timeZoneName: "short", + timeZoneName: "short" }; var g_LocalOptions = { @@ -508,7 +545,7 @@ var g_LocalOptions = { hour: "2-digit", minute: "2-digit", second: "2-digit", - timeZoneName: "short", + timeZoneName: "short" }; var g_earthShadowImageArray = Array(); @@ -571,14 +608,17 @@ var g_gridAlpha = "88"; if (typeof g_mapMemory[6] == "undefined") g_mapMemory[6] = g_mapMemory[0]; -function qsoBackupFileInit() { +function qsoBackupFileInit() +{ var adifHeader = "GridTracker v" + gtVersion + " \r\n"; - if (!fs.existsSync(g_qsoLogFile)) { + if (!fs.existsSync(g_qsoLogFile)) + { fs.writeFileSync(g_qsoLogFile, adifHeader); } } -function gtBandFilterChanged(selector) { +function gtBandFilterChanged(selector) +{ g_appSettings.gtBandFilter = selector.value; removePaths(); @@ -586,65 +626,78 @@ function gtBandFilterChanged(selector) { redrawSpots(); } -function gtModeFilterChanged(selector) { +function gtModeFilterChanged(selector) +{ g_appSettings.gtModeFilter = selector.value; redrawGrids(); redrawSpots(); } -function gtPropFilterChanged(selector) { +function gtPropFilterChanged(selector) +{ g_appSettings.gtPropFilter = selector.value; redrawGrids(); redrawSpots(); } -function setBandAndModeToAuto() { +function setBandAndModeToAuto() +{ g_appSettings.gtModeFilter = g_appSettings.gtBandFilter = gtBandFilter.value = gtModeFilter.value = "auto"; redrawGrids(); redrawSpots(); } -function hideLiveGrid(i) { - if (g_layerSources["live"].hasFeature(g_liveGrids[i].rectangle)) { - g_layerSources["live"].removeFeature(g_liveGrids[i].rectangle); +function hideLiveGrid(i) +{ + if (g_layerSources.live.hasFeature(g_liveGrids[i].rectangle)) + { + g_layerSources.live.removeFeature(g_liveGrids[i].rectangle); } } -function liveTriangleGrid(i) { - if (g_liveGrids[i].isTriangle == false) { - if (g_layerSources["live"].hasFeature(g_liveGrids[i].rectangle)) { - g_layerSources["live"].removeFeature(g_liveGrids[i].rectangle); +function liveTriangleGrid(i) +{ + if (g_liveGrids[i].isTriangle == false) + { + if (g_layerSources.live.hasFeature(g_liveGrids[i].rectangle)) + { + g_layerSources.live.removeFeature(g_liveGrids[i].rectangle); } gridToTriangle(i, g_liveGrids[i].rectangle, false); g_liveGrids[i].isTriangle = true; - g_layerSources["live"].addFeature(g_liveGrids[i].rectangle); + g_layerSources.live.addFeature(g_liveGrids[i].rectangle); } } -function qsoTriangleGrid(i) { - if (g_qsoGrids[i].isTriangle == false) { - if (g_layerSources["qso"].hasFeature(g_qsoGrids[i].rectangle)) { - g_layerSources["qso"].removeFeature(g_qsoGrids[i].rectangle); +function qsoTriangleGrid(i) +{ + if (g_qsoGrids[i].isTriangle == false) + { + if (g_layerSources.qso.hasFeature(g_qsoGrids[i].rectangle)) + { + g_layerSources.qso.removeFeature(g_qsoGrids[i].rectangle); } gridToTriangle(i, g_qsoGrids[i].rectangle, true); g_qsoGrids[i].isTriangle = true; - g_layerSources["qso"].addFeature(g_qsoGrids[i].rectangle); + g_layerSources.qso.addFeature(g_qsoGrids[i].rectangle); } } -function setGridViewMode(mode) { +function setGridViewMode(mode) +{ g_appSettings.gridViewMode = mode; gridViewButton.innerHTML = g_gridViewArray[g_appSettings.gridViewMode]; redrawGrids(); goProcessRoster(); } -function cycleGridView() { +function cycleGridView() +{ var mode = g_appSettings.gridViewMode; mode++; if (mode > 3) mode = 1; @@ -655,23 +708,29 @@ function cycleGridView() { redrawGrids(); } -function toggleEarth() { +function toggleEarth() +{ g_appSettings.earthImgSrc ^= 1; earthImg.src = g_earthShadowImageArray[g_appSettings.earthImgSrc]; - if (g_appSettings.earthImgSrc == 1) { + if (g_appSettings.earthImgSrc == 1) + { dayNight.hide(); g_nightTime = dayNight.refresh(); - } else { + } + else + { g_nightTime = dayNight.refresh(); dayNight.show(); } changeMapLayer(); } -function toggleOffline() { +function toggleOffline() +{ if (g_map == null) return; - if (g_mapSettings.offlineMode == true) { + if (g_mapSettings.offlineMode == true) + { g_mapSettings.offlineMode = false; offlineImg.src = g_mapImageArray[1]; conditionsButton.style.display = "inline-block"; @@ -681,28 +740,37 @@ function toggleOffline() { buttonPSKSpotsBoxDiv.style.display = "inline-block"; donateButton.style.display = "inline-block"; - if (g_appSettings.gtShareEnable == true) { + if (g_appSettings.gtShareEnable == true) + { gtFlagButton.style.display = "inline-block"; if (g_appSettings.gtMsgEnable == true) - msgButton.style.display = "inline-block"; + { msgButton.style.display = "inline-block"; } else msgButton.style.display = "none"; - } else { + } + else + { msgButton.style.display = "none"; gtFlagButton.style.display = "none"; } - for (var key in g_adifLogSettings.menu) { + for (var key in g_adifLogSettings.menu) + { var value = g_adifLogSettings.menu[key]; var where = key + "Div"; document.getElementById(key).checked = value; - if (value == true) { + if (value == true) + { document.getElementById(where).style.display = "inline-block"; - } else { + } + else + { document.getElementById(where).style.display = "none"; } } pskReporterBandActivityDiv.style.display = "block"; - } else { + } + else + { g_mapSettings.offlineMode = true; offlineImg.src = g_mapImageArray[0]; conditionsButton.style.display = "none"; @@ -724,14 +792,18 @@ function toggleOffline() { changeMapValues(); } -function ignoreMessagesToggle() { +function ignoreMessagesToggle() +{ g_ignoreMessages ^= 1; - if (g_ignoreMessages == 0) { + if (g_ignoreMessages == 0) + { txrxdec.style.backgroundColor = "Green"; txrxdec.style.borderColor = "GreenYellow"; txrxdec.innerHTML = "RECEIVE"; txrxdec.title = "Click to ignore incoming messages"; - } else { + } + else + { txrxdec.style.backgroundColor = "DimGray"; txrxdec.style.borderColor = "DarkGray"; txrxdec.innerHTML = "IGNORE"; @@ -739,18 +811,21 @@ function ignoreMessagesToggle() { } } -function toggleTime() { +function toggleTime() +{ g_appSettings.useLocalTime ^= 1; displayTime(); } -function dateToString(dateTime) { +function dateToString(dateTime) +{ if (g_appSettings.useLocalTime == 1) - return dateTime.toLocaleString().replace(/,/g, ""); + { return dateTime.toLocaleString().replace(/,/g, ""); } else return dateTime.toUTCString().replace(/GMT/g, "UTC").replace(/,/g, ""); } -function userDayString(Msec) { +function userDayString(Msec) +{ var dateTime; if (Msec != null) dateTime = new Date(Msec); else dateTime = new Date(); @@ -763,30 +838,34 @@ function userDayString(Msec) { return dra.join(" "); } -function userTimeString(Msec) { +function userTimeString(Msec) +{ var dateTime; if (Msec != null) dateTime = new Date(Msec); else dateTime = new Date(); return dateToString(dateTime); } -function getWpx(callsign) { +function getWpx(callsign) +{ var prefix = null; if (callsign.includes("/")) - // Handle in the future? - return null; + // Handle in the future? + { return null; } if (!/\d/.test(callsign)) - // Insert 0, never seen this - return null; + // Insert 0, never seen this + { return null; } var end = callsign.length; var foundPrefix = false; var prefixEnd = 1; - while (prefixEnd != end) { - if (/\d/.test(callsign.charAt(prefixEnd))) { + while (prefixEnd != end) + { + if (/\d/.test(callsign.charAt(prefixEnd))) + { while (prefixEnd + 1 != end && /\d/.test(callsign.charAt(prefixEnd + 1))) - prefixEnd++; + { prefixEnd++; } foundPrefix = true; break; } @@ -798,56 +877,65 @@ function getWpx(callsign) { return prefix; } -function setState(details) { - if (details.state != null && details.state.length > 0) { +function setState(details) +{ + if (details.state != null && details.state.length > 0) + { var isDigi = details.digital; if (details.state.substr(0, 2) != "US") - details.state = "US-" + details.state; + { details.state = "US-" + details.state; } g_tracker.worked.state[details.state + details.band + details.mode] = true; g_tracker.worked.state[details.state] = true; g_tracker.worked.state[details.state + details.mode] = true; g_tracker.worked.state[details.state + details.band] = true; - if (isDigi) { + if (isDigi) + { g_tracker.worked.state[details.state + "dg"] = true; g_tracker.worked.state[details.state + details.band + "dg"] = true; } - if (details.confirmed) { + if (details.confirmed) + { g_tracker.confirmed.state[ details.state + details.band + details.mode ] = true; g_tracker.confirmed.state[details.state] = true; g_tracker.confirmed.state[details.state + details.mode] = true; g_tracker.confirmed.state[details.state + details.band] = true; - if (isDigi) { + if (isDigi) + { g_tracker.confirmed.state[details.state + "dg"] = true; g_tracker.confirmed.state[details.state + details.band + "dg"] = true; } } } - if (details.cnty != null && details.cnty.length > 0) { + if (details.cnty != null && details.cnty.length > 0) + { var isDigi = details.digital; g_tracker.worked.cnty[details.cnty + details.band + details.mode] = true; g_tracker.worked.cnty[details.cnty] = true; g_tracker.worked.cnty[details.cnty + details.mode] = true; g_tracker.worked.cnty[details.cnty + details.band] = true; - if (isDigi) { + if (isDigi) + { g_tracker.worked.cnty[details.cnty + "dg"] = true; g_tracker.worked.cnty[details.cnty + details.band + "dg"] = true; } - if (details.confirmed) { + if (details.confirmed) + { g_tracker.confirmed.cnty[ details.cnty + details.band + details.mode ] = true; g_tracker.confirmed.cnty[details.cnty] = true; g_tracker.confirmed.cnty[details.cnty + details.mode] = true; g_tracker.confirmed.cnty[details.cnty + details.band] = true; - if (isDigi) { + if (isDigi) + { g_tracker.confirmed.cnty[details.cnty + "dg"] = true; g_tracker.confirmed.cnty[details.cnty + details.band + "dg"] = true; } @@ -855,17 +943,20 @@ function setState(details) { } } -function isKnownCallsignDXCC(dxcc) { +function isKnownCallsignDXCC(dxcc) +{ if (dxcc in g_callsignDatabaseDXCC) return true; return false; } -function isKnownCallsignUS(dxcc) { +function isKnownCallsignUS(dxcc) +{ if (dxcc in g_callsignDatabaseUS) return true; return false; } -function isKnownCallsignUSplus(dxcc) { +function isKnownCallsignUSplus(dxcc) +{ if (dxcc in g_callsignDatabaseUSplus) return true; return false; } @@ -897,7 +988,8 @@ function addDeDx( finalPhone = false, finalIOTA = "", finalSatName = "" -) { +) +{ var callsign = null; var rect = null; var worked = false; @@ -908,22 +1000,25 @@ function addDeDx( var finalMsg = ifinalMsg.trim(); if (finalMsg.length > 40) finalMsg = finalMsg.substring(0, 40) + "..."; var details = null; - if (!notQso) { + if (!notQso) + { var timeMod = finalTime - (finalTime % 360) + 180; hash = unique(mode + band + finalDXcall + timeMod); var lookupCall = false; - if (hash in g_QSOhash) { + if (hash in g_QSOhash) + { details = g_QSOhash[hash]; - if (finalGrid.length > 0 && finalGrid != details.grid) { + if (finalGrid.length > 0 && finalGrid != details.grid) + { // only touch the grid if it's larger than the last grid && the 4wide is the same if ( details.grid.length < 6 && (details.grid.substr(0, 4) == finalGrid.substr(0, 4) || details.grid.length == 0) ) - details.grid = finalGrid; + { details.grid = finalGrid; } } if (finalRSTsent.length > 0) details.RSTsent = finalRSTsent; if (finalRSTrecv.length > 0) details.RSTrecv = finalRSTrecv; @@ -938,7 +1033,9 @@ function addDeDx( if (finalVucc.length > 0) details.vucc_grids = finalVucc; if (finalIOTA.length > 0) details.IOTA = finalIOTA; if (finalSatName.length > 0) details.satName = finalSatName; - } else { + } + else + { details = {}; details.grid = finalGrid; details.RSTsent = finalRSTsent; @@ -970,40 +1067,50 @@ function addDeDx( if (finalDxcc < 1) finalDxcc = callsignToDxcc(finalDXcall); details.dxcc = finalDxcc; - if (details.dxcc > 0 && details.px == null) { + if (details.dxcc > 0 && details.px == null) + { details.px = getWpx(finalDXcall); if (details.px) - details.zone = Number(details.px.charAt(details.px.length - 1)); + { details.zone = Number(details.px.charAt(details.px.length - 1)); } } if ( details.state == null && isKnownCallsignUSplus(finalDxcc) && finalGrid.length > 0 - ) { + ) + { var fourGrid = finalGrid.substr(0, 4); - if (fourGrid in g_gridToState && g_gridToState[fourGrid].length == 1) { + if (fourGrid in g_gridToState && g_gridToState[fourGrid].length == 1) + { details.state = g_gridToState[fourGrid][0]; } lookupCall = true; } details.cont = finalCont; - if (details.cont == null && finalDxcc > 0) { + if (details.cont == null && finalDxcc > 0) + { details.cont = g_worldGeoData[g_dxccToGeoData[finalDxcc]].continent; if (details.dxcc == 390 && details.zone == 1) details.cont = "EU"; } details.cnty = finalCnty; - if (details.cnty) { + if (details.cnty) + { details.qual = true; } - if (isKnownCallsignUSplus(finalDxcc)) { - if (details.cnty == null) { + if (isKnownCallsignUSplus(finalDxcc)) + { + if (details.cnty == null) + { lookupCall = true; - } else { - if (!(details.cnty in g_cntyToCounty)) { + } + else + { + if (!(details.cnty in g_cntyToCounty)) + { lookupCall = true; } } @@ -1020,18 +1127,21 @@ function addDeDx( g_tracker.worked.call[finalDXcall + mode] = true; g_tracker.worked.call[finalDXcall + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.call[finalDXcall + "dg"] = true; g_tracker.worked.call[finalDXcall + band + "dg"] = true; } var fourGrid = details.grid.substr(0, 4); - if (fourGrid != "") { + if (fourGrid != "") + { g_tracker.worked.grid[fourGrid + band + mode] = true; g_tracker.worked.grid[fourGrid] = true; g_tracker.worked.grid[fourGrid + mode] = true; g_tracker.worked.grid[fourGrid + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.grid[fourGrid + "dg"] = true; g_tracker.worked.grid[fourGrid + band + "dg"] = true; } @@ -1040,15 +1150,18 @@ function addDeDx( details.ituz.length == 0 && fourGrid in g_gridToITUZone && g_gridToITUZone[fourGrid].length == 1 - ) { + ) + { details.ituz = g_gridToITUZone[fourGrid][0]; } - if (details.ituz.length > 0) { + if (details.ituz.length > 0) + { g_tracker.worked.ituz[details.ituz + band + mode] = true; g_tracker.worked.ituz[details.ituz] = true; g_tracker.worked.ituz[details.ituz + mode] = true; g_tracker.worked.ituz[details.ituz + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.ituz[details.ituz + "dg"] = true; g_tracker.worked.ituz[details.ituz + band + "dg"] = true; } @@ -1057,57 +1170,68 @@ function addDeDx( details.cqz.length == 0 && fourGrid in g_gridToCQZone && g_gridToCQZone[fourGrid].length == 1 - ) { + ) + { details.cqz = g_gridToCQZone[fourGrid][0]; } - if (details.cqz.length > 0) { + if (details.cqz.length > 0) + { g_tracker.worked.cqz[details.cqz + band + mode] = true; g_tracker.worked.cqz[details.cqz] = true; g_tracker.worked.cqz[details.cqz + mode] = true; g_tracker.worked.cqz[details.cqz + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.cqz[details.cqz + "dg"] = true; g_tracker.worked.cqz[details.cqz + band + "dg"] = true; } } - if (details.dxcc > 0) { + if (details.dxcc > 0) + { var sDXCC = String(details.dxcc); g_tracker.worked.dxcc[sDXCC + band + mode] = true; g_tracker.worked.dxcc[sDXCC] = true; g_tracker.worked.dxcc[sDXCC + mode] = true; g_tracker.worked.dxcc[sDXCC + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.dxcc[sDXCC + "dg"] = true; g_tracker.worked.dxcc[sDXCC + band + "dg"] = true; } } - if (details.px) { + if (details.px) + { g_tracker.worked.px[details.px + band + mode] = true; g_tracker.worked.px[details.px] = hash; g_tracker.worked.px[details.px + mode] = true; g_tracker.worked.px[details.px + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.px[details.px + "dg"] = true; g_tracker.worked.px[details.px + band + "dg"] = true; } - if (isPhone == true) { + if (isPhone == true) + { g_tracker.worked.px[details.px + "ph"] = true; g_tracker.worked.px[details.px + band + "ph"] = true; } } - if (details.cont) { + if (details.cont) + { g_tracker.worked.cont[details.cont + band + mode] = true; g_tracker.worked.cont[details.cont] = hash; g_tracker.worked.cont[details.cont + mode] = true; g_tracker.worked.cont[details.cont + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.worked.cont[details.cont + "dg"] = true; g_tracker.worked.cont[details.cont + band + "dg"] = true; } - if (isPhone == true) { + if (isPhone == true) + { g_tracker.worked.cont[details.cont + "ph"] = true; g_tracker.worked.cont[details.cont + band + "ph"] = true; } @@ -1116,7 +1240,8 @@ function addDeDx( worked = true; locked = true; details.worked = worked; - if (typeof details.confirmed == "undefined" || details.confirmed == false) { + if (typeof details.confirmed == "undefined" || details.confirmed == false) + { details.confirmed = confirmed; } @@ -1124,73 +1249,88 @@ function addDeDx( setState(details); - if (lookupCall) { - if (g_callsignLookups.ulsUseEnable) { + if (lookupCall) + { + if (g_callsignLookups.ulsUseEnable) + { lookupUsCallsign(details, true); } } - if (confirmed == true) { - if (fourGrid != "") { + if (confirmed == true) + { + if (fourGrid != "") + { g_tracker.confirmed.grid[fourGrid + band + mode] = true; g_tracker.confirmed.grid[fourGrid] = true; g_tracker.confirmed.grid[fourGrid + mode] = true; g_tracker.confirmed.grid[fourGrid + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.grid[fourGrid + "dg"] = true; g_tracker.confirmed.grid[fourGrid + band + "dg"] = true; } } - if (details.ituz.length > 0) { + if (details.ituz.length > 0) + { g_tracker.confirmed.ituz[details.ituz + band + mode] = true; g_tracker.confirmed.ituz[details.ituz] = true; g_tracker.confirmed.ituz[details.ituz + mode] = true; g_tracker.confirmed.ituz[details.ituz + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.ituz[details.ituz + "dg"] = true; g_tracker.confirmed.ituz[details.ituz + band + "dg"] = true; } } - if (details.cqz.length > 0) { + if (details.cqz.length > 0) + { g_tracker.confirmed.cqz[details.cqz + band + mode] = true; g_tracker.confirmed.cqz[details.cqz] = true; g_tracker.confirmed.cqz[details.cqz + mode] = true; g_tracker.confirmed.cqz[details.cqz + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.cqz[details.cqz + "dg"] = true; g_tracker.confirmed.cqz[details.cqz + band + "dg"] = true; } } - if (details.dxcc > 0) { + if (details.dxcc > 0) + { var sDXCC = String(details.dxcc); g_tracker.confirmed.dxcc[sDXCC + band + mode] = true; g_tracker.confirmed.dxcc[sDXCC] = true; g_tracker.confirmed.dxcc[sDXCC + mode] = true; g_tracker.confirmed.dxcc[sDXCC + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.dxcc[sDXCC + "dg"] = true; g_tracker.confirmed.dxcc[sDXCC + band + "dg"] = true; } } - if (details.px) { + if (details.px) + { g_tracker.confirmed.px[details.px + band + mode] = true; g_tracker.confirmed.px[details.px] = hash; g_tracker.confirmed.px[details.px + mode] = true; g_tracker.confirmed.px[details.px + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.px[details.px + "dg"] = true; g_tracker.confirmed.px[details.px + band + "dg"] = true; } } - if (details.cont) { + if (details.cont) + { g_tracker.confirmed.cont[details.cont + band + mode] = true; g_tracker.confirmed.cont[details.cont] = hash; g_tracker.confirmed.cont[details.cont + mode] = true; g_tracker.confirmed.cont[details.cont + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.cont[details.cont + "dg"] = true; g_tracker.confirmed.cont[details.cont + band + "dg"] = true; } @@ -1200,7 +1340,8 @@ function addDeDx( g_tracker.confirmed.call[finalDXcall] = true; g_tracker.confirmed.call[finalDXcall + mode] = true; g_tracker.confirmed.call[finalDXcall + band] = true; - if (isDigi == true) { + if (isDigi == true) + { g_tracker.confirmed.call[finalDXcall + "dg"] = true; g_tracker.confirmed.call[finalDXcall + band + "dg"] = true; } @@ -1211,11 +1352,13 @@ function addDeDx( if (finalDxcc < 1) finalDxcc = callsignToDxcc(finalDXcall); hash = finalDXcall + band + mode; - if (notQso) { + if (notQso) + { if (hash in g_liveCallsigns) callsign = g_liveCallsigns[hash]; } - if (!notQso) { + if (!notQso) + { if ( (g_appSettings.gtBandFilter.length == 0 || (g_appSettings.gtBandFilter == "auto" @@ -1223,7 +1366,8 @@ function addDeDx( : g_appSettings.gtBandFilter == band)) && validateMapMode(mode) && validatePropMode(finalPropMode) - ) { + ) + { details.rect = qthToQsoBox( finalGrid, hash, @@ -1238,7 +1382,9 @@ function addDeDx( ); } return; - } else { + } + else + { if (finalDxcc in g_dxccCount) g_dxccCount[finalDxcc]++; else g_dxccCount[finalDxcc] = 1; @@ -1248,7 +1394,8 @@ function addDeDx( ? myBand == band : g_appSettings.gtBandFilter == band)) && validateMapMode(mode) - ) { + ) + { rect = qthToBox( finalGrid, finalDXcall, @@ -1263,7 +1410,8 @@ function addDeDx( } } - if (callsign == null) { + if (callsign == null) + { var newCallsign = {}; newCallsign.DEcall = finalDXcall; newCallsign.grid = finalGrid; @@ -1282,23 +1430,29 @@ function addDeDx( newCallsign.zone = null; newCallsign.cnty = finalCnty; newCallsign.cont = finalCont; - if (finalDxcc > -1) { + if (finalDxcc > -1) + { newCallsign.px = getWpx(finalDXcall); if (newCallsign.px) + { newCallsign.zone = Number( newCallsign.px.charAt(newCallsign.px.length - 1) ); + } - if (newCallsign.cont == null) { + if (newCallsign.cont == null) + { newCallsign.cont = g_worldGeoData[g_dxccToGeoData[finalDxcc]].continent; if (newCallsign.dxcc == 390 && newCallsign.zone == 1) - newCallsign.cont = "EU"; + { newCallsign.cont = "EU"; } } } - if (finalRSTsent != null) { + if (finalRSTsent != null) + { newCallsign.RSTsent = finalRSTsent; } - if (finalRSTrecv != null) { + if (finalRSTrecv != null) + { newCallsign.RSTrecv = finalRSTrecv; } newCallsign.time = finalTime; @@ -1323,24 +1477,31 @@ function addDeDx( newCallsign.state == null && isKnownCallsignDXCC(finalDxcc) && finalGrid.length > 0 - ) { - if (g_callsignLookups.ulsUseEnable) { + ) + { + if (g_callsignLookups.ulsUseEnable) + { lookupUsCallsign(newCallsign); } - if (newCallsign.state == null && isKnownCallsignUSplus(finalDxcc)) { + if (newCallsign.state == null && isKnownCallsignUSplus(finalDxcc)) + { var fourGrid = finalGrid.substr(0, 4); if ( fourGrid in g_gridToState && g_gridToState[finalGrid.substr(0, 4)].length == 1 - ) { + ) + { newCallsign.state = g_gridToState[finalGrid.substr(0, 4)][0]; } } } g_liveCallsigns[hash] = newCallsign; - } else { - if (callsign.DXcall != "Self" && finalTime > callsign.time) { + } + else + { + if (callsign.DXcall != "Self" && finalTime > callsign.time) + { callsign.time = finalTime; callsign.mode = mode; callsign.band = band; @@ -1355,7 +1516,7 @@ function addDeDx( finalGrid.length == callsign.grid.length && finalGrid != callsign.grid ) - callsign.grid = finalGrid; + { callsign.grid = finalGrid; } if (finalRSTsent != null) callsign.RSTsent = finalRSTsent; if (finalRSTrecv != null) callsign.RSTrecv = finalRSTrecv; callsign.vucc_grids = []; @@ -1368,20 +1529,23 @@ function addDeDx( } } -function timeoutSetUdpPort() { +function timeoutSetUdpPort() +{ g_appSettings.wsjtUdpPort = udpPortInput.value; lastMsgTimeDiv.innerHTML = "Waiting for msg..."; g_setNewUdpPortTimeoutHandle = null; } -function setUdpPort() { +function setUdpPort() +{ if (g_setNewUdpPortTimeoutHandle != null) - window.clearTimeout(g_setNewUdpPortTimeoutHandle); + { window.clearTimeout(g_setNewUdpPortTimeoutHandle); } lastMsgTimeDiv.innerHTML = "..setting.."; g_setNewUdpPortTimeoutHandle = window.setTimeout(timeoutSetUdpPort, 1000); } -function changeGridDecay() { +function changeGridDecay() +{ g_appSettings.gridsquareDecayTime = parseInt(gridDecay.value); decayRateTd.innerHTML = Number(g_appSettings.gridsquareDecayTime) == 0 @@ -1389,56 +1553,69 @@ function changeGridDecay() { : Number(g_appSettings.gridsquareDecayTime).toDHMS(); } -function changeMouseOverValue() { +function changeMouseOverValue() +{ g_mapSettings.mouseOver = mouseOverValue.checked; saveMapSettings(); } -function changeMergeOverlayValue() { +function changeMergeOverlayValue() +{ g_mapSettings.mergeOverlay = mergeOverlayValue.checked; saveMapSettings(); setTrophyOverlay(g_currentOverlay); } -function getPathColor() { - if (g_mapSettings.nightMapEnable && g_nightTime) { +function getPathColor() +{ + if (g_mapSettings.nightMapEnable && g_nightTime) + { if (g_mapSettings.nightPathColor == 0) return "#000"; if (g_mapSettings.nightPathColor == 361) return "#FFF"; return "hsl(" + g_mapSettings.nightPathColor + ", 100%, 50%)"; - } else { + } + else + { if (g_mapSettings.pathColor == 0) return "#000"; if (g_mapSettings.pathColor == 361) return "#FFF"; return "hsl(" + g_mapSettings.pathColor + ", 100%, 50%)"; } } -function getQrzPathColor() { - if (g_mapSettings.nightMapEnable && g_nightTime) { +function getQrzPathColor() +{ + if (g_mapSettings.nightMapEnable && g_nightTime) + { if (g_mapSettings.nightQrzPathColor == 0) return "#000"; if (g_mapSettings.nightQrzPathColor == 361) return "#FFF"; return "hsl(" + g_mapSettings.nightQrzPathColor + ", 100%, 50%)"; - } else { + } + else + { if (g_mapSettings.qrzPathColor == 0) return "#000"; if (g_mapSettings.qrzPathColor == 361) return "#FFF"; return "hsl(" + g_mapSettings.qrzPathColor + ", 100%, 50%)"; } } -function changeShadow() { +function changeShadow() +{ g_mapSettings.shadow = shadowValue.value; showDarknessTd.innerHTML = parseInt(shadowValue.value * 100) + "%"; saveMapSettings(); g_nightTime = dayNight.refresh(); } -function changePathWidth() { +function changePathWidth() +{ g_appSettings.pathWidthWeight = pathWidthValue.value; g_appSettings.qrzPathWidthWeight = qrzPathWidthValue.value; pathWidthTd.innerHTML = pathWidthValue.value; qrzPathWidthTd.innerHTML = qrzPathWidthValue.value; - for (var i = g_flightPaths.length - 1; i >= 0; i--) { + for (var i = g_flightPaths.length - 1; i >= 0; i--) + { var featureStyle = g_flightPaths[i].getStyle(); var featureStroke = featureStyle.getStroke(); @@ -1447,10 +1624,11 @@ function changePathWidth() { ? qrzPathWidthValue.value : pathWidthValue.value; - if (width == 0) { + if (width == 0) + { if (typeof g_flightPaths[i].Arrow != "undefined") - g_layerSources["flight"].removeFeature(g_flightPaths[i].Arrow); - g_layerSources["flight"].removeFeature(g_flightPaths[i]); + { g_layerSources.flight.removeFeature(g_flightPaths[i].Arrow); } + g_layerSources.flight.removeFeature(g_flightPaths[i]); delete g_flightPaths[i]; g_flightPaths[i] = null; @@ -1465,43 +1643,49 @@ function changePathWidth() { featureStyle.setStroke(featureStroke); g_flightPaths[i].setStyle(featureStyle); - if (typeof g_flightPaths[i].Arrow != "undefined") { + if (typeof g_flightPaths[i].Arrow != "undefined") + { var stroke = new ol.style.Stroke({ color: color, - width: width, + width: width }); var thisStle = new ol.style.Style({ image: new ol.style.Circle({ stroke: stroke, - radius: 3, - }), + radius: 3 + }) }); g_flightPaths[i].Arrow.setStyle(thisStle); } } - if (g_transmitFlightPath != null) { + if (g_transmitFlightPath != null) + { var featureStyle = g_transmitFlightPath.getStyle(); var featureStroke = featureStyle.getStroke(); - if (qrzPathWidthValue.value == 0) { - g_layerSources["transmit"].clear(); + if (qrzPathWidthValue.value == 0) + { + g_layerSources.transmit.clear(); g_transmitFlightPath = null; - } else { + } + else + { featureStroke.setWidth(qrzPathWidthValue.value); featureStroke.setColor(getQrzPathColor()); featureStyle.setStroke(featureStroke); g_transmitFlightPath.setStyle(featureStyle); - if (typeof g_transmitFlightPath.Arrow != "undefined") { + if (typeof g_transmitFlightPath.Arrow != "undefined") + { var stroke = new ol.style.Stroke({ color: getQrzPathColor(), - width: qrzPathWidthValue.value, + width: qrzPathWidthValue.value }); var thisStle = new ol.style.Style({ image: new ol.style.Circle({ stroke: stroke, - radius: 3, - }), + radius: 3 + }) }); g_transmitFlightPath.Arrow.setStyle(thisStle); } @@ -1509,25 +1693,30 @@ function changePathWidth() { } } -function compareCallsignTime(a, b) { +function compareCallsignTime(a, b) +{ if (a.time < b.time) return -1; if (a.time > b.time) return 1; return 0; } -function createFlagTipTable(toolElement) { +function createFlagTipTable(toolElement) +{ var myFlagtip = document.getElementById("myFlagtip"); var worker = ""; - if (toolElement.size == 1) { + if (toolElement.size == 1) + { var key = toolElement.key; var dxcc = callsignToDxcc(g_gtFlagPins[key].call); var dxccName = g_dxccToAltName[dxcc]; var workColor = "cyan"; - if (g_gtFlagPins[key].call + myBand + myMode in g_tracker.worked.call) { + if (g_gtFlagPins[key].call + myBand + myMode in g_tracker.worked.call) + { workColor = "yellow"; } - if (g_gtFlagPins[key].call + myBand + myMode in g_tracker.confirmed.call) { + if (g_gtFlagPins[key].call + myBand + myMode in g_tracker.confirmed.call) + { workColor = "#00FF00"; } @@ -1593,7 +1782,9 @@ function createFlagTipTable(toolElement) { "°"; worker += ""; - } else if (toolElement.size == 73) { + } + else if (toolElement.size == 73) + { var props = toolElement.getProperties(); moment.locale(navigator.languages[0]); @@ -1626,37 +1817,47 @@ function createFlagTipTable(toolElement) { return 1; } -function remove_duplicates(arr) { +function remove_duplicates(arr) +{ var obj = {}; var ret_arr = []; - for (var i = 0; i < arr.length; i++) { + for (var i = 0; i < arr.length; i++) + { obj[arr[i]] = true; } - for (var key in obj) { + for (var key in obj) + { ret_arr.push(key); } return ret_arr; } -function splitNoParen(s) { +function splitNoParen(s) +{ var results = []; var next; var str = ""; var left = 0, right = 0; - function keepResult() { + function keepResult() + { results.push(str.trim()); str = ""; } - for (var i = 0; i < s.length; i++) { - switch (s[i]) { + for (var i = 0; i < s.length; i++) + { + switch (s[i]) + { case ",": - if (left === right) { + if (left === right) + { keepResult(); left = right = 0; - } else { + } + else + { str += s[i]; } break; @@ -1676,11 +1877,13 @@ function splitNoParen(s) { return results; } -function createSpotTipTable(toolElement) { +function createSpotTipTable(toolElement) +{ var now = timeNowSec(); var myTooltip = document.getElementById("myTooltip"); var worker = ""; - if (toolElement.spot in g_receptionReports.spots) { + if (toolElement.spot in g_receptionReports.spots) + { g_layerSources["psk-hop"].clear(); var report = g_receptionReports.spots[toolElement.spot]; @@ -1705,12 +1908,14 @@ function createSpotTipTable(toolElement) { ""; if (report.dxcc > 0) + { worker += "DXCC" + g_dxccToAltName[report.dxcc] + " (" + g_worldGeoData[g_dxccToGeoData[report.dxcc]].pp + ")"; + } worker += "Grid" + @@ -1774,7 +1979,7 @@ function createSpotTipTable(toolElement) { { weight: strokeWeight, color: getQrzPathColor(), - steps: 75, + steps: 75 }, "psk-hop", false @@ -1785,8 +1990,10 @@ function createSpotTipTable(toolElement) { return 10; } -function createTooltTipTable(toolElement) { - if (typeof toolElement.spot != "undefined") { +function createTooltTipTable(toolElement) +{ + if (typeof toolElement.spot != "undefined") + { return createSpotTipTable(toolElement); } var myTooltip = document.getElementById("myTooltip"); @@ -1802,25 +2009,30 @@ function createTooltTipTable(toolElement) { " style='color:cyan'>" + toolElement.qth + ""; - if (toolElement.qth in g_gridToDXCC) { + if (toolElement.qth in g_gridToDXCC) + { worker += ""; - for (var x = 0; x < g_gridToDXCC[toolElement.qth].length; x++) { + for (var x = 0; x < g_gridToDXCC[toolElement.qth].length; x++) + { worker += g_dxccToAltName[g_gridToDXCC[toolElement.qth][x]]; - if (toolElement.qth in g_gridToState) { + if (toolElement.qth in g_gridToState) + { worker += " ("; var added = false; - for (var y = 0; y < g_gridToState[toolElement.qth].length; y++) { + for (var y = 0; y < g_gridToState[toolElement.qth].length; y++) + { if ( g_gridToDXCC[toolElement.qth][x] == g_StateData[g_gridToState[toolElement.qth][y]].dxcc - ) { + ) + { worker += g_StateData[g_gridToState[toolElement.qth][y]].name + " / "; added = true; } } if (added == true) - worker = worker.substr(0, worker.length - " / ".length); + { worker = worker.substr(0, worker.length - " / ".length); } worker += ")"; } if (x + 1 < g_gridToDXCC[toolElement.qth].length) worker += ", "; @@ -1828,8 +2040,10 @@ function createTooltTipTable(toolElement) { worker += ""; } var newCallList = Array(); - if (toolElement.qso == true) { - if (Object.keys(toolElement.hashes).length > 0) { + if (toolElement.qso == true) + { + if (Object.keys(toolElement.hashes).length > 0) + { worker += "CallFreqSentRcvdStationModeBandQSLLast MsgDXCCTime"; @@ -1838,8 +2052,10 @@ function createTooltTipTable(toolElement) { if (g_callsignLookups.oqrsUseEnable == true) worker += "OQRS"; worker += ""; } - for (var KeyIsHash in toolElement.hashes) { - if (KeyIsHash in g_QSOhash) { + for (var KeyIsHash in toolElement.hashes) + { + if (KeyIsHash in g_QSOhash) + { newCallList.push(g_QSOhash[KeyIsHash]); } } @@ -1847,14 +2063,19 @@ function createTooltTipTable(toolElement) { toolElement.qth in g_liveGrids && g_liveGrids[toolElement.qth].rectangle != null && g_liveGrids[toolElement.qth].isTriangle == false - ) { - for (var KeyIsCall in g_liveGrids[toolElement.qth].rectangle.liveHash) { + ) + { + for (var KeyIsCall in g_liveGrids[toolElement.qth].rectangle.liveHash) + { if (KeyIsCall in g_liveCallsigns && g_appSettings.gridViewMode == 3) - newCallList.push(g_liveCallsigns[KeyIsCall]); + { newCallList.push(g_liveCallsigns[KeyIsCall]); } } } - } else { - if (Object.keys(toolElement.liveHash).length > 0) { + } + else + { + if (Object.keys(toolElement.liveHash).length > 0) + { worker += "CallFreqSentRcvdStationModeBandLast MsgDXCCTime"; @@ -1863,33 +2084,36 @@ function createTooltTipTable(toolElement) { if (g_callsignLookups.oqrsUseEnable == true) worker += "OQRS"; worker += ""; } - for (var KeyIsCall in toolElement.liveHash) { + for (var KeyIsCall in toolElement.liveHash) + { if (KeyIsCall in g_liveCallsigns) - newCallList.push(g_liveCallsigns[KeyIsCall]); + { newCallList.push(g_liveCallsigns[KeyIsCall]); } } } newCallList.sort(compareCallsignTime).reverse(); - for (var x = 0; x < newCallList.length; x++) { + for (var x = 0; x < newCallList.length; x++) + { var callsign = newCallList[x]; var bgDX = " style='font-weight:bold;color:cyan;' "; var bgDE = " style='font-weight:bold;color:yellow;' "; if (callsign.DXcall == myDEcall) - bgDX = " style='background-color:cyan;color:#000;font-weight:bold' "; + { bgDX = " style='background-color:cyan;color:#000;font-weight:bold' "; } if (callsign.DEcall == myDEcall) - bgDE = " style='background-color:#FFFF00;color:#000;font-weight:bold' "; + { bgDE = " style='background-color:#FFFF00;color:#000;font-weight:bold' "; } if (typeof callsign.msg == "undefined" || callsign.msg == "") - callsign.msg = "-"; + { callsign.msg = "-"; } var ageString = ""; if (timeNowSec() - callsign.time < 3601) - ageString = (timeNowSec() - callsign.time).toDHMS(); - else { + { ageString = (timeNowSec() - callsign.time).toDHMS(); } + else + { ageString = userTimeString(callsign.time * 1000); } worker += ""; worker += "
" + callsign.DEcall.formatCallsign() + @@ -1899,14 +2123,16 @@ function createTooltTipTable(toolElement) { worker += "" + callsign.RSTsent + ""; worker += "" + callsign.RSTrecv + "" + ""; if (callsign.DXcall.indexOf("CQ") == 0 || callsign.DXcall == "-") - worker += callsign.DXcall.formatCallsign(); + { worker += callsign.DXcall.formatCallsign(); } else + { worker += "
" + callsign.DXcall.formatCallsign() + "
"; + } worker += "" + "" + @@ -1915,7 +2141,8 @@ function createTooltTipTable(toolElement) { "" + callsign.band + ""; - if (toolElement.qso == true) { + if (toolElement.qso == true) + { worker += "" + (callsign.confirmed ? "✔" : "") + @@ -1933,20 +2160,26 @@ function createTooltTipTable(toolElement) { ageString + ""; if (g_callsignLookups.lotwUseEnable == true) + { worker += "" + (callsign.DEcall in g_lotwCallsigns ? "✔" : "") + ""; + } if (g_callsignLookups.eqslUseEnable == true) + { worker += "" + (callsign.DEcall in g_eqslCallsigns ? "✔" : "") + ""; + } if (g_callsignLookups.oqrsUseEnable == true) + { worker += "" + (callsign.DEcall in g_oqrsCallsigns ? "✔" : "") + ""; + } worker += ""; } worker += ""; @@ -1955,9 +2188,12 @@ function createTooltTipTable(toolElement) { return newCallList.length; } -function renderTooltipWindow(feature) { - if (g_popupWindowHandle != null) { - try { +function renderTooltipWindow(feature) +{ + if (g_popupWindowHandle != null) + { + try + { createTooltTipTable(feature); var adif = g_popupWindowHandle.window.document.getElementById( "adifTable" @@ -1970,34 +2206,42 @@ function renderTooltipWindow(feature) { g_popupWindowHandle.width = parseInt(positionInfo.width) + 20; g_popupWindowHandle.height = parseInt(positionInfo.height) + 50; - } catch (e) {} + } + catch (e) {} } } -function leftClickGtFlag(feature) { +function leftClickGtFlag(feature) +{ var e = window.event; - if ((e.which && e.which == 1) || (e.button && e.button == 1)) { + if ((e.which && e.which == 1) || (e.button && e.button == 1)) + { startLookup(g_gtFlagPins[feature.key].call, g_gtFlagPins[feature.key].grid); } return false; } -function openConditionsWindow() { - if (g_conditionsWindowHandle == null) { +function openConditionsWindow() +{ + if (g_conditionsWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( "gt_conditions.html", { show: false, - id: "GT-Conditions", + id: "GT-Conditions" }, - function (new_win) { + function (new_win) + { g_conditionsWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_conditionsWindowHandle.setMinimumSize(490, 290); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_conditionsWindowHandle.window.g_isShowing = false; g_conditionsWindowHandle.window.saveScreenSettings(); g_conditionsWindowHandle.hide(); @@ -2005,13 +2249,17 @@ function openConditionsWindow() { } ); lockNewWindows(); - } else { - try { + } + else + { + try + { g_conditionsWindowHandle.window.g_isShowing = true; g_conditionsWindowHandle.window.saveScreenSettings(); g_conditionsWindowHandle.show(); g_conditionsWindowHandle.focus(); - } catch (e) {} + } + catch (e) {} } } @@ -2023,19 +2271,23 @@ function insertMessageInRoster( msgDXcallsign, callObj, hash -) { +) +{ var now = timeNowSec(); - if (!(hash in g_callRoster)) { + if (!(hash in g_callRoster)) + { g_callRoster[hash] = {}; callObj.life = now; callObj.reset = false; } - if (callObj.reset) { + if (callObj.reset) + { callObj.life = now; callObj.reset = false; } - if (typeof callObj.life == "undefined") { + if (typeof callObj.life == "undefined") + { callObj.life = now; callObj.reset = false; } @@ -2047,8 +2299,10 @@ function insertMessageInRoster( goProcessRoster(true); } -function openCallRosterWindow(show = true) { - if (g_callRosterWindowHandle == null) { +function openCallRosterWindow(show = true) +{ + if (g_callRosterWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( @@ -2056,16 +2310,19 @@ function openCallRosterWindow(show = true) { { show: false, id: "GT-roster", - icon: "img/roster-icon.png", + icon: "img/roster-icon.png" }, - function (new_win) { + function (new_win) + { g_callRosterWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_callRosterWindowHandle.setMinimumSize(390, 250); g_callRosterWindowHandle.setResizable(true); setRosterTop(); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_callRosterWindowHandle.window.g_isShowing = false; g_callRosterWindowHandle.window.saveScreenSettings(); g_callRosterWindowHandle.hide(); @@ -2073,54 +2330,72 @@ function openCallRosterWindow(show = true) { } ); lockNewWindows(); - } else { - try { + } + else + { + try + { g_callRosterWindowHandle.show(); g_callRosterWindowHandle.window.g_isShowing = true; g_callRosterWindowHandle.window.saveScreenSettings(); g_callRosterWindowHandle.focus(); goProcessRoster(); - } catch (e) {} + } + catch (e) {} } } -function updateRosterWorked() { - if (g_callRosterWindowHandle) { - try { +function updateRosterWorked() +{ + if (g_callRosterWindowHandle) + { + try + { g_callRosterWindowHandle.window.updateWorked(); - } catch (e) {} + } + catch (e) {} } } -function updateRosterInstances() { - if (g_callRosterWindowHandle) { - try { +function updateRosterInstances() +{ + if (g_callRosterWindowHandle) + { + try + { g_callRosterWindowHandle.window.updateInstances(); - } catch (e) {} + } + catch (e) {} } } -function updateLogbook() { +function updateLogbook() +{ showWorkedBox(0, 0, true); } -function openStatsWindow(show = true) { - if (g_statsWindowHandle == null) { +function openStatsWindow(show = true) +{ + if (g_statsWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( "gt_stats.html", { show: false, - id: "GT-stats", + id: "GT-stats" }, - function (new_win) { + function (new_win) + { g_statsWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_statsWindowHandle.setMinimumSize(620, 200); g_statsWindowHandle.setResizable(true); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_statsWindowHandle.window.g_isShowing = false; g_statsWindowHandle.window.saveScreenSettings(); g_statsWindowHandle.hide(); @@ -2128,33 +2403,42 @@ function openStatsWindow(show = true) { } ); lockNewWindows(); - } else { - try { + } + else + { + try + { g_statsWindowHandle.show(); g_statsWindowHandle.window.g_isShowing = true; g_statsWindowHandle.window.saveScreenSettings(); g_statsWindowHandle.focus(); - } catch (e) {} + } + catch (e) {} } } -function showMessaging(show = true, cid) { - if (g_chatWindowHandle == null) { +function showMessaging(show = true, cid) +{ + if (g_chatWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( "gt_chat.html", { show: false, - id: "GT-chat", + id: "GT-chat" }, - function (new_win) { + function (new_win) + { g_chatWindowHandle = new_win; - g_chatWindowHandle.on("loaded", function () { + g_chatWindowHandle.on("loaded", function () + { g_chatWindowHandle.setMinimumSize(450, 140); g_chatWindowHandle.setResizable(true); }); - g_chatWindowHandle.on("close", function () { + g_chatWindowHandle.on("close", function () + { g_chatWindowHandle.window.closeMessageArea(); g_chatWindowHandle.window.g_isShowing = false; g_chatWindowHandle.window.saveScreenSettings(); @@ -2163,146 +2447,184 @@ function showMessaging(show = true, cid) { } ); lockNewWindows(); - } else { - try { + } + else + { + try + { g_chatWindowHandle.window.g_isShowing = true; g_chatWindowHandle.window.saveScreenSettings(); g_chatWindowHandle.show(); g_chatWindowHandle.focus(); if (typeof cid != "undefined") g_chatWindowHandle.window.openId(cid); - } catch (e) {} + } + catch (e) {} } } -function onRightClickGridSquare(feature) { +function onRightClickGridSquare(feature) +{ var e = window.event; if ( (e.which && e.button == 2 && event.shiftKey) || (e.button && e.button == 2 && event.shiftKey) - ) { + ) + { var myTooltip = document.getElementById("myTooltip"); createTooltTipTable(feature); selectElementContents(myTooltip); - } else if (e.button == 0 && g_mapSettings.mouseOver == false) { + } + else if (e.button == 0 && g_mapSettings.mouseOver == false) + { mouseOverDataItem(feature, false); - } else if ((e.which && e.which == 3) || (e.button && e.button == 2)) { - if (g_popupWindowHandle == null) { + } + else if ((e.which && e.which == 3) || (e.button && e.button == 2)) + { + if (g_popupWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( "gt_popup.html", { show: false, - id: "GT-popup", + id: "GT-popup" }, - function (new_win) { + function (new_win) + { g_popupWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_popupWindowHandle.show(); renderTooltipWindow(feature); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_popupWindowHandle.hide(); }); } ); lockNewWindows(); - } else { - try { + } + else + { + try + { renderTooltipWindow(feature); - } catch (e) {} + } + catch (e) {} } mouseOutOfDataItem(); - } else if ((e.which && e.which == 1) || (e.button && e.button == 0)) { - if (typeof feature.spot != "undefined") { + } + else if ((e.which && e.which == 1) || (e.button && e.button == 0)) + { + if (typeof feature.spot != "undefined") + { spotLookupAndSetCall(feature.spot); } } return false; } -function onMouseUpdate(e) { +function onMouseUpdate(e) +{ g_mouseX = e.pageX; g_mouseY = e.pageY; mouseMoveGrid(); } -function getMouseX() { +function getMouseX() +{ return g_mouseX; } -function getMouseY() { +function getMouseY() +{ return g_mouseY; } var g_tempGridBox = null; -function tempGridToBox(iQTH, oldGrid, borderColor, boxColor, layer) { +function tempGridToBox(iQTH, oldGrid, borderColor, boxColor, layer) +{ var borderWeight = 2; var newGridBox = null; var LL = squareToLatLong(iQTH.substr(0, 4)); - if (oldGrid) { - if (g_layerSources["temp"].hasFeature(oldGrid)) - g_layerSources["temp"].removeFeature(oldGrid); + if (oldGrid) + { + if (g_layerSources.temp.hasFeature(oldGrid)) + { g_layerSources.temp.removeFeature(oldGrid); } } var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; newGridBox = rectangle(bounds); newGridBox.setId(iQTH); const featureStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: boxColor, + color: boxColor }), stroke: new ol.style.Stroke({ color: borderColor, width: borderWeight, - lineJoin: "round", + lineJoin: "round" }), - zIndex: 60, + zIndex: 60 }); newGridBox.setStyle(featureStyle); newGridBox.grid = iQTH; newGridBox.size = 0; - g_layerSources["temp"].addFeature(newGridBox); + g_layerSources.temp.addFeature(newGridBox); return newGridBox; } var g_tempGrids = Array(); -function onMyKeyDown(event) { - if (g_MyGridIsUp == true && g_MyCurrentGrid.length == 4) { +function onMyKeyDown(event) +{ + if (g_MyGridIsUp == true && g_MyCurrentGrid.length == 4) + { var processedAlert = false; var mediaClip = ""; var failedToAdd = g_dirSeperator + "Balloon-deflating-1.mp3"; - if (event.code == "KeyM") { + if (event.code == "KeyM") + { mediaClip = g_dirSeperator + "Clicky-1.mp3"; var valid = addAlert(g_MyCurrentGrid, 2, 3, 2, "", ""); - if (!valid) { - mediaClip = failedToAdd; - } - processedAlert = true; - } else if (event.code == "KeyT") { - mediaClip = g_dirSeperator + "Ping-coin.mp3"; - var valid = addAlert(g_MyCurrentGrid, 2, 1, 2, "", ""); - if (!valid) { - mediaClip = failedToAdd; - } - processedAlert = true; - } else if (event.code == "KeyV") { - mediaClip = g_dirSeperator + "Slide-ping.mp3"; - var valid = addAlert(g_MyCurrentGrid, 2, 2, 2, "", ""); - if (!valid) { + if (!valid) + { mediaClip = failedToAdd; } processedAlert = true; } - if (processedAlert == true) { + else if (event.code == "KeyT") + { + mediaClip = g_dirSeperator + "Ping-coin.mp3"; + var valid = addAlert(g_MyCurrentGrid, 2, 1, 2, "", ""); + if (!valid) + { + mediaClip = failedToAdd; + } + processedAlert = true; + } + else if (event.code == "KeyV") + { + mediaClip = g_dirSeperator + "Slide-ping.mp3"; + var valid = addAlert(g_MyCurrentGrid, 2, 2, 2, "", ""); + if (!valid) + { + mediaClip = failedToAdd; + } + processedAlert = true; + } + if (processedAlert == true) + { playAlertMediaFile(mediaClip); } return; } - if (event.keyCode == 27) { + if (event.keyCode == 27) + { alertsPopDiv.style.display = "none"; rootSettingsDiv.style.display = "none"; @@ -2313,55 +2635,75 @@ function onMyKeyDown(event) { if ( alertsPopDiv.style.display == "none" && rootSettingsDiv.style.display == "none" - ) { - if (event.code in g_hotKeys) { - if (typeof g_hotKeys[event.code].param1 != "undefined") { + ) + { + if (event.code in g_hotKeys) + { + if (typeof g_hotKeys[event.code].param1 != "undefined") + { var param2 = null; - if (typeof g_hotKeys[event.code].param2 != "undefined") { + if (typeof g_hotKeys[event.code].param2 != "undefined") + { if (typeof event[g_hotKeys[event.code].param2] != "undefined") - param2 = event[g_hotKeys[event.code].param2]; + { param2 = event[g_hotKeys[event.code].param2]; } } g_hotKeys[event.code].func(g_hotKeys[event.code].param1, param2); - } else { + } + else + { if (event.ctrlKey == false) g_hotKeys[event.code].func(); } - } else if (event.key in g_hotKeys) { - if (typeof g_hotKeys[event.key].param1 != "undefined") { + } + else if (event.key in g_hotKeys) + { + if (typeof g_hotKeys[event.key].param1 != "undefined") + { var param2 = null; - if (typeof g_hotKeys[event.key].param2 != "undefined") { + if (typeof g_hotKeys[event.key].param2 != "undefined") + { if (typeof event[g_hotKeys[event.key].param2] != "undefined") - param2 = event[g_hotKeys[event.key].param2]; + { param2 = event[g_hotKeys[event.key].param2]; } } g_hotKeys[event.key].func(g_hotKeys[event.key].param1, param2); - } else { + } + else + { if (event.ctrlKey == false) g_hotKeys[event.key].func(); } } } } -function clearTempGrids() { - g_layerSources["temp"].clear(); +function clearTempGrids() +{ + g_layerSources.temp.clear(); g_tempGrids = Array(); } var g_currentShapes = {}; -function clearCurrentShapes() { - g_layerSources["award"].clear(); +function clearCurrentShapes() +{ + g_layerSources.award.clear(); g_currentShapes = {}; } -function mapMemory(x, save, exit = false) { - if (save == true) { +function mapMemory(x, save, exit = false) +{ + if (save == true) + { g_mapMemory[x].LoLa = g_mapView.getCenter(); g_mapMemory[x].zoom = g_mapView.getZoom(); localStorage.mapMemory = JSON.stringify(g_mapMemory); - if (exit == false) { + if (exit == false) + { playAlertMediaFile("Clicky-3.mp3"); } - } else { - if (g_mapMemory[x].zoom != -1) { + } + else + { + if (g_mapMemory[x].zoom != -1) + { g_mapView.setCenter(g_mapMemory[x].LoLa); g_mapView.setZoom(g_mapMemory[x].zoom); } @@ -2370,14 +2712,16 @@ function mapMemory(x, save, exit = false) { var g_hotKeys = {}; -function registerHotKey(key, func, param1, param2) { +function registerHotKey(key, func, param1, param2) +{ g_hotKeys[key] = {}; g_hotKeys[key].func = func; g_hotKeys[key].param1 = param1; g_hotKeys[key].param2 = param2; } -function registerHotKeys() { +function registerHotKeys() +{ registerHotKey("1", setTrophyOverlay, 0); registerHotKey("2", setTrophyOverlay, 1); registerHotKey("3", setTrophyOverlay, 2); @@ -2398,7 +2742,7 @@ function registerHotKeys() { registerHotKey("KeyG", toggleGtMap); registerHotKey("KeyH", toggleHeatSpots); registerHotKey("KeyI", showRootInfoBox); - //registerHotKey("KeyJ", setTrophyOverlay, 8); + // registerHotKey("KeyJ", setTrophyOverlay, 8); registerHotKey("KeyK", makeScreenshots); registerHotKey("KeyL", adifLoadDialog); registerHotKey("KeyM", toggleAlertMute); @@ -2429,85 +2773,103 @@ function registerHotKeys() { registerHotKey("Equal", cycleTrophyOverlay); } -function toggleMoon() { +function toggleMoon() +{ g_appSettings.moonTrack ^= 1; - if (g_appSettings.moonTrack == 1) { + if (g_appSettings.moonTrack == 1) + { moonLayer.show(); - } else { + } + else + { moonLayer.hide(); } } -function toggleMoonTrack() { +function toggleMoonTrack() +{ g_appSettings.moonPath ^= 1; moonLayer.refresh(); } -function toggleFullscreen() { - if (document.fullscreenElement == null) { +function toggleFullscreen() +{ + if (document.fullscreenElement == null) + { mainBody.requestFullscreen(); - } else { + } + else + { document.exitFullscreen(); } } -function toggleMenu() { +function toggleMenu() +{ if (g_menuShowing == false) collapseMenu(false); else collapseMenu(true); } g_helpShow = false; -function toggleHelp() { +function toggleHelp() +{ g_helpShow = !g_helpShow; - if (g_helpShow == true) { + if (g_helpShow == true) + { helpDiv.style.display = "block"; - } else helpDiv.style.display = "none"; + } + else helpDiv.style.display = "none"; } function onMyKeyUp(event) {} var g_currentOverlay = 0; -function cycleTrophyOverlay() { +function cycleTrophyOverlay() +{ g_currentOverlay++; g_currentOverlay %= 8; setTrophyOverlay(g_currentOverlay); } -function didWork(testObj) { +function didWork(testObj) +{ return testObj.worked; } -function didConfirm(testObj) { +function didConfirm(testObj) +{ return testObj.confirmed; } -function makeTitleInfo(mapWindow) { +function makeTitleInfo(mapWindow) +{ var band = g_appSettings.gtBandFilter.length == 0 ? "Mixed" : g_appSettings.gtBandFilter == "auto" - ? myBand - : g_appSettings.gtBandFilter; + ? myBand + : g_appSettings.gtBandFilter; var mode = g_appSettings.gtModeFilter.length == 0 ? "Mixed" : g_appSettings.gtModeFilter == "auto" - ? myMode - : g_appSettings.gtModeFilter; + ? myMode + : g_appSettings.gtModeFilter; var space = " "; var news = "GridTracker [Band: " + band + " Mode: " + mode; var end = "]"; - if (mapWindow) { + if (mapWindow) + { news += " Layer: " + g_viewInfo[g_currentOverlay][1]; } if (g_currentOverlay == 0 && g_appSettings.gridViewMode == 1) - return news + end; + { return news + end; } var workline = " - Worked " + @@ -2518,14 +2880,17 @@ function makeTitleInfo(mapWindow) { g_viewInfo[g_currentOverlay][2] <= g_viewInfo[g_currentOverlay][4] && g_viewInfo[g_currentOverlay][4] > 0 ) + { end = " Needed " + (g_viewInfo[g_currentOverlay][4] - g_viewInfo[g_currentOverlay][2]) + "]"; + } return news + workline + end; } -function setTrophyOverlay(which) { +function setTrophyOverlay(which) +{ g_currentOverlay = which; window.document.title = makeTitleInfo(true); trophyImg.src = g_trophyImageArray[which]; @@ -2534,75 +2899,102 @@ function setTrophyOverlay(which) { // set the scope of key var key = 0; - if (which == 0) { - for (key in g_layerVectors) { + if (which == 0) + { + for (key in g_layerVectors) + { g_layerVectors[key].setVisible(true); } if ( g_appSettings.gtFlagImgSrc > 0 && g_appSettings.gtShareEnable == true && g_mapSettings.offlineMode == false - ) { - g_layerVectors["gtflags"].setVisible(true); - } else { - g_layerVectors["gtflags"].setVisible(false); + ) + { + g_layerVectors.gtflags.setVisible(true); } - g_layerVectors["award"].setVisible(false); - if (g_showAllGrids == false) { + else + { + g_layerVectors.gtflags.setVisible(false); + } + g_layerVectors.award.setVisible(false); + if (g_showAllGrids == false) + { g_layerVectors["line-grids"].setVisible(false); g_layerVectors["big-grids"].setVisible(false); g_layerVectors["short-grids"].setVisible(false); g_layerVectors["long-grids"].setVisible(false); } - if (g_timezoneLayer) { - if (g_timezonesEnable == 1) { + if (g_timezoneLayer) + { + if (g_timezonesEnable == 1) + { g_timezoneLayer.setVisible(true); - } else { + } + else + { g_timezoneLayer.setVisible(false); } } - } else { - if (g_mapSettings.mergeOverlay == false) { - for (key in g_layerVectors) { + } + else + { + if (g_mapSettings.mergeOverlay == false) + { + for (key in g_layerVectors) + { g_layerVectors[key].setVisible(false); } - } else { - for (key in g_layerVectors) { + } + else + { + for (key in g_layerVectors) + { g_layerVectors[key].setVisible(true); } if ( g_appSettings.gtFlagImgSrc > 0 && g_appSettings.gtShareEnable == true && g_mapSettings.offlineMode == false - ) { - g_layerVectors["gtflags"].setVisible(true); - } else { - g_layerVectors["gtflags"].setVisible(false); + ) + { + g_layerVectors.gtflags.setVisible(true); } - if (g_showAllGrids == false) { + else + { + g_layerVectors.gtflags.setVisible(false); + } + if (g_showAllGrids == false) + { g_layerVectors["line-grids"].setVisible(false); g_layerVectors["big-grids"].setVisible(false); g_layerVectors["short-grids"].setVisible(false); g_layerVectors["long-grids"].setVisible(false); } } - g_layerVectors["award"].setVisible(true); - if (g_timezoneLayer) { + g_layerVectors.award.setVisible(true); + if (g_timezoneLayer) + { g_timezoneLayer.setVisible(false); } mapLoseFocus(); } - g_layerVectors["strikes"].setVisible(true); + g_layerVectors.strikes.setVisible(true); - if (which == 1) { - for (key in g_cqZones) { + if (which == 1) + { + for (key in g_cqZones) + { var boxColor = "#FF000015"; var borderColor = "#005500FF"; var borderWeight = 1; - if (didConfirm(g_cqZones[key])) { + if (didConfirm(g_cqZones[key])) + { boxColor = "#00FF0066"; - } else if (didWork(g_cqZones[key])) { + } + else if (didWork(g_cqZones[key])) + { boxColor = "#FFFF0066"; } @@ -2614,18 +3006,23 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } - if (which == 2) { - for (key in g_ituZones) { + if (which == 2) + { + for (key in g_ituZones) + { var boxColor = "#FF000015"; var borderColor = "#800080FF"; var borderWeight = 1; - if (didConfirm(g_ituZones[key])) { + if (didConfirm(g_ituZones[key])) + { boxColor = "#00FF0066"; borderWeight = 1; - } else if (didWork(g_ituZones[key])) { + } + else if (didWork(g_ituZones[key])) + { boxColor = "#FFFF0066"; borderWeight = 1; } @@ -2638,18 +3035,23 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } - if (which == 3) { - for (key in g_wacZones) { + if (which == 3) + { + for (key in g_wacZones) + { var boxColor = "#FF000015"; var borderColor = "#006666FF"; var borderWeight = 1; var originalKey = key; - if (didConfirm(g_wacZones[key])) { + if (didConfirm(g_wacZones[key])) + { boxColor = "#00FF0066"; - } else if (didWork(g_wacZones[key])) { + } + else if (didWork(g_wacZones[key])) + { boxColor = "#FFFF0066"; } @@ -2661,17 +3063,22 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[originalKey]); + g_layerSources.award.addFeature(g_currentShapes[originalKey]); } } - if (which == 4) { - for (key in g_wasZones) { + if (which == 4) + { + for (key in g_wasZones) + { var boxColor = "#FF000020"; var borderColor = "#0000FFFF"; var borderWeight = 1; - if (didConfirm(g_wasZones[key])) { + if (didConfirm(g_wasZones[key])) + { boxColor = "#00FF0066"; - } else if (didWork(g_wasZones[key])) { + } + else if (didWork(g_wasZones[key])) + { boxColor = "#FFFF0066"; } @@ -2683,21 +3090,27 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } - if (which == 5) { - for (key in g_worldGeoData) { + if (which == 5) + { + for (key in g_worldGeoData) + { var boxColor = "#FF000015"; var borderColor = "#0000FFFF"; var borderWeight = 1; - if (didConfirm(g_worldGeoData[key])) { + if (didConfirm(g_worldGeoData[key])) + { boxColor = "#00FF0066"; - } else if (didWork(g_worldGeoData[key])) { + } + else if (didWork(g_worldGeoData[key])) + { boxColor = "#FFFF0066"; } - if (g_worldGeoData[key].geo != "deleted") { + if (g_worldGeoData[key].geo != "deleted") + { g_currentShapes[key] = shapeFeature( key, g_worldGeoData[key].geo, @@ -2706,19 +3119,24 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } } - if (which == 6) { - for (key in g_countyData) { + if (which == 6) + { + for (key in g_countyData) + { var boxColor = "#00000000"; var borderColor = "#0000FFFF"; var borderWeight = 0.1; - if (didConfirm(g_countyData[key])) { + if (didConfirm(g_countyData[key])) + { boxColor = "#00FF0066"; borderWeight = 1; - } else if (didWork(g_countyData[key])) { + } + else if (didWork(g_countyData[key])) + { boxColor = "#FFFF0066"; borderWeight = 1; } @@ -2731,24 +3149,29 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } - if (which == 7) { - for (key in g_us48Data) { + if (which == 7) + { + for (key in g_us48Data) + { var LL = squareToLatLong(key); var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; var boxColor = "#FF000015"; var borderColor = "#0000FFFF"; var borderWeight = 0.1; - if (g_us48Data[key].confirmed) { + if (g_us48Data[key].confirmed) + { boxColor = "#00FF0066"; borderWeight = 0.2; - } else if (g_us48Data[key].worked) { + } + else if (g_us48Data[key].worked) + { boxColor = "#FFFF0066"; borderWeight = 0.2; } @@ -2761,7 +3184,7 @@ function setTrophyOverlay(which) { borderColor, borderWeight ); - g_layerSources["award"].addFeature(g_currentShapes[key]); + g_layerSources.award.addFeature(g_currentShapes[key]); } } @@ -2775,15 +3198,16 @@ function gridFeature( fillColor, borderColor, borderWidth -) { +) +{ var style = new ol.style.Style({ stroke: new ol.style.Stroke({ color: borderColor, - width: borderWidth, + width: borderWidth }), fill: new ol.style.Fill({ - color: fillColor, - }), + color: fillColor + }) }); objectData.setStyle(style); @@ -2795,7 +3219,8 @@ function gridFeature( var g_lastMoon = null; -function moonOver(feature) { +function moonOver(feature) +{ var data = subLunar(timeNowSec()); var object = doRAconvert(g_myLon, g_myLat, data.RA, data.Dec); @@ -2820,7 +3245,8 @@ function moonOver(feature) { myMoonTooltip.innerHTML = worker; - if (g_lastMoon) { + if (g_lastMoon) + { moonMove(); return; } @@ -2833,12 +3259,14 @@ function moonOver(feature) { myMoonTooltip.style.display = "block"; } -function moonOut() { +function moonOut() +{ g_lastMoon = null; myMoonTooltip.style.zIndex = -1; } -function moonMove() { +function moonMove() +{ var positionInfo = myMoonTooltip.getBoundingClientRect(); myMoonTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; myMoonTooltip.style.top = getMouseY() + 22 + "px"; @@ -2846,8 +3274,10 @@ function moonMove() { var g_lastTrophy = null; -function trophyOver(feature) { - if (g_lastTrophy && g_lastTrophy == feature) { +function trophyOver(feature) +{ + if (g_lastTrophy && g_lastTrophy == feature) + { trophyMove(); return; } @@ -2860,26 +3290,31 @@ function trophyOver(feature) { var zone = null; var key = feature.get("prop"); - if (key == "cqzone") { + if (key == "cqzone") + { trophy = "CQ Zone"; infoObject = g_cqZones[name]; zone = name; name = g_cqZones[name].name; } - if (key == "ituzone") { + if (key == "ituzone") + { trophy = "ITU Zone"; infoObject = g_ituZones[name]; } - if (key == "wac" && name in g_wacZones) { + if (key == "wac" && name in g_wacZones) + { trophy = "Continent"; infoObject = g_wacZones[name]; } - if (key == "was" && name in g_wasZones) { + if (key == "was" && name in g_wasZones) + { trophy = "US State"; infoObject = g_wasZones[name]; } - if (key == "dxcc" && name in g_worldGeoData) { + if (key == "dxcc" && name in g_worldGeoData) + { trophy = "DXCC"; var ref = name; infoObject = g_worldGeoData[ref]; @@ -2889,26 +3324,33 @@ function trophyOver(feature) { g_worldGeoData[ref].pp + ")"; } - if (key == "usc") { + if (key == "usc") + { trophy = "US County"; infoObject = g_countyData[name]; name = infoObject.geo.properties.n + ", " + infoObject.geo.properties.st; } - if (key == "us48") { + if (key == "us48") + { trophy = "US Continental Grids"; infoObject = g_us48Data[feature.get("grid")]; name = feature.get("grid"); - if (name in g_gridToState) { + if (name in g_gridToState) + { zone = ""; - for (var x = 0; x < g_gridToDXCC[name].length; x++) { - if (name in g_gridToState) { - for (var y = 0; y < g_gridToState[name].length; y++) { + for (var x = 0; x < g_gridToDXCC[name].length; x++) + { + if (name in g_gridToState) + { + for (var y = 0; y < g_gridToState[name].length; y++) + { if ( g_gridToDXCC[name][x] == g_StateData[g_gridToState[name][y]].dxcc && g_gridToDXCC[name][x] == 291 - ) { + ) + { zone += g_StateData[g_gridToState[name][y]].name + ", "; } } @@ -2927,20 +3369,24 @@ function trophyOver(feature) { ""; if (zone) + { worker += " " + zone + ""; + } var wc1Table = ""; - if (infoObject.worked) { + if (infoObject.worked) + { wc1Table = ""; wc1Table += ""; wc1Table += ""; wc1Table += "
Worked
Band"; var keys = Object.keys(infoObject.worked_bands).sort(); - for (key in keys) { + for (key in keys) + { wc1Table += ""; wc1Table += ""; } var wcTable = ""; - if (infoObject.confirmed) { + if (infoObject.confirmed) + { wcTable = "
" + keys[key] + @@ -2955,7 +3401,8 @@ function trophyOver(feature) { wc1Table += "Mode"; keys = Object.keys(infoObject.worked_modes).sort(); - for (key in keys) { + for (key in keys) + { wc1Table += "
" + keys[key] + @@ -2970,14 +3417,16 @@ function trophyOver(feature) { wc1Table += "
"; wcTable += ""; wcTable += ""; wcTable += "
Confirmed
Band"; var keys = Object.keys(infoObject.confirmed_bands).sort(); - for (key in keys) { + for (key in keys) + { wcTable += ""; wcTable += ""; } if (!infoObject.worked && !infoObject.confirmed) + { worker += ""; - else { + } + else + { worker += "" + wc1Table + wcTable + ""; } @@ -3025,12 +3478,14 @@ function trophyOver(feature) { myTrophyTooltip.style.display = "block"; } -function trophyOut() { +function trophyOut() +{ g_lastTrophy = null; myTrophyTooltip.style.zIndex = -1; } -function trophyMove() { +function trophyMove() +{ var positionInfo = myTrophyTooltip.getBoundingClientRect(); myTrophyTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; myTrophyTooltip.style.top = getMouseY() - positionInfo.height - 22 + "px"; @@ -3039,7 +3494,8 @@ function trophyMove() { var g_MyCurrentGrid = ""; var g_MyGridIsUp = false; -function mouseDownGrid(longlat, event) { +function mouseDownGrid(longlat, event) +{ var grid = ""; grid = latLonToGridSquare(longlat[1], longlat[0]); g_MyCurrentGrid = grid.substr(0, 4); @@ -3071,11 +3527,13 @@ function mouseDownGrid(longlat, event) { "
" + keys[key] + @@ -2992,7 +3441,8 @@ function trophyOver(feature) { wcTable += "Mode"; keys = Object.keys(infoObject.confirmed_modes).sort(); - for (key in keys) { + for (key in keys) + { wcTable += "
" + keys[key] + @@ -3006,9 +3456,12 @@ function trophyOver(feature) { wcTable += "
Needed
Long" + longlat[0].toFixed(3) + "
"; - if (grid in g_gridToDXCC) { + if (grid in g_gridToDXCC) + { worker += ""; worker += ""; - for (var x = 0; x < g_gridToDXCC[grid].length; x++) { + for (var x = 0; x < g_gridToDXCC[grid].length; x++) + { worker += ""; } - if (grid in g_gridToState) { + if (grid in g_gridToState) + { worker += ""; - for (var x = 0; x < g_gridToDXCC[grid].length; x++) { + for (var x = 0; x < g_gridToDXCC[grid].length; x++) + { worker += ""; Object.keys(List) .sort() - .forEach(function (key, i) { + .forEach(function (key, i) + { worker += ""; worker += ""; var key = null; - for (var i = startIndex; i < endIndex; i++) { + for (var i = startIndex; i < endIndex; i++) + { key = list[i]; worker += ""; if (g_callsignLookups.lotwUseEnable == true) + { worker += ""; + } if (g_callsignLookups.eqslUseEnable == true) + { worker += ""; + } if (g_callsignLookups.oqrsUseEnable == true) + { worker += ""; + } worker += ""; } @@ -7183,10 +8241,12 @@ function showWorkedBox(sortIndex, nextPage, redraw) { option.text = "Mixed"; newSelect.appendChild(option); Object.keys(bands) - .sort(function (a, b) { + .sort(function (a, b) + { return parseInt(a) - parseInt(b); }) - .forEach(function (key) { + .forEach(function (key) + { var option = document.createElement("option"); option.value = key; option.text = key; @@ -7220,7 +8280,8 @@ function showWorkedBox(sortIndex, nextPage, redraw) { Object.keys(modes) .sort() - .forEach(function (key) { + .forEach(function (key) + { var option = document.createElement("option"); option.value = key; option.text = key; @@ -7245,7 +8306,8 @@ function showWorkedBox(sortIndex, nextPage, redraw) { Object.keys(dxccs) .sort() - .forEach(function (key) { + .forEach(function (key) + { var option = document.createElement("option"); option.value = dxccs[key]; option.text = key; @@ -7289,53 +8351,66 @@ function showWorkedBox(sortIndex, nextPage, redraw) { statsFocus(g_lastSearchSelection); setStatsDivHeight("workedListDiv", getStatsWindowHeight() - 6 + "px"); - } else setStatsDiv("workedListDiv", "None"); + } + else setStatsDiv("workedListDiv", "None"); myObjects = null; - } catch (e) { + } + catch (e) + { console.log(e); } } -function statsValidateCallByElement(elementString) { +function statsValidateCallByElement(elementString) +{ if ( g_statsWindowHandle != null && typeof g_statsWindowHandle.window.validateCallByElement !== "undefined" - ) { + ) + { g_statsWindowHandle.window.validateCallByElement(elementString); } } -function statsFocus(selection) { +function statsFocus(selection) +{ if ( g_statsWindowHandle != null && typeof g_statsWindowHandle.window.statsFocus !== "undefined" - ) { + ) + { g_statsWindowHandle.window.statsFocus(selection); } } -function lookupValidateCallByElement(elementString) { +function lookupValidateCallByElement(elementString) +{ if ( g_lookupWindowHandle != null && typeof g_statsWindowHandle.window.validateCallByElement !== "undefined" - ) { + ) + { g_lookupWindowHandle.window.validateCallByElement(elementString); } } -function lookupFocus(selection) { +function lookupFocus(selection) +{ if ( g_lookupWindowHandle != null && typeof g_statsWindowHandle.window.statsFocus !== "undefined" - ) { + ) + { g_lookupWindowHandle.window.statsFocus(selection); } } -function statsAppendChild(elementString, object, onInputString, defaultValue) { +function statsAppendChild(elementString, object, onInputString, defaultValue) +{ if ( g_statsWindowHandle != null && typeof g_statsWindowHandle.window.appendToChild !== "undefined" - ) { + ) + { g_statsWindowHandle.window.appendToChild( elementString, object, @@ -7344,7 +8419,8 @@ function statsAppendChild(elementString, object, onInputString, defaultValue) { ); } } -function showDXCCsBox() { +function showDXCCsBox() +{ var worker = getCurrentBandModeHTML(); var confirmed = 0; var worked = 0; @@ -7352,9 +8428,12 @@ function showDXCCsBox() { var List = {}; var ListConfirmed = {}; var ListNotWorked = {}; - for (var key in g_worldGeoData) { - if (key != -1) { - if (g_worldGeoData[key].worked == true) { + for (var key in g_worldGeoData) + { + if (key != -1) + { + if (g_worldGeoData[key].worked == true) + { var item = {}; item.dxcc = g_worldGeoData[key].dxcc; @@ -7363,7 +8442,8 @@ function showDXCCsBox() { List[g_worldGeoData[key].name] = item; worked++; } - if (g_worldGeoData[key].confirmed == true) { + if (g_worldGeoData[key].confirmed == true) + { var item = {}; item.dxcc = g_worldGeoData[key].dxcc; @@ -7377,7 +8457,8 @@ function showDXCCsBox() { g_worldGeoData[key].confirmed == false && g_worldGeoData[key].pp != "" && g_worldGeoData[key].geo != "deleted" - ) { + ) + { var item = {}; item.dxcc = g_worldGeoData[key].dxcc; item.flag = g_worldGeoData[key].flag; @@ -7388,7 +8469,8 @@ function showDXCCsBox() { } } - if (worked > 0) { + if (worked > 0) + { worker += "
"; Object.keys(ListConfirmed) .sort() - .forEach(function (key, i) { + .forEach(function (key, i) + { worker += ""; worker += ""; Object.keys(ListNotWorked) .sort() - .forEach(function (key, i) { + .forEach(function (key, i) + { worker += ""; worker += "
" + g_dxccToAltName[g_gridToDXCC[grid][x]] + @@ -3083,15 +3541,20 @@ function mouseDownGrid(longlat, event) { g_worldGeoData[g_dxccToGeoData[g_gridToDXCC[grid][x]]].pp + ")
"; - if (grid in g_gridToState) { - for (var y = 0; y < g_gridToState[grid].length; y++) { + if (grid in g_gridToState) + { + for (var y = 0; y < g_gridToState[grid].length; y++) + { if ( g_gridToDXCC[grid][x] == g_StateData[g_gridToState[grid][y]].dxcc - ) { + ) + { worker += g_StateData[g_gridToState[grid][y]].name + "
"; } } @@ -3116,29 +3579,35 @@ function mouseDownGrid(longlat, event) { g_MyGridIsUp = true; } -function mouseMoveGrid() { - if (g_MyGridIsUp == true) { +function mouseMoveGrid() +{ + if (g_MyGridIsUp == true) + { var positionInfo = myGridTooltip.getBoundingClientRect(); myGridTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; myGridTooltip.style.top = getMouseY() - positionInfo.height - 22 + "px"; } } -function mouseUpGrid() { +function mouseUpGrid() +{ g_MyGridIsUp = false; myGridTooltip.style.zIndex = -1; - if (g_tempGridBox) { - if (g_layerSources["temp"].hasFeature(g_tempGridBox)) - g_layerSources["temp"].removeFeature(g_tempGridBox); + if (g_tempGridBox) + { + if (g_layerSources.temp.hasFeature(g_tempGridBox)) + { g_layerSources.temp.removeFeature(g_tempGridBox); } } g_tempGridBox = null; } var g_lastGtFlag = null; -function mouseOverGtFlag(feature) { - if (g_lastGtFlag && g_lastGtFlag == feature) { +function mouseOverGtFlag(feature) +{ + if (g_lastGtFlag && g_lastGtFlag == feature) + { gtFlagMove(); return; } @@ -3153,35 +3622,38 @@ function mouseOverGtFlag(feature) { myFlagtip.style.zIndex = 499; myFlagtip.style.display = "block"; - if (feature.size == 73 && feature != g_lasttimezone) { - if (g_lasttimezone != null) { + if (feature.size == 73 && feature != g_lasttimezone) + { + if (g_lasttimezone != null) + { g_lasttimezone.setStyle(null); } var style = new ol.style.Style({ fill: new ol.style.Fill({ - color: "#FFFF0088", - }), + color: "#FFFF0088" + }) }); feature.setStyle(style); g_lasttimezone = feature; } - - return; } -function mouseOutGtFlag(mouseEvent) { +function mouseOutGtFlag(mouseEvent) +{ g_lastGtFlag = null; myFlagtip.style.zIndex = -1; - if (g_lasttimezone != null) { + if (g_lasttimezone != null) + { g_lasttimezone.setStyle(null); g_lasttimezone = null; } } -function gtFlagMove() { +function gtFlagMove() +{ var positionInfo = myFlagtip.getBoundingClientRect(); myFlagtip.style.left = getMouseX() + 15 + "px"; myFlagtip.style.top = getMouseY() - positionInfo.height - 5 + "px"; @@ -3189,9 +3661,11 @@ function gtFlagMove() { var g_lastDataGridUp = null; -function mouseOverDataItem(mouseEvent, fromHover) { +function mouseOverDataItem(mouseEvent, fromHover) +{ if (g_MyGridIsUp) return; - if (g_lastDataGridUp && g_lastDataGridUp == mouseEvent) { + if (g_lastDataGridUp && g_lastDataGridUp == mouseEvent) + { mouseMoveDataItem(mouseEvent); return; } @@ -3215,18 +3689,21 @@ function mouseOverDataItem(mouseEvent, fromHover) { typeof mouseEvent.spot != "undefined" && g_receptionReports.spots[mouseEvent.spot].bearing > 180 ) - noRoomRight = true; + { noRoomRight = true; } myTooltip.style.left = getMouseX() + 15 + "px"; top = parseInt(getMouseY() - 20 - (callListLength / 2) * 25); - if (windowWidth - getMouseX() < positionInfo.width || noRoomRight == true) { + if (windowWidth - getMouseX() < positionInfo.width || noRoomRight == true) + { myTooltip.style.left = getMouseX() - (10 + positionInfo.width) + "px"; top = parseInt(getMouseY() - 20 - (callListLength / 2) * 25); noRoomRight = true; } - if (getMouseX() - positionInfo.width < 0) { + if (getMouseX() - positionInfo.width < 0) + { noRoomLeft = true; } - if (noRoomLeft == true && noRoomRight == true) { + if (noRoomLeft == true && noRoomRight == true) + { myTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; top = getMouseY() + 30; } @@ -3236,7 +3713,8 @@ function mouseOverDataItem(mouseEvent, fromHover) { myTooltip.style.display = "block"; } -function mouseMoveDataItem(mouseEvent) { +function mouseMoveDataItem(mouseEvent) +{ var myTooltip = document.getElementById("myTooltip"); var positionInfo = myTooltip.getBoundingClientRect(); var windowWidth = window.innerWidth; @@ -3247,19 +3725,22 @@ function mouseMoveDataItem(mouseEvent) { typeof mouseEvent.spot != "undefined" && g_receptionReports.spots[mouseEvent.spot].bearing > 180 ) - noRoomRight = true; + { noRoomRight = true; } myTooltip.style.left = getMouseX() + 15 + "px"; top = Number(myTooltip.style.top); if (top > 20) top = getMouseY() - 20 + "px"; - if (windowWidth - getMouseX() < positionInfo.width || noRoomRight == true) { + if (windowWidth - getMouseX() < positionInfo.width || noRoomRight == true) + { myTooltip.style.left = getMouseX() - (10 + positionInfo.width) + "px"; if (top > 20) top = getMouseY() - 20 + "px"; noRoomRight = true; } - if (getMouseX() - positionInfo.width < 0) { + if (getMouseX() - positionInfo.width < 0) + { noRoomLeft = true; } - if (noRoomLeft == true && noRoomRight == true) { + if (noRoomLeft == true && noRoomRight == true) + { myTooltip.style.left = getMouseX() - positionInfo.width / 2 + "px"; top = getMouseY() + 30; } @@ -3267,7 +3748,8 @@ function mouseMoveDataItem(mouseEvent) { myTooltip.style.top = top + "px"; } -function mouseOutOfDataItem(mouseEvent) { +function mouseOutOfDataItem(mouseEvent) +{ var myTooltip = document.getElementById("myTooltip"); myTooltip.style.zIndex = -1; g_lastDataGridUp = null; @@ -3275,15 +3757,20 @@ function mouseOutOfDataItem(mouseEvent) { if (g_spotsEnabled == 1) g_layerSources["psk-hop"].clear(); } -function reloadInfo(bandOrMode) { - if (g_statsWindowHandle != null) { - try { +function reloadInfo(bandOrMode) +{ + if (g_statsWindowHandle != null) + { + try + { g_statsWindowHandle.window.reloadInfo(); - } catch (e) {} + } + catch (e) {} } } -function twoWideToLatLong(qth) { +function twoWideToLatLong(qth) +{ qth = qth.toUpperCase(); var a = qth.charCodeAt(0) - 65; var b = qth.charCodeAt(1) - 65; @@ -3305,7 +3792,8 @@ function twoWideToLatLong(qth) { return LatLong; } -function squareToLatLongAll(qth) { +function squareToLatLongAll(qth) +{ qth = qth.toUpperCase(); var a = qth.charCodeAt(0) - 65; var b = qth.charCodeAt(1) - 65; @@ -3316,11 +3804,14 @@ function squareToLatLongAll(qth) { var la2; var lo2; var LatLong = []; - if (qth.length == 4) { + if (qth.length == 4) + { la2 = la1 + 1; lo2 = lo1 + 2; LatLong.size = 4; - } else { + } + else + { var lo3; var la3; var e = qth.charCodeAt(4) - 65; @@ -3347,7 +3838,8 @@ function squareToLatLongAll(qth) { return LatLong; } -function squareToLatLong(qth) { +function squareToLatLong(qth) +{ qth = qth.toUpperCase(); var a = qth.charCodeAt(0) - 65; var b = qth.charCodeAt(1) - 65; @@ -3358,11 +3850,14 @@ function squareToLatLong(qth) { var la2; var lo2; var LatLong = []; - if (qth.length == 4 || g_appSettings.sixWideMode == 0) { + if (qth.length == 4 || g_appSettings.sixWideMode == 0) + { la2 = la1 + 1; lo2 = lo1 + 2; LatLong.size = 4; - } else { + } + else + { var lo3; var la3; var e = qth.charCodeAt(4) - 65; @@ -3388,15 +3883,16 @@ function squareToLatLong(qth) { return LatLong; } -function iconFeature(center, iconObj, zIndex) { +function iconFeature(center, iconObj, zIndex) +{ var feature = new ol.Feature({ geometry: new ol.geom.Point(center), - name: "pin", + name: "pin" }); var iconStyle = new ol.style.Style({ zIndex: zIndex, - image: iconObj, + image: iconObj }); feature.setStyle(iconStyle); @@ -3414,7 +3910,8 @@ function qthToQsoBox( confirmed, band, wspr -) { +) +{ if (g_appSettings.gridViewMode == 1) return null; var borderColor = "#222288FF"; @@ -3423,39 +3920,50 @@ function qthToQsoBox( var myDEzOffset = 10; var myDEbox = false; - if (worked) { + if (worked) + { boxColor = "#FFFF00" + g_gridAlpha; borderColor = g_qsoWorkedBorderColor; } - if (confirmed) { + if (confirmed) + { boxColor = "#FF0000" + g_gridAlpha; borderColor = g_qsoWorkedBorderColor; } - if (wspr != null) { + if (wspr != null) + { boxColor = "hsl(" + wspr + ",100%,50%)"; borderColor = "gray"; } var zIndex = 2; - var entityVisibility = Number(g_appSettings.gridViewMode) > 1 ? true : false; + var entityVisibility = Number(g_appSettings.gridViewMode) > 1; var returnRectangle = null; if (g_appSettings.sixWideMode == 0) iQTH = iQTH.substr(0, 4); else iQTH = iQTH.substr(0, 6); var rect = null; - if (iQTH == "") { - for (var key in g_qsoGrids) { - if (iHash in g_qsoGrids[key].rectangle.hashes) { + if (iQTH == "") + { + for (var key in g_qsoGrids) + { + if (iHash in g_qsoGrids[key].rectangle.hashes) + { rect = g_qsoGrids[key]; break; } } - } else { - if (iQTH in g_qsoGrids) { + } + else + { + if (iQTH in g_qsoGrids) + { rect = g_qsoGrids[iQTH]; } } - if (rect == null) { - if (iQTH != "") { + if (rect == null) + { + if (iQTH != "") + { // Valid QTH var triangleView = false; if ( @@ -3463,16 +3971,21 @@ function qthToQsoBox( iQTH in g_liveGrids && entityVisibility == true && g_pushPinMode == false - ) { - if (confirmed) { + ) + { + if (confirmed) + { hideLiveGrid(iQTH); - } else { + } + else + { liveTriangleGrid(iQTH); triangleView = true; } } LL = squareToLatLong(iQTH); - if (LL.size == 6) { + if (LL.size == 6) + { borderColor = "#000000FF"; zIndex = 50; } @@ -3482,7 +3995,7 @@ function qthToQsoBox( var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; if (triangleView == true) newRect.rectangle = triangle(bounds, true); else newRect.rectangle = rectangle(bounds); @@ -3491,21 +4004,21 @@ function qthToQsoBox( const featureHoverStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: boxColor, + color: boxColor }), stroke: new ol.style.Stroke({ color: borderColor, width: borderWeight, - lineJoin: "round", + lineJoin: "round" }), - zIndex: zIndex, + zIndex: zIndex }); newRect.rectangle.setStyle(featureHoverStyle); newRect.rectangle.qth = iQTH; if (g_pushPinMode == false && entityVisibility == true) - g_layerSources["qso"].addFeature(newRect.rectangle); + { g_layerSources.qso.addFeature(newRect.rectangle); } var newPin = g_colorLeafletQPins.worked[band]; if (confirmed) newPin = g_colorLeafletQPins.confirmed[band]; @@ -3521,7 +4034,7 @@ function qthToQsoBox( newRect.rectangle.pin.size = LL.size; if (g_pushPinMode && entityVisibility == true) - g_layerSources["qso-pins"].addFeature(newRect.rectangle.pin); + { g_layerSources["qso-pins"].addFeature(newRect.rectangle.pin); } newRect.rectangle.locked = locked; newRect.rectangle.worked = worked; @@ -3535,22 +4048,27 @@ function qthToQsoBox( g_qsoGrids[iQTH] = newRect; returnRectangle = newRect.rectangle; } - } else { - if (!(iHash in rect.rectangle.hashes)) { + } + else + { + if (!(iHash in rect.rectangle.hashes)) + { rect.rectangle.hashes[iHash] = 1; rect.rectangle.pin.hashes[iHash] = 1; } - if (!confirmed && rect.rectangle.confirmed) { + if (!confirmed && rect.rectangle.confirmed) + { return rect.rectangle; } if (worked && !rect.rectangle.worked) rect.rectangle.worked = worked; if (confirmed && !rect.rectangle.confirmed) - rect.rectangle.confirmed = confirmed; + { rect.rectangle.confirmed = confirmed; } borderColor = g_qsoWorkedBorderColor; if (myDEbox) borderWeight = 1; zIndex = 2; - if (rect.rectangle.size == 6) { + if (rect.rectangle.size == 6) + { borderColor = "#000000FF"; zIndex = 50; } @@ -3558,14 +4076,14 @@ function qthToQsoBox( const featureHoverStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: boxColor, + color: boxColor }), stroke: new ol.style.Stroke({ color: borderColor, width: borderWeight, - lineJoin: "round", + lineJoin: "round" }), - zIndex: zIndex, + zIndex: zIndex }); rect.rectangle.setStyle(featureHoverStyle); returnRectangle = rect.rectangle; @@ -3573,7 +4091,8 @@ function qthToQsoBox( return returnRectangle; } -function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { +function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) +{ if (g_appSettings.gridViewMode == 2) return null; var borderColor = "#222288FF"; @@ -3582,54 +4101,69 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { var myDEzOffset = 0; var myDEbox = false; - if (iCQ && iNew) { + if (iCQ && iNew) + { borderColor = "#008888FF"; boxColor = "#00FF00" + g_gridAlpha; - } else if (iCQ && !iNew) { + } + else if (iCQ && !iNew) + { borderColor = "#FFFF00FF"; boxColor = "#FFFF00" + g_gridAlpha; } - if (DE == myDEcall) { + if (DE == myDEcall) + { borderColor = "#FF0000FF"; boxColor = "#FFFF00" + g_gridAlpha; borderWeight = 1.0; myDEzOffset = 20; myDEbox = true; } - if (DE.indexOf("CQ DX") > -1) { + if (DE.indexOf("CQ DX") > -1) + { borderColor = "#008888FF"; boxColor = "#00FFFF" + g_gridAlpha; } - if (locked) { + if (locked) + { boxColor = "#FFA500" + g_gridAlpha; borderColor = "#000000FF"; borderOpacity = 1; } - if (wspr != null) { + if (wspr != null) + { boxColor = "hsl(" + wspr + ",100%,50%)"; borderColor = "gray"; - //borderWeight = 1; + // borderWeight = 1; } var zIndex = 2; var returnRectangle = null; if (g_appSettings.sixWideMode == 0) iQTH = iQTH.substr(0, 4); else iQTH = iQTH.substr(0, 6); var rect = null; - if (iQTH == "") { - for (var key in g_liveGrids) { - if (hash in g_liveGrids[key].rectangle.liveHash) { + if (iQTH == "") + { + for (var key in g_liveGrids) + { + if (hash in g_liveGrids[key].rectangle.liveHash) + { rect = g_liveGrids[key]; break; } } - } else { - if (iQTH in g_liveGrids) { + } + else + { + if (iQTH in g_liveGrids) + { rect = g_liveGrids[iQTH]; } } - if (rect == null) { - if (iQTH != "") { + if (rect == null) + { + if (iQTH != "") + { // Valid QTH var entityVisibility = true; var triangleView = false; @@ -3637,20 +4171,24 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { Number(g_appSettings.gridViewMode) == 3 && iQTH in g_qsoGrids && g_pushPinMode == false - ) { + ) + { if ( g_mapSettings.splitQSL || g_qsoGrids[iQTH].rectangle.confirmed == false - ) { + ) + { qsoTriangleGrid(iQTH); triangleView = true; entityVisibility = true; - } else entityVisibility = false; + } + else entityVisibility = false; } LL = squareToLatLong(iQTH); - if (LL.size == 6) { + if (LL.size == 6) + { borderColor = "#000000FF"; - //borderWeight = 1.0; + // borderWeight = 1.0; zIndex = 50; } newRect = {}; @@ -3660,7 +4198,7 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; if (triangleView == true) newRect.rectangle = triangle(bounds, false); else newRect.rectangle = rectangle(bounds); @@ -3670,21 +4208,22 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { const featureHoverStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: boxColor, + color: boxColor }), stroke: new ol.style.Stroke({ color: borderColor, width: borderWeight, - lineJoin: "round", + lineJoin: "round" }), - zIndex: zIndex, + zIndex: zIndex }); newRect.rectangle.setStyle(featureHoverStyle); newRect.rectangle.qth = iQTH; - if (g_pushPinMode == false && entityVisibility) { - g_layerSources["live"].addFeature(newRect.rectangle); + if (g_pushPinMode == false && entityVisibility) + { + g_layerSources.live.addFeature(newRect.rectangle); } newRect.rectangle.pin = iconFeature( @@ -3698,7 +4237,7 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { newRect.rectangle.pin.size = LL.size; if (g_pushPinMode && entityVisibility == true) - g_layerSources["live-pins"].addFeature(newRect.rectangle.pin); + { g_layerSources["live-pins"].addFeature(newRect.rectangle.pin); } newRect.rectangle.locked = locked; newRect.rectangle.size = LL.size; @@ -3710,20 +4249,25 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { g_liveGrids[iQTH] = newRect; returnRectangle = newRect.rectangle; } - } else { - if (!(hash in rect.rectangle.liveHash)) { + } + else + { + if (!(hash in rect.rectangle.liveHash)) + { rect.rectangle.liveHash[hash] = 1; rect.rectangle.pin.liveHash[hash] = 1; } if (locked && !rect.rectangle.locked) rect.rectangle.locked = locked; - if (rect.rectangle.locked) { + if (rect.rectangle.locked) + { borderColor = "#000000FF"; } if (myDEbox) borderWeight = 1; - if (rect.rectangle.size == 6) { + if (rect.rectangle.size == 6) + { borderColor = "#000000FF"; - //borderWeight = 1.0; + // borderWeight = 1.0; zIndex = 50; } newRect.age = g_timeNow; @@ -3731,14 +4275,14 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { const featureHoverStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: boxColor, + color: boxColor }), stroke: new ol.style.Stroke({ color: borderColor, width: borderWeight, - lineJoin: "round", + lineJoin: "round" }), - zIndex: zIndex, + zIndex: zIndex }); rect.rectangle.setStyle(featureHoverStyle); @@ -3747,31 +4291,38 @@ function qthToBox(iQTH, iDEcallsign, iCQ, iNew, locked, DE, band, wspr, hash) { return returnRectangle; } -function alphaFrom(rgba) { +function alphaFrom(rgba) +{ var alphaInt = hexToA(rgba); var alphaFloat = alphaInt / 255.0; return alphaFloat; } -function alphaTo(rgba, alphaFloat) { +function alphaTo(rgba, alphaFloat) +{ var alphaInt = parseInt(alphaFloat * 255); var alphaHex = alphaInt.toString(16); - if (alphaHex.length == 1) { + if (alphaHex.length == 1) + { alphaHex = "0" + alphaHex; } return rgba.slice(0, -2) + alphaHex; } -function intAlphaToRGB(rgb, alphaInt) { +function intAlphaToRGB(rgb, alphaInt) +{ var alphaHex = alphaInt.toString(16); - if (alphaHex.length == 1) { + if (alphaHex.length == 1) + { alphaHex = "0" + alphaHex; } return rgb + alphaHex; } -function dimFunction(qthObj) { - if (qthObj.rectangle.locked == false) { +function dimFunction(qthObj) +{ + if (qthObj.rectangle.locked == false) + { var featureStyle = qthObj.rectangle.getStyle(); var featureFill = featureStyle.getFill(); var fillColor = featureFill.getColor(); @@ -3792,58 +4343,70 @@ function dimFunction(qthObj) { } } -function toggleTrafficDecode() { - trafficDecode.checked = trafficDecode.checked == true ? false : true; +function toggleTrafficDecode() +{ + trafficDecode.checked = trafficDecode.checked != true; changeTrafficDecode(); } -function changeTrafficDecode() { +function changeTrafficDecode() +{ g_mapSettings.trafficDecode = trafficDecode.checked; trafficDecodeView(); saveMapSettings(); } -function trafficDecodeView() { - if (g_mapSettings.trafficDecode == false) { +function trafficDecodeView() +{ + if (g_mapSettings.trafficDecode == false) + { trafficDiv.innerHTML = ""; g_lastTraffic = Array(); } } -function changeFitQRZvalue() { +function changeFitQRZvalue() +{ g_mapSettings.fitQRZ = fitQRZvalue.checked; saveMapSettings(); } -function changeQrzDxccFallbackValue() { +function changeQrzDxccFallbackValue() +{ g_mapSettings.qrzDxccFallback = qrzDxccFallbackValue.checked; saveMapSettings(); } -function changeCqHiliteValue(check) { +function changeCqHiliteValue(check) +{ g_mapSettings.CQhilite = check.checked; saveMapSettings(); if (check.checked == false) removePaths(); } -function changeFocusRigValue(check) { +function changeFocusRigValue(check) +{ g_mapSettings.focusRig = check.checked; saveMapSettings(); } -function changeHaltOntTxValue(check) { +function changeHaltOntTxValue(check) +{ g_mapSettings.haltAllOnTx = check.checked; saveMapSettings(); } -function changeStrikesAlert() { +function changeStrikesAlert() +{ g_mapSettings.strikesAlert = strikesAlert.value; saveMapSettings(); playStrikeAlert(); } -function playStrikeAlert() { - switch (g_mapSettings.strikesAlert) { +function playStrikeAlert() +{ + switch (g_mapSettings.strikesAlert) + { case 1: playAlertMediaFile("short-strike.wav", true); break; @@ -3859,68 +4422,88 @@ function playStrikeAlert() { } } -function setStrikesButton() { - if (g_mapSettings.strikes) { +function setStrikesButton() +{ + if (g_mapSettings.strikes) + { strikesImg.style.webkitFilter = ""; - } else { + } + else + { strikesImg.style.webkitFilter = "grayscale(1)"; } } -function toggleStrikesValue() { - if (g_mapSettings.strikesNotify == false && g_mapSettings.strikes == false) { +function toggleStrikesValue() +{ + if (g_mapSettings.strikesNotify == false && g_mapSettings.strikes == false) + { var confirmed = window.confirm( "Lighting Strike Detection is provided by Blitzortung.org\nWe are not responsible for missed strikes that could result in damage.\nBe sure to check your local weather providers for accurate data." ); - if (confirmed == false) { + if (confirmed == false) + { return; - } else { + } + else + { g_mapSettings.strikesNotify = true; } } - g_mapSettings.strikes = g_mapSettings.strikes == true ? false : true; + g_mapSettings.strikes = g_mapSettings.strikes != true; setStrikesButton(); saveMapSettings(); } -function changeSplitQSL() { +function changeSplitQSL() +{ g_mapSettings.splitQSL = splitQSLValue.checked; saveMapSettings(); redrawGrids(); } -function setAnimateView() { - if (animateValue.checked) { +function setAnimateView() +{ + if (animateValue.checked) + { animationSpeedTd.style.display = "inline-table"; - } else { + } + else + { animationSpeedTd.style.display = "none"; } } -function toggleAnimate() { - animateValue.checked = animateValue.checked == true ? false : true; +function toggleAnimate() +{ + animateValue.checked = animateValue.checked != true; changeAnimate(); } -function toggleAllGrids() { - g_showAllGrids = g_showAllGrids ? false : true; +function toggleAllGrids() +{ + g_showAllGrids = !g_showAllGrids; setTrophyOverlay(g_currentOverlay); } -function changeAnimate() { +function changeAnimate() +{ g_mapSettings.animate = animateValue.checked; saveMapSettings(); var dash = []; var dashOff = 0; - if (g_mapSettings.animate == true) { + if (g_mapSettings.animate == true) + { dash = g_flightPathLineDash; dashOff = g_flightPathTotal - g_flightPathOffset; } - for (var i = g_flightPaths.length - 1; i >= 0; i--) { - if (g_flightPaths[i].isShapeFlight == 0) { + for (var i = g_flightPaths.length - 1; i >= 0; i--) + { + if (g_flightPaths[i].isShapeFlight == 0) + { var featureStyle = g_flightPaths[i].getStyle(); var featureStroke = featureStyle.getStroke(); @@ -3931,7 +4514,8 @@ function changeAnimate() { g_flightPaths[i].setStyle(featureStyle); } } - if (g_transmitFlightPath != null) { + if (g_transmitFlightPath != null) + { var featureStyle = g_transmitFlightPath.getStyle(); var featureStroke = featureStyle.getStroke(); @@ -3944,7 +4528,8 @@ function changeAnimate() { setAnimateView(); } -function changeAnimateSpeedValue() { +function changeAnimateSpeedValue() +{ g_mapSettings.animateSpeed = 21 - animateSpeedValue.value; saveMapSettings(); } @@ -3953,7 +4538,8 @@ var g_animateFrame = 0; var g_nextDimTime = 0; var g_last = 0; -function animatePaths() { +function animatePaths() +{ requestAnimationFrame(animatePaths); g_last ^= g_last; @@ -3964,11 +4550,13 @@ function animatePaths() { if (g_animateFrame > 0) return; - for (var i = g_flightPaths.length - 1; i >= 0; i--) { - if (g_flightPaths[i].age < g_timeNow) { + for (var i = g_flightPaths.length - 1; i >= 0; i--) + { + if (g_flightPaths[i].age < g_timeNow) + { if (typeof g_flightPaths[i].Arrow != "undefined") - g_layerSources["flight"].removeFeature(g_flightPaths[i].Arrow); - g_layerSources["flight"].removeFeature(g_flightPaths[i]); + { g_layerSources.flight.removeFeature(g_flightPaths[i].Arrow); } + g_layerSources.flight.removeFeature(g_flightPaths[i]); delete g_flightPaths[i]; g_flightPaths[i] = null; @@ -3976,7 +4564,8 @@ function animatePaths() { } } - if (g_timeNow > g_nextDimTime) { + if (g_timeNow > g_nextDimTime) + { dimGridsquare(); } @@ -3988,8 +4577,10 @@ function animatePaths() { var targetOffset = g_flightPathTotal - g_flightPathOffset; var featureStyle = null; var featureStroke = null; - for (var i = 0; i < g_flightPaths.length; i++) { - if (g_flightPaths[i].isShapeFlight == 0) { + for (var i = 0; i < g_flightPaths.length; i++) + { + if (g_flightPaths[i].isShapeFlight == 0) + { featureStyle = g_flightPaths[i].getStyle(); featureStroke = featureStyle.getStroke(); featureStroke.setLineDashOffset(targetOffset); @@ -3997,7 +4588,8 @@ function animatePaths() { } } - if (g_transmitFlightPath != null) { + if (g_transmitFlightPath != null) + { var featureStyle = g_transmitFlightPath.getStyle(); var featureStroke = featureStyle.getStroke(); @@ -4008,48 +4600,61 @@ function animatePaths() { } } -function removePaths() { - g_layerSources["flight"].clear(); +function removePaths() +{ + g_layerSources.flight.clear(); g_flightPaths = Array(); } -function fadePaths() { - if (pathWidthValue.value == 0) { +function fadePaths() +{ + if (pathWidthValue.value == 0) + { removePaths(); - return; } } -function dimGridsquare() { +function dimGridsquare() +{ if (gridDecay.value == 0) return; - for (var i in g_liveGrids) { + for (var i in g_liveGrids) + { dimFunction(g_liveGrids[i]); if ( g_timeNow - g_liveGrids[i].age >= gridDecay.value && g_liveGrids[i].rectangle.locked == false - ) { + ) + { // Walk the rectangles DEcall's and remove them from g_liveCallsigns - for (var CallIsKey in g_liveGrids[i].rectangle.liveHash) { - if (CallIsKey in g_liveCallsigns) { + for (var CallIsKey in g_liveGrids[i].rectangle.liveHash) + { + if (CallIsKey in g_liveCallsigns) + { g_liveCallsigns[CallIsKey].rect = null; delete g_liveCallsigns[CallIsKey]; } } - if (g_liveGrids[i].rectangle.pin != null) { + if (g_liveGrids[i].rectangle.pin != null) + { if ( g_layerSources["live-pins"].hasFeature(g_liveGrids[i].rectangle.pin) ) + { g_layerSources["live-pins"].removeFeature( g_liveGrids[i].rectangle.pin ); + } } - if (g_layerSources["live"].hasFeature(g_liveGrids[i].rectangle)) { - g_layerSources["live"].removeFeature(g_liveGrids[i].rectangle); + if (g_layerSources.live.hasFeature(g_liveGrids[i].rectangle)) + { + g_layerSources.live.removeFeature(g_liveGrids[i].rectangle); - if (Number(g_appSettings.gridViewMode) == 3 && i in g_qsoGrids) { - if (g_qsoGrids[i].isTriangle) { + if (Number(g_appSettings.gridViewMode) == 3 && i in g_qsoGrids) + { + if (g_qsoGrids[i].isTriangle) + { triangleToGrid(i, g_qsoGrids[i].rectangle); g_qsoGrids[i].isTriangle = false; } @@ -4063,7 +4668,8 @@ function dimGridsquare() { g_nextDimTime = g_timeNow + 7; } -function updateCountStats() { +function updateCountStats() +{ var count = Object.keys(g_liveCallsigns).length; if (myDEcall in g_liveCallsigns) count--; @@ -4075,22 +4681,28 @@ function updateCountStats() { countryCount.innerHTML = Object.keys(g_dxccCount).length; - if (Object.keys(g_QSOhash).length > 0) { + if (Object.keys(g_QSOhash).length > 0) + { clearOrLoadButton.innerHTML = "Clear Log"; g_loadQSOs = false; - } else { + } + else + { clearOrLoadButton.innerHTML = "Load Logs"; g_loadQSOs = true; } } -function clearGrids() { - g_layerSources["live"].clear(); +function clearGrids() +{ + g_layerSources.live.clear(); g_layerSources["live-pins"].clear(); - for (var i in g_liveGrids) { + for (var i in g_liveGrids) + { // Walk the rectangles DEcall's and remove the rect from the g_liveCallsigns - for (var CallIsKey in g_liveGrids[i].rectangle.liveHash) { + for (var CallIsKey in g_liveGrids[i].rectangle.liveHash) + { if (CallIsKey in g_liveCallsigns) g_liveCallsigns[CallIsKey].rect = null; } } @@ -4098,13 +4710,15 @@ function clearGrids() { g_liveGrids = {}; } -function clearQsoGrids() { - g_layerSources["qso"].clear(); +function clearQsoGrids() +{ + g_layerSources.qso.clear(); g_layerSources["qso-pins"].clear(); g_qsoGrids = {}; - for (var key in g_worldGeoData) { + for (var key in g_worldGeoData) + { g_worldGeoData[key].worked = false; g_worldGeoData[key].confirmed = false; g_worldGeoData[key].worked_bands = {}; @@ -4112,7 +4726,8 @@ function clearQsoGrids() { g_worldGeoData[key].worked_modes = {}; g_worldGeoData[key].confirmed_modes = {}; } - for (var key in g_cqZones) { + for (var key in g_cqZones) + { g_cqZones[key].worked = false; g_cqZones[key].confirmed = false; @@ -4121,7 +4736,8 @@ function clearQsoGrids() { g_cqZones[key].worked_modes = {}; g_cqZones[key].confirmed_modes = {}; } - for (var key in g_ituZones) { + for (var key in g_ituZones) + { g_ituZones[key].worked = false; g_ituZones[key].confirmed = false; @@ -4130,7 +4746,8 @@ function clearQsoGrids() { g_ituZones[key].worked_modes = {}; g_ituZones[key].confirmed_modes = {}; } - for (var key in g_wasZones) { + for (var key in g_wasZones) + { g_wasZones[key].worked = false; g_wasZones[key].confirmed = false; @@ -4139,7 +4756,8 @@ function clearQsoGrids() { g_wasZones[key].worked_modes = {}; g_wasZones[key].confirmed_modes = {}; } - for (var key in g_wacZones) { + for (var key in g_wacZones) + { g_wacZones[key].worked = false; g_wacZones[key].confirmed = false; g_wacZones[key].worked_bands = {}; @@ -4147,7 +4765,8 @@ function clearQsoGrids() { g_wacZones[key].worked_modes = {}; g_wacZones[key].confirmed_modes = {}; } - for (var key in g_countyData) { + for (var key in g_countyData) + { g_countyData[key].worked = false; g_countyData[key].confirmed = false; g_countyData[key].worked_bands = {}; @@ -4155,7 +4774,8 @@ function clearQsoGrids() { g_countyData[key].worked_modes = {}; g_countyData[key].confirmed_modes = {}; } - for (var key in g_us48Data) { + for (var key in g_us48Data) + { g_us48Data[key].worked = false; g_us48Data[key].confirmed = false; g_us48Data[key].worked_bands = {}; @@ -4165,15 +4785,18 @@ function clearQsoGrids() { } } -function clearCalls() { +function clearCalls() +{ removePaths(); - for (var i in g_liveCallsigns) { + for (var i in g_liveCallsigns) + { if ( typeof g_liveCallsigns[i].rect != "undefined" && g_liveCallsigns[i].rect != null - ) { + ) + { if (i in g_liveCallsigns[i].rect.liveHash) - delete g_liveCallsigns[i].rect.liveHash[i]; + { delete g_liveCallsigns[i].rect.liveHash[i]; } } } @@ -4182,7 +4805,8 @@ function clearCalls() { redrawGrids(); } -function clearLive() { +function clearLive() +{ g_Decodes = 0; g_lastMessages = Array(); @@ -4202,7 +4826,8 @@ function clearLive() { goProcessRoster(); } -function clearAll() { +function clearAll() +{ clearTempGrids(); clearCalls(); clearQSOs(); @@ -4219,15 +4844,20 @@ function clearAll() { goProcessRoster(); } -function clearOrLoadQSOs() { - if (g_loadQSOs == true) { +function clearOrLoadQSOs() +{ + if (g_loadQSOs == true) + { startupAdifLoadCheck(); - } else { + } + else + { clearQSOs(); } } -function clearAndLoadQSOs() { +function clearAndLoadQSOs() +{ initQSOdata(); g_QSOhash = {}; g_QSLcount = 0; @@ -4242,7 +4872,8 @@ function clearAndLoadQSOs() { startupAdifLoadCheck(); } -function clearQSOs() { +function clearQSOs() +{ initQSOdata(); g_QSOhash = {}; g_QSLcount = 0; @@ -4256,7 +4887,8 @@ function clearQSOs() { clearLogFilesAndCounts(); } -function clearLogFilesAndCounts() { +function clearLogFilesAndCounts() +{ tryToDeleteLog("lotw_QSL.adif"); tryToDeleteLog("lotw_QSO.adif"); tryToDeleteLog("lotw.adif"); @@ -4266,19 +4898,20 @@ function clearLogFilesAndCounts() { localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); } -function getCurrentBandModeHTML() { +function getCurrentBandModeHTML() +{ var band = g_appSettings.gtBandFilter == "auto" ? myBand + " (Auto)" : g_appSettings.gtBandFilter.length == 0 - ? "Mixed Bands" - : g_appSettings.gtBandFilter; + ? "Mixed Bands" + : g_appSettings.gtBandFilter; var mode = g_appSettings.gtModeFilter == "auto" ? myMode + " (Auto)" : g_appSettings.gtModeFilter.length == 0 - ? "Mixed Modes" - : g_appSettings.gtModeFilter; + ? "Mixed Modes" + : g_appSettings.gtModeFilter; return ( "
Viewing: " + band + @@ -4297,9 +4930,11 @@ var g_currentNightState = false; var g_timeNow = timeNowSec(); -function displayTime() { +function displayTime() +{ g_timeNow = timeNowSec(); - if (menuDiv.className == "menuDivStart" && g_menuShowing == true) { + if (menuDiv.className == "menuDivStart" && g_menuShowing == true) + { menuDiv.className = "menuDivEnd"; mapDiv.className = "mapDivEnd"; LegendDiv.className = "legendDivEnd"; @@ -4308,59 +4943,78 @@ function displayTime() { currentTime.innerHTML = "" + userTimeString(null) + ""; - if (g_lastTimeSinceMessageInSeconds > 0) { + if (g_lastTimeSinceMessageInSeconds > 0) + { var since = g_timeNow - g_lastTimeSinceMessageInSeconds; secondsAgoMsg.innerHTML = since.toDHMS(); - if (since > 17 && since < 122) { + if (since > 17 && since < 122) + { secondsAgoMsg.style.backgroundColor = "yellow"; secondsAgoMsg.style.color = "#000"; - } else if (since > 121) { + } + else if (since > 121) + { secondsAgoMsg.style.backgroundColor = "red"; secondsAgoMsg.style.color = "#000"; - } else { + } + else + { secondsAgoMsg.style.backgroundColor = "blue"; secondsAgoMsg.style.color = "#FF0"; } - } else secondsAgoMsg.innerHTML = "Never"; + } + else secondsAgoMsg.innerHTML = "Never"; checkWsjtxListener(); - if (g_timeNow % 22 == 0) { + if (g_timeNow % 22 == 0) + { g_nightTime = dayNight.refresh(); moonLayer.refresh(); } pskSpotCheck(g_timeNow); - if (g_mapSettings.strikes && g_mapSettings.offlineMode == false) { + if (g_mapSettings.strikes && g_mapSettings.offlineMode == false) + { if (g_strikeWebSocket == null) loadStrikes(); var now = Date.now(); - for (var time in g_bolts) { - if (now - time > 120000) { - if (g_layerSources["strikes"].hasFeature(g_bolts[time])) - g_layerSources["strikes"].removeFeature(g_bolts[time]); + for (var time in g_bolts) + { + if (now - time > 120000) + { + if (g_layerSources.strikes.hasFeature(g_bolts[time])) + { g_layerSources.strikes.removeFeature(g_bolts[time]); } delete g_bolts[time]; } } - } else { - g_layerSources["strikes"].clear(); - if (g_strikeWebSocket != null) { - try { + } + else + { + g_layerSources.strikes.clear(); + if (g_strikeWebSocket != null) + { + try + { g_strikeWebSocket.close(); - } catch (e) { + } + catch (e) + { g_strikeWebSocket = null; } } } - if (g_currentNightState != g_nightTime) { + if (g_currentNightState != g_nightTime) + { changeMapLayer(); g_currentNightState = g_nightTime; } } -function timeNowSec() { +function timeNowSec() +{ return parseInt(Date.now() / 1000); } @@ -4371,66 +5025,74 @@ var g_liveHoverInteraction = null; var g_gtFlagHoverInteraction = null; var g_trophyHoverInteraction = null; -function createGlobalHeatmapLayer(name, radius, blur) { +function createGlobalHeatmapLayer(name, radius, blur) +{ g_layerSources[name] = new ol.source.Vector({}); g_layerVectors[name] = new ol.layer.Heatmap({ source: g_layerSources[name], - zIndex: Object.keys(g_layerVectors).length + 1, + zIndex: Object.keys(g_layerVectors).length + 1 }); g_layerVectors[name].set("name", name); } -function createGlobalMapLayer(name, maxResolution, minResolution) { +function createGlobalMapLayer(name, maxResolution, minResolution) +{ g_layerSources[name] = new ol.source.Vector({}); if ( typeof maxResolution == "undefined" && typeof minResolution == "undefined" - ) { + ) + { var zIndex = Object.keys(g_layerVectors).length + 1; if (name == "strikes") zIndex = 2000; g_layerVectors[name] = new ol.layer.Vector({ source: g_layerSources[name], - zIndex: zIndex, + zIndex: zIndex }); - } else if (typeof minResolution == "undefined") { + } + else if (typeof minResolution == "undefined") + { g_layerVectors[name] = new ol.layer.Vector({ source: g_layerSources[name], maxResolution: maxResolution, - zIndex: Object.keys(g_layerVectors).length + 1, + zIndex: Object.keys(g_layerVectors).length + 1 }); - } else { + } + else + { g_layerVectors[name] = new ol.layer.Vector({ source: g_layerSources[name], maxResolution: maxResolution, minResolution: minResolution, - zIndex: Object.keys(g_layerVectors).length + 1, + zIndex: Object.keys(g_layerVectors).length + 1 }); } g_layerVectors[name].set("name", name); } -function createGeoJsonLayer(name, url, color, stroke) { +function createGeoJsonLayer(name, url, color, stroke) +{ var style = new ol.style.Style({ stroke: new ol.style.Stroke({ color: color, - width: stroke, + width: stroke }), fill: new ol.style.Fill({ - color: "#00000000", - }), + color: "#00000000" + }) }); var layerSource = new ol.source.Vector({ url: url, format: new ol.format.GeoJSON({ geometryName: name }), - overlaps: false, + overlaps: false }); var layerVector = new ol.layer.Vector({ source: layerSource, style: style, visible: true, - zIndex: 1, + zIndex: 1 }); layerVector.set("name", name); return layerVector; @@ -4440,22 +5102,23 @@ var g_gtFlagIcon = new ol.style.Icon({ src: "./img/flag_gt_user.png", anchorYUnits: "pixels", anchorXUnits: "pixels", - anchor: [12, 17], + anchor: [12, 17] }); var g_pushPinIconOff = new ol.style.Icon({ src: "./img/red-circle.png", anchorYUnits: "pixels", anchorXUnits: "pixels", - anchor: [5, 18], + anchor: [5, 18] }); -function panTo(location) { +function panTo(location) +{ var duration = 1000; g_mapView.animate({ center: location, - duration: duration, + duration: duration }); } @@ -4465,7 +5128,7 @@ var g_lightningBolt = new ol.style.Icon({ anchorXUnits: "pixels", size: [64, 64], anchor: [9, 58], - scale: 0.75, + scale: 0.75 }); var g_lightningGlobal = Array(); @@ -4475,7 +5138,7 @@ g_lightningGlobal[0] = new ol.style.Icon({ anchorYUnits: "pixels", anchorXUnits: "pixels", opacity: 0.2, - anchor: [2, 31], + anchor: [2, 31] }); g_lightningGlobal[1] = new ol.style.Icon({ @@ -4483,7 +5146,7 @@ g_lightningGlobal[1] = new ol.style.Icon({ anchorYUnits: "pixels", anchorXUnits: "pixels", opacity: 0.2, - anchor: [1, 34], + anchor: [1, 34] }); var g_bolts = {}; @@ -4491,9 +5154,10 @@ var g_strikeWebSocket = null; var g_strikeInterval = null; var g_strikeRange = 0.4; -function toggleStrikeGlobal() { +function toggleStrikeGlobal() +{ g_mapSettings.strikesGlobal = - g_mapSettings.strikesGlobal == false ? true : false; + g_mapSettings.strikesGlobal == false; saveMapSettings(); var msg = "Local Strikes"; @@ -4502,38 +5166,47 @@ function toggleStrikeGlobal() { var worker = "Strike Distance Changed
" + msg + "
"; if (g_mapSettings.strikes == false) - worker += "
Detection is not enabled!"; + { worker += "
Detection is not enabled!"; } addLastTraffic(worker); - g_layerSources["strikes"].clear(); + g_layerSources.strikes.clear(); } -function setStrikeDistance() { +function setStrikeDistance() +{ if ( g_mapSettings.offlineMode == true && g_strikeWebSocket != null && g_strikeWebSocket.readyState != 3 - ) { + ) + { g_strikeWebSocket.close(); return; } - if (g_strikeWebSocket != null) { + if (g_strikeWebSocket != null) + { var distance = g_strikeRange; if (g_mapSettings.strikesGlobal == true) distance = 1000; - var send = '{"west":-180,"east":180,"north":-90,"south":-90}'; + var send = "{\"west\":-180,\"east\":180,\"north\":-90,\"south\":-90}"; if (g_strikeInterval == null) - g_strikeInterval = setInterval(setStrikeDistance, 300000); + { g_strikeInterval = setInterval(setStrikeDistance, 300000); } - try { + try + { g_strikeWebSocket.send(send); - } catch (e) { + } + catch (e) + { g_strikeWebSocket = null; } - } else { - if (g_strikeInterval != null) { + } + else + { + if (g_strikeInterval != null) + { clearInterval(g_strikeInterval); g_strikeInterval = null; } @@ -4541,33 +5214,46 @@ function setStrikeDistance() { } var g_strikeCount = 0; -function loadStrikes() { +function loadStrikes() +{ if (g_strikeWebSocket) return; var rnd = parseInt(Math.random() * 4); var ws_server = ""; - if (rnd < 1) { + if (rnd < 1) + { ws_server = "ws7.blitzortung.org"; - } else if (rnd < 2) { + } + else if (rnd < 2) + { ws_server = "ws6.blitzortung.org"; - } else if (rnd < 3) { + } + else if (rnd < 3) + { ws_server = "ws5.blitzortung.org"; - } else { + } + else + { ws_server = "ws1.blitzortung.org"; } - try { + try + { g_strikeWebSocket = new WebSocket("wss:///" + ws_server + ":3000"); - } catch (e) { + } + catch (e) + { g_strikeWebSocket = null; return; } - g_strikeWebSocket.onopen = function () { + g_strikeWebSocket.onopen = function () + { setStrikeDistance(); }; - g_strikeWebSocket.onmessage = function (evt) { + g_strikeWebSocket.onmessage = function (evt) + { var Strikes = JSON.parse(evt.data); Strikes.sig = null; @@ -4576,7 +5262,8 @@ function loadStrikes() { "time" in Strikes && "lat" in Strikes && "lon" in Strikes - ) { + ) + { var index = Date.now(); while (index in g_bolts) index++; @@ -4589,17 +5276,19 @@ function loadStrikes() { 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]); + g_layerSources.strikes.addFeature(g_bolts[index]); } - if (inRange == true) { + if (inRange == true) + { playStrikeAlert(); var dist = @@ -4638,35 +5327,42 @@ function loadStrikes() { delete evt.data; }; - g_strikeWebSocket.onerror = function () { + g_strikeWebSocket.onerror = function () + { g_strikeWebSocket = null; }; - g_strikeWebSocket.onclose = function () { + g_strikeWebSocket.onclose = function () + { g_strikeWebSocket = null; }; } -function toggleMouseTrack() { +function toggleMouseTrack() +{ g_appSettings.mouseTrack ^= 1; if (g_appSettings.mouseTrack == 0) mouseTrackDiv.style.display = "none"; } -function myGmapNameCompare(a, b) { +function myGmapNameCompare(a, b) +{ return g_maps[a].name.localeCompare(g_maps[b].name); } var g_Nexrad = null; -function initMap() { +function initMap() +{ document.getElementById("mapDiv").innerHTML = ""; g_maps = JSON.parse(fs.readFileSync(g_mapsFile)); - if (g_maps) { + if (g_maps) + { var entries = Object.keys(g_maps).sort(myGmapNameCompare); - for (var lmap in entries) { + for (var lmap in entries) + { var key = entries[lmap]; g_mapsLayer[key] = new ol.source.XYZ(g_maps[key]); var option = document.createElement("option"); @@ -4681,33 +5377,38 @@ function initMap() { } mapSelect.value = g_mapSettings.mapIndex; mapNightSelect.value = g_mapSettings.nightMapIndex; - } else g_mapsLayer[0] = new ol.source.OSM(); + } + else g_mapsLayer[0] = new ol.source.OSM(); g_offlineLayer = new ol.source.XYZ({ - url: "/map/sat/{z}/{x}/{y}.png", + url: "/map/sat/{z}/{x}/{y}.png" }); if (g_mapSettings.offlineMode) + { g_tileLayer = new ol.layer.Tile({ source: g_offlineLayer, loadTilesWhileInteracting: true, - loadTilesWhileAnimating: true, + loadTilesWhileAnimating: true }); + } else + { g_tileLayer = new ol.layer.Tile({ source: g_mapsLayer[mapSelect.value], loadTilesWhileInteracting: true, - loadTilesWhileAnimating: true, + loadTilesWhileAnimating: true }); + } g_scaleLine = new ol.control.ScaleLine({ - units: g_scaleUnits[g_appSettings.distanceUnit], + units: g_scaleUnits[g_appSettings.distanceUnit] }); var g_mapControl = [ g_scaleLine, new ol.control.Zoom(), - new ol.control.FullScreen({ source: "mainBody" }), + new ol.control.FullScreen({ source: "mainBody" }) ]; createGlobalMapLayer("award"); @@ -4735,7 +5436,7 @@ function initMap() { center: [g_myLon, g_myLat], zoomFactor: 1.25, zoom: g_mapSettings.zoom, - showFullExtent: true, + showFullExtent: true }); g_map = new ol.Map({ @@ -4743,11 +5444,11 @@ function initMap() { layers: [ g_tileLayer, - g_layerVectors["award"], + g_layerVectors.award, g_layerVectors["psk-heat"], - g_layerVectors["qso"], + g_layerVectors.qso, g_layerVectors["qso-pins"], - g_layerVectors["live"], + g_layerVectors.live, g_layerVectors["live-pins"], g_layerVectors["line-grids"], g_layerVectors["long-grids"], @@ -4756,27 +5457,30 @@ function initMap() { g_layerVectors["psk-flights"], g_layerVectors["psk-spots"], g_layerVectors["psk-hop"], - g_layerVectors["flight"], - g_layerVectors["transmit"], - g_layerVectors["gtflags"], - g_layerVectors["temp"], - g_layerVectors["tz"], - g_layerVectors["radar"], - g_layerVectors["strikes"], + g_layerVectors.flight, + g_layerVectors.transmit, + g_layerVectors.gtflags, + g_layerVectors.temp, + g_layerVectors.tz, + g_layerVectors.radar, + g_layerVectors.strikes ], controls: g_mapControl, loadTilesWhileInteracting: false, loadTilesWhileAnimating: false, - view: g_mapView, + view: g_mapView }); - mapDiv.addEventListener("mousemove", function (event) { + mapDiv.addEventListener("mousemove", function (event) + { onMouseUpdate(event); var mousePosition = g_map.getEventPixel(event); - if (g_appSettings.mouseTrack == 1) { + if (g_appSettings.mouseTrack == 1) + { var mouseLngLat = g_map.getEventCoordinate(event); - if (mouseLngLat) { + if (mouseLngLat) + { var LL = ol.proj.toLonLat(mouseLngLat); var dist = parseInt( @@ -4810,50 +5514,61 @@ function initMap() { var noMoon = true; var noTimeZone = true; - if (g_map.hasFeatureAtPixel(mousePosition)) { + if (g_map.hasFeatureAtPixel(mousePosition)) + { var features = g_map.getFeaturesAtPixel(mousePosition); - if (features != null) { + if (features != null) + { features = features.reverse(); var finalGridFeature = null; - for (var index in features) { - if (features[index].geometryName_ == "tz") { + for (var index in features) + { + if (features[index].geometryName_ == "tz") + { features[index].size = 73; } if (typeof features[index].size == "undefined") continue; - if (features[index].size == 99 && finalGridFeature == null) { + if (features[index].size == 99 && finalGridFeature == null) + { moonOver(features[index]); noMoon = false; break; } - if (features[index].size == 2 && g_currentOverlay != 0) { + if (features[index].size == 2 && g_currentOverlay != 0) + { trophyOver(features[index]); noAward = false; break; } - if (features[index].size == 1) { + if (features[index].size == 1) + { mouseOverGtFlag(features[index]); noFlag = false; noFeature = true; break; } - if (features[index].size == 6) { + if (features[index].size == 6) + { noFeature = false; finalGridFeature = features[index]; } - if (features[index].size == 4 && finalGridFeature == null) { + if (features[index].size == 4 && finalGridFeature == null) + { noFeature = false; finalGridFeature = features[index]; noFlag = true; } - if (features[index].size == 73 && finalGridFeature == null) { + if (features[index].size == 73 && finalGridFeature == null) + { mouseOverGtFlag(features[index]); noFlag = false; } } - if (finalGridFeature) { + if (finalGridFeature) + { mouseOverDataItem(finalGridFeature, true); } } @@ -4864,48 +5579,58 @@ function initMap() { if (noMoon) moonOut(); }); - //mapDiv.addEventListener('mouseout', mapLoseFocus, false); + // mapDiv.addEventListener('mouseout', mapLoseFocus, false); mapDiv.addEventListener("mouseleave", mapLoseFocus, false); - mapDiv.addEventListener("contextmenu", function (event) { + mapDiv.addEventListener("contextmenu", function (event) + { event.preventDefault(); }); - g_map.on("pointerdown", function (event) { + g_map.on("pointerdown", function (event) + { var shouldReturn = false; var features = g_map.getFeaturesAtPixel(event.pixel); - if (features != null) { + if (features != null) + { features = features.reverse(); var finalGridFeature = null; - for (var index in features) { + for (var index in features) + { if (typeof features[index].size == "undefined") continue; - if (features[index].size == 6) { + if (features[index].size == 6) + { noFeature = false; finalGridFeature = features[index]; } - if (features[index].size == 4 && finalGridFeature == null) { + if (features[index].size == 4 && finalGridFeature == null) + { noFeature = false; finalGridFeature = features[index]; } - if (features[index].size == 1) { + if (features[index].size == 1) + { leftClickGtFlag(features[index]); shouldReturn = true; } } - if (finalGridFeature) { + if (finalGridFeature) + { onRightClickGridSquare(finalGridFeature); shouldReturn = true; } } if (shouldReturn) return true; - if (event.pointerEvent.buttons == 2 && g_currentOverlay == 0) { + if (event.pointerEvent.buttons == 2 && g_currentOverlay == 0) + { mouseDownGrid(ol.proj.toLonLat(event.coordinate), event); return true; } }); - g_map.on("pointerup", function (event) { + g_map.on("pointerup", function (event) + { mouseUpGrid(); if (g_mapSettings.mouseOver == false) mouseOutOfDataItem(); }); @@ -4913,16 +5638,22 @@ function initMap() { document.getElementById("menuDiv").style.display = "block"; dayNight.init(g_map); - if (g_appSettings.earthImgSrc == 1) { + if (g_appSettings.earthImgSrc == 1) + { dayNight.hide(); - } else { + } + else + { g_nightTime = dayNight.show(); } moonLayer.init(g_map); - if (g_appSettings.moonTrack == 1) { + if (g_appSettings.moonTrack == 1) + { moonLayer.show(); - } else { + } + else + { moonLayer.hide(); } @@ -4934,13 +5665,17 @@ function initMap() { changeNightMapEnable(nightMapEnable); } -function changeNightMapEnable(check) { - if (check.checked) { +function changeNightMapEnable(check) +{ + if (check.checked) + { nightMapTd.style.display = "inline-table"; spotNightPathColorDiv.style.display = "inline-block"; g_mapSettings.nightMapEnable = true; g_nightTime = dayNight.refresh(); - } else { + } + else + { nightMapTd.style.display = "none"; spotNightPathColorDiv.style.display = "none"; g_mapSettings.nightMapEnable = false; @@ -4956,16 +5691,17 @@ var g_nexradInterval = null; var g_nexradEnable = 0; -function createNexRad() { +function createNexRad() +{ var layerSource = new ol.source.TileWMS({ url: "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0q.cgi", - params: { LAYERS: "nexrad-n0q" }, + params: { LAYERS: "nexrad-n0q" } }); var layerVector = new ol.layer.Tile({ source: layerSource, visible: true, - zIndex: 900, + zIndex: 900 }); layerVector.set("name", "radar"); @@ -4973,10 +5709,13 @@ function createNexRad() { return layerVector; } -function toggleNexrad() { +function toggleNexrad() +{ g_nexradEnable ^= 1; - if (g_nexradEnable == 1) { - if (g_Nexrad != null) { + if (g_nexradEnable == 1) + { + if (g_Nexrad != null) + { g_map.removeLayer(g_Nexrad); } @@ -4984,35 +5723,45 @@ function toggleNexrad() { g_map.addLayer(g_Nexrad); if (g_nexradInterval == null) - g_nexradInterval = setInterval(nexradRefresh, 600000); - } else { - if (g_nexradInterval != null) { + { g_nexradInterval = setInterval(nexradRefresh, 600000); } + } + else + { + if (g_nexradInterval != null) + { clearInterval(g_nexradInterval); g_nexradInterval = null; } - if (g_Nexrad) { + if (g_Nexrad) + { g_map.removeLayer(g_Nexrad); g_Nexrad = null; } } - g_mapSettings.usNexrad = g_nexradEnable == 1 ? true : false; + g_mapSettings.usNexrad = g_nexradEnable == 1; } -function nexradRefresh() { - if (g_Nexrad != null) { +function nexradRefresh() +{ + if (g_Nexrad != null) + { g_Nexrad.getSource().refresh(); } } -function collapseMenu(shouldCollapse) { - if (shouldCollapse == true) { +function collapseMenu(shouldCollapse) +{ + if (shouldCollapse == true) + { g_menuShowing = false; mapDiv.className = "mapDivStart"; menuDiv.className = "menuDivStart"; LegendDiv.className = "legendDivStart"; chevronDiv.className = "chevronDivEnd"; - } else { + } + else + { g_menuShowing = true; chevronDiv.className = "chevronDivStart"; displayTime(); @@ -5020,7 +5769,8 @@ function collapseMenu(shouldCollapse) { g_map.updateSize(); } -function mapLoseFocus() { +function mapLoseFocus() +{ mouseOutOfDataItem(); trophyOut(); mouseUpGrid(); @@ -5028,65 +5778,72 @@ function mapLoseFocus() { mouseOutGtFlag(); } -function lineString(points) { +function lineString(points) +{ var thing = new ol.geom.LineString(points); var rect = new ol.Feature({ - geometry: thing, + geometry: thing }); return rect; } -function rectangle(bounds, options) { +function rectangle(bounds, options) +{ var thing = new ol.geom.Polygon([ [ ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), ol.proj.fromLonLat([bounds[0][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), - ol.proj.fromLonLat([bounds[1][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[1][0], bounds[0][1]]) + ] ]); var rect = new ol.Feature({ name: "rect", - geometry: thing, + geometry: thing }); return rect; } -function triangle(bounds, topLeft) { +function triangle(bounds, topLeft) +{ var thing = null; - if (topLeft) { + if (topLeft) + { thing = new ol.geom.Polygon([ [ ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), ol.proj.fromLonLat([bounds[0][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), - ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]) + ] ]); - } else { + } + else + { thing = new ol.geom.Polygon([ [ ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[0][1]]), - ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]) + ] ]); } var rect = new ol.Feature({ name: "rect", - geometry: thing, + geometry: thing }); return rect; } -function triangleToGrid(iQTH, feature) { +function triangleToGrid(iQTH, feature) +{ var LL = squareToLatLong(iQTH); var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; var thing = new ol.geom.Polygon([ @@ -5095,51 +5852,58 @@ function triangleToGrid(iQTH, feature) { ol.proj.fromLonLat([bounds[0][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[0][1]]), - ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]) + ] ]); feature.setGeometry(thing); } -function gridToTriangle(iQTH, feature, topLeft) { +function gridToTriangle(iQTH, feature, topLeft) +{ var LL = squareToLatLong(iQTH); var bounds = [ [LL.lo1, LL.la1], - [LL.lo2, LL.la2], + [LL.lo2, LL.la2] ]; var thing = null; - if (topLeft) { + if (topLeft) + { thing = new ol.geom.Polygon([ [ ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), ol.proj.fromLonLat([bounds[0][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), - ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]) + ] ]); - } else { + } + else + { thing = new ol.geom.Polygon([ [ ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[1][1]]), ol.proj.fromLonLat([bounds[1][0], bounds[0][1]]), - ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]), - ], + ol.proj.fromLonLat([bounds[0][0], bounds[0][1]]) + ] ]); } feature.setGeometry(thing); } -function liveHash(call, band, mode) { +function liveHash(call, band, mode) +{ return call + band + mode; } -function setHomeGridsquare() { +function setHomeGridsquare() +{ g_appSettings.centerGridsquare = myDEGrid; - if (g_appSettings.centerGridsquare.length > 0) { + if (g_appSettings.centerGridsquare.length > 0) + { homeQTHInput.value = g_appSettings.centerGridsquare; } var hash = myDEcall; @@ -5155,13 +5919,16 @@ function setHomeGridsquare() { null, hash ); - if (typeof rect != "undefined" && rect != null) { + if (typeof rect != "undefined" && rect != null) + { var push = false; - if (!(hash in g_liveCallsigns)) { + if (!(hash in g_liveCallsigns)) + { newCallsign = {}; push = true; - } else newCallsign = g_liveCallsigns[hash]; + } + else newCallsign = g_liveCallsigns[hash]; newCallsign.DEcall = myDEcall; newCallsign.grid = myDEGrid; newCallsign.wspr = null; @@ -5192,9 +5959,12 @@ function setHomeGridsquare() { var g_transmitFlightPath = null; -function haltAllTx(allTx = false) { - for (var instance in g_instances) { - if (instance != g_activeInstance || allTx == true) { +function haltAllTx(allTx = false) +{ + for (var instance in g_instances) + { + if (instance != g_activeInstance || allTx == true) + { var responseArray = Buffer.alloc(1024); var length = 0; @@ -5213,18 +5983,22 @@ function haltAllTx(allTx = false) { } } -function initiateQso(thisCall) { +function initiateQso(thisCall) +{ if ( thisCall in g_callRoster && g_callRoster[thisCall].message.instance in g_instances - ) { + ) + { if ( g_mapSettings.focusRig && g_activeInstance != g_callRoster[thisCall].message.instance - ) { + ) + { activeRig(g_callRoster[thisCall].message.instance); } - if (g_mapSettings.haltAllOnTx) { + if (g_mapSettings.haltAllOnTx) + { haltAllTx(); } @@ -5252,17 +6026,20 @@ function initiateQso(thisCall) { } } -function spotLookupAndSetCall(spot) { +function spotLookupAndSetCall(spot) +{ var call = g_receptionReports.spots[spot].call; var grid = g_receptionReports.spots[spot].grid; var band = g_receptionReports.spots[spot].band; var mode = g_receptionReports.spots[spot].mode; - for (var instance in g_instances) { + for (var instance in g_instances) + { if ( g_instances[instance].valid && g_instances[instance].status.Band == band && g_instances[instance].status.MO == mode - ) { + ) + { setCallAndGrid(call, grid, instance); return; } @@ -5270,24 +6047,32 @@ function spotLookupAndSetCall(spot) { setCallAndGrid(call, grid, null); } -function setCallAndGrid(callsign, grid, instance = null) { +function setCallAndGrid(callsign, grid, instance = null) +{ var thisInstance = null; var port; var address; - if (instance != null) { - if (instance in g_instances) { + if (instance != null) + { + if (instance in g_instances) + { thisInstance = g_instances[instance].status; port = g_instances[instance].remote.port; address = g_instances[instance].remote.address; - } else alert("major instance error"); - } else { - if (g_instances[g_activeInstance].valid) { + } + else alert("major instance error"); + } + else + { + if (g_instances[g_activeInstance].valid) + { thisInstance = g_instances[g_activeInstance].status; port = g_instances[g_activeInstance].remote.port; address = g_instances[g_activeInstance].remote.address; } } - if (thisInstance && thisInstance.TxEnabled == 0) { + if (thisInstance && thisInstance.TxEnabled == 0) + { var responseArray = Buffer.alloc(1024); var length = 0; length = encodeQUINT32(responseArray, length, thisInstance.magic_key); @@ -5304,7 +6089,7 @@ function setCallAndGrid(callsign, grid, instance = null) { var hash = liveHash(callsign, thisInstance.Band, thisInstance.MO); if (hash in g_liveCallsigns && g_liveCallsigns[hash].grid.length > 1) - grid = g_liveCallsigns[hash].grid; + { grid = g_liveCallsigns[hash].grid; } if (grid.length == 0) grid = " "; @@ -5315,7 +6100,8 @@ function setCallAndGrid(callsign, grid, instance = null) { wsjtUdpMessage(responseArray, responseArray.length, port, address); addLastTraffic("Generated Msgs"); } - if (thisInstance && thisInstance.TxEnabled == 1) { + if (thisInstance && thisInstance.TxEnabled == 1) + { addLastTraffic( "Transmit Enabled!
Generate Msgs Aborted" ); @@ -5335,26 +6121,31 @@ var g_wsjtHandlers = { 9: handleWsjtxNotSupported, 10: handleWsjtxWSPR, 11: handleWsjtxNotSupported, - 12: handleWsjtxADIF, + 12: handleWsjtxADIF }; var g_oldQSOTimer = null; -function handleWsjtxADIF(newMessage) { - if (g_oldQSOTimer) { +function handleWsjtxADIF(newMessage) +{ + if (g_oldQSOTimer) + { clearTimeout(g_oldQSOTimer); g_oldQSOTimer = null; } - if (g_ignoreMessages == 0) { + if (g_ignoreMessages == 0) + { onAdiLoadComplete(newMessage.ADIF); } sendToLogger(newMessage.ADIF); } -function handleWsjtxQSO(newMessage) { - if (g_oldQSOTimer) { +function handleWsjtxQSO(newMessage) +{ + if (g_oldQSOTimer) + { clearTimeout(g_oldQSOTimer); g_oldQSOTimer = null; } @@ -5378,13 +6169,17 @@ var g_localDXcall = ""; var g_countIndex = 0; var g_lastCountIndex = 0; -function rigChange(up) { +function rigChange(up) +{ if (g_activeInstance == "") return; var targetInstance = 0; - if (up) { + if (up) + { targetInstance = g_instances[g_activeInstance].intId + 1; - } else { + } + else + { targetInstance = g_instances[g_activeInstance].intId - 1; if (targetInstance < 0) targetInstance = g_instancesIndex.length - 1; } @@ -5394,9 +6189,12 @@ function rigChange(up) { setRig(targetInstance); } -function setRig(instanceId) { - if (g_instances[g_instancesIndex[instanceId]].valid) { - if (g_lastMapView != null) { +function setRig(instanceId) +{ + if (g_instances[g_instancesIndex[instanceId]].valid) + { + if (g_lastMapView != null) + { g_mapView.animate({ zoom: g_lastMapView.zoom, duration: 100 }); g_mapView.animate({ center: g_lastMapView.LoLa, duration: 100 }); g_lastMapView = null; @@ -5409,9 +6207,12 @@ function setRig(instanceId) { } } -function activeRig(instance) { - if (g_instances[instance].valid) { - if (g_lastMapView != null) { +function activeRig(instance) +{ + if (g_instances[instance].valid) + { + if (g_lastMapView != null) + { g_mapView.animate({ zoom: g_lastMapView.zoom, duration: 100 }); g_mapView.animate({ center: g_lastMapView.LoLa, duration: 100 }); g_lastMapView = null; @@ -5428,50 +6229,62 @@ var g_lastDecodeCallsign = ""; var g_lastTransmitCallsign = {}; var g_lastStatusCallsign = {}; -function handleWsjtxStatus(newMessage) { +function handleWsjtxStatus(newMessage) +{ if (g_ignoreMessages == 1) return; - if (g_callRosterWindowHandle) { - try { + if (g_callRosterWindowHandle) + { + try + { g_callRosterWindowHandle.window.processStatus(newMessage); - } catch (e) {} + } + catch (e) {} } - if (g_activeInstance == "") { + if (g_activeInstance == "") + { g_activeInstance = newMessage.instance; } - if (Object.keys(g_instances).length > 1) { + if (Object.keys(g_instances).length > 1) + { rigWrap.style.display = "block"; - } else { + } + else + { rigWrap.style.display = "none"; } var DXcall = newMessage.DXcall.trim(); - if (DXcall.length > 1) { + if (DXcall.length > 1) + { if (!(newMessage.instance in g_lastTransmitCallsign)) - g_lastTransmitCallsign[newMessage.instance] = ""; + { g_lastTransmitCallsign[newMessage.instance] = ""; } if (!(newMessage.instance in g_lastStatusCallsign)) - g_lastStatusCallsign[newMessage.instance] = ""; + { g_lastStatusCallsign[newMessage.instance] = ""; } if ( lookupOnTx.checked == true && newMessage.Transmitting == 1 && g_lastTransmitCallsign[newMessage.instance] != DXcall - ) { + ) + { openLookupWindow(true); g_lastTransmitCallsign[newMessage.instance] = DXcall; } - if (g_lastStatusCallsign[newMessage.instance] != DXcall) { + if (g_lastStatusCallsign[newMessage.instance] != DXcall) + { g_lastStatusCallsign[newMessage.instance] = DXcall; lookupCallsign(DXcall, newMessage.DXgrid.trim()); } } - if (g_activeInstance == newMessage.instance) { + if (g_activeInstance == newMessage.instance) + { var sp = newMessage.Id.split(" - "); rigDiv.innerHTML = sp[sp.length - 1].substring(0, 18); @@ -5482,25 +6295,30 @@ function handleWsjtxStatus(newMessage) { wsjtxMode.innerHTML = "" + newMessage.MO + ""; myMode = newMessage.MO; myBand = Number(newMessage.Frequency / 1000000).formatBand(); - if (g_lastBand != myBand) { + if (g_lastBand != myBand) + { g_lastBand = myBand; bandChange = true; - if (g_pskBandActivityTimerHandle != null) { + if (g_pskBandActivityTimerHandle != null) + { clearInterval(g_pskBandActivityTimerHandle); g_pskBandActivityTimerHandle = null; } removePaths(); } - if (g_lastMode != myMode) { + if (g_lastMode != myMode) + { g_lastMode = myMode; modeChange = true; - if (g_pskBandActivityTimerHandle != null) { + if (g_pskBandActivityTimerHandle != null) + { clearInterval(g_pskBandActivityTimerHandle); g_pskBandActivityTimerHandle = null; } } if (g_pskBandActivityTimerHandle == null) pskGetBandActivity(); - if (bandChange || modeChange) { + if (bandChange || modeChange) + { goProcessRoster(); redrawGrids(); redrawSpots(); @@ -5528,7 +6346,8 @@ function handleWsjtxStatus(newMessage) { var LL = squareToLatLongAll(myRawGrid); g_mapSettings.latitude = g_myLat = LL.la2 - (LL.la2 - LL.la1) / 2; g_mapSettings.longitude = g_myLon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - if (myRawGrid != g_lastRawGrid) { + if (myRawGrid != g_lastRawGrid) + { g_lastRawGrid = myRawGrid; } @@ -5536,33 +6355,40 @@ function handleWsjtxStatus(newMessage) { var hash = DXcall + myBand + myMode; - if (hash in g_tracker.worked.call) { + if (hash in g_tracker.worked.call) + { dxCallBoxDiv.className = "DXCallBoxWorked"; } - if (hash in g_tracker.confirmed.call) { + if (hash in g_tracker.confirmed.call) + { dxCallBoxDiv.className = "DXCallBoxConfirmed"; } g_localDXcall = DXcall; localDXcall.innerHTML = DXcall.formatCallsign(); - if (localDXcall.innerHTML.length == 0) { + if (localDXcall.innerHTML.length == 0) + { localDXcall.innerHTML = "-"; g_localDXcall = ""; } localDXGrid.innerHTML = myDXGrid = newMessage.DXgrid.trim(); - if (myDXGrid.length == 0 && hash in g_liveCallsigns) { + if (myDXGrid.length == 0 && hash in g_liveCallsigns) + { localDXGrid.innerHTML = myDXGrid = g_liveCallsigns[hash].grid.substr( 0, 4 ); } - if (localDXGrid.innerHTML.length == 0) { + if (localDXGrid.innerHTML.length == 0) + { localDXGrid.innerHTML = "-"; localDXDistance.innerHTML = " "; localDXAzimuth.innerHTML = " "; - } else { + } + else + { var LL = squareToLatLongAll(myDXGrid); localDXDistance.innerHTML = parseInt( @@ -5584,14 +6410,17 @@ function handleWsjtxStatus(newMessage) { ) ) + "°"; } - if (localDXcall.innerHTML != "-") { + if (localDXcall.innerHTML != "-") + { localDXReport.innerHTML = Number( newMessage.Report.trim() ).formatSignalReport(); if (DXcall.length > 0) - localDXCountry.innerHTML = g_dxccToAltName[callsignToDxcc(DXcall)]; + { localDXCountry.innerHTML = g_dxccToAltName[callsignToDxcc(DXcall)]; } else localDXCountry.innerHTML = " "; - } else { + } + else + { localDXReport.innerHTML = localDXCountry.innerHTML = ""; } myDEcall = newMessage.DEcall; @@ -5599,7 +6428,8 @@ function handleWsjtxStatus(newMessage) { if (myDEGrid.length > 0) setHomeGridsquare(); if (myDEGrid.length > 0) g_appSettings.centerGridsquare = myDEGrid; - if (newMessage.Decoding == 1) { + if (newMessage.Decoding == 1) + { // Decoding dimGridsquare(); fadePaths(); @@ -5608,18 +6438,23 @@ function handleWsjtxStatus(newMessage) { txrxdec.innerHTML = "DECODE"; g_countIndex++; g_weAreDecoding = true; - } else { + } + else + { g_weAreDecoding = false; - if (g_countIndex != g_lastCountIndex) { + if (g_countIndex != g_lastCountIndex) + { g_lastCountIndex = g_countIndex; updateCountStats(); - if (g_appSettings.gtShareEnable == "true") { + if (g_appSettings.gtShareEnable == "true") + { g_gtLiveStatusUpdate = true; g_gtShareCount++; - } else g_gtShareCount = 0; + } + else g_gtShareCount = 0; if (bandChange || modeChange) reloadInfo(bandChange || modeChange); var worker = ""; @@ -5647,7 +6482,8 @@ function handleWsjtxStatus(newMessage) { if ( g_appSettings.gtShareEnable === true && Object.keys(g_spotCollector).length > 0 - ) { + ) + { gtChatSendSpots(g_spotCollector); g_spotCollector = {}; } @@ -5658,23 +6494,29 @@ function handleWsjtxStatus(newMessage) { txrxdec.innerHTML = "RECEIVE"; } - if (newMessage.TxEnabled) { + if (newMessage.TxEnabled) + { if ( g_mapSettings.fitQRZ && (!g_spotsEnabled || g_receptionSettings.mergeSpots) - ) { - if (g_lastMapView == null) { + ) + { + if (g_lastMapView == null) + { g_lastMapView = {}; g_lastMapView.LoLa = g_mapView.getCenter(); g_lastMapView.zoom = g_mapView.getZoom(); } - if (myDXGrid.length > 0) { + if (myDXGrid.length > 0) + { fitViewBetweenPoints([getPoint(myRawGrid), getPoint(myDXGrid)]); - } else if ( + } + else if ( g_mapSettings.qrzDxccFallback && DXcall.length > 0 && callsignToDxcc(DXcall) > 0 - ) { + ) + { var dxcc = callsignToDxcc(DXcall); var Lat = g_worldGeoData[g_dxccToGeoData[dxcc]].lat; var Lon = g_worldGeoData[g_dxccToGeoData[dxcc]].lon; @@ -5684,29 +6526,36 @@ function handleWsjtxStatus(newMessage) { ); } } - } else { - if (g_lastMapView != null) { + } + else + { + if (g_lastMapView != null) + { g_mapView.animate({ zoom: g_lastMapView.zoom, duration: 1200 }); g_mapView.animate({ center: g_lastMapView.LoLa, duration: 1200 }); g_lastMapView = null; } } - if (newMessage.Transmitting == 0) { + if (newMessage.Transmitting == 0) + { // Not Transmitting - g_layerSources["transmit"].clear(); + g_layerSources.transmit.clear(); g_transmitFlightPath = null; - } else { + } + else + { txrxdec.style.backgroundColor = "Red"; txrxdec.style.borderColor = "Orange"; txrxdec.innerHTML = "TRANSMIT"; - g_layerSources["transmit"].clear(); + g_layerSources.transmit.clear(); g_transmitFlightPath = null; if ( qrzPathWidthValue.value != 0 && g_appSettings.gridViewMode != 2 && validateGridFromString(myRawGrid) - ) { + ) + { var strokeColor = getQrzPathColor(); var strokeWeight = qrzPathWidthValue.value; var LL = squareToLatLongAll(myRawGrid); @@ -5715,17 +6564,20 @@ function handleWsjtxStatus(newMessage) { var fromPoint = ol.proj.fromLonLat([Lon, Lat]); var toPoint = null; - if (validateGridFromString(myDXGrid)) { + if (validateGridFromString(myDXGrid)) + { LL = squareToLatLongAll(myDXGrid); Lat = LL.la2 - (LL.la2 - LL.la1) / 2; Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; toPoint = ol.proj.fromLonLat([Lon, Lat]); - } else if ( + } + else if ( g_mapSettings.qrzDxccFallback && DXcall.length > 0 && callsignToDxcc(DXcall) > 0 - ) { + ) + { var dxcc = callsignToDxcc(DXcall); Lat = g_worldGeoData[g_dxccToGeoData[dxcc]].lat; Lon = g_worldGeoData[g_dxccToGeoData[dxcc]].lon; @@ -5735,7 +6587,8 @@ function handleWsjtxStatus(newMessage) { var locality = g_worldGeoData[g_dxccToGeoData[dxcc]].geo; if (locality == "deleted") locality = null; - if (locality != null) { + if (locality != null) + { var feature = shapeFeature( "qrz", locality, @@ -5744,18 +6597,19 @@ function handleWsjtxStatus(newMessage) { "#FF0000FF", 1.0 ); - g_layerSources["transmit"].addFeature(feature); + g_layerSources.transmit.addFeature(feature); } } - if (toPoint) { + if (toPoint) + { g_transmitFlightPath = flightFeature( [fromPoint, toPoint], { weight: strokeWeight, color: strokeColor, steps: 75, - zIndex: 90, + zIndex: 90 }, "transmit", true @@ -5774,7 +6628,8 @@ function handleWsjtxStatus(newMessage) { g_appSettings.myRawGrid = myRawGrid; } - if (newMessage.Decoding == 0) { + if (newMessage.Decoding == 0) + { goProcessRoster(); processClassicAlerts(); } @@ -5782,22 +6637,28 @@ function handleWsjtxStatus(newMessage) { var g_lastMapView = null; -function drawTraffic() { +function drawTraffic() +{ while (g_lastTraffic.length > 60) g_lastTraffic.pop(); var worker = g_lastTraffic.join("
"); worker = worker.split("80%'>
").join("80%'>"); if (g_localDXcall.length > 1) + { worker = worker .split(g_localDXcall) .join("" + g_localDXcall + ""); + } if (myRawCall.length > 1) + { worker = worker .split(myRawCall) .join("" + myRawCall + ""); + } trafficDiv.innerHTML = worker; } -function getPoint(grid) { +function getPoint(grid) +{ var LL = squareToLatLongAll(grid); var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; @@ -5805,15 +6666,20 @@ function getPoint(grid) { } var g_showCQRU = true; -function fitViewBetweenPoints(points, maxZoom = 20) { +function fitViewBetweenPoints(points, maxZoom = 20) +{ var start = ol.proj.toLonLat(points[0]); var end = ol.proj.toLonLat(points[1]); - if (Math.abs(start[0] - end[0]) > 180) { + if (Math.abs(start[0] - end[0]) > 180) + { // Wrapped - if (end[0] < start[0]) { + if (end[0] < start[0]) + { start[0] -= 360; - } else { + } + else + { end[0] -= 360; } } @@ -5827,14 +6693,14 @@ function fitViewBetweenPoints(points, maxZoom = 20) { g_mapView.fit(extent, { duration: 500, maxZoom: maxZoom, - padding: [75, 75, 75, 75], + padding: [75, 75, 75, 75] }); - } var g_spotCollector = {}; -function handleWsjtxDecode(newMessage) { +function handleWsjtxDecode(newMessage) +{ if (g_ignoreMessages == 1 || g_map == null) return; var didAlert = false; var didCustomAlert = false; @@ -5846,9 +6712,12 @@ function handleWsjtxDecode(newMessage) { var theirQTH = ""; var countryName = ""; var newF; - if (newMessage.OF > 0) { + if (newMessage.OF > 0) + { newF = Number((newMessage.OF + newMessage.DF) / 1000).formatMhz(3, 3); - } else { + } + else + { newF = newMessage.DF; } theTimeStamp = @@ -5860,9 +6729,12 @@ function handleWsjtxDecode(newMessage) { var decodeWords = newMessage.Msg.split(" ").slice(0, 5); while (decodeWords[decodeWords.length - 1] == "") decodeWords.pop(); - if (decodeWords.length > 1 && newMessage.Msg.indexOf("<...>") == -1) { - if (newMessage.Msg.indexOf("<") != -1) { - for (var i in decodeWords) { + if (decodeWords.length > 1 && newMessage.Msg.indexOf("<...>") == -1) + { + if (newMessage.Msg.indexOf("<") != -1) + { + for (var i in decodeWords) + { decodeWords[i] = decodeWords[i].replace("<", "").replace(">", ""); } } @@ -5870,14 +6742,19 @@ function handleWsjtxDecode(newMessage) { var rect = null; // Grab the last word in the decoded message var qth = decodeWords[decodeWords.length - 1].trim(); - if (qth.length == 4) { + if (qth.length == 4) + { var LETTERS = qth.substr(0, 2); var NUMBERS = qth.substr(2, 2); - if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) { + if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) + { theirQTH = LETTERS + NUMBERS; - if (theirQTH != "RR73") { + if (theirQTH != "RR73") + { validQTH = true; - } else { + } + else + { theirQTH = ""; validQTH = false; } @@ -5886,26 +6763,31 @@ function handleWsjtxDecode(newMessage) { if (validQTH) msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); if (validQTH == false && decodeWords.length == 3) - msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); + { msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); } if (validQTH == false && decodeWords.length == 2) - msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); - if (decodeWords[0] == "CQ") { + { msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); } + if (decodeWords[0] == "CQ") + { CQ = true; msgDXcallsign = "CQ"; } - if (decodeWords.length == 4 && CQ == true) { + if (decodeWords.length == 4 && CQ == true) + { msgDXcallsign += " " + decodeWords[1]; } - if (decodeWords.length == 3 && CQ == false) { + if (decodeWords.length == 3 && CQ == false) + { msgDXcallsign = decodeWords[0]; } - if (decodeWords.length >= 3 && CQ == true && validQTH == false) { + if (decodeWords.length >= 3 && CQ == true && validQTH == false) + { if (validateNumAndLetter(decodeWords[decodeWords.length - 1].trim())) - msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); + { msgDEcallsign = decodeWords[decodeWords.length - 1].trim(); } else msgDEcallsign = decodeWords[decodeWords.length - 2].trim(); } - if (decodeWords.length >= 4 && CQ == false) { + if (decodeWords.length >= 4 && CQ == false) + { msgDXcallsign = decodeWords[0]; msgDEcallsign = decodeWords[1]; } @@ -5915,9 +6797,10 @@ function handleWsjtxDecode(newMessage) { var hash = msgDEcallsign + newMessage.OB + newMessage.OM; if (hash in g_liveCallsigns) callsign = g_liveCallsigns[hash]; - if (validQTH == "" && msgDEcallsign in g_gtCallsigns) { + if (validQTH == "" && msgDEcallsign in g_gtCallsigns) + { if (g_gtFlagPins[g_gtCallsigns[msgDEcallsign]].grid.length > 0) - validQTH = g_gtFlagPins[g_gtCallsigns[msgDEcallsign]].grid; + { validQTH = g_gtFlagPins[g_gtCallsigns[msgDEcallsign]].grid; } } var canPath = false; @@ -5929,7 +6812,8 @@ function handleWsjtxDecode(newMessage) { (g_appSettings.gtModeFilter == "auto" && newMessage.OM == myMode) || newMessage.OM == g_appSettings.gtModeFilter || g_appSettings.gtModeFilter == "Digital") - ) { + ) + { rect = qthToBox( theirQTH, msgDEcallsign, @@ -5945,15 +6829,18 @@ function handleWsjtxDecode(newMessage) { canPath = true; } - if (rect != null && theirQTH == "") { + if (rect != null && theirQTH == "") + { theirQTH = rect.qth; } - if (rect) { + if (rect) + { g_liveGrids[theirQTH].age = g_timeNow; } - if (callsign == null) { + if (callsign == null) + { newCallsign = {}; newCallsign.DEcall = msgDEcallsign; newCallsign.grid = theirQTH; @@ -5981,17 +6868,20 @@ function handleWsjtxDecode(newMessage) { newCallsign.phone = false; newCallsign.IOTA = ""; newCallsign.satName = ""; - if (newCallsign.dxcc != -1) { + if (newCallsign.dxcc != -1) + { newCallsign.px = getWpx(newCallsign.DEcall); if (newCallsign.px) + { newCallsign.zone = Number( newCallsign.px.charAt(newCallsign.px.length - 1) ); + } newCallsign.cont = g_worldGeoData[g_dxccToGeoData[newCallsign.dxcc]].continent; if (newCallsign.dxcc == 390 && newCallsign.zone == 1) - details.cont = "EU"; + { details.cont = "EU"; } } newCallsign.ituza = Array(); @@ -6007,7 +6897,8 @@ function handleWsjtxDecode(newMessage) { if ( g_callsignLookups.ulsUseEnable == true && isKnownCallsignDXCC(newCallsign.dxcc) - ) { + ) + { lookupUsCallsign(newCallsign, false); } @@ -6018,11 +6909,15 @@ function handleWsjtxDecode(newMessage) { newCallsign.shouldAlert = false; g_liveCallsigns[hash] = newCallsign; callsign = newCallsign; - } else { - if (validQTH) { + } + else + { + if (validQTH) + { callsign.grid = theirQTH; - if (rect != null && callsign.grid != rect.qth) { + if (rect != null && callsign.grid != rect.qth) + { if ( (g_appSettings.gtBandFilter.length == 0 || (g_appSettings.gtBandFilter == "auto" && @@ -6033,7 +6928,8 @@ function handleWsjtxDecode(newMessage) { newMessage.OM == myMode) || newMessage.OM == g_appSettings.gtModeFilter || g_appSettings.gtModeFilter == "Digital") - ) { + ) + { rect = qthToBox( theirQTH, msgDEcallsign, @@ -6069,7 +6965,8 @@ function handleWsjtxDecode(newMessage) { if (msgDXcallsign == myDEcall) callsign.qrz = true; else callsign.qrz = false; - if (callsign.grid.length > 0 && callsign.distance == 0) { + if (callsign.grid.length > 0 && callsign.distance == 0) + { var LL = squareToLatLongAll(callsign.grid); callsign.distance = MyCircle.distance( g_myLat, @@ -6085,15 +6982,18 @@ function handleWsjtxDecode(newMessage) { LL.lo2 - (LL.lo2 - LL.lo1) / 2 ); - if (callsign.grid in g_gridToITUZone) { + if (callsign.grid in g_gridToITUZone) + { callsign.ituza = g_gridToITUZone[callsign.grid]; } - if (callsign.grid in g_gridToCQZone) { + if (callsign.grid in g_gridToCQZone) + { callsign.cqza = g_gridToCQZone[callsign.grid]; } } - if (newMessage.NW) { + if (newMessage.NW) + { didCustomAlert = processAlertMessage( decodeWords, newMessage.Msg.substr(0, 30).trim(), @@ -6114,12 +7014,15 @@ function handleWsjtxDecode(newMessage) { if ( g_mapSettings.trafficDecode && (didAlert == true || didCustomAlert == true) - ) { + ) + { var traffic = htmlEntities(newMessage.Msg); - if (didAlert == true) { + if (didAlert == true) + { traffic = "⚠️ " + traffic; } - if (didCustomAlert == true) { + if (didCustomAlert == true) + { traffic = traffic + " 🚩"; } @@ -6136,48 +7039,58 @@ function handleWsjtxDecode(newMessage) { g_appSettings.gtSpotEnable === true && g_appSettings.gtSpotEnable === true && callsign.DEcall in g_gtCallsigns - ) { + ) + { if ( g_gtCallsigns[callsign.DEcall] in g_gtFlagPins && g_gtFlagPins[g_gtCallsigns[callsign.DEcall]].o == 1 ) - g_spotCollector[g_gtCallsigns[callsign.DEcall]] = callsign.RSTsent; + { g_spotCollector[g_gtCallsigns[callsign.DEcall]] = callsign.RSTsent; } } } if (callsign.dxcc != -1) countryName = g_dxccToAltName[callsign.dxcc]; - if (canPath == true) { + if (canPath == true) + { if ( callsign.DXcall.indexOf("CQ") < 0 && g_appSettings.gridViewMode != 2 - ) { + ) + { // Nothing special, we know the callers grid - if (callsign.grid != "") { + if (callsign.grid != "") + { // Our msgDEcallsign is not sending a CQ. // Let's see if we can locate who he's talking to in our known list var DEcallsign = null; if ( callsign.DXcall + newMessage.OB + newMessage.OM in g_liveCallsigns - ) { + ) + { DEcallsign = g_liveCallsigns[callsign.DXcall + newMessage.OB + newMessage.OM]; - } else if (callsign.DXcall in g_liveCallsigns) { + } + else if (callsign.DXcall in g_liveCallsigns) + { DEcallsign = g_liveCallsigns[callsign.DXcall]; } - if (DEcallsign != null && DEcallsign.grid != "") { + if (DEcallsign != null && DEcallsign.grid != "") + { var strokeColor = getPathColor(); var strokeWeight = pathWidthValue.value; var flightPath = null; var isQRZ = false; - if (msgDXcallsign == myDEcall) { + if (msgDXcallsign == myDEcall) + { strokeColor = getQrzPathColor(); strokeWeight = qrzPathWidthValue.value; isQRZ = true; } - if (strokeWeight != 0) { + if (strokeWeight != 0) + { var fromPoint = getPoint(callsign.grid); var toPoint = getPoint(DEcallsign.grid); @@ -6187,7 +7100,7 @@ function handleWsjtxDecode(newMessage) { weight: strokeWeight, color: strokeColor, steps: 75, - zIndex: 90, + zIndex: 90 }, "flight", true @@ -6200,11 +7113,13 @@ function handleWsjtxDecode(newMessage) { g_flightPaths.push(flightPath); } } - } else if ( + } + else if ( g_mapSettings.qrzDxccFallback && msgDXcallsign == myDEcall && callsign.dxcc > 0 - ) { + ) + { // the caller is calling us, but they don't have a grid, so lookup the DXCC and show it var strokeColor = getQrzPathColor(); var strokeWeight = qrzPathWidthValue.value; @@ -6212,7 +7127,8 @@ function handleWsjtxDecode(newMessage) { var isQRZ = true; var DEcallsign = g_liveCallsigns[myDEcall]; - if (strokeWeight != 0) { + if (strokeWeight != 0) + { var toPoint = getPoint(DEcallsign.grid); var Lat = g_worldGeoData[g_dxccToGeoData[callsign.dxcc]].lat; @@ -6225,7 +7141,7 @@ function handleWsjtxDecode(newMessage) { weight: strokeWeight, color: strokeColor, steps: 75, - zIndex: 90, + zIndex: 90 }, "flight", true @@ -6248,41 +7164,50 @@ function handleWsjtxDecode(newMessage) { feature.age = g_timeNow + g_flightDuration; feature.isShapeFlight = 1; feature.isQRZ = isQRZ; - g_layerSources["flight"].addFeature(feature); + g_layerSources.flight.addFeature(feature); g_flightPaths.push(feature); } } - } else if ( + } + else if ( g_mapSettings.CQhilite && msgDXcallsign.indexOf("CQ ") == 0 && callsign.grid != "" && g_appSettings.gridViewMode != 2 && pathWidthValue.value != 0 - ) { + ) + { var CCd = msgDXcallsign.replace("CQ ", "").split(" ")[0]; - if (CCd.length < 5 && !(CCd in g_pathIgnore)) { + if (CCd.length < 5 && !(CCd in g_pathIgnore)) + { var locality = null; // Direct lookup US states, Continents, possibly if (CCd in g_replaceCQ) CCd = g_replaceCQ[CCd]; - if (CCd.length == 2 && CCd in g_shapeData) { + if (CCd.length == 2 && CCd in g_shapeData) + { locality = g_shapeData[CCd]; - } else if (CCd.length == 3) { + } + else if (CCd.length == 3) + { // maybe it's DEL, or WYO. check the first two letters if (CCd.substr(0, 2) in g_shapeData) - locality = g_shapeData[CCd.substr(0, 2)]; + { locality = g_shapeData[CCd.substr(0, 2)]; } } - if (locality == null) { + if (locality == null) + { // Check the prefix for dxcc direct var dxcc = callsignToDxcc(CCd); - if (dxcc != -1) { + if (dxcc != -1) + { locality = g_worldGeoData[g_dxccToGeoData[dxcc]].geo; if (locality == "deleted") locality = null; } } - if (locality != null) { + if (locality != null) + { var strokeColor = getPathColor(); var strokeWeight = pathWidthValue.value; var flightPath = null; @@ -6299,7 +7224,7 @@ function handleWsjtxDecode(newMessage) { feature.age = g_timeNow + g_flightDuration; feature.isShapeFlight = 1; feature.isQRZ = false; - g_layerSources["flight"].addFeature(feature); + g_layerSources.flight.addFeature(feature); g_flightPaths.push(feature); var fromPoint = getPoint(callsign.grid); @@ -6311,7 +7236,7 @@ function handleWsjtxDecode(newMessage) { weight: strokeWeight, color: strokeColor, steps: 75, - zIndex: 90, + zIndex: 90 }, "flight", true @@ -6355,7 +7280,8 @@ function handleWsjtxDecode(newMessage) { while (g_lastMessages.length > 100) g_lastMessages.pop(); } -function addLastTraffic(traffic) { +function addLastTraffic(traffic) +{ g_lastTraffic.unshift(traffic); g_lastTraffic.unshift( "
" @@ -6363,7 +7289,8 @@ function addLastTraffic(traffic) { drawTraffic(); } -function htmlEntities(str) { +function htmlEntities(str) +{ return String(str) .replace(/&/g, "&") .replace(/ 300) { + for (var call in g_callRoster) + { + if (now - g_callRoster[call].callObj.age > 300) + { g_callRoster[call].callObj.alerted = false; g_callRoster[call].callObj.shouldAlert = false; delete g_callRoster[call]; continue; } } - if (g_callRosterWindowHandle) { - try { - if (isRealtime == true) { + if (g_callRosterWindowHandle) + { + try + { + if (isRealtime == true) + { if (g_callRosterWindowHandle.window.g_rosterSettings.realtime == false) - return; + { return; } } g_callRosterWindowHandle.window.processRoster(g_callRoster); - } catch (e) {} + } + catch (e) {} } } -function handleClosed(newMessage) { +function handleClosed(newMessage) +{ if ( g_activeInstance == newMessage.Id && g_instances[newMessage.Id].open == false - ) { + ) + { txrxdec.style.backgroundColor = "Purple"; txrxdec.style.borderColor = "Purple"; var name = newMessage.Id.toUpperCase().split(" - "); @@ -6454,14 +7394,16 @@ function handleClosed(newMessage) { } } -function handleWsjtxClose(newMessage) { +function handleWsjtxClose(newMessage) +{ updateCountStats(); g_instances[newMessage.Id].open = false; handleClosed(newMessage); updateRosterInstances(); } -function handleWsjtxWSPR(newMessage) { +function handleWsjtxWSPR(newMessage) +{ if (g_ignoreMessages == 1) return; addDeDx( @@ -6499,43 +7441,50 @@ function handleWsjtxWSPR(newMessage) { updateCountStats(); } -function centerOn(grid) { - if (grid.length >= 4) { +function centerOn(grid) +{ + if (grid.length >= 4) + { var LL = squareToLatLong(grid); g_map .getView() .setCenter( ol.proj.fromLonLat([ LL.lo2 - (LL.lo2 - LL.lo1) / 2, - LL.la2 - (LL.la2 - LL.la1) / 2, + LL.la2 - (LL.la2 - LL.la1) / 2 ]) ); } } -function setCenterQTH() { - if (homeQTHInput.value.length >= 4) { +function setCenterQTH() +{ + if (homeQTHInput.value.length >= 4) + { g_appSettings.centerGridsquare = homeQTHInput.value; // Grab home QTH Gridsquare from Center QTH var LL = squareToLatLong(homeQTHInput.value); - //panTo(ol.proj.fromLonLat([LL.lo2 - (LL.lo2 - LL.lo1) / 2, LL.la2 - ((LL.la2 - LL.la1) / 2)])); + // panTo(ol.proj.fromLonLat([LL.lo2 - (LL.lo2 - LL.lo1) / 2, LL.la2 - ((LL.la2 - LL.la1) / 2)])); g_map .getView() .setCenter( ol.proj.fromLonLat([ LL.lo2 - (LL.lo2 - LL.lo1) / 2, - LL.la2 - (LL.la2 - LL.la1) / 2, + LL.la2 - (LL.la2 - LL.la1) / 2 ]) ); - } else { + } + else + { homeQTHInput.value = ""; - return; } } -function setCenterGridsquare() { - if (g_mapMemory[6].zoom != -1) { +function setCenterGridsquare() +{ + if (g_mapMemory[6].zoom != -1) + { mapMemory(6, false); return; } @@ -6543,22 +7492,28 @@ function setCenterGridsquare() { setCenterQTH(); } -function changeLookupMerge() { +function changeLookupMerge() +{ g_appSettings.lookupMerge = lookupMerge.checked; g_appSettings.lookupMissingGrid = lookupMissingGrid.checked; - if (g_appSettings.lookupMerge == true) { + if (g_appSettings.lookupMerge == true) + { lookupMissingGridDiv.style.display = "inline-block"; - } else { + } + else + { lookupMissingGridDiv.style.display = "none"; } } -function changelookupOnTx() { +function changelookupOnTx() +{ g_appSettings.lookupOnTx = lookupOnTx.checked; g_appSettings.lookupCloseLog = lookupCloseLog.checked; } -function exportSettings() { +function exportSettings() +{ var filename = g_appData + g_dirSeperator + "gt_settings.json"; var toWrite = JSON.stringify(localStorage); @@ -6567,40 +7522,53 @@ function exportSettings() { checkForSettings(); } -function checkForSettings() { +function checkForSettings() +{ var filename = g_appData + g_dirSeperator + "gt_settings.json"; - if (fs.existsSync(filename)) { + if (fs.existsSync(filename)) + { importSettingsButton.style.display = "inline-block"; importSettingsFile.style.display = "inline-block"; importSettingsFile.innerHTML = filename; - } else { + } + else + { importSettingsButton.style.display = "none"; importSettingsFile.style.display = "none"; } } -function importSettings() { +function importSettings() +{ checkForSettings(); var filename = g_appData + g_dirSeperator + "gt_settings.json"; - if (fs.existsSync(filename)) { + if (fs.existsSync(filename)) + { var data = fs.readFileSync(filename); data = JSON.parse(data); if ( typeof data.appSettings != "undefined" && data.currentVersion == localStorage.currentVersion - ) { + ) + { localStorage.clear(); - for (var key in data) { + for (var key in data) + { localStorage[key] = data[key]; } fs.unlinkSync(filename); chrome.runtime.reload(); - } else { - if (typeof data.appSettings == "undefined") { + } + else + { + if (typeof data.appSettings == "undefined") + { importSettingsFile.innerHTML = "Settings File Corrupt!"; - } else if (data.currentVersion != localStorage.currentVersion) { + } + else if (data.currentVersion != localStorage.currentVersion) + { importSettingsFile.innerHTML = "Settings Version Mismatch!"; } @@ -6608,29 +7576,34 @@ function importSettings() { } } -function showCallsignBox(redraw) { +function showCallsignBox(redraw) +{ var worker = "
Callsigns and DXCC Heard

"; g_newCallsignCount = Object.keys(g_liveCallsigns).length; - if (g_newCallsignCount > 0) { + if (g_newCallsignCount > 0) + { var newCallList = Array(); worker += "
"; //"; + "px;'>
CallsignGridDXCCCQITUFlagQSOQSLWhenITUzCQzISO
"; // "; if (g_callsignLookups.lotwUseEnable == true) worker += ""; if (g_callsignLookups.eqslUseEnable == true) worker += ""; if (g_callsignLookups.oqrsUseEnable == true) worker += ""; g_lastCallsignCount = g_newCallsignCount; - for (var x in g_liveCallsigns) { - if (g_liveCallsigns[x].dxcc != -1) { + for (var x in g_liveCallsigns) + { + if (g_liveCallsigns[x].dxcc != -1) + { newCallList.push(g_liveCallsigns[x]); } } newCallList.sort(compareCallsignTime).reverse(); - for (var x in newCallList) { + for (var x in newCallList) + { if (newCallList[x].DEcall == myRawCall) continue; var grid = newCallList[x].rect ? newCallList[x].rect.qth : "-"; var cqzone = @@ -6642,7 +7615,7 @@ function showCallsignBox(redraw) { worker += ""; var ageString = ""; if (timeNowSec() - newCallList[x].time < 3601) - ageString = (timeNowSec() - newCallList[x].time).toDHMS(); - else { + { ageString = (timeNowSec() - newCallList[x].time).toDHMS(); } + else + { ageString = userTimeString(newCallList[x].time * 1000); } worker += ""; if (g_callsignLookups.lotwUseEnable == true) + { worker += ""; + } if (g_callsignLookups.eqslUseEnable == true) + { worker += ""; + } if (g_callsignLookups.oqrsUseEnable == true) + { worker += ""; + } worker += ""; } worker += "
CallsignGridDXCCCQITUFlagQSOQSLWhenITUzCQzISOLoTWeQSLOQRS
" + thisCall + @@ -6666,26 +7639,33 @@ function showCallsignBox(redraw) { "" + ageString + "" + (thisCall in g_lotwCallsigns ? "✔" : "") + "" + (thisCall in g_eqslCallsigns ? "✔" : "") + "" + (thisCall in g_oqrsCallsigns ? "✔" : "") + "
"; @@ -6693,9 +7673,12 @@ function showCallsignBox(redraw) { var heard = 0; var List = {}; - if (Object.keys(g_dxccCount).length > 0) { - for (var key in g_dxccCount) { - if (key != -1) { + if (Object.keys(g_dxccCount).length > 0) + { + for (var key in g_dxccCount) + { + if (key != -1) + { var item = {}; item.total = g_dxccCount[key]; item.confirmed = g_worldGeoData[g_dxccToGeoData[key]].confirmed; @@ -6717,7 +7700,8 @@ function showCallsignBox(redraw) { ")
NameFlagCalls
" + key + ""; @@ -7111,12 +8162,13 @@ function showWorkedBox(sortIndex, nextPage, redraw) { worker += "
" + key.DEcall.formatCallsign() + @@ -7151,20 +8203,26 @@ function showWorkedBox(sortIndex, nextPage, redraw) { userTimeString(key.time * 1000) + "" + (key.DEcall in g_lotwCallsigns ? "✔" : "") + "" + (key.DEcall in g_eqslCallsigns ? "✔" : "") + "" + (key.DEcall in g_oqrsCallsigns ? "✔" : "") + "
NameFlagDXCC
" + key + "
NameFlagDXCC
" + key + "Worked Prefixes (" + worked + @@ -7619,7 +8726,8 @@ function showWPXBox() { "px;'>"; Object.keys(List) .sort() - .forEach(function (key, i) { + .forEach(function (key, i) + { worker += "
" + key.formatCallsign() + @@ -7632,7 +8740,8 @@ function showWPXBox() { worker += ""; } - if (confirmed > 0) { + if (confirmed > 0) + { worker += "
Confirmed Prefixes (" + confirmed + @@ -7643,7 +8752,8 @@ function showWPXBox() { "px;'>"; Object.keys(ListConfirmed) .sort() - .forEach(function (key, i) { + .forEach(function (key, i) + { worker += ""; - for (var key in AwardNames) { + for (var key in AwardNames) + { scoreSection = "Award " + AwardNames[key][1]; var infoObject = output[AwardNames[key][0]]; worker += ""; @@ -8393,7 +9626,8 @@ function renderStatsBox() { infoObject.worked_high + ")"; - if (infoObject.confirmed_high_key) { + if (infoObject.confirmed_high_key) + { worker += ""; - } else worker += ""; + } + else worker += ""; worker += ""; } @@ -8424,7 +9659,8 @@ function renderStatsBox() { g_QSOhash[long_distance.worked_hash].grid + ""; - if (long_distance.confirmed_hash && long_distance.confirmed_unit > 0) { + if (long_distance.confirmed_hash && long_distance.confirmed_unit > 0) + { worker += ""; - } else worker += ""; + } + else worker += ""; scoreSection = "Short Distance"; @@ -8457,7 +9694,8 @@ function renderStatsBox() { g_QSOhash[short_distance.worked_hash].grid + ""; - if (short_distance.confirmed_hash && short_distance.confirmed_unit > 0) { + if (short_distance.confirmed_hash && short_distance.confirmed_unit > 0) + { worker += ""; - } else worker += ""; + } + else worker += ""; worker += ""; worker += "
" + key.formatCallsign() + @@ -7659,34 +8769,44 @@ function showWPXBox() { setStatsDiv("wpxListDiv", worker); } -function showRootInfoBox() { +function showRootInfoBox() +{ openStatsWindow(); - return; } -function showSettingsBox() { +function showSettingsBox() +{ updateRunningProcesses(); helpDiv.style.display = "none"; g_helpShow = false; rootSettingsDiv.style.display = "inline-block"; } -function toggleBaWindow(event) { +function toggleBaWindow(event) +{ event.preventDefault(); - if (g_baWindowHandle == null) { + if (g_baWindowHandle == null) + { openBaWindow(true); - } else { - if (g_baWindowHandle.window.g_isShowing == true) { + } + else + { + if (g_baWindowHandle.window.g_isShowing == true) + { openBaWindow(false); - } else { + } + else + { openBaWindow(true); } } } -function openBaWindow(show = true) { - if (g_baWindowHandle == null) { +function openBaWindow(show = true) +{ + if (g_baWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( @@ -7696,14 +8816,17 @@ function openBaWindow(show = true) { id: "GT-baac", frame: false, resizable: true, - always_on_top: true, + always_on_top: true }, - function (new_win) { + function (new_win) + { g_baWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_baWindowHandle.setMinimumSize(198, 52); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_baWindowHandle.window.g_isShowing = false; g_baWindowHandle.window.saveScreenSettings(); g_baWindowHandle.hide(); @@ -7711,23 +8834,32 @@ function openBaWindow(show = true) { } ); lockNewWindows(); - } else { - try { - if (show == true) { + } + else + { + try + { + if (show == true) + { g_baWindowHandle.show(); g_baWindowHandle.window.g_isShowing = true; g_baWindowHandle.window.saveScreenSettings(); - } else { + } + else + { g_baWindowHandle.window.g_isShowing = false; g_baWindowHandle.window.saveScreenSettings(); g_baWindowHandle.hide(); } - } catch (e) {} + } + catch (e) {} } } -function openLookupWindow(show = false) { - if (g_lookupWindowHandle == null) { +function openLookupWindow(show = false) +{ + if (g_lookupWindowHandle == null) + { popupNewWindows(); var gui = require("nw.gui"); gui.Window.open( @@ -7735,15 +8867,18 @@ function openLookupWindow(show = false) { { show: false, id: "GT-lookups", - icon: "img/lookup-icon.png", + icon: "img/lookup-icon.png" }, - function (new_win) { + function (new_win) + { g_lookupWindowHandle = new_win; - new_win.on("loaded", function () { + new_win.on("loaded", function () + { g_lookupWindowHandle.setMinimumSize(680, 200); g_lookupWindowHandle.setResizable(true); }); - new_win.on("close", function () { + new_win.on("close", function () + { g_lookupWindowHandle.window.g_isShowing = false; g_lookupWindowHandle.window.saveScreenSettings(); g_lookupWindowHandle.hide(); @@ -7751,39 +8886,50 @@ function openLookupWindow(show = false) { } ); lockNewWindows(); - } else { - try { - if (show) { + } + else + { + try + { + if (show) + { g_lookupWindowHandle.show(); g_lookupWindowHandle.window.g_isShowing = true; g_lookupWindowHandle.window.saveScreenSettings(); - } else { + } + else + { g_lookupWindowHandle.hide(); g_lookupWindowHandle.window.g_isShowing = false; g_lookupWindowHandle.window.saveScreenSettings(); } - } catch (e) {} + } + catch (e) {} } } -function openInfoTab(evt, tabName, callFunc, callObj) { +function openInfoTab(evt, tabName, callFunc, callObj) +{ openStatsWindow(); - if (g_statsWindowHandle != null) { + if (g_statsWindowHandle != null) + { // Declare all variables var i, infoTabcontent, infoTablinks; // Get all elements with class="infoTabcontent" and hide them infoTabcontent = g_statsWindowHandle.window.document.getElementsByClassName( "infoTabcontent" ); - for (i = 0; i < infoTabcontent.length; i++) { + for (i = 0; i < infoTabcontent.length; i++) + { infoTabcontent[i].style.display = "none"; } // Get all elements with class="infoTablinks" and remove the class "active" infoTablinks = g_statsWindowHandle.window.document.getElementsByClassName( "infoTablinks" ); - for (i = 0; i < infoTablinks.length; i++) { + for (i = 0; i < infoTablinks.length; i++) + { infoTablinks[i].className = infoTablinks[i].className.replace( " active", "" @@ -7794,33 +8940,39 @@ function openInfoTab(evt, tabName, callFunc, callObj) { g_statsWindowHandle.window.document.getElementById(tabName).style.display = "block"; - if (evt) { + if (evt) + { evt = g_statsWindowHandle.window.document.getElementById(evt); } - if (evt) { + if (evt) + { if (typeof evt.currentTarget != "undefined") - evt.currentTarget.className += " active"; + { evt.currentTarget.className += " active"; } else evt.className += " active"; } - if (callFunc) { + if (callFunc) + { if (callObj) callFunc(callObj); else callFunc(); } } } -function openSettingsTab(evt, tabName) { +function openSettingsTab(evt, tabName) +{ // Declare all variables var i, settingsTabcontent, settingsTablinks; // Get all elements with class="settingsTabcontent" and hide them settingsTabcontent = document.getElementsByClassName("settingsTabcontent"); - for (i = 0; i < settingsTabcontent.length; i++) { + for (i = 0; i < settingsTabcontent.length; i++) + { settingsTabcontent[i].style.display = "none"; } // Get all elements with class="settingsTablinks" and remove the class "active" settingsTablinks = document.getElementsByClassName("settingsTablinks"); - for (i = 0; i < settingsTablinks.length; i++) { + for (i = 0; i < settingsTablinks.length; i++) + { settingsTablinks[i].className = settingsTablinks[i].className.replace( " active", "" @@ -7830,25 +8982,28 @@ function openSettingsTab(evt, tabName) { // Show the current tab, and add an "active" class to the button that opened the tab document.getElementById(tabName).style.display = "block"; if (typeof evt.currentTarget != "undefined") - evt.currentTarget.className += " active"; + { evt.currentTarget.className += " active"; } else evt.className += " active"; } -function setGridMode(mode) { +function setGridMode(mode) +{ g_appSettings.sixWideMode = mode; modeImg.src = g_maidenheadModeImageArray[g_appSettings.sixWideMode]; clearTempGrids(); redrawGrids(); } -function toggleGridMode() { +function toggleGridMode() +{ g_appSettings.sixWideMode ^= 1; modeImg.src = g_maidenheadModeImageArray[g_appSettings.sixWideMode]; clearTempGrids(); redrawGrids(); } -function newStatObject() { +function newStatObject() +{ var statObject = {}; statObject.worked = 0; statObject.confirmed = 0; @@ -7861,7 +9016,8 @@ function newStatObject() { return statObject; } -function newStatCountObject() { +function newStatCountObject() +{ var statCountObject = {}; statCountObject.worked = 0; @@ -7881,7 +9037,8 @@ function newStatCountObject() { return statCountObject; } -function newDistanceObject(start = 0) { +function newDistanceObject(start = 0) +{ var distance = {}; distance.worked_unit = start; distance.worked_hash = ""; @@ -7890,7 +9047,8 @@ function newDistanceObject(start = 0) { return distance; } -function newModeType() { +function newModeType() +{ var modeType = {}; modeType.worked = 0; modeType.confirmed = 0; @@ -7900,24 +9058,29 @@ function newModeType() { var g_statBoxTimer = null; -function showStatBox(resize) { +function showStatBox(resize) +{ var count = Object.keys(g_QSOhash).length; - if (typeof resize != "undefined" && resize) { + if (typeof resize != "undefined" && resize) + { setStatsDivHeight("statViewDiv", getStatsWindowHeight() + 29 + "px"); return; } if (g_statBoxTimer) clearTimeout(g_statBoxTimer); - if (count > 0) { + if (count > 0) + { setStatsDiv( "statViewDiv", " 
...Parsing Log Entries...
 " ); setStatsDivHeight("statViewDiv", "auto"); g_statBoxTimer = setTimeout(renderStatsBox, 250); - } else { + } + else + { setStatsDiv( "statViewDiv", " 
No log entries available, load one or more ADIF logs
 " @@ -7926,8 +9089,10 @@ function showStatBox(resize) { } } -function getTypeFromMode(mode) { - if (mode in g_modes) { +function getTypeFromMode(mode) +{ + if (mode in g_modes) + { if (g_modes[mode] == true) return "Digital"; else if (g_modes_phone[mode] == true) return "Phone"; else if (mode == "CW") return "CW"; @@ -7935,34 +9100,40 @@ function getTypeFromMode(mode) { return "Other"; } -function workObject(obj, count, band, mode, type, didConfirm) { +function workObject(obj, count, band, mode, type, didConfirm) +{ obj.worked++; obj.worked_bands[band] = ~~obj.worked_bands[band] + 1; obj.worked_modes[mode] = ~~obj.worked_modes[mode] + 1; - if (!count) { - obj.worked_types["Mixed"] = ~~obj.worked_modes["Mixed"] + 1; + if (!count) + { + obj.worked_types.Mixed = ~~obj.worked_modes.Mixed + 1; if (type) obj.worked_types[type] = ~~obj.worked_modes[type] + 1; } - if (didConfirm) { + if (didConfirm) + { obj.confirmed++; obj.confirmed_bands[band] = ~~obj.confirmed_bands[band] + 1; obj.confirmed_modes[mode] = ~~obj.confirmed_modes[mode] + 1; - if (!count) { - obj.confirmed_types["Mixed"] = ~~obj.confirmed_types["Mixed"] + 1; + if (!count) + { + obj.confirmed_types.Mixed = ~~obj.confirmed_types.Mixed + 1; if (type) obj.confirmed_types[type] = ~~obj.confirmed_types[type] + 1; } } return obj; } -function renderStatsBox() { +function renderStatsBox() +{ var worker = ""; var scoreSection = "Initial"; - try { + try + { var worldGeoData = {}; var cqZones = {}; var ituZones = {}; @@ -7998,7 +9169,8 @@ function renderStatsBox() { scoreSection = "QSO"; - for (var i in g_QSOhash) { + for (var i in g_QSOhash) + { var finalGrid = g_QSOhash[i].grid; var didConfirm = g_QSOhash[i].confirmed; var band = g_QSOhash[i].band; @@ -8021,29 +9193,40 @@ function renderStatsBox() { details.callsigns[call] = ~~details.callsigns[call] + 1; if (g_QSOhash[i].time < details.oldest) - details.oldest = g_QSOhash[i].time; + { details.oldest = g_QSOhash[i].time; } if (g_QSOhash[i].time > details.newest) - details.newest = g_QSOhash[i].time; + { details.newest = g_QSOhash[i].time; } workObject(modet.Mixed, true, band, mode, type, didConfirm); - if (mode in g_modes) { - if (g_modes[mode] == true) { + if (mode in g_modes) + { + if (g_modes[mode] == true) + { workObject(modet.Digital, true, band, mode, type, didConfirm); - } else if (g_modes_phone[mode] == true) { + } + else if (g_modes_phone[mode] == true) + { workObject(modet.Phone, true, band, mode, type, didConfirm); - } else if (mode == "CW") { + } + else if (mode == "CW") + { workObject(modet.CW, true, band, mode, type, didConfirm); - } else workObject(modet.Other, true, band, mode, type, didConfirm); - } else workObject(modet.Other, true, band, mode, type, didConfirm); + } + else workObject(modet.Other, true, band, mode, type, didConfirm); + } + else workObject(modet.Other, true, band, mode, type, didConfirm); - if (state != null && isKnownCallsignUS(finalDxcc)) { + if (state != null && isKnownCallsignUS(finalDxcc)) + { if (state.substr(0, 2) != "US") state = "US-" + state; - if (state in g_StateData) { + if (state in g_StateData) + { var name = g_StateData[state].name; - if (name in g_wasZones) { + if (name in g_wasZones) + { if (!(name in wasZones)) wasZones[name] = newStatObject(); workObject(wasZones[name], false, band, mode, type, didConfirm); @@ -8051,29 +9234,36 @@ function renderStatsBox() { } } - if (wpx != null) { + if (wpx != null) + { if (!(wpx in wpxData)) wpxData[wpx] = newStatObject(); workObject(wpxData[wpx], false, band, mode, type, didConfirm); } - if (who in g_gtCallsigns) { + if (who in g_gtCallsigns) + { if (!(i in gtData)) gtData[i] = newStatObject(); gtData[i] = true; } - if (cnty != null) { - if (cnty in g_cntyToCounty) { + if (cnty != null) + { + if (cnty in g_cntyToCounty) + { if (!(cnty in countyData)) countyData[cnty] = newStatObject(); workObject(countyData[cnty], false, band, mode, type, didConfirm); } } - if (cont != null) { - if (cont in g_shapeData) { + if (cont != null) + { + if (cont in g_shapeData) + { var name = g_shapeData[cont].properties.name; - if (name in g_wacZones) { + if (name in g_wacZones) + { if (!(name in wacZones)) wacZones[name] = newStatObject(); workObject(wacZones[name], false, band, mode, type, didConfirm); @@ -8081,7 +9271,8 @@ function renderStatsBox() { } } - if (finalGrid.length > 0) { + if (finalGrid.length > 0) + { LL = squareToLatLongAll(finalGrid); unit = parseInt( MyCircle.distance( @@ -8093,91 +9284,110 @@ function renderStatsBox() { ) * MyCircle.validateRadius(distanceUnit.value) ); - if (unit > long_distance.worked_unit) { + if (unit > long_distance.worked_unit) + { long_distance.worked_unit = unit; long_distance.worked_hash = i; } if (!(band in long_distance.band)) - long_distance.band[band] = newDistanceObject(); + { long_distance.band[band] = newDistanceObject(); } if (!(mode in long_distance.mode)) - long_distance.mode[mode] = newDistanceObject(); + { long_distance.mode[mode] = newDistanceObject(); } if (!(type in long_distance.type)) - long_distance.type[type] = newDistanceObject(); + { long_distance.type[type] = newDistanceObject(); } - if (unit > long_distance.mode[mode].worked_unit) { + if (unit > long_distance.mode[mode].worked_unit) + { long_distance.mode[mode].worked_unit = unit; long_distance.mode[mode].worked_hash = i; } - if (unit > long_distance.band[band].worked_unit) { + if (unit > long_distance.band[band].worked_unit) + { long_distance.band[band].worked_unit = unit; long_distance.band[band].worked_hash = i; } - if (unit > long_distance.type[type].worked_unit) { + if (unit > long_distance.type[type].worked_unit) + { long_distance.type[type].worked_unit = unit; long_distance.type[type].worked_hash = i; } - if (didConfirm) { - if (unit > long_distance.confirmed_unit) { + if (didConfirm) + { + if (unit > long_distance.confirmed_unit) + { long_distance.confirmed_unit = unit; long_distance.confirmed_hash = i; } - if (unit > long_distance.mode[mode].confirmed_unit) { + if (unit > long_distance.mode[mode].confirmed_unit) + { long_distance.mode[mode].confirmed_unit = unit; long_distance.mode[mode].confirmed_hash = i; } - if (unit > long_distance.band[band].confirmed_unit) { + if (unit > long_distance.band[band].confirmed_unit) + { long_distance.band[band].confirmed_unit = unit; long_distance.band[band].confirmed_hash = i; } - if (unit > long_distance.type[type].confirmed_unit) { + if (unit > long_distance.type[type].confirmed_unit) + { long_distance.type[type].confirmed_unit = unit; long_distance.type[type].confirmed_hash = i; } } - if (unit > 0) { - if (unit < short_distance.worked_unit) { + if (unit > 0) + { + if (unit < short_distance.worked_unit) + { short_distance.worked_unit = unit; short_distance.worked_hash = i; } if (!(band in short_distance.band)) - short_distance.band[band] = newDistanceObject(100000); + { short_distance.band[band] = newDistanceObject(100000); } if (!(mode in short_distance.mode)) - short_distance.mode[mode] = newDistanceObject(100000); + { short_distance.mode[mode] = newDistanceObject(100000); } if (!(type in short_distance.type)) - short_distance.type[type] = newDistanceObject(100000); + { short_distance.type[type] = newDistanceObject(100000); } - if (unit < short_distance.mode[mode].worked_unit) { + if (unit < short_distance.mode[mode].worked_unit) + { short_distance.mode[mode].worked_unit = unit; short_distance.mode[mode].worked_hash = i; } - if (unit < short_distance.band[band].worked_unit) { + if (unit < short_distance.band[band].worked_unit) + { short_distance.band[band].worked_unit = unit; short_distance.band[band].worked_hash = i; } - if (unit < short_distance.type[type].worked_unit) { + if (unit < short_distance.type[type].worked_unit) + { short_distance.type[type].worked_unit = unit; short_distance.type[type].worked_hash = i; } - if (didConfirm) { - if (unit < short_distance.confirmed_unit) { + if (didConfirm) + { + if (unit < short_distance.confirmed_unit) + { short_distance.confirmed_unit = unit; short_distance.confirmed_hash = i; } - if (unit < short_distance.mode[mode].confirmed_unit) { + if (unit < short_distance.mode[mode].confirmed_unit) + { short_distance.mode[mode].confirmed_unit = unit; short_distance.mode[mode].confirmed_hash = i; } - if (unit < short_distance.band[band].confirmed_unit) { + if (unit < short_distance.band[band].confirmed_unit) + { short_distance.band[band].confirmed_unit = unit; short_distance.band[band].confirmed_hash = i; } - if (unit < short_distance.type[type].confirmed_unit) { + if (unit < short_distance.type[type].confirmed_unit) + { short_distance.type[type].confirmed_unit = unit; short_distance.type[type].confirmed_hash = i; } @@ -8186,7 +9396,7 @@ function renderStatsBox() { } if (!(g_dxccToAltName[finalDxcc] in worldGeoData)) - worldGeoData[g_dxccToAltName[finalDxcc]] = newStatObject(); + { worldGeoData[g_dxccToAltName[finalDxcc]] = newStatObject(); } workObject( worldGeoData[g_dxccToAltName[finalDxcc]], @@ -8197,16 +9407,21 @@ function renderStatsBox() { didConfirm ); - if (finalGrid.length > 0) { + if (finalGrid.length > 0) + { var gridCheck = finalGrid.substr(0, 4); - if (cqz.length > 0) { + if (cqz.length > 0) + { var name = g_cqZones[cqz].name; if (!(name in cqZones)) cqZones[name] = newStatObject(); workObject(cqZones[name], false, band, mode, type, didConfirm); - } else if (gridCheck in g_gridToCQZone) { - if (g_gridToCQZone[gridCheck].length == 1) { + } + else if (gridCheck in g_gridToCQZone) + { + if (g_gridToCQZone[gridCheck].length == 1) + { var name = g_cqZones[g_gridToCQZone[gridCheck][0]].name; if (!(name in cqZones)) cqZones[name] = newStatObject(); @@ -8214,14 +9429,18 @@ function renderStatsBox() { } } - if (ituz.length > 0) { + if (ituz.length > 0) + { if (!(ituz in ituZones)) ituZones[ituz] = newStatObject(); workObject(ituZones[ituz], false, band, mode, type, didConfirm); - } else if (gridCheck in g_gridToITUZone) { - if (g_gridToITUZone[gridCheck].length == 1) { + } + else if (gridCheck in g_gridToITUZone) + { + if (g_gridToITUZone[gridCheck].length == 1) + { if (!(g_gridToITUZone[gridCheck][0] in ituZones)) - ituZones[g_gridToITUZone[gridCheck][0]] = newStatObject(); + { ituZones[g_gridToITUZone[gridCheck][0]] = newStatObject(); } workObject( ituZones[g_gridToITUZone[gridCheck][0]], @@ -8246,58 +9465,70 @@ function renderStatsBox() { var output = {}; worldGeoData.order = 1; - stats["DXCC"] = worldGeoData; - stats["GRID"] = gridData; - stats["CQ"] = cqZones; - stats["ITU"] = ituZones; - stats["WAC"] = wacZones; - stats["WAS"] = wasZones; - stats["USC"] = countyData; - stats["WPX"] = wpxData; - stats["WRFA"] = callData; + stats.DXCC = worldGeoData; + stats.GRID = gridData; + stats.CQ = cqZones; + stats.ITU = ituZones; + stats.WAC = wacZones; + stats.WAS = wasZones; + stats.USC = countyData; + stats.WPX = wpxData; + stats.WRFA = callData; - for (i in stats) { + for (i in stats) + { output[i] = newStatCountObject(); - for (var key in stats[i]) { - if (stats[i][key].worked) { + for (var key in stats[i]) + { + if (stats[i][key].worked) + { output[i].worked++; - if (stats[i][key].worked > output[i].worked_high) { + if (stats[i][key].worked > output[i].worked_high) + { output[i].worked_high = stats[i][key].worked; output[i].worked_high_key = key; } } - if (stats[i][key].confirmed) { + if (stats[i][key].confirmed) + { output[i].confirmed++; - if (stats[i][key].confirmed > output[i].confirmed_high) { + if (stats[i][key].confirmed > output[i].confirmed_high) + { output[i].confirmed_high = stats[i][key].confirmed; output[i].confirmed_high_key = key; } } - for (var band in stats[i][key].worked_bands) { + for (var band in stats[i][key].worked_bands) + { output[i].worked_bands[band] = ~~output[i].worked_bands[band] + 1; } - for (var band in stats[i][key].confirmed_bands) { + for (var band in stats[i][key].confirmed_bands) + { output[i].confirmed_bands[band] = ~~output[i].confirmed_bands[band] + 1; } - for (var mode in stats[i][key].worked_modes) { + for (var mode in stats[i][key].worked_modes) + { output[i].worked_modes[mode] = ~~output[i].worked_modes[mode] + 1; } - for (var mode in stats[i][key].confirmed_modes) { + for (var mode in stats[i][key].confirmed_modes) + { output[i].confirmed_modes[mode] = ~~output[i].confirmed_modes[mode] + 1; } - for (var type in stats[i][key].worked_types) { + for (var type in stats[i][key].worked_types) + { output[i].worked_types[type] = ~~output[i].worked_types[type] + 1; } - for (var type in stats[i][key].confirmed_types) { + for (var type in stats[i][key].confirmed_types) + { output[i].confirmed_types[type] = ~~output[i].confirmed_types[type] + 1; } @@ -8308,13 +9539,14 @@ function renderStatsBox() { scoreSection = "Modes"; - output["MIXED"] = modet.Mixed; - output["DIGITAL"] = modet.Digital; - output["PHONE"] = modet.Phone; - output["CW"] = modet.CW; - output["Other"] = modet.Other; + output.MIXED = modet.Mixed; + output.DIGITAL = modet.Digital; + output.PHONE = modet.Phone; + output.CW = modet.CW; + output.Other = modet.Other; - for (var i in output) { + for (var i in output) + { output[i].worked_band_count = Object.keys(output[i].worked_bands).length; output[i].confirmed_band_count = Object.keys( output[i].confirmed_bands @@ -8334,7 +9566,7 @@ function renderStatsBox() { 1: ["DIGITAL", "Digital", ""], 2: ["PHONE", "Phone", ""], 3: ["CW", "CW", ""], - 4: ["Other", "Other", ""], + 4: ["Other", "Other", ""] }; var AwardNames = { @@ -8346,7 +9578,7 @@ function renderStatsBox() { 5: ["WAC", "Continents", "WAC", "cyan"], 6: ["WAS", "US States", "WAS", "lightblue"], 7: ["USC", "US Counties", "USA-CA", "orange"], - 8: ["WPX", "Prefixes", "WPX", "yellow"], + 8: ["WPX", "Prefixes", "WPX", "yellow"] }; worker = ""; @@ -8380,7 +9612,8 @@ function renderStatsBox() { worker += "
Top ScoreWorkedConfirmed
" + AwardNames[key][1] + " (" + infoObject.confirmed_high + ")
" + long_distance.confirmed_unit + @@ -8438,7 +9674,8 @@ function renderStatsBox() { " " + g_QSOhash[long_distance.confirmed_hash].grid + "" + short_distance.confirmed_unit + @@ -8471,7 +9709,8 @@ function renderStatsBox() { " " + g_QSOhash[short_distance.confirmed_hash].grid + "
"; @@ -8480,11 +9719,13 @@ function renderStatsBox() { scoreSection = "Award Types"; for (var key in AwardNames) + { worker += createStatTable( AwardNames[key][1], output[AwardNames[key][0]], AwardNames[key][2] ); + } worker += "
"; @@ -8492,11 +9733,13 @@ function renderStatsBox() { worker += "

Mode Types

"; for (var key in TypeNames) + { worker += createStatTable( TypeNames[key][1], output[TypeNames[key][0]], TypeNames[key][2] ); + } worker += "
"; @@ -8506,7 +9749,8 @@ function renderStatsBox() { worker += createDistanceTable(short_distance, "Shortest Distance"); worker += "
"; - if (g_appSettings.gtShareEnable == true) { + if (g_appSettings.gtShareEnable == true) + { scoreSection = "GT Users"; worker += "

Worked GridTracker Stations
Online Now

"; worker += "
"; @@ -8516,7 +9760,9 @@ function renderStatsBox() { worker += ""; } worker += ""; - } catch (e) { + } + catch (e) + { worker += "
In Section: " + scoreSection + @@ -8527,37 +9773,41 @@ function renderStatsBox() { setStatsDivHeight("statViewDiv", getStatsWindowHeight() + 29 + "px"); } -function hashNameSort(a, b) { +function hashNameSort(a, b) +{ if (g_QSOhash[a].DEcall > g_QSOhash[b].DEcall) return 1; if (g_QSOhash[b].DEcall > g_QSOhash[a].DEcall) return -1; return 0; } -function createGtStationsTable(obj) { +function createGtStationsTable(obj) +{ var worker = ""; worker += ""; var keys = Object.keys(obj).sort(hashNameSort); - for (var key in keys) { + for (var key in keys) + { var callsign = g_QSOhash[keys[key]]; var bgDX = " style='font-weight:bold;color:cyan;' "; var bgDE = " style='font-weight:bold;color:yellow;' "; if (typeof callsign.msg == "undefined" || callsign.msg == "") - callsign.msg = "-"; + { callsign.msg = "-"; } var ageString = ""; if (timeNowSec() - callsign.time < 3601) - ageString = (timeNowSec() - callsign.time).toDHMS(); - else { + { ageString = (timeNowSec() - callsign.time).toDHMS(); } + else + { ageString = userTimeString(callsign.time * 1000); } worker += ""; worker += "
" + callsign.DEcall.formatCallsign() + @@ -8596,7 +9846,8 @@ function createGtStationsTable(obj) { return worker; } -function createDistanceTable(obj, name) { +function createDistanceTable(obj, name) +{ var worker = "
CallGridSentRcvdModeBandQSLCommentDXCCTime
"; worker += @@ -8608,7 +9859,8 @@ function createDistanceTable(obj, name) { worker += ""; worker += ""; worker += ""; @@ -8662,7 +9917,8 @@ function createDistanceTable(obj, name) { worker += ""; worker += ""; worker += ""; worker += ""; worker += ""; worker += ""; worker += ""; worker += ""; @@ -8769,16 +10032,19 @@ function createDistanceTable(obj, name) { return worker; } -function numberSort(a, b) { +function numberSort(a, b) +{ if (parseInt(a) > parseInt(b)) return 1; if (parseInt(b) > parseInt(a)) return -1; return 0; } -function createStatTable(title, infoObject, awardName) { +function createStatTable(title, infoObject, awardName) +{ var wc1Table = ""; - if (infoObject.worked) { + if (infoObject.worked) + { wc1Table = "
Bands"; var keys = Object.keys(obj.band).sort(numberSort); - for (var key in keys) { + for (var key in keys) + { var grid = g_QSOhash[obj.band[keys[key]].worked_hash].grid; var call = g_QSOhash[obj.band[keys[key]].worked_hash].DEcall; worker += @@ -8622,7 +9874,7 @@ function createDistanceTable(obj, name) { worker += "
" + call + @@ -8632,8 +9884,10 @@ function createDistanceTable(obj, name) { } worker += "
"; - for (var key in keys) { - if (keys[key] in obj.band && obj.band[keys[key]].confirmed_hash) { + for (var key in keys) + { + if (keys[key] in obj.band && obj.band[keys[key]].confirmed_hash) + { var grid = g_QSOhash[obj.band[keys[key]].confirmed_hash].grid; var call = g_QSOhash[obj.band[keys[key]].confirmed_hash].DEcall; worker += @@ -8647,14 +9901,15 @@ function createDistanceTable(obj, name) { worker += ""; worker += ""; worker += ""; - } else worker += ""; + } + else worker += ""; } worker += "
" + call + "" + grid + "
 
 
Modes"; keys = Object.keys(obj.mode).sort(); - for (var key in keys) { + for (var key in keys) + { var grid = g_QSOhash[obj.mode[keys[key]].worked_hash].grid; var call = g_QSOhash[obj.mode[keys[key]].worked_hash].DEcall; worker += @@ -8676,7 +9932,7 @@ function createDistanceTable(obj, name) { worker += "
" + call + @@ -8686,8 +9942,10 @@ function createDistanceTable(obj, name) { } worker += "
"; - for (var key in keys) { - if (keys[key] in obj.mode && obj.mode[keys[key]].confirmed_hash) { + for (var key in keys) + { + if (keys[key] in obj.mode && obj.mode[keys[key]].confirmed_hash) + { var grid = g_QSOhash[obj.mode[keys[key]].confirmed_hash].grid; var call = g_QSOhash[obj.mode[keys[key]].confirmed_hash].DEcall; worker += @@ -8701,21 +9959,23 @@ function createDistanceTable(obj, name) { worker += ""; worker += ""; worker += ""; - } else worker += ""; + } + else worker += ""; } worker += "
" + call + "" + grid + "
 
 
Types"; keys = Object.keys(obj.type).sort(); - for (var key in keys) { + for (var key in keys) + { var grid = g_QSOhash[obj.type[keys[key]].worked_hash].grid; var call = g_QSOhash[obj.type[keys[key]].worked_hash].DEcall; worker += @@ -8729,7 +9989,7 @@ function createDistanceTable(obj, name) { worker += "
" + call + @@ -8739,8 +9999,10 @@ function createDistanceTable(obj, name) { } worker += "
"; - for (var key in keys) { - if (keys[key] in obj.type && obj.type[keys[key]].confirmed_hash) { + for (var key in keys) + { + if (keys[key] in obj.type && obj.type[keys[key]].confirmed_hash) + { var grid = g_QSOhash[obj.type[keys[key]].confirmed_hash].grid; var call = g_QSOhash[obj.type[keys[key]].confirmed_hash].DEcall; worker += @@ -8754,14 +10016,15 @@ function createDistanceTable(obj, name) { worker += ""; worker += ""; worker += ""; - } else worker += ""; + } + else worker += ""; } worker += "
" + call + "" + grid + "
 
 
"; wc1Table += @@ -8801,7 +10067,8 @@ function createStatTable(title, infoObject, awardName) { wc1Table += ""; wc1Table += ""; wc1Table += ""; @@ -8830,7 +10100,8 @@ function createStatTable(title, infoObject, awardName) { wc1Table += ""; wc1Table += "
"; var keys = Object.keys(infoObject.worked_bands).sort(numberSort); - for (var key in keys) { + for (var key in keys) + { wc1Table += "
" + keys[key] + @@ -8813,15 +10080,18 @@ function createStatTable(title, infoObject, awardName) { wc1Table += "
"; - for (var key in keys) { - if (keys[key] in infoObject.confirmed_bands) { + for (var key in keys) + { + if (keys[key] in infoObject.confirmed_bands) + { wc1Table += ""; - } else wc1Table += ""; + } + else wc1Table += ""; } wc1Table += "
" + keys[key] + " (" + infoObject.confirmed_bands[keys[key]] + ")
 
 
Modes"; keys = Object.keys(infoObject.worked_modes).sort(); - for (var key in keys) { + for (var key in keys) + { wc1Table += ""; wc1Table += ""; - if (infoObject.worked_type_count > 0) { + if (infoObject.worked_type_count > 0) + { wc1Table += ""; wc1Table += ""; wc1Table += "
" + keys[key] + @@ -8843,26 +10114,31 @@ function createStatTable(title, infoObject, awardName) { wc1Table += ""; - for (var key in keys) { - if (keys[key] in infoObject.confirmed_modes) { + for (var key in keys) + { + if (keys[key] in infoObject.confirmed_modes) + { wc1Table += ""; - } else wc1Table += ""; + } + else wc1Table += ""; } wc1Table += "
" + keys[key] + " (" + infoObject.confirmed_modes[keys[key]] + ")
 
 
Types"; var keys = Object.keys(infoObject.worked_types).sort(); - for (var key in keys) { + for (var key in keys) + { wc1Table += ""; @@ -8898,22 +10177,26 @@ function createStatTable(title, infoObject, awardName) { return wc1Table; } -function validatePropMode(propMode) { +function validatePropMode(propMode) +{ if (g_appSettings.gtPropFilter == "mixed") return true; return g_appSettings.gtPropFilter == propMode; } -function validateMapMode(mode) { +function validateMapMode(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.gtModeFilter == "Digital") + { if (mode in g_modes && g_modes[mode]) return true; return false; } - if (g_appSettings.gtModeFilter == "Phone") { + if (g_appSettings.gtModeFilter == "Phone") + { if (mode in g_modes_phone && g_modes_phone[mode]) return true; return false; } @@ -8923,7 +10206,8 @@ function validateMapMode(mode) { return g_appSettings.gtModeFilter == mode; } -function redrawGrids() { +function redrawGrids() +{ if (g_appSettings.gridViewMode == 2) removePaths(); clearGrids(); clearQsoGrids(); @@ -8931,7 +10215,8 @@ function redrawGrids() { g_QSLcount = 0; g_QSOcount = 0; - for (var i in g_QSOhash) { + for (var i in g_QSOhash) + { var finalGrid = g_QSOhash[i].grid; var worked = g_QSOhash[i].worked; var didConfirm = g_QSOhash[i].confirmed; @@ -8947,8 +10232,10 @@ function redrawGrids() { : 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) + { g_QSOhash[i].rect = qthToQsoBox( g_QSOhash[i].grid, i, @@ -8961,7 +10248,8 @@ function redrawGrids() { g_QSOhash[i].band, g_QSOhash[i].wspr ); - for (var vucc in g_QSOhash[i].vucc_grids) { + for (var vucc in g_QSOhash[i].vucc_grids) + { qthToQsoBox( g_QSOhash[i].vucc_grids[vucc], i, @@ -8984,26 +10272,33 @@ function redrawGrids() { var ituz = g_QSOhash[i].ituz; var cqz = g_QSOhash[i].cqz; - if (state != null && isKnownCallsignUS(finalDxcc)) { + if (state != null && isKnownCallsignUS(finalDxcc)) + { if (state.substr(0, 2) != "US") state = "US-" + state; - if (state in g_StateData) { + if (state in g_StateData) + { var name = g_StateData[state].name; - if (name in g_wasZones) { - if (g_wasZones[name].worked == false) { + if (name in g_wasZones) + { + if (g_wasZones[name].worked == false) + { g_wasZones[name].worked = worked; } - if (worked) { + if (worked) + { g_wasZones[name].worked_bands[band] = ~~g_wasZones[name].worked_bands[band] + 1; g_wasZones[name].worked_modes[mode] = ~~g_wasZones[name].worked_modes[mode] + 1; } - if (g_wasZones[name].confirmed == false) { + if (g_wasZones[name].confirmed == false) + { g_wasZones[name].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_wasZones[name].confirmed_bands[band] = ~~g_wasZones[name].confirmed_bands[band] + 1; g_wasZones[name].confirmed_modes[mode] = @@ -9013,21 +10308,27 @@ function redrawGrids() { } } - if (cnty != null) { - if (cnty in g_cntyToCounty) { - if (g_countyData[cnty].worked == false) { + if (cnty != null) + { + if (cnty in g_cntyToCounty) + { + if (g_countyData[cnty].worked == false) + { g_countyData[cnty].worked = worked; } - if (worked) { + if (worked) + { g_countyData[cnty].worked_bands[band] = ~~g_countyData[cnty].worked_bands[band] + 1; g_countyData[cnty].worked_modes[mode] = ~~g_countyData[cnty].worked_modes[mode] + 1; } - if (g_countyData[cnty].confirmed == false) { + if (g_countyData[cnty].confirmed == false) + { g_countyData[cnty].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_countyData[cnty].confirmed_bands[band] = ~~g_countyData[cnty].confirmed_bands[band] + 1; g_countyData[cnty].confirmed_modes[mode] = @@ -9035,24 +10336,31 @@ function redrawGrids() { } } } - if (cont != null) { - if (cont in g_shapeData) { + if (cont != null) + { + if (cont in g_shapeData) + { var name = g_shapeData[cont].properties.name; - if (name in g_wacZones) { - if (g_wacZones[name].worked == false) { + if (name in g_wacZones) + { + if (g_wacZones[name].worked == false) + { g_wacZones[name].worked = worked; } - if (worked) { + if (worked) + { g_wacZones[name].worked_bands[band] = ~~g_wacZones[name].worked_bands[band] + 1; g_wacZones[name].worked_modes[mode] = ~~g_wacZones[name].worked_modes[mode] + 1; } - if (g_wacZones[name].confirmed == false) { + if (g_wacZones[name].confirmed == false) + { g_wacZones[name].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_wacZones[name].confirmed_bands[band] = ~~g_wacZones[name].confirmed_bands[band] + 1; g_wacZones[name].confirmed_modes[mode] = @@ -9062,19 +10370,23 @@ function redrawGrids() { } } - if (g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked == false) { + if (g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked == false) + { g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked = worked; } - if (worked) { + if (worked) + { g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked_bands[band] = ~~g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked_bands[band] + 1; g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked_modes[mode] = ~~g_worldGeoData[g_dxccToGeoData[finalDxcc]].worked_modes[mode] + 1; } - if (g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed == false) { + if (g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed == false) + { g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed_bands[band] = ~~g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed_bands[band] + 1; @@ -9082,23 +10394,29 @@ function redrawGrids() { ~~g_worldGeoData[g_dxccToGeoData[finalDxcc]].confirmed_modes[mode] + 1; } - if (finalGrid.length > 0) { + if (finalGrid.length > 0) + { var gridCheck = finalGrid.substr(0, 4); - if (gridCheck in g_us48Data) { - if (g_us48Data[gridCheck].worked == false) { + if (gridCheck in g_us48Data) + { + if (g_us48Data[gridCheck].worked == false) + { g_us48Data[gridCheck].worked = worked; } - if (worked) { + if (worked) + { g_us48Data[gridCheck].worked_bands[band] = ~~g_us48Data[gridCheck].worked_bands[band] + 1; g_us48Data[gridCheck].worked_modes[mode] = ~~g_us48Data[gridCheck].worked_modes[mode] + 1; } - if (g_us48Data[gridCheck].confirmed == false) { + if (g_us48Data[gridCheck].confirmed == false) + { g_us48Data[gridCheck].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_us48Data[gridCheck].confirmed_bands[band] = ~~g_us48Data[gridCheck].confirmed_bands[band] + 1; g_us48Data[gridCheck].confirmed_modes[mode] = @@ -9106,31 +10424,41 @@ function redrawGrids() { } } - if (cqz.length > 0) { - if (g_cqZones[cqz].worked == false) { + if (cqz.length > 0) + { + if (g_cqZones[cqz].worked == false) + { g_cqZones[cqz].worked = worked; } - if (worked) { + if (worked) + { g_cqZones[cqz].worked_bands[band] = ~~g_cqZones[cqz].worked_bands[band] + 1; g_cqZones[cqz].worked_modes[mode] = ~~g_cqZones[cqz].worked_modes[mode] + 1; } - if (g_cqZones[cqz].confirmed == false) { + if (g_cqZones[cqz].confirmed == false) + { g_cqZones[cqz].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_cqZones[cqz].confirmed_bands[band] = ~~g_cqZones[cqz].confirmed_bands[band] + 1; g_cqZones[cqz].confirmed_modes[mode] = ~~g_cqZones[cqz].confirmed_modes[mode] + 1; } - } else if (gridCheck in g_gridToCQZone) { - if (g_gridToCQZone[gridCheck].length == 1) { - if (g_cqZones[g_gridToCQZone[gridCheck][0]].worked == false) { + } + else if (gridCheck in g_gridToCQZone) + { + if (g_gridToCQZone[gridCheck].length == 1) + { + if (g_cqZones[g_gridToCQZone[gridCheck][0]].worked == false) + { g_cqZones[g_gridToCQZone[gridCheck][0]].worked = worked; } - if (worked) { + if (worked) + { g_cqZones[g_gridToCQZone[gridCheck][0]].worked_bands[band] = ~~g_cqZones[g_gridToCQZone[gridCheck][0]].worked_bands[band] + 1; @@ -9138,10 +10466,12 @@ function redrawGrids() { ~~g_cqZones[g_gridToCQZone[gridCheck][0]].worked_modes[mode] + 1; } - if (g_cqZones[g_gridToCQZone[gridCheck][0]].confirmed == false) { + if (g_cqZones[g_gridToCQZone[gridCheck][0]].confirmed == false) + { g_cqZones[g_gridToCQZone[gridCheck][0]].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_cqZones[g_gridToCQZone[gridCheck][0]].confirmed_bands[band] = ~~g_cqZones[g_gridToCQZone[gridCheck][0]].confirmed_bands[ band @@ -9154,31 +10484,41 @@ function redrawGrids() { } } - if (ituz.length > 0) { - if (g_ituZones[ituz].worked == false) { + if (ituz.length > 0) + { + if (g_ituZones[ituz].worked == false) + { g_ituZones[ituz].worked = worked; } - if (worked) { + if (worked) + { g_ituZones[ituz].worked_bands[band] = ~~g_ituZones[ituz].worked_bands[band] + 1; g_ituZones[ituz].worked_modes[mode] = ~~g_ituZones[ituz].worked_modes[mode] + 1; } - if (g_ituZones[ituz].confirmed == false) { + if (g_ituZones[ituz].confirmed == false) + { g_ituZones[ituz].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_ituZones[ituz].confirmed_bands[band] = ~~g_ituZones[ituz].confirmed_bands[band] + 1; g_ituZones[ituz].confirmed_modes[mode] = ~~g_ituZones[ituz].confirmed_modes[mode] + 1; } - } else if (gridCheck in g_gridToITUZone) { - if (g_gridToITUZone[gridCheck].length == 1) { - if (g_ituZones[g_gridToITUZone[gridCheck][0]].worked == false) { + } + else if (gridCheck in g_gridToITUZone) + { + if (g_gridToITUZone[gridCheck].length == 1) + { + if (g_ituZones[g_gridToITUZone[gridCheck][0]].worked == false) + { g_ituZones[g_gridToITUZone[gridCheck][0]].worked = worked; } - if (worked) { + if (worked) + { g_ituZones[g_gridToITUZone[gridCheck][0]].worked_bands[band] = ~~g_ituZones[g_gridToITUZone[gridCheck][0]].worked_bands[band] + 1; @@ -9186,10 +10526,12 @@ function redrawGrids() { ~~g_ituZones[g_gridToITUZone[gridCheck][0]].worked_modes[mode] + 1; } - if (g_ituZones[g_gridToITUZone[gridCheck][0]].confirmed == false) { + if (g_ituZones[g_gridToITUZone[gridCheck][0]].confirmed == false) + { g_ituZones[g_gridToITUZone[gridCheck][0]].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_ituZones[g_gridToITUZone[gridCheck][0]].confirmed_bands[band] = ~~g_ituZones[g_gridToITUZone[gridCheck][0]].confirmed_bands[ band @@ -9203,22 +10545,28 @@ function redrawGrids() { } } - for (var key in g_QSOhash[i].vucc_grids) { + for (var key in g_QSOhash[i].vucc_grids) + { var grid = g_QSOhash[i].vucc_grids[key].substr(0, 4); - if (grid in g_us48Data) { - if (g_us48Data[grid].worked == false) { + if (grid in g_us48Data) + { + if (g_us48Data[grid].worked == false) + { g_us48Data[grid].worked = worked; } - if (worked) { + if (worked) + { g_us48Data[grid].worked_bands[band] = ~~g_us48Data[grid].worked_bands[band] + 1; g_us48Data[grid].worked_modes[mode] = ~~g_us48Data[grid].worked_modes[mode] + 1; } - if (g_us48Data[grid].confirmed == false) { + if (g_us48Data[grid].confirmed == false) + { g_us48Data[grid].confirmed = didConfirm; } - if (didConfirm) { + if (didConfirm) + { g_us48Data[grid].confirmed_bands[band] = ~~g_us48Data[grid].confirmed_bands[band] + 1; g_us48Data[grid].confirmed_modes[mode] = @@ -9229,28 +10577,38 @@ function redrawGrids() { } } - for (var layer in g_viewInfo) { + for (var layer in g_viewInfo) + { var search = window[g_viewInfo[layer][0]]; var worked = (confirmed = 0); - if (layer == 0) { - for (var key in search) { + if (layer == 0) + { + for (var key in search) + { if (search[key].rectangle.worked) worked++; if (search[key].rectangle.confirmed) confirmed++; } g_viewInfo[layer][2] = worked; g_viewInfo[layer][3] = confirmed; - } else if (layer == 5) { - for (var key in search) { - if (search[key].geo != "deleted") { + } + else if (layer == 5) + { + for (var key in search) + { + if (search[key].geo != "deleted") + { if (search[key].worked) worked++; if (search[key].confirmed) confirmed++; } } g_viewInfo[layer][2] = worked; g_viewInfo[layer][3] = confirmed; - } else { - for (var key in search) { + } + else + { + for (var key in search) + { if (search[key].worked) worked++; if (search[key].confirmed) confirmed++; } @@ -9259,7 +10617,8 @@ function redrawGrids() { } } - for (var i in g_liveCallsigns) { + for (var i in g_liveCallsigns) + { if ( g_appSettings.gridViewMode != 2 && (g_appSettings.gtBandFilter.length == 0 || @@ -9267,8 +10626,10 @@ function redrawGrids() { ? 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) + { g_liveCallsigns[i].rect = qthToBox( g_liveCallsigns[i].grid, g_liveCallsigns[i].DEcall, @@ -9290,15 +10651,18 @@ function redrawGrids() { updateCountStats(); } -function toggleAlertMute() { +function toggleAlertMute() +{ g_appSettings.alertMute ^= 1; alertMuteImg.src = g_alertImageArray[g_appSettings.alertMute]; - if (g_appSettings.alertMute == 1) { + if (g_appSettings.alertMute == 1) + { chrome.tts.stop(); } } -function togglePushPinMode() { +function togglePushPinMode() +{ if (g_pushPinMode == false) g_pushPinMode = true; else g_pushPinMode = false; g_appSettings.pushPinMode = g_pushPinMode; @@ -9307,44 +10671,58 @@ function togglePushPinMode() { redrawGrids(); } -function stopAsking(checkbox) { +function stopAsking(checkbox) +{ g_appSettings.stopAskingVersion = checkbox.checked; } -function toggleGtShareEnable() { - if (g_appSettings.gtShareEnable == true) { +function toggleGtShareEnable() +{ + if (g_appSettings.gtShareEnable == true) + { g_appSettings.gtShareEnable = false; - } else g_appSettings.gtShareEnable = true; + } + else g_appSettings.gtShareEnable = true; setGtShareButtons(); } -function setGtShareButtons() { +function setGtShareButtons() +{ if ( g_appSettings.gtShareEnable == true && g_mapSettings.offlineMode == false - ) { + ) + { if (g_appSettings.gtMsgEnable == true) - msgButton.style.display = "inline-block"; + { msgButton.style.display = "inline-block"; } else msgButton.style.display = "none"; gtFlagButton.style.display = "inline-block"; - if (g_appSettings.gtFlagImgSrc > 0) { - g_layerVectors["gtflags"].setVisible(true); - } else { - g_layerVectors["gtflags"].setVisible(false); + if (g_appSettings.gtFlagImgSrc > 0) + { + g_layerVectors.gtflags.setVisible(true); } - } else { + else + { + g_layerVectors.gtflags.setVisible(false); + } + } + else + { msgButton.style.display = "none"; gtFlagButton.style.display = "none"; - g_layerVectors["gtflags"].setVisible(false); + g_layerVectors.gtflags.setVisible(false); clearGtFlags(); // Clear list g_gtFlagPins = {}; - if (g_chatWindowHandle != null) { - try { + if (g_chatWindowHandle != null) + { + try + { g_chatWindowHandle.hide(); - } catch (e) {} + } + catch (e) {} } } @@ -9352,27 +10730,37 @@ function setGtShareButtons() { g_gtShareFlagImageArray[g_appSettings.gtShareEnable == false ? 0 : 1]; } -function setMulticastIp() { +function setMulticastIp() +{ g_appSettings.wsjtIP = multicastIpInput.value; } -function setMulticastEnable(checkbox) { - if (checkbox.checked == true) { +function setMulticastEnable(checkbox) +{ + if (checkbox.checked == true) + { multicastTD.style.display = "block"; - if (ValidateMulticast(multicastIpInput)) { + if (ValidateMulticast(multicastIpInput)) + { g_appSettings.wsjtIP = multicastIpInput.value; - } else { + } + else + { g_appSettings.wsjtIP = ""; } - } else { + } + else + { multicastTD.style.display = "none"; g_appSettings.wsjtIP = ""; } g_appSettings.multicast = checkbox.checked; } -function setUdpForwardEnable(checkbox) { - if (checkbox.checked) { +function setUdpForwardEnable(checkbox) +{ + if (checkbox.checked) + { if ( ValidatePort( udpForwardPortInput, @@ -9380,7 +10768,8 @@ function setUdpForwardEnable(checkbox) { CheckForwardPortIsNotReceivePort ) && ValidateIPaddress(udpForwardIpInput, null) - ) { + ) + { g_appSettings.wsjtForwardUdpEnable = checkbox.checked; return; } @@ -9389,20 +10778,25 @@ function setUdpForwardEnable(checkbox) { g_appSettings.wsjtForwardUdpEnable = checkbox.checked; } -function setGTspotEnable(checkbox) { +function setGTspotEnable(checkbox) +{ g_appSettings.gtSpotEnable = checkbox.checked; g_gtLiveStatusUpdate = true; } -function setMsgEnable(checkbox) { +function setMsgEnable(checkbox) +{ g_appSettings.gtMsgEnable = checkbox.checked; - if (g_appSettings.gtShareEnable == true) { + if (g_appSettings.gtShareEnable == true) + { if (g_appSettings.gtMsgEnable == true) - msgButton.style.display = "inline-block"; - else { + { msgButton.style.display = "inline-block"; } + else + { msgButton.style.display = "none"; - if (g_chatWindowHandle != null) { + if (g_chatWindowHandle != null) + { g_chatWindowHandle.hide(); } } @@ -9411,16 +10805,20 @@ function setMsgEnable(checkbox) { setMsgSettingsView(); } -function newMessageSetting(whichSetting) { - if (whichSetting.id in g_msgSettings) { +function newMessageSetting(whichSetting) +{ + if (whichSetting.id in g_msgSettings) + { g_msgSettings[whichSetting.id] = whichSetting.value; localStorage.msgSettings = JSON.stringify(g_msgSettings); setMsgSettingsView(); } } -function checkForNewVersion(showUptoDate) { +function checkForNewVersion(showUptoDate) +{ if (typeof nw != "undefined") + { getBuffer( "http://app.gridtracker.org/version.txt?lang=" + g_localeString, versionCheck, @@ -9428,11 +10826,14 @@ function checkForNewVersion(showUptoDate) { "http", 80 ); + } } -function renderBandActivity() { +function renderBandActivity() +{ var buffer = ""; - if (typeof g_bandActivity.lines[myMode] != "undefined") { + if (typeof g_bandActivity.lines[myMode] != "undefined") + { var lines = g_bandActivity.lines[myMode]; var bands = [ @@ -9449,9 +10850,10 @@ function renderBandActivity() { "10m", "6m", "4m", - "2m", + "2m" ]; if (g_myDXCC in g_callsignDatabaseUSplus) + { bands = [ "630m", "160m", @@ -9465,11 +10867,13 @@ function renderBandActivity() { "12m", "10m", "6m", - "2m", + "2m" ]; + } var bandData = {}; var maxValue = 0; - for (var i = 0; i < bands.length; i++) { + for (var i = 0; i < bands.length; i++) + { bandData[bands[i]] = {}; bandData[bands[i]].score = 0; @@ -9477,14 +10881,17 @@ function renderBandActivity() { bandData[bands[i]].tx = 0; bandData[bands[i]].rx = 0; } - for (var x = 0; x < lines.length; x++) { + for (var x = 0; x < lines.length; x++) + { var firstChar = lines[x].charCodeAt(0); - if (firstChar != 35 && lines[x].length > 1) { + if (firstChar != 35 && lines[x].length > 1) + { // doesn't begins with # and has something var values = lines[x].trim().split(" "); var band = Number(Number(values[0]) / 1000000).formatBand(); - if (band in bandData) { + if (band in bandData) + { var place = bandData[band]; place.score += Number(values[1]); @@ -9498,10 +10905,12 @@ function renderBandActivity() { } var scaleFactor = 1.0; - if (maxValue > 26) { + if (maxValue > 26) + { scaleFactor = 26 / maxValue; } - for (var band in bandData) { + for (var band in bandData) + { var blockMyBand = ""; if (band == myBand) blockMyBand = " class='myBand' "; @@ -9534,18 +10943,23 @@ function renderBandActivity() { ""; buffer += ""; } - } else { + } + else + { buffer = "..no data yet.."; } graphDiv.innerHTML = buffer; - if (g_baWindowHandle) { + if (g_baWindowHandle) + { g_baWindowHandle.window.graphDiv.innerHTML = buffer; } } -function pskBandActivityCallback(buffer, flag) { +function pskBandActivityCallback(buffer, flag) +{ var result = String(buffer); - if (result.indexOf("frequency score") > -1) { + if (result.indexOf("frequency score") > -1) + { // looks good so far g_bandActivity.lines[myMode] = result.split("\n"); g_bandActivity.lastUpdate[myMode] = g_timeNow + 600; @@ -9555,9 +10969,11 @@ function pskBandActivityCallback(buffer, flag) { renderBandActivity(); } -function pskGetBandActivity() { +function pskGetBandActivity() +{ if (g_mapSettings.offlineMode == true) return; - if (typeof g_bandActivity.lastUpdate[myMode] == "undefined") { + if (typeof g_bandActivity.lastUpdate[myMode] == "undefined") + { g_bandActivity.lastUpdate[myMode] = 0; } @@ -9565,7 +10981,8 @@ function pskGetBandActivity() { myMode.length > 0 && myDEGrid.length > 0 && g_timeNow > g_bandActivity.lastUpdate[myMode] - ) { + ) + { getBuffer( "https://pskreporter.info/cgi-bin/psk-freq.pl?mode=" + myMode + @@ -9580,16 +10997,19 @@ function pskGetBandActivity() { renderBandActivity(); - if (g_pskBandActivityTimerHandle != null) { + if (g_pskBandActivityTimerHandle != null) + { clearInterval(g_pskBandActivityTimerHandle); } - g_pskBandActivityTimerHandle = setInterval(function () { + g_pskBandActivityTimerHandle = setInterval(function () + { pskGetBandActivity(); }, 601000); // every 20 minutes, 1 second } -function getIniFromApp(appName) { +function getIniFromApp(appName) +{ var result = Array(); result.port = -1; result.ip = ""; @@ -9605,64 +11025,81 @@ function getIniFromApp(appName) { var wsjtxCfgPath = ""; var data = String(nw.App.dataPath); var end = 0; - if (g_platform == "windows") { + if (g_platform == "windows") + { end = data.indexOf("GridTracker\\User Data\\Default"); - if (end > -1) { + if (end > -1) + { wsjtxCfgPath = data.substr(0, end) + appName + "\\" + appName + ".ini"; } - } else if (g_platform == "mac") { + } + else if (g_platform == "mac") + { wsjtxCfgPath = process.env.HOME + "/Library/Preferences/WSJT-X.ini"; - } else { + } + else + { wsjtxCfgPath = process.env.HOME + "/.config/" + appName + ".ini"; } - if (fs.existsSync(wsjtxCfgPath)) { + if (fs.existsSync(wsjtxCfgPath)) + { var fileBuf = fs.readFileSync(wsjtxCfgPath, "ascii"); var fileArray = fileBuf.split("\n"); for (var key in fileArray) fileArray[key] = fileArray[key].trim(); result.IniPath = data.substr(0, end) + appName + "\\"; - for (var x = 0; x < fileArray.length; x++) { + for (var x = 0; x < fileArray.length; x++) + { var indexOfPort = fileArray[x].indexOf("UDPServerPort="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.port = portSplit[1]; } indexOfPort = fileArray[x].indexOf("UDPServer="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.ip = portSplit[1]; } indexOfPort = fileArray[x].indexOf("MyCall="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.MyCall = portSplit[1]; } indexOfPort = fileArray[x].indexOf("MyGrid="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.MyGrid = portSplit[1].substr(0, 6); } indexOfPort = fileArray[x].indexOf("Mode="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.MyMode = portSplit[1]; } indexOfPort = fileArray[x].indexOf("DialFreq="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.MyBand = Number(portSplit[1] / 1000000).formatBand(); } indexOfPort = fileArray[x].indexOf("N1MMServerPort="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.N1MMServerPort = portSplit[1]; } indexOfPort = fileArray[x].indexOf("N1MMServer="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.N1MMServer = portSplit[1]; } indexOfPort = fileArray[x].indexOf("BroadcastToN1MM="); - if (indexOfPort == 0) { + if (indexOfPort == 0) + { var portSplit = fileArray[x].split("="); result.BroadcastToN1MM = portSplit[1] == "true"; } @@ -9671,7 +11108,8 @@ function getIniFromApp(appName) { return result; } -function checkRunningProcesses() { +function checkRunningProcesses() +{ var child_process = require("child_process"); var list = g_platform == "windows" @@ -9682,10 +11120,14 @@ function checkRunningProcesses() { g_jtdxProcessRunning = list.indexOf("jtdx") > -1; } -function updateRunningProcesses() { - try { +function updateRunningProcesses() +{ + try + { checkRunningProcesses(); - } catch (e) { + } + catch (e) + { g_wsjtxProcessRunning = false; g_jtdxProcessRunning = false; } @@ -9693,52 +11135,65 @@ function updateRunningProcesses() { if (g_wsjtxProcessRunning == true) runningAppsDiv.innerHTML += " - up - "; else runningAppsDiv.innerHTML += " - ? - "; g_wsjtxIni = getIniFromApp("WSJT-X"); - if (g_wsjtxIni.port > -1) { + if (g_wsjtxIni.port > -1) + { runningAppsDiv.innerHTML += "(" + g_wsjtxIni.ip + " / " + g_wsjtxIni.port + ") "; - } else runningAppsDiv.innerHTML += "(?) "; - if (g_platform != "mac") { + } + else runningAppsDiv.innerHTML += "(?) "; + if (g_platform != "mac") + { runningAppsDiv.innerHTML += " / JTDX "; if (g_jtdxProcessRunning == true) runningAppsDiv.innerHTML += " - up - "; else runningAppsDiv.innerHTML += " - ? - "; g_jtdxIni = getIniFromApp("JTDX"); - if (g_jtdxIni.port > -1) { + if (g_jtdxIni.port > -1) + { runningAppsDiv.innerHTML += "(" + g_jtdxIni.ip + " / " + g_jtdxIni.port + ") "; - } else runningAppsDiv.innerHTML += "(?) "; + } + else runningAppsDiv.innerHTML += "(?) "; } } -function updateBasedOnIni() { +function updateBasedOnIni() +{ var which = null; var count = 0; if (g_wsjtxProcessRunning) count++; if (g_jtdxProcessRunning) count++; // UdpPortNotSet - if (g_appSettings.wsjtUdpPort == 0 && count == 1) { + if (g_appSettings.wsjtUdpPort == 0 && count == 1) + { if (g_wsjtxProcessRunning) which = g_wsjtxIni; else if (g_jtdxProcessRunning) which = g_jtdxIni; - if (which != null && which.port > -1) { + if (which != null && which.port > -1) + { g_appSettings.wsjtUdpPort = which.port; g_appSettings.wsjtIP = which.ip; } - if (which == null) { + if (which == null) + { g_appSettings.wsjtUdpPort = 2237; g_appSettings.wsjtIP = ""; } if ( ipToInt(g_appSettings.wsjtIP) >= ipToInt("224.0.0.0") && ipToInt(g_appSettings.wsjtIP) < ipToInt("240.0.0.0") - ) { + ) + { g_appSettings.multicast = true; - } else g_appSettings.multicast = false; + } + else g_appSettings.multicast = false; } // Which INI do we load? - if (g_appSettings.wsjtUdpPort) { + if (g_appSettings.wsjtUdpPort) + { which = null; if (g_wsjtxIni.port == g_appSettings.wsjtUdpPort) which = g_wsjtxIni; else if (g_jtdxIni.port == g_appSettings.wsjtUdpPort) which = g_jtdxIni; - if (which != null) { + if (which != null) + { myDEcall = which.MyCall; myDEGrid = which.MyGrid; g_lastBand = myBand; @@ -9749,11 +11204,13 @@ function updateBasedOnIni() { which != null && which.BroadcastToN1MM == true && g_N1MMSettings.enable == true - ) { + ) + { if ( which.N1MMServer == g_N1MMSettings.ip && which.N1MMServerPort == g_N1MMSettings.port - ) { + ) + { buttonN1MMCheckBox.checked = g_N1MMSettings.enable = false; localStorage.N1MMSettings = JSON.stringify(g_N1MMSettings); alert( @@ -9762,15 +11219,19 @@ function updateBasedOnIni() { ); } } - if (which != null) { - if (g_appSettings.wsjtIP == "") { + if (which != null) + { + if (g_appSettings.wsjtIP == "") + { g_appSettings.wsjtIP = which.ip; } } } if (myDEGrid.length > 0) setHomeGridsquare(); - else { - if (typeof nw != "undefined") { + else + { + if (typeof nw != "undefined") + { // lets see if we can find our location the hard way getBuffer( "https://api.ipstack.com/check?access_key=8c9233ec1c09861a707951ab3718a7f6&format=1", @@ -9783,113 +11244,143 @@ function updateBasedOnIni() { } } -function CheckReceivePortIsNotForwardPort(value) { +function CheckReceivePortIsNotForwardPort(value) +{ if ( udpForwardIpInput.value == "127.0.0.1" && udpForwardPortInput.value == value && g_appSettings.wsjtIP == "" && udpForwardEnable.checked - ) { + ) + { return false; } return true; } -function CheckForwardPortIsNotReceivePort(value) { +function CheckForwardPortIsNotReceivePort(value) +{ if ( udpForwardIpInput.value == "127.0.0.1" && udpPortInput.value == value && g_appSettings.wsjtIP == "" ) - return false; + { return false; } return true; } -function setForwardIp() { +function setForwardIp() +{ g_appSettings.wsjtForwardUdpIp = udpForwardIpInput.value; - if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) { + if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) + { setUdpPort(); } ValidatePort(udpForwardPortInput, null, CheckForwardPortIsNotReceivePort); } -function setForwardPort() { +function setForwardPort() +{ g_appSettings.wsjtForwardUdpPort = udpForwardPortInput.value; ValidateIPaddress(udpForwardIpInput, null); - if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) { + if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) + { setUdpPort(); } } -function validIpKeys(value) { +function validIpKeys(value) +{ if (value == 46) return true; return value >= 48 && value <= 57; } -function validNumberKeys(value) { +function validNumberKeys(value) +{ return value >= 48 && value <= 57; } -function validateNumAndLetter(input) { +function validateNumAndLetter(input) +{ if (/\d/.test(input) && /[A-Z]/.test(input)) return true; else return false; } -function validCallsignsKeys(value) { +function validCallsignsKeys(value) +{ if (value == 44) return true; if (value >= 47 && value <= 57) return true; if (value >= 65 && value <= 90) return true; return value >= 97 && value <= 122; } -function ValidateCallsigns(inputText, validDiv) { +function ValidateCallsigns(inputText, validDiv) +{ inputText.value = inputText.value.toUpperCase(); var callsigns = inputText.value.split(","); var passed = false; - for (var call in callsigns) { - if (callsigns[call].length > 0) { - if (/\d/.test(callsigns[call]) && /[A-Z]/.test(callsigns[call])) { + for (var call in callsigns) + { + if (callsigns[call].length > 0) + { + if (/\d/.test(callsigns[call]) && /[A-Z]/.test(callsigns[call])) + { passed = true; - } else { + } + else + { passed = false; break; } - } else { + } + else + { passed = false; break; } } - if (passed) { + if (passed) + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; } return passed; } -function ValidateCallsign(inputText, validDiv) { +function ValidateCallsign(inputText, validDiv) +{ addError.innerHTML = ""; - if (inputText.value.length > 0) { + if (inputText.value.length > 0) + { var passed = false; inputText.value = inputText.value.toUpperCase(); - if (/\d/.test(inputText.value) || /[A-Z]/.test(inputText.value)) { + if (/\d/.test(inputText.value) || /[A-Z]/.test(inputText.value)) + { passed = true; } - if (passed) { + if (passed) + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; if (validDiv) validDiv.innerHTML = "Valid!"; return true; - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; if (validDiv) validDiv.innerHTML = "Invalid!"; return false; } - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; if (validDiv) validDiv.innerHTML = "Invalid!"; @@ -9897,28 +11388,36 @@ function ValidateCallsign(inputText, validDiv) { } } -function ValidateGridsquareOnly4(inputText, validDiv) { +function ValidateGridsquareOnly4(inputText, validDiv) +{ addError.innerHTML = ""; - if (inputText.value.length == 4) { + if (inputText.value.length == 4) + { var gridSquare = ""; var LETTERS = inputText.value.substr(0, 2).toUpperCase(); var NUMBERS = inputText.value.substr(2, 2).toUpperCase(); - if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) { + if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) + { gridSquare = LETTERS + NUMBERS; } - if (gridSquare != "") { + if (gridSquare != "") + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; inputText.value = gridSquare; if (validDiv) validDiv.innerHTML = "Valid!"; return true; - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (validDiv) validDiv.innerHTML = "Invalid!"; return false; } - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; if (validDiv) validDiv.innerHTML = "Valid!"; @@ -9926,67 +11425,87 @@ function ValidateGridsquareOnly4(inputText, validDiv) { } } -function validateGridFromString(inputText) { - if (inputText.length == 4 || inputText.length == 6) { +function validateGridFromString(inputText) +{ + if (inputText.length == 4 || inputText.length == 6) + { var gridSquare = ""; var LETTERS = inputText.substr(0, 2).toUpperCase(); var NUMBERS = inputText.substr(2, 2).toUpperCase(); - if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) { + if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) + { gridSquare = LETTERS + NUMBERS; } - if (inputText.length > 4) { + if (inputText.length > 4) + { var LETTERS_SUB = inputText.substr(4, 2).toUpperCase(); gridSquare = ""; if ( /^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS) && /^[A-Xa-x]+$/.test(LETTERS_SUB) - ) { + ) + { gridSquare = LETTERS + NUMBERS + LETTERS_SUB; } } - if (gridSquare != "") { + if (gridSquare != "") + { return true; - } else { + } + else + { return false; } - } else { + } + else + { return false; } } -function ValidateGridsquare(inputText, validDiv) { - if (inputText.value.length == 4 || inputText.value.length == 6) { +function ValidateGridsquare(inputText, validDiv) +{ + if (inputText.value.length == 4 || inputText.value.length == 6) + { var gridSquare = ""; var LETTERS = inputText.value.substr(0, 2).toUpperCase(); var NUMBERS = inputText.value.substr(2, 2).toUpperCase(); - if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) { + if (/^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS)) + { gridSquare = LETTERS + NUMBERS; } - if (inputText.value.length > 4) { + if (inputText.value.length > 4) + { var LETTERS_SUB = inputText.value.substr(4, 2); gridSquare = ""; if ( /^[A-R]+$/.test(LETTERS) && /^[0-9]+$/.test(NUMBERS) && /^[A-Xa-x]+$/.test(LETTERS_SUB) - ) { + ) + { gridSquare = LETTERS + NUMBERS + LETTERS_SUB; } } - if (gridSquare != "") { + if (gridSquare != "") + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; inputText.value = gridSquare; if (validDiv) validDiv.innerHTML = "Valid!"; return true; - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (validDiv) validDiv.innerHTML = "Invalid!"; return false; } - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (validDiv) validDiv.innerHTML = "Invalid!"; @@ -9994,62 +11513,85 @@ function ValidateGridsquare(inputText, validDiv) { } } -function ipToInt(ip) { +function ipToInt(ip) +{ return ip .split(".") - .map((octet, index, array) => { + .map((octet, index, array) => + { return parseInt(octet) * Math.pow(256, array.length - index - 1); }) - .reduce((prev, curr) => { + .reduce((prev, curr) => + { return prev + curr; }); } -function ValidateMulticast(inputText) { +function ValidateMulticast(inputText) +{ var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; - if (inputText.value.match(ipformat)) { - if (inputText.value != "0.0.0.0" && inputText.value != "255.255.255.255") { + if (inputText.value.match(ipformat)) + { + if (inputText.value != "0.0.0.0" && inputText.value != "255.255.255.255") + { var ipInt = ipToInt(inputText.value); - if (ipInt >= ipToInt("224.0.0.0") && ipInt < ipToInt("240.0.0.0")) { - if (ipInt > ipToInt("224.0.0.255")) { + if (ipInt >= ipToInt("224.0.0.0") && ipInt < ipToInt("240.0.0.0")) + { + if (ipInt > ipToInt("224.0.0.255")) + { inputText.style.color = "black"; inputText.style.backgroundColor = "yellow"; - } else { + } + else + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; } return true; - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; return false; } - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; return false; } - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; return false; } } -function ValidateIPaddress(inputText, checkBox) { +function ValidateIPaddress(inputText, checkBox) +{ var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; - if (inputText.value.match(ipformat)) { - if (inputText.value != "0.0.0.0" && inputText.value != "255.255.255.255") { + if (inputText.value.match(ipformat)) + { + if (inputText.value != "0.0.0.0" && inputText.value != "255.255.255.255") + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; return true; - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (checkBox) checkBox.checked = false; return false; } - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (checkBox) checkBox.checked = false; @@ -10057,20 +11599,27 @@ function ValidateIPaddress(inputText, checkBox) { } } -function ValidatePort(inputText, checkBox, callBackCheck) { +function ValidatePort(inputText, checkBox, callBackCheck) +{ var value = Number(inputText.value); - if (value > 1023 && value < 65536) { - if (callBackCheck && !callBackCheck(value)) { + if (value > 1023 && value < 65536) + { + if (callBackCheck && !callBackCheck(value)) + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (checkBox) checkBox.checked = false; return false; - } else { + } + else + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; return true; } - } else { + } + else + { inputText.style.color = "#FFF"; inputText.style.backgroundColor = "red"; if (checkBox) checkBox.checked = false; @@ -10078,17 +11627,20 @@ function ValidatePort(inputText, checkBox, callBackCheck) { } } -function workingCallsignEnableChanged(ele) { +function workingCallsignEnableChanged(ele) +{ g_appSettings.workingCallsignEnable = ele.checked; applyCallsignsAndDateDiv.style.display = ""; } -function workingDateEnableChanged(ele) { +function workingDateEnableChanged(ele) +{ g_appSettings.workingDateEnable = ele.checked; applyCallsignsAndDateDiv.style.display = ""; } -function workingDateChanged() { +function workingDateChanged() +{ var fields = workingDateValue.value.split("-"); var date = new Date( Date.UTC( @@ -10113,35 +11665,43 @@ function workingDateChanged() { applyCallsignsAndDateDiv.style.display = ""; } -function displayWorkingDate() { +function displayWorkingDate() +{ var date = new Date(g_appSettings.workingDate * 1000); workingDateString.innerHTML = dateToString(date); } var g_tempWorkingCallsigns = {}; -function workingCallsignsChanged(ele) { +function workingCallsignsChanged(ele) +{ g_tempWorkingCallsigns = {}; var callsigns = ele.value.split(","); - for (var call in callsigns) { + for (var call in callsigns) + { g_tempWorkingCallsigns[callsigns[call]] = true; } - if (callsigns.length > 0) { + if (callsigns.length > 0) + { g_appSettings.workingCallsigns = Object.assign({}, g_tempWorkingCallsigns); if (g_appSettings.workingCallsignEnable) - applyCallsignsAndDateDiv.style.display = ""; - } else applyCallsignsAndDateDiv.style.display = "none"; + { applyCallsignsAndDateDiv.style.display = ""; } + } + else applyCallsignsAndDateDiv.style.display = "none"; } -function applyCallsignsAndDates() { +function applyCallsignsAndDates() +{ clearAndLoadQSOs(); applyCallsignsAndDateDiv.style.display = "none"; } -function selectElementContents(el) { +function selectElementContents(el) +{ var body = document.body, range, sel; - if (document.createRange && window.getSelection) { + if (document.createRange && window.getSelection) + { range = document.createRange(); sel = window.getSelection(); sel.removeAllRanges(); @@ -10159,27 +11719,33 @@ function selectElementContents(el) { } } -function ipLocation(buffer, flag) { +function ipLocation(buffer, flag) +{ var obj = JSON.parse(buffer); if ( typeof obj != "undefined" && obj != null && typeof obj.latitude != "undefined" - ) { + ) + { g_appSettings.centerGridsquare = latLonToGridSquare( obj.latitude, obj.longitude ).substr(0, 6); - if (g_appSettings.centerGridsquare.length > 0) { + if (g_appSettings.centerGridsquare.length > 0) + { homeQTHInput.value = g_appSettings.centerGridsquare; if (ValidateGridsquare(homeQTHInput, null)) setCenterGridsquare(); } } } -function popupNewWindows() { - if (typeof nw != "undefined") { - win.on("new-win-policy", function (frame, url, policy) { +function popupNewWindows() +{ + if (typeof nw != "undefined") + { + win.on("new-win-policy", function (frame, url, policy) + { policy.forceNewPopup(); g_lastUrl = ""; }); @@ -10187,10 +11753,14 @@ function popupNewWindows() { } var g_lastUrl = ""; -function lockNewWindows() { - if (typeof nw != "undefined") { - win.on("new-win-policy", function (frame, url, policy) { - if (url != g_lastUrl) { +function lockNewWindows() +{ + if (typeof nw != "undefined") + { + win.on("new-win-policy", function (frame, url, policy) + { + if (url != g_lastUrl) + { nw.Shell.openExternal(url); g_lastUrl = url; } @@ -10199,7 +11769,8 @@ function lockNewWindows() { } } -function byName(a, b) { +function byName(a, b) +{ if (g_enums[a] < g_enums[b]) return -1; if (g_enums[a] > g_enums[b]) return 1; return 0; @@ -10207,53 +11778,69 @@ function byName(a, b) { var ancPrefixes = ["P", "M", "MM", "AM", "A", "NWS"]; -function callsignToDxcc(insign) { +function callsignToDxcc(insign) +{ var callsign = insign; - if (!/\d/.test(callsign) || !/[a-zA-Z]/.test(callsign)) { + if (!/\d/.test(callsign) || !/[a-zA-Z]/.test(callsign)) + { return -1; } if (callsign in g_directCallToDXCC) - return Number(g_directCallToDXCC[callsign]); + { return Number(g_directCallToDXCC[callsign]); } - if (callsign.includes("/")) { + if (callsign.includes("/")) + { var parts = callsign.split("/"); var end = parts.length - 1; - if (ancPrefixes.includes(parts[end])) { + if (ancPrefixes.includes(parts[end])) + { parts.pop(); end = parts.length - 1; } - if (end) { - if (isNaN(parts[end])) { - if (parts[1].length > parts[0].length) { + if (end) + { + if (isNaN(parts[end])) + { + if (parts[1].length > parts[0].length) + { callsign = parts[0]; - } else { + } + else + { if (callsignToDxcc(parts[1]) != -1) callsign = parts[1]; else callsign = parts[0]; } - } else callsign = parts[0]; - } else callsign = parts[0]; + } + else callsign = parts[0]; + } + else callsign = parts[0]; if (callsign in g_directCallToDXCC) - return Number(g_directCallToDXCC[callsign]); + { return Number(g_directCallToDXCC[callsign]); } } - for (var x = callsign.length; x > 0; x--) { - if (callsign.substr(0, x) in g_prefixToMap) { + for (var x = callsign.length; x > 0; x--) + { + if (callsign.substr(0, x) in g_prefixToMap) + { return Number(g_worldGeoData[g_prefixToMap[callsign.substr(0, x)]].dxcc); } } return -1; } -function loadMaidenHeadData() { +function loadMaidenHeadData() +{ var file = "./data/mh-root-prefixed.json"; - if (fs.existsSync(file)) { + if (fs.existsSync(file)) + { var fileBuf = fs.readFileSync(file, "UTF-8"); g_worldGeoData = JSON.parse(fileBuf); - for (var key in g_worldGeoData) { + for (var key in g_worldGeoData) + { g_worldGeoData[key].geo = "deleted"; g_worldGeoData[key].worked_bands = {}; g_worldGeoData[key].confirmed_bands = {}; @@ -10263,16 +11850,20 @@ function loadMaidenHeadData() { g_dxccToADIFName[g_worldGeoData[key].dxcc] = g_worldGeoData[key].aname; g_dxccToGeoData[g_worldGeoData[key].dxcc] = key; - for (var x = 0; x < g_worldGeoData[key].prefix.length; x++) { + for (var x = 0; x < g_worldGeoData[key].prefix.length; x++) + { if (g_worldGeoData[key].prefix[x].charAt(0) == "=") + { g_directCallToDXCC[g_worldGeoData[key].prefix[x].substr(1)] = g_worldGeoData[key].dxcc; + } else g_prefixToMap[g_worldGeoData[key].prefix[x]] = key; } delete g_worldGeoData[key].prefix; - for (var x = 0; x < g_worldGeoData[key].mh.length; x++) { + for (var x = 0; x < g_worldGeoData[key].mh.length; x++) + { if (!(g_worldGeoData[key].mh[x] in g_gridToDXCC)) - g_gridToDXCC[g_worldGeoData[key].mh[x]] = Array(); + { g_gridToDXCC[g_worldGeoData[key].mh[x]] = Array(); } g_gridToDXCC[g_worldGeoData[key].mh[x]].push(g_worldGeoData[key].dxcc); } @@ -10281,14 +11872,15 @@ function loadMaidenHeadData() { g_worldGeoData[key].dxcc != 110 && g_worldGeoData[key].dxcc != 6 ) - delete g_worldGeoData[key].mh; + { delete g_worldGeoData[key].mh; } } file = "./data/dxcc.json"; var files = fs.readFileSync(file); var dxccGeo = JSON.parse(files); - for (var key in dxccGeo.features) { + for (var key in dxccGeo.features) + { var dxcc = dxccGeo.features[key].properties.dxcc_entity_code; g_worldGeoData[g_dxccToGeoData[dxcc]].geo = dxccGeo.features[key]; } @@ -10296,9 +11888,10 @@ function loadMaidenHeadData() { files = fs.readFileSync(file); var countyData = JSON.parse(files); - for (var id in countyData) { + for (var id in countyData) + { if (!(countyData[id].properties.st in g_stateToCounty)) - g_stateToCounty[countyData[id].properties.st] = Array(); + { g_stateToCounty[countyData[id].properties.st] = Array(); } g_stateToCounty[countyData[id].properties.st].push(id); var cnty = @@ -10306,7 +11899,7 @@ function loadMaidenHeadData() { "," + countyData[id].properties.n.toUpperCase().replaceAll(" ", ""); if (!(cnty in g_cntyToCounty)) - g_cntyToCounty[cnty] = countyData[id].properties.n.toProperCase(); + { g_cntyToCounty[cnty] = countyData[id].properties.n.toProperCase(); } g_countyData[cnty] = {}; g_countyData[cnty].geo = countyData[id]; @@ -10318,9 +11911,11 @@ function loadMaidenHeadData() { g_countyData[cnty].worked_modes = {}; g_countyData[cnty].confirmed_modes = {}; - for (var x in countyData[id].properties.z) { + for (var x in countyData[id].properties.z) + { var zipS = String(countyData[id].properties.z[x]); - if (!(zipS in g_zipToCounty)) { + if (!(zipS in g_zipToCounty)) + { g_zipToCounty[zipS] = Array(); } g_zipToCounty[zipS].push(cnty); @@ -10330,74 +11925,77 @@ function loadMaidenHeadData() { countyData = null; g_shapeData = JSON.parse(fs.readFileSync(g_shapeFile)); - for (var key in g_shapeData) { + for (var key in g_shapeData) + { if (g_shapeData[key].properties.alias == key) - g_shapeData[key].properties.alias = null; + { g_shapeData[key].properties.alias = null; } else if ( g_shapeData[key].properties.alias && g_shapeData[key].properties.alias.length > 2 && (g_shapeData[key].properties.alias.indexOf("US") == 0 || g_shapeData[key].properties.alias.indexOf("CA") == 0) ) - g_shapeData[key].properties.alias = null; + { g_shapeData[key].properties.alias = null; } if ( g_shapeData[key].properties.alias && g_shapeData[key].properties.alias.length < 2 ) - g_shapeData[key].properties.alias = null; - if (g_shapeData[key].properties.alias != null) { - if (key.indexOf("CN-") == 0) { + { g_shapeData[key].properties.alias = null; } + if (g_shapeData[key].properties.alias != null) + { + if (key.indexOf("CN-") == 0) + { if (g_shapeData[key].properties.alias == key.replace("CN-", "")) - g_shapeData[key].properties.alias = null; + { g_shapeData[key].properties.alias = null; } } } if ( g_shapeData[key].properties.alias != null && g_shapeData[key].properties.alias.length != 2 ) - g_shapeData[key].properties.alias = null; + { g_shapeData[key].properties.alias = null; } } - //finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6 + // finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6 // Create "US" shape from US Dxcc geos var x = g_worldGeoData[g_dxccToGeoData[291]].geo.geometry; - var y = g_shapeData["AK"].geometry; - var z = g_shapeData["HI"].geometry; + var y = g_shapeData.AK.geometry; + var z = g_shapeData.HI.geometry; var feature = { type: "Feature", geometry: { type: "GeometryCollection", - geometries: [x, y, z], + geometries: [x, y, z] }, properties: { name: "United States", center: g_worldGeoData[g_dxccToGeoData[291]].geo.properties.center, postal: "US", - type: "Country", - }, + type: "Country" + } }; - g_shapeData["US"] = feature; + g_shapeData.US = feature; - y = g_shapeData["OC"].geometry; - z = g_shapeData["AU"].geometry; - q = g_shapeData["AN"].geometry; + y = g_shapeData.OC.geometry; + z = g_shapeData.AU.geometry; + q = g_shapeData.AN.geometry; feature = { type: "Feature", geometry: { type: "GeometryCollection", - geometries: [y, z, q], + geometries: [y, z, q] }, properties: { name: "Oceania", center: [167.97602, -29.037824], postal: "OC", - type: "Continent", - }, + type: "Continent" + } }; - g_shapeData["OC"] = feature; - g_shapeData["AU"].properties.type = "Country"; + g_shapeData.OC = feature; + g_shapeData.AU.properties.type = "Country"; g_StateData = JSON.parse(fs.readFileSync("./data/state.json")); @@ -10413,10 +12011,12 @@ function loadMaidenHeadData() { g_StateData["US-HI"].mh = g_worldGeoData[100].mh; g_StateData["US-HI"].dxcc = 110; - for (var key in g_StateData) { - for (var x = 0; x < g_StateData[key].mh.length; x++) { + for (var key in g_StateData) + { + for (var x = 0; x < g_StateData[key].mh.length; x++) + { if (!(g_StateData[key].mh[x] in g_gridToState)) - g_gridToState[g_StateData[key].mh[x]] = Array(); + { g_gridToState[g_StateData[key].mh[x]] = Array(); } g_gridToState[g_StateData[key].mh[x]].push(g_StateData[key].postal); } g_StateData[key].worked_bands = {}; @@ -10431,16 +12031,20 @@ function loadMaidenHeadData() { fileBuf = fs.readFileSync(file, "UTF-8"); g_enums = JSON.parse(fileBuf); - for (var key in g_worldGeoData) { + for (var key in g_worldGeoData) + { if ( g_worldGeoData[key].pp != "" && g_worldGeoData[key].geo != "deleted" - ) { + ) + { g_enums[g_worldGeoData[key].dxcc] = g_worldGeoData[key].name; } - if (key == 270) { + if (key == 270) + { // US Mainland - for (var mh in g_worldGeoData[key].mh) { + for (var mh in g_worldGeoData[key].mh) + { var sqr = g_worldGeoData[key].mh[mh]; g_us48Data[sqr] = {}; @@ -10458,10 +12062,12 @@ function loadMaidenHeadData() { fileBuf = fs.readFileSync("./data/cqzone.json"); g_cqZones = JSON.parse(fileBuf); - for (var key in g_cqZones) { - for (var x = 0; x < g_cqZones[key].mh.length; x++) { + for (var key in g_cqZones) + { + for (var x = 0; x < g_cqZones[key].mh.length; x++) + { if (!(g_cqZones[key].mh[x] in g_gridToCQZone)) - g_gridToCQZone[g_cqZones[key].mh[x]] = Array(); + { g_gridToCQZone[g_cqZones[key].mh[x]] = Array(); } g_gridToCQZone[g_cqZones[key].mh[x]].push(String(key)); } delete g_cqZones[key].mh; @@ -10470,21 +12076,26 @@ function loadMaidenHeadData() { fileBuf = fs.readFileSync("./data/ituzone.json"); g_ituZones = JSON.parse(fileBuf); - for (var key in g_ituZones) { - for (var x = 0; x < g_ituZones[key].mh.length; x++) { + for (var key in g_ituZones) + { + for (var x = 0; x < g_ituZones[key].mh.length; x++) + { if (!(g_ituZones[key].mh[x] in g_gridToITUZone)) - g_gridToITUZone[g_ituZones[key].mh[x]] = Array(); + { g_gridToITUZone[g_ituZones[key].mh[x]] = Array(); } g_gridToITUZone[g_ituZones[key].mh[x]].push(String(key)); } delete g_ituZones[key].mh; } - for (var key in g_StateData) { - if (key.substr(0, 3) == "US-") { + for (var key in g_StateData) + { + if (key.substr(0, 3) == "US-") + { var shapeKey = key.substr(3, 2); var name = g_StateData[key].name; - if (shapeKey in g_shapeData) { + if (shapeKey in g_shapeData) + { g_wasZones[name] = {}; g_wasZones[name].geo = g_shapeData[shapeKey]; g_wasZones[name].worked = false; @@ -10523,8 +12134,10 @@ function loadMaidenHeadData() { g_wasZones[name].worked_modes = {}; g_wasZones[name].confirmed_modes = {}; - for (var key in g_shapeData) { - if (g_shapeData[key].properties.type == "Continent") { + for (var key in g_shapeData) + { + if (g_shapeData[key].properties.type == "Continent") + { var name = g_shapeData[key].properties.name; g_wacZones[name] = {}; g_wacZones[name].geo = g_shapeData[key]; @@ -10544,7 +12157,8 @@ function loadMaidenHeadData() { var g_timezonesEnable = 0; var g_timezoneLayer = null; -function createZoneLayer() { +function createZoneLayer() +{ g_timezoneLayer = createGeoJsonLayer( "tz", "./data/combined-with-oceans.json", @@ -10555,31 +12169,39 @@ function createZoneLayer() { g_timezoneLayer.setVisible(false); } -function toggleTimezones() { +function toggleTimezones() +{ if (g_currentOverlay != 0) return; g_timezonesEnable ^= 1; mouseOutGtFlag(); - if (g_timezonesEnable == 1) { - if (g_timezoneLayer == null) { + if (g_timezonesEnable == 1) + { + if (g_timezoneLayer == null) + { createZoneLayer(); } g_timezoneLayer.setVisible(true); - } else { - if (g_timezoneLayer != null) { + } + else + { + if (g_timezoneLayer != null) + { g_map.removeLayer(g_timezoneLayer); g_timezoneLayer = null; } } } -function drawAllGrids() { +function drawAllGrids() +{ var borderColor = "#000"; var borderWeight = 0.5; - for (var x = -178; x < 181; x += 2) { + for (var x = -178; x < 181; x += 2) + { var fromPoint = ol.proj.fromLonLat([x, -90]); var toPoint = ol.proj.fromLonLat([x, 90]); @@ -10593,15 +12215,16 @@ function drawAllGrids() { var featureStyle = new ol.style.Style({ stroke: new ol.style.Stroke({ color: borderColor, - width: borderWeight, - }), + width: borderWeight + }) }); newGridBox.setStyle(featureStyle); g_layerSources["line-grids"].addFeature(newGridBox); } - for (var x = -90; x < 91; x++) { + for (var x = -90; x < 91; x++) + { var fromPoint = ol.proj.fromLonLat([-180, x]); var toPoint = ol.proj.fromLonLat([180, x]); @@ -10615,8 +12238,8 @@ function drawAllGrids() { var featureStyle = new ol.style.Style({ stroke: new ol.style.Stroke({ color: borderColor, - width: borderWeight, - }), + width: borderWeight + }) }); newGridBox.setStyle(featureStyle); @@ -10624,9 +12247,13 @@ function drawAllGrids() { } for (var x = 65; x < 83; x++) - for (var y = 65; y < 83; y++) { + { + for (var y = 65; y < 83; y++) + { for (var a = 0; a < 10; a++) - for (var b = 0; b < 10; b++) { + { + for (var b = 0; b < 10; b++) + { var LL = squareToLatLong( String.fromCharCode(x) + String.fromCharCode(y) + @@ -10638,7 +12265,7 @@ function drawAllGrids() { var point = ol.proj.fromLonLat([Lon, Lat]); var feature = new ol.Feature({ geometry: new ol.geom.Point(point), - name: String(a) + String(b), + name: String(a) + String(b) }); var featureStyle = new ol.style.Style({ @@ -10647,18 +12274,18 @@ function drawAllGrids() { font: "normal 16px sans-serif", stroke: new ol.style.Stroke({ color: "#88888888", - width: 1, + width: 1 }), text: String(a) + String(b), - offsetY: 1, - }), + offsetY: 1 + }) }); feature.setStyle(featureStyle); g_layerSources["short-grids"].addFeature(feature); feature = new ol.Feature({ geometry: new ol.geom.Point(point), - name: String(a) + String(b), + name: String(a) + String(b) }); featureStyle = new ol.style.Style({ @@ -10667,19 +12294,20 @@ function drawAllGrids() { font: "normal 16px sans-serif", stroke: new ol.style.Stroke({ color: "#88888888", - width: 1, + width: 1 }), text: String.fromCharCode(x) + String.fromCharCode(y) + String(a) + String(b), - offsetY: 1, - }), + offsetY: 1 + }) }); feature.setStyle(featureStyle); g_layerSources["long-grids"].addFeature(feature); } + } var LL = twoWideToLatLong( String.fromCharCode(x) + String.fromCharCode(y) @@ -10695,27 +12323,32 @@ function drawAllGrids() { font: "normal 24px sans-serif", stroke: new ol.style.Stroke({ color: "#88888888", - width: 1, + width: 1 }), - text: String.fromCharCode(x) + String.fromCharCode(y), - }), + text: String.fromCharCode(x) + String.fromCharCode(y) + }) }); feature.setStyle(featureStyle); g_layerSources["big-grids"].addFeature(feature); } + } } -function versionCheck(buffer, flag) { +function versionCheck(buffer, flag) +{ var version = String(buffer); - if (version.indexOf("gridtracker") == 0) { + if (version.indexOf("gridtracker") == 0) + { // good, we're looking at our version string var versionArray = version.split(":"); - if (versionArray.length == 3) { + if (versionArray.length == 3) + { // Good, there are 3 parts var stableVersion = Number(versionArray[1]); var betaVersion = Number(versionArray[2]); - if (gtVersion < stableVersion) { + if (gtVersion < stableVersion) + { var verString = String(stableVersion); main.style.display = "none"; newVersionMustDownloadDiv.innerHTML = @@ -10727,9 +12360,13 @@ function versionCheck(buffer, flag) { verString.substr(3) + " available for download.
Go there now?

"; versionDiv.style.display = "block"; - } else { - if (flag) { - if (gtVersion < betaVersion) { + } + else + { + if (flag) + { + if (gtVersion < betaVersion) + { var verString = String(betaVersion); main.style.display = "none"; newVersionMustDownloadDiv.innerHTML = @@ -10741,7 +12378,9 @@ function versionCheck(buffer, flag) { verString.substr(3) + " available for download.
Go there now?

"; versionDiv.style.display = "block"; - } else { + } + else + { main.style.display = "none"; upToDateDiv.style.display = "block"; } @@ -10751,30 +12390,36 @@ function versionCheck(buffer, flag) { } } -function onExitAppToGoWebsite() { +function onExitAppToGoWebsite() +{ require("nw.gui").Shell.openExternal("https://gridtracker.org/"); saveAndCloseApp(); } -function mailThem(address) { +function mailThem(address) +{ require("nw.gui").Shell.openExternal("mailto:" + address); } -function openSite(address) { +function openSite(address) +{ require("nw.gui").Shell.openExternal(address); } -function closeUpdateToDateDiv() { +function closeUpdateToDateDiv() +{ upToDateDiv.style.display = "none"; main.style.display = "block"; } -function cancelVersion() { +function cancelVersion() +{ main.style.display = "block"; versionDiv.style.display = "none"; } -function getBuffer(file_url, callback, flag, mode, port, cache = null) { +function getBuffer(file_url, callback, flag, mode, port, cache = null) +{ var url = require("url"); var http = require(mode); var fileBuffer = null; @@ -10784,26 +12429,31 @@ function getBuffer(file_url, callback, flag, mode, port, cache = null) { host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api port: port, followAllRedirects: true, - path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api + path: url.parse(file_url).path // eslint-disable-line node/no-deprecated-api }; - http.get(options, function (res) { + http.get(options, function (res) + { var fsize = res.headers["content-length"]; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cache); } }) - .on("error", function (e) { + .on("error", function (e) + { console.error("getBuffer " + file_url + " error: " + e.message); }); }); @@ -10819,7 +12469,8 @@ function getPostBuffer( timeoutMs, timeoutCallback, who -) { +) +{ var querystring = require("querystring"); var postData = querystring.stringify(theData); var url = require("url"); @@ -10832,40 +12483,51 @@ function getPostBuffer( method: "post", headers: { "Content-Type": "application/x-www-form-urlencoded", - "Content-Length": postData.length, - }, + "Content-Length": postData.length + } }; - var req = http.request(options, function (res) { + var req = http.request(options, function (res) + { var fsize = res.headers["content-length"]; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cookies); } }) - .on("error", function () { - if (typeof errorCallback === "function") { + .on("error", function () + { + if (typeof errorCallback === "function") + { errorCallback(); } }); }); - if (typeof timeoutMs == "number" && timeoutMs > 0) { - req.on("socket", function (socket) { + if (typeof timeoutMs == "number" && timeoutMs > 0) + { + req.on("socket", function (socket) + { socket.setTimeout(timeoutMs); - socket.on("timeout", function () { + socket.on("timeout", function () + { req.abort(); }); }); - req.on("error", function (err) { // eslint-disable-line node/handle-callback-err + req.on("error", function (err) // eslint-disable-line node/handle-callback-err + { if (typeof timeoutCallback != "undefined") + { timeoutCallback( file_url, callback, @@ -10877,14 +12539,17 @@ function getPostBuffer( timeoutCallback, who ); + } }); } req.write(postData); req.end(); } -function colorToHex(color) { - if (color.substr(0, 1) === "#") { +function colorToHex(color) +{ + if (color.substr(0, 1) === "#") + { return color; } var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color); @@ -10897,12 +12562,14 @@ function colorToHex(color) { return "#" + rgb; } -function setHueColor() { +function setHueColor() +{ g_mapHue = colorToHex(hueDiv.style.backgroundColor); if (g_mapHue == "#000000") g_mapHue = 0; } -function loadMapSettings() { +function loadMapSettings() +{ shadowValue.value = g_mapSettings.shadow; showDarknessTd.innerHTML = parseInt(shadowValue.value * 100) + "%"; pathWidthTd.innerHTML = pathWidthValue.value = g_appSettings.pathWidthWeight; @@ -10954,12 +12621,15 @@ function loadMapSettings() { pathColorValue.value == 0 ? "#000" : pathColorValue.value == 361 - ? "#FFF" - : "hsl(" + pathColorValue.value + ", 100%, 50%)"; - if (pathColorValue.value != 0) { + ? "#FFF" + : "hsl(" + pathColorValue.value + ", 100%, 50%)"; + if (pathColorValue.value != 0) + { pathColorDiv.style.color = "#000"; pathColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { pathColorDiv.style.color = "#FFF"; pathColorDiv.style.backgroundColor = pathColor; } @@ -10968,12 +12638,15 @@ function loadMapSettings() { qrzPathColorValue.value == 0 ? "#000" : qrzPathColorValue.value == 361 - ? "#FFF" - : "hsl(" + qrzPathColorValue.value + ", 100%, 50%)"; - if (qrzPathColorValue.value != 0) { + ? "#FFF" + : "hsl(" + qrzPathColorValue.value + ", 100%, 50%)"; + if (qrzPathColorValue.value != 0) + { qrzPathColorDiv.style.color = "#000"; qrzPathColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { qrzPathColorDiv.style.color = "#FFF"; qrzPathColorDiv.style.backgroundColor = pathColor; } @@ -10983,13 +12656,15 @@ function loadMapSettings() { displayLegend(); } -function changeDistanceUnit() { +function changeDistanceUnit() +{ g_appSettings.distanceUnit = distanceUnit.value; g_scaleLine.setUnits(g_scaleUnits[g_appSettings.distanceUnit]); goProcessRoster(); } -function changeMapNightValues() { +function changeMapNightValues() +{ g_mapSettings.nightPathColor = nightPathColorValue.value; g_mapSettings.nightQrzPathColor = nightQrzPathColorValue.value; g_mapSettings.nightMapIndex = mapNightSelect.value; @@ -11000,18 +12675,22 @@ function changeMapNightValues() { changeMapLayer(); } -function setNightHtml() { +function setNightHtml() +{ var pathColor = g_mapSettings.nightPathColor == 0 ? "#000" : g_mapSettings.nightPathColor == 361 - ? "#FFF" - : "hsl(" + g_mapSettings.nightPathColor + ", 100%, 50%)"; + ? "#FFF" + : "hsl(" + g_mapSettings.nightPathColor + ", 100%, 50%)"; - if (g_mapSettings.nightPathColor != 0) { + if (g_mapSettings.nightPathColor != 0) + { pathNightColorDiv.style.color = "#000"; pathNightColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { pathNightColorDiv.style.color = "#FFF"; pathNightColorDiv.style.backgroundColor = pathColor; } @@ -11020,18 +12699,22 @@ function setNightHtml() { g_mapSettings.nightQrzPathColor == 0 ? "#000" : g_mapSettings.nightQrzPathColor == 361 - ? "#FFF" - : "hsl(" + g_mapSettings.nightQrzPathColor + ", 100%, 50%)"; - if (g_mapSettings.nightQrzPathColor != 0) { + ? "#FFF" + : "hsl(" + g_mapSettings.nightQrzPathColor + ", 100%, 50%)"; + if (g_mapSettings.nightQrzPathColor != 0) + { pathNightQrzColorDiv.style.color = "#000"; pathNightQrzColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { pathNightQrzColorDiv.style.color = "#FFF"; pathNightQrzColorDiv.style.backgroundColor = pathColor; } } -function changeMapValues() { +function changeMapValues() +{ g_mapSettings.pathColor = pathColorValue.value; g_mapSettings.qrzPathColor = qrzPathColorValue.value; g_mapSettings.loudness = brightnessValue.value; @@ -11042,8 +12725,8 @@ function changeMapValues() { g_mapSettings.offlineMode == false && g_appSettings.gtShareEnable == true ) - g_layerVectors["gtflags"].setVisible(true); - else g_layerVectors["gtflags"].setVisible(false); + { g_layerVectors.gtflags.setVisible(true); } + else g_layerVectors.gtflags.setVisible(false); saveMapSettings(); @@ -11053,13 +12736,16 @@ function changeMapValues() { g_mapSettings.pathColor == 0 ? "#000" : g_mapSettings.pathColor == 361 - ? "#FFF" - : "hsl(" + g_mapSettings.pathColor + ", 100%, 50%)"; + ? "#FFF" + : "hsl(" + g_mapSettings.pathColor + ", 100%, 50%)"; - if (g_mapSettings.pathColor != 0) { + if (g_mapSettings.pathColor != 0) + { pathColorDiv.style.color = "#000"; pathColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { pathColorDiv.style.color = "#FFF"; pathColorDiv.style.backgroundColor = pathColor; } @@ -11068,12 +12754,15 @@ function changeMapValues() { g_mapSettings.qrzPathColor == 0 ? "#000" : g_mapSettings.qrzPathColor == 361 - ? "#FFF" - : "hsl(" + g_mapSettings.qrzPathColor + ", 100%, 50%)"; - if (g_mapSettings.qrzPathColor != 0) { + ? "#FFF" + : "hsl(" + g_mapSettings.qrzPathColor + ", 100%, 50%)"; + if (g_mapSettings.qrzPathColor != 0) + { qrzPathColorDiv.style.color = "#000"; qrzPathColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { qrzPathColorDiv.style.color = "#FFF"; qrzPathColorDiv.style.backgroundColor = pathColor; } @@ -11082,7 +12771,8 @@ function changeMapValues() { displayLegend(); } -function toggleLegend() { +function toggleLegend() +{ if (g_mapSettings.legend == true) g_mapSettings.legend = false; else g_mapSettings.legend = true; @@ -11091,25 +12781,32 @@ function toggleLegend() { displayLegend(); } -function hideLegend() { +function hideLegend() +{ LegendDiv.style.display = "none"; } -function displayLegend() { - if (g_mapSettings.legend == true) { +function displayLegend() +{ + if (g_mapSettings.legend == true) + { LegendDiv.style.display = "block"; legendImg.style.webkitFilter = ""; - } else { + } + else + { LegendDiv.style.display = "none"; legendImg.style.webkitFilter = "grayscale(1) brightness(50%)"; } } -function rgbToHex(R, G, B) { +function rgbToHex(R, G, B) +{ return toHex(R) + toHex(G) + toHex(B); } -function toHex(n) { +function toHex(n) +{ n = parseInt(n, 10); if (isNaN(n)) return "00"; n = Math.max(0, Math.min(n, 255)); @@ -11119,35 +12816,47 @@ function toHex(n) { ); } -function hexToR(h) { +function hexToR(h) +{ return parseInt(cutHex(h).substring(0, 2), 16); } -function hexToG(h) { +function hexToG(h) +{ return parseInt(cutHex(h).substring(2, 4), 16); } -function hexToB(h) { +function hexToB(h) +{ return parseInt(cutHex(h).substring(4, 6), 16); } -function hexToA(h) { +function hexToA(h) +{ return parseInt(cutHex(h).substring(6, 8), 16); } -function cutHex(h) { +function cutHex(h) +{ return h.charAt(0) == "#" ? h.substring(1, 9) : h; } -function changeMapLayer() { - if (g_mapSettings.offlineMode) { +function changeMapLayer() +{ + if (g_mapSettings.offlineMode) + { g_tileLayer.setSource(g_offlineLayer); g_tileLayer.setOpacity(Number(g_mapSettings.loudness)); - } else { - if (g_mapSettings.nightMapEnable && g_nightTime) { + } + else + { + if (g_mapSettings.nightMapEnable && g_nightTime) + { g_tileLayer.setSource(g_mapsLayer[g_mapSettings.nightMapIndex]); g_tileLayer.setOpacity(Number(g_mapSettings.nightLoudness)); - } else { + } + else + { g_tileLayer.setSource(g_mapsLayer[g_mapSettings.mapIndex]); g_tileLayer.setOpacity(Number(g_mapSettings.loudness)); } @@ -11157,23 +12866,28 @@ function changeMapLayer() { redrawSpots(); } -function voiceChangedValue() { +function voiceChangedValue() +{ g_speechSettings.voice = Number(alertVoiceInput.value) + 1; changeSpeechValues(); } -function timedGetVoices() { +function timedGetVoices() +{ g_voices = window.speechSynthesis.getVoices(); - if (g_voices.length > 0) { + if (g_voices.length > 0) + { var newSelect = document.createElement("select"); newSelect.id = "alertVoiceInput"; newSelect.title = "Select Voice"; - for (var i = 0; i < g_voices.length; i++) { + for (var i = 0; i < g_voices.length; i++) + { var option = document.createElement("option"); option.value = i; newstring = g_voices[i].name.replace(/ /g, ""); option.text = newstring; - if (g_voices[i].default) { + if (g_voices[i].default) + { option.selected = true; } newSelect.appendChild(option); @@ -11185,8 +12899,10 @@ function timedGetVoices() { loadAlerts(); } -function initSpeech() { - window.speechSynthesis.onvoiceschanged = function () { +function initSpeech() +{ + window.speechSynthesis.onvoiceschanged = function () + { setTimeout(timedGetVoices, 500); }; var msg = new SpeechSynthesisUtterance("."); @@ -11194,7 +12910,8 @@ function initSpeech() { window.speechSynthesis.speak(msg); } -function initSoundCards() { +function initSoundCards() +{ navigator.mediaDevices .enumerateDevices() .then(gotAudioDevices) @@ -11202,15 +12919,18 @@ function initSoundCards() { } function errorCallback(e) {} -function gotAudioDevices(deviceInfos) { +function gotAudioDevices(deviceInfos) +{ soundCardDiv.innerHTML = ""; var newSelect = document.createElement("select"); newSelect.id = "soundCardInput"; newSelect.title = "Select Sound Card"; - for (var i = 0; i !== deviceInfos.length; ++i) { + for (var i = 0; i !== deviceInfos.length; ++i) + { var deviceInfo = deviceInfos[i]; - if (deviceInfo.kind === "audiooutput") { + if (deviceInfo.kind === "audiooutput") + { var option = document.createElement("option"); option.value = deviceInfo.deviceId; option.text = deviceInfo.label || "Speaker " + (newSelect.length + 1); @@ -11223,42 +12943,46 @@ function gotAudioDevices(deviceInfos) { soundCardInput.value = g_soundCard; } -function soundCardChangedValue() { +function soundCardChangedValue() +{ g_appSettings.soundCard = g_soundCard = soundCardInput.value; playTestFile(); } -function setPins() { +function setPins() +{ g_colorLeafletPins = {}; g_colorLeafleteQPins = {}; g_colorLeafletQPins.worked = {}; g_colorLeafletQPins.confirmed = {}; - for (var i = 0; i < g_colorBands.length; i++) { + for (var i = 0; i < g_colorBands.length; i++) + { var pin = new ol.style.Icon({ src: "./img/pin/" + g_colorBands[i] + ".png", anchorYUnits: "pixels", anchorXUnits: "pixels", - anchor: [5, 18], + anchor: [5, 18] }); g_colorLeafletPins[g_colorBands[i]] = pin; pin = new ol.style.Icon({ src: "./img/pin/" + g_colorBands[i] + "w.png", anchorYUnits: "pixels", anchorXUnits: "pixels", - anchor: [5, 18], + anchor: [5, 18] }); g_colorLeafletQPins.worked[g_colorBands[i]] = pin; pin = new ol.style.Icon({ src: "./img/pin/" + g_colorBands[i] + "q.png", anchorYUnits: "pixels", anchorXUnits: "pixels", - anchor: [5, 18], + anchor: [5, 18] }); g_colorLeafletQPins.confirmed[g_colorBands[i]] = pin; } } -function loadViewSettings() { +function loadViewSettings() +{ gtBandFilter.value = g_appSettings.gtBandFilter; gtModeFilter.value = g_appSettings.gtModeFilter; gtPropFilter.value = g_appSettings.gtPropFilter; @@ -11311,15 +13035,21 @@ function loadViewSettings() { lookupMerge.checked = g_appSettings.lookupMerge; lookupMissingGrid.checked = g_appSettings.lookupMissingGrid; - if (g_appSettings.lookupMerge == true) { + if (g_appSettings.lookupMerge == true) + { lookupMissingGridDiv.style.display = "inline-block"; - } else { + } + else + { lookupMissingGridDiv.style.display = "none"; } - if (g_receptionSettings.viewPaths) { + if (g_receptionSettings.viewPaths) + { spotPathWidthDiv.style.display = "inline-block"; - } else { + } + else + { spotPathWidthDiv.style.display = "none"; } @@ -11327,46 +13057,55 @@ function loadViewSettings() { setRosterTimeView(); } -function loadMsgSettings() { +function loadMsgSettings() +{ msgEnable.checked = g_appSettings.gtMsgEnable; GTspotEnable.checked = g_appSettings.gtSpotEnable; pskSpotsImg.style.filter = g_spotsEnabled == 1 ? "" : "grayscale(1)"; - for (var key in g_msgSettings) { + for (var key in g_msgSettings) + { document.getElementById(key).value = g_msgSettings[key]; } ValidateText(msgAwayText); setMsgSettingsView(); } -function setMsgSettingsView() { +function setMsgSettingsView() +{ if (msgEnable.checked) msgSettingsDiv.style.display = "inline-block"; else msgSettingsDiv.style.display = "none"; - if (g_msgSettings.msgAlertSelect > 0) { + if (g_msgSettings.msgAlertSelect > 0) + { msgFrequencySelectDiv.style.display = "inline-block"; - if (g_msgSettings.msgAlertSelect == 1) { + if (g_msgSettings.msgAlertSelect == 1) + { msgAlertWord.style.display = "inline-block"; msgAlertMedia.style.display = "none"; ValidateText(msgAlertWord); } - if (g_msgSettings.msgAlertSelect == 2) { + if (g_msgSettings.msgAlertSelect == 2) + { msgAlertWord.style.display = "none"; msgAlertMedia.style.display = "inline-block"; } - } else { + } + else + { msgFrequencySelectDiv.style.display = "none"; msgAlertWord.style.display = "none"; msgAlertMedia.style.display = "none"; } if (g_msgSettings.msgAwaySelect > 0) - msgAwayTextDiv.style.display = "inline-block"; + { msgAwayTextDiv.style.display = "inline-block"; } else msgAwayTextDiv.style.display = "none"; } -function loadAdifSettings() { +function loadAdifSettings() +{ workingCallsignEnable.checked = g_appSettings.workingCallsignEnable; workingCallsignsValue.value = Object.keys( g_appSettings.workingCallsigns @@ -11377,68 +13116,94 @@ function loadAdifSettings() { workingDateEnable.checked = g_appSettings.workingDateEnable; displayWorkingDate(); - if (g_platform == "mac") { + if (g_platform == "mac") + { selectTQSLButton.style.display = "none"; } - for (var key in g_adifLogSettings.menu) { + for (var key in g_adifLogSettings.menu) + { var value = g_adifLogSettings.menu[key]; var where = key + "Div"; - if (document.getElementById(key) != null) { + if (document.getElementById(key) != null) + { document.getElementById(key).checked = value; - if (value == true) { + if (value == true) + { document.getElementById(where).style.display = "inline-block"; - } else { + } + else + { document.getElementById(where).style.display = "none"; } } } - for (var key in g_adifLogSettings.startup) { + for (var key in g_adifLogSettings.startup) + { if (document.getElementById(key) != null) - document.getElementById(key).checked = g_adifLogSettings.startup[key]; + { document.getElementById(key).checked = g_adifLogSettings.startup[key]; } } - for (var key in g_adifLogSettings.nickname) { - if (document.getElementById(key) != null) { + for (var key in g_adifLogSettings.nickname) + { + if (document.getElementById(key) != null) + { document.getElementById(key).checked = g_adifLogSettings.nickname[key]; - if (key == "nicknameeQSLCheckBox") { - if (document.getElementById(key).checked == true) { + if (key == "nicknameeQSLCheckBox") + { + if (document.getElementById(key).checked == true) + { eQSLNickname.style.display = "inline-block"; - } else { + } + else + { eQSLNickname.style.display = "none"; } } } } - for (var key in g_adifLogSettings.text) { - if (document.getElementById(key) != null) { + for (var key in g_adifLogSettings.text) + { + if (document.getElementById(key) != null) + { document.getElementById(key).value = g_adifLogSettings.text[key]; ValidateText(document.getElementById(key)); } } - for (var key in g_adifLogSettings.qsolog) { - if (document.getElementById(key) != null) { + for (var key in g_adifLogSettings.qsolog) + { + if (document.getElementById(key) != null) + { document.getElementById(key).checked = g_adifLogSettings.qsolog[key]; - if (key == "logLOTWqsoCheckBox") { - if (document.getElementById(key).checked == true) { + if (key == "logLOTWqsoCheckBox") + { + if (document.getElementById(key).checked == true) + { lotwUpload.style.display = "inline-block"; trustedTestButton.style.display = "inline-block"; - } else { + } + else + { lotwUpload.style.display = "none"; trustedTestButton.style.display = "none"; } } } } - if (clubCall.value == "" && myRawCall != "NOCALL") { + if (clubCall.value == "" && myRawCall != "NOCALL") + { clubCall.value = myRawCall; ValidateText(clubCall); localStorage.adifLogSettings = JSON.stringify(g_adifLogSettings); } - try { + try + { findTrustedQSLPaths(); - } catch (e) { - if (logLOTWqsoCheckBox.checked == true) { + } + catch (e) + { + if (logLOTWqsoCheckBox.checked == true) + { alert( "Unable to access LoTW TrustedQSL (TQSL) due to OS permissions\nLogging to LoTW disabled for this session\nRun as administrator or allow file access to GridTracker if problem persists" ); @@ -11449,25 +13214,32 @@ function loadAdifSettings() { ValidateQrzApi(qrzApiKey); } -function startupVersionInit() { - if (!g_developerMode) { - document.body.addEventListener("contextmenu", function (ev) { +function startupVersionInit() +{ + if (!g_developerMode) + { + document.body.addEventListener("contextmenu", function (ev) + { ev.preventDefault(); }); } imSureCheck.checked = false; stopAskingCheckbox.checked = g_appSettings.stopAskingVersion; - if (stopAskingCheckbox.checked == false) { + if (stopAskingCheckbox.checked == false) + { checkForNewVersion(false); - setInterval(function () { + setInterval(function () + { checkForNewVersion(false); }, 86400000); } } -function startupButtonsAndInputs() { - try { +function startupButtonsAndInputs() +{ + try + { g_pushPinMode = !(g_appSettings.pushPinMode == true); togglePushPinMode(); udpForwardEnable.checked = g_appSettings.wsjtForwardUdpEnable; @@ -11484,13 +13256,15 @@ function startupButtonsAndInputs() { rosterAlwaysOnTop.checked = g_appSettings.rosterAlwaysOnTop; - if (g_appSettings.centerGridsquare.length > 0) { + if (g_appSettings.centerGridsquare.length > 0) + { homeQTHInput.value = g_appSettings.centerGridsquare.substr(0, 6); if (ValidateGridsquare(homeQTHInput, null)) setCenterGridsquare(); } ValidateCallsign(alertValueInput, null); - if (g_mapSettings.offlineMode == true) { + if (g_mapSettings.offlineMode == true) + { conditionsButton.style.display = "none"; buttonPsk24CheckBoxDiv.style.display = "none"; buttonQRZCheckBoxDiv.style.display = "none"; @@ -11506,17 +13280,20 @@ function startupButtonsAndInputs() { } setGtShareButtons(); - } catch (e) {} + } + catch (e) {} } -function startupEventsAndTimers() { +function startupEventsAndTimers() +{ document.addEventListener("keydown", onMyKeyDown, true); document.addEventListener("keyup", onMyKeyUp, false); displayTimeInterval = setInterval(displayTime, 1000); } var g_finishedLoading = false; -function postInit() { +function postInit() +{ redrawSpots(); checkForSettings(); updateForwardListener(); @@ -11525,16 +13302,18 @@ function postInit() { g_nexradEnable = g_mapSettings.usNexrad ? 0 : 1; toggleNexrad(); - if (String(gtVersion) != String(g_startVersion)) { - //generalbut.className = "settingsTablinks"; + if (String(gtVersion) != String(g_startVersion)) + { + // generalbut.className = "settingsTablinks"; showSettingsBox(); openSettingsTab(updatebut, "updateSettingsDiv"); } g_finishedLoading = true; - //tagme + // tagme var x = document.querySelectorAll("input[type='range']"); - for (var i = 0; i < x.length; i++) { + for (var i = 0; i < x.length; i++) + { if (x[i].title.length > 0) x[i].title += "\n"; x[i].title += "(Use Arrow Keys For Smaller Increments)"; } @@ -11546,11 +13325,13 @@ function postInit() { showMessaging(false); } -document.addEventListener("dragover", function (event) { +document.addEventListener("dragover", function (event) +{ event.preventDefault(); }); -document.addEventListener("drop", function (event) { +document.addEventListener("drop", function (event) +{ event.preventDefault(); if (g_finishedLoading == true) dropHandler(event); }); @@ -11579,18 +13360,22 @@ var g_startupTable = [ [startupEventsAndTimers, "Set Events and Timers"], [registerHotKeys, "Registered Hotkeys"], [gtChatSystemInit, "User System Initialized"], - [postInit, "Finalizing System"], + [postInit, "Finalizing System"] ]; -function init() { +function init() +{ startupVersionDiv.innerHTML = gtVersionString; aboutVersionDiv.innerHTML = gtVersionString; g_currentDay = parseInt(timeNowSec() / 86400); - if (mediaCheck() == false) { + if (mediaCheck() == false) + { startupDiv.style.display = "none"; documentsDiv.style.display = "block"; searchedDocFolder.innerHTML = g_appData; - } else { + } + else + { documentsDiv.style.display = "none"; startupDiv.style.display = "block"; startupStatusDiv.innerHTML = "Starting..."; @@ -11598,13 +13383,17 @@ function init() { } } -function startupEngine() { - if (g_startupTable.length > 0) { +function startupEngine() +{ + if (g_startupTable.length > 0) + { var funcInfo = g_startupTable.shift(); funcInfo[0](); startupStatusDiv.innerHTML = funcInfo[1]; setTimeout(startupEngine, 10); - } else { + } + else + { startupStatusDiv.innerHTML = "Completed"; setTimeout(endStartup, 2000); startupAdifLoadCheck(); @@ -11612,18 +13401,21 @@ function startupEngine() { } } -function directoryInput(what) { +function directoryInput(what) +{ g_appSettings.savedAppData = what.files[0].path; init(); } -function endStartup() { +function endStartup() +{ startupDiv.style.display = "none"; main.style.display = "block"; g_map.updateSize(); } -function loadPortSettings() { +function loadPortSettings() +{ multicastEnable.checked = g_appSettings.multicast; multicastIpInput.value = g_appSettings.wsjtIP; setMulticastEnable(multicastEnable); @@ -11643,56 +13435,68 @@ var g_wsjtUdpSocketReady = false; var g_wsjtUdpSocketError = false; var g_qtToSplice = 0; -function decodeQUINT8(byteArray) { +function decodeQUINT8(byteArray) +{ g_qtToSplice = 1; return byteArray[0]; } -function encodeQBOOL(byteArray, offset, value) { +function encodeQBOOL(byteArray, offset, value) +{ return byteArray.writeUInt8(value, offset); } -function decodeQUINT32(byteArray) { +function decodeQUINT32(byteArray) +{ g_qtToSplice = 4; return byteArray.readUInt32BE(0); } -function encodeQUINT32(byteArray, offset, value) { +function encodeQUINT32(byteArray, offset, value) +{ if (value == -1) value = 4294967295; return byteArray.writeUInt32BE(value, offset); } -function decodeQINT32(byteArray) { +function decodeQINT32(byteArray) +{ g_qtToSplice = 4; return byteArray.readInt32BE(0); } -function encodeQINT32(byteArray, offset, value) { +function encodeQINT32(byteArray, offset, value) +{ return byteArray.writeInt32BE(value, offset); } -function decodeQUINT64(byteArray) { +function decodeQUINT64(byteArray) +{ var value = 0; - for (var i = 0; i < 8; i++) { + for (var i = 0; i < 8; i++) + { value = value * 256 + byteArray[i]; } g_qtToSplice = 8; return value; } -function encodeQUINT64(byteArray, offset, value) { +function encodeQUINT64(byteArray, offset, value) +{ var breakOut = Array(); - for (var i = 0; i < 8; i++) { + for (var i = 0; i < 8; i++) + { breakOut[i] = value & 0xff; value >>= 8; } - for (var i = 0; i < 8; i++) { + for (var i = 0; i < 8; i++) + { offset = encodeQBOOL(byteArray, offset, breakOut[7 - i]); } return offset; } -function decodeQUTF8(byteArray) { +function decodeQUTF8(byteArray) +{ var utf8_len = decodeQUINT32(byteArray); var result = ""; byteArray = byteArray.slice(g_qtToSplice); @@ -11702,25 +13506,30 @@ function decodeQUTF8(byteArray) { return result.toString(); } -function encodeQUTF8(byteArray, offset, value) { +function encodeQUTF8(byteArray, offset, value) +{ offset = encodeQUINT32(byteArray, offset, value.length); var wrote = byteArray.write(value, offset, value.length); return wrote + offset; } -function decodeQDOUBLE(byteArray) { +function decodeQDOUBLE(byteArray) +{ g_qtToSplice = 8; return byteArray.readDoubleBE(0); } -function encodeQDOUBLE(byteArray, offset, value) { +function encodeQDOUBLE(byteArray, offset, value) +{ return byteArray.writeDoubleBE(value, offset); } var g_forwardUdpServer = null; -function updateForwardListener() { - if (g_forwardUdpServer != null) { +function updateForwardListener() +{ + if (g_forwardUdpServer != null) + { g_forwardUdpServer.close(); } if (g_closing == true) return; @@ -11728,21 +13537,24 @@ function updateForwardListener() { var dgram = require("dgram"); g_forwardUdpServer = dgram.createSocket({ type: "udp4", - reuseAddr: true, + reuseAddr: true }); g_forwardUdpServer.on("listening", function () {}); - g_forwardUdpServer.on("error", function () { + g_forwardUdpServer.on("error", function () + { g_forwardUdpServer.close(); g_forwardUdpServer = null; }); - g_forwardUdpServer.on("message", function (originalMessage, remote) { + g_forwardUdpServer.on("message", function (originalMessage, remote) + { // Decode enough to get the rig-name, so we know who to send to var message = Object.assign({}, originalMessage); var newMessage = {}; newMessage.magic_key = decodeQUINT32(message); message = message.slice(g_qtToSplice); - if (newMessage.magic_key == 0xadbccbda) { + if (newMessage.magic_key == 0xadbccbda) + { newMessage.schema_number = decodeQUINT32(message); message = message.slice(g_qtToSplice); newMessage.type = decodeQUINT32(message); @@ -11751,7 +13563,8 @@ function updateForwardListener() { message = message.slice(g_qtToSplice); var instanceId = newMessage.Id; - if (instanceId in g_instances) { + if (instanceId in g_instances) + { wsjtUdpMessage( originalMessage, originalMessage.length, @@ -11764,23 +13577,29 @@ function updateForwardListener() { g_forwardUdpServer.bind(0); } -function sendForwardUdpMessage(msg, length, port, address) { - if (g_forwardUdpServer) { +function sendForwardUdpMessage(msg, length, port, address) +{ + if (g_forwardUdpServer) + { g_forwardUdpServer.send(msg, 0, length, port, address); } } -function wsjtUdpMessage(msg, length, port, address) { - if (g_wsjtUdpServer) { +function wsjtUdpMessage(msg, length, port, address) +{ + if (g_wsjtUdpServer) + { g_wsjtUdpServer.send(msg, 0, length, port, address); } } -function checkWsjtxListener() { +function checkWsjtxListener() +{ if ( g_wsjtUdpServer == null || (g_wsjtUdpSocketReady == false && g_wsjtUdpSocketError == true) - ) { + ) + { g_wsjtCurrentPort = -1; g_wsjtCurrentIP = "none"; } @@ -11795,14 +13614,19 @@ var g_activeIndex = 0; var g_currentID = null; -function updateWsjtxListener(port) { +function updateWsjtxListener(port) +{ if (port == g_wsjtCurrentPort && g_appSettings.wsjtIP == g_wsjtCurrentIP) - return; - if (g_wsjtUdpServer != null) { - if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") { - try { + { return; } + if (g_wsjtUdpServer != null) + { + if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") + { + try + { g_wsjtUdpServer.dropMembership(g_appSettings.wsjtIP); - } catch (e) {} + } + catch (e) {} } g_wsjtUdpServer.close(); g_wsjtUdpServer = null; @@ -11813,37 +13637,45 @@ function updateWsjtxListener(port) { var dgram = require("dgram"); g_wsjtUdpServer = dgram.createSocket({ type: "udp4", - reuseAddr: true, + reuseAddr: true }); - if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") { - g_wsjtUdpServer.on("listening", function () { + if (multicastEnable.checked == true && g_appSettings.wsjtIP != "") + { + g_wsjtUdpServer.on("listening", function () + { var address = g_wsjtUdpServer.address(); g_wsjtUdpServer.setBroadcast(true); g_wsjtUdpServer.setMulticastTTL(128); g_wsjtUdpServer.addMembership(g_appSettings.wsjtIP); g_wsjtUdpSocketReady = true; }); - } else { + } + else + { g_appSettings.multicast = false; g_wsjtCurrentIP = g_appSettings.wsjtIP = ""; - g_wsjtUdpServer.on("listening", function () { + g_wsjtUdpServer.on("listening", function () + { g_wsjtUdpServer.setBroadcast(true); g_wsjtUdpSocketReady = true; }); } - g_wsjtUdpServer.on("error", function () { + g_wsjtUdpServer.on("error", function () + { g_wsjtUdpServer.close(); g_wsjtUdpServer = null; g_wsjtUdpSocketReady = false; g_wsjtUdpSocketError = true; }); - g_wsjtUdpServer.on("message", function (message, remote) { + g_wsjtUdpServer.on("message", function (message, remote) + { // if (g_closing == true) true; if ( typeof udpForwardEnable != "undefined" && udpForwardEnable.checked == true - ) { + ) + { sendForwardUdpMessage( message, message.length, @@ -11855,7 +13687,8 @@ function updateWsjtxListener(port) { var newMessage = {}; newMessage.magic_key = decodeQUINT32(message); message = message.slice(g_qtToSplice); - if (newMessage.magic_key == 0xadbccbda) { + if (newMessage.magic_key == 0xadbccbda) + { newMessage.schema_number = decodeQUINT32(message); message = message.slice(g_qtToSplice); newMessage.type = decodeQUINT32(message); @@ -11864,13 +13697,15 @@ function updateWsjtxListener(port) { message = message.slice(g_qtToSplice); var instanceId = newMessage.Id; - if (!(instanceId in g_instances)) { + if (!(instanceId in g_instances)) + { g_instances[instanceId] = {}; g_instances[instanceId].valid = false; g_instancesIndex.push(instanceId); g_instances[instanceId].intId = g_instancesIndex.length - 1; g_instances[instanceId].crEnable = true; - if (g_instancesIndex.length > 1) { + if (g_instancesIndex.length > 1) + { multiRigCRDiv.style.display = "inline-block"; haltTXDiv.style.display = "inline-block"; } @@ -11883,7 +13718,8 @@ function updateWsjtxListener(port) { if (notify) updateRosterInstances(); - if (newMessage.type == 1) { + if (newMessage.type == 1) + { newMessage.event = "Status"; newMessage.Frequency = decodeQUINT64(message); newMessage.Band = Number(newMessage.Frequency / 1000000).formatBand(); @@ -11919,36 +13755,50 @@ function updateWsjtxListener(port) { newMessage.Fastmode = decodeQUINT8(message); message = message.slice(g_qtToSplice); - if (message.length > 0) { + if (message.length > 0) + { newMessage.SopMode = decodeQUINT8(message); message = message.slice(g_qtToSplice); - } else { + } + else + { newMessage.SopMode = -1; } - if (message.length > 0) { + if (message.length > 0) + { newMessage.FreqTol = decodeQINT32(message); message = message.slice(g_qtToSplice); - } else { + } + else + { newMessage.FreqTol = -1; } - if (message.length > 0) { + if (message.length > 0) + { newMessage.TRP = decodeQINT32(message); message = message.slice(g_qtToSplice); - } else { + } + else + { newMessage.TRP = -1; } - if (message.length > 0) { + if (message.length > 0) + { newMessage.ConfName = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else { + } + else + { newMessage.ConfName = null; } g_instances[instanceId].status = newMessage; g_instances[instanceId].valid = true; } - if (g_instances[instanceId].valid == true) { - if (newMessage.type == 2) { + if (g_instances[instanceId].valid == true) + { + if (newMessage.type == 2) + { newMessage.event = "Decode"; newMessage.NW = decodeQUINT8(message); message = message.slice(g_qtToSplice); @@ -11974,10 +13824,12 @@ function updateWsjtxListener(port) { newMessage.OM = g_instances[instanceId].status.MO; newMessage.OB = g_instances[instanceId].status.Band; } - if (newMessage.type == 3) { + if (newMessage.type == 3) + { newMessage.event = "Clear"; } - if (newMessage.type == 5) { + if (newMessage.type == 5) + { newMessage.event = "QSO Logged"; newMessage.DateOff = decodeQUINT64(message); message = message.slice(g_qtToSplice); @@ -11985,7 +13837,8 @@ function updateWsjtxListener(port) { message = message.slice(g_qtToSplice); newMessage.timespecOff = decodeQUINT8(message); message = message.slice(g_qtToSplice); - if (newMessage.timespecOff == 2) { + if (newMessage.timespecOff == 2) + { newMessage.offsetOff = decodeQINT32(message); message = message.slice(g_qtToSplice); } @@ -12013,39 +13866,52 @@ function updateWsjtxListener(port) { message = message.slice(g_qtToSplice); newMessage.timespecOn = decodeQUINT8(message); message = message.slice(g_qtToSplice); - if (newMessage.timespecOn == 2) { + if (newMessage.timespecOn == 2) + { newMessage.offsetOn = decodeQINT32(message); message = message.slice(g_qtToSplice); } - if (message.length > 0) { + if (message.length > 0) + { newMessage.Operatorcall = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else newMessage.Operatorcall = ""; + } + else newMessage.Operatorcall = ""; - if (message.length > 0) { + if (message.length > 0) + { newMessage.Mycall = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else newMessage.Mycall = ""; + } + else newMessage.Mycall = ""; - if (message.length > 0) { + if (message.length > 0) + { newMessage.Mygrid = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else newMessage.Mygrid = ""; + } + else newMessage.Mygrid = ""; - if (message.length > 0) { + if (message.length > 0) + { newMessage.ExchangeSent = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else newMessage.ExchangeSent = ""; + } + else newMessage.ExchangeSent = ""; - if (message.length > 0) { + if (message.length > 0) + { newMessage.ExchangeReceived = decodeQUTF8(message); message = message.slice(g_qtToSplice); - } else newMessage.ExchangeReceived = ""; + } + else newMessage.ExchangeReceived = ""; } - if (newMessage.type == 6) { + if (newMessage.type == 6) + { newMessage.event = "Close"; } - if (newMessage.type == 10) { + if (newMessage.type == 10) + { newMessage.event = "WSPRDecode"; newMessage.NW = decodeQUINT8(message); message = message.slice(g_qtToSplice); @@ -12073,13 +13939,15 @@ function updateWsjtxListener(port) { newMessage.OM = g_instances[instanceId].status.MO; newMessage.OB = g_instances[instanceId].status.Band; } - if (newMessage.type == 12) { + if (newMessage.type == 12) + { newMessage.event = "ADIF"; newMessage.ADIF = decodeQUTF8(message); message = message.slice(g_qtToSplice); } - if (newMessage.type in g_wsjtHandlers) { + if (newMessage.type in g_wsjtHandlers) + { newMessage.remote = remote; newMessage.instance = instanceId; @@ -12096,39 +13964,48 @@ function updateWsjtxListener(port) { g_wsjtCurrentIP = g_appSettings.wsjtIP; } -function loadLookupDetails() { +function loadLookupDetails() +{ lookupService.value = g_appSettings.lookupService; - if (lookupService.value == "QRZ") { + if (lookupService.value == "QRZ") + { lookupLogin.value = g_appSettings.lookupLoginQrz; lookupPassword.value = g_appSettings.lookupPasswordQrz; } - if (lookupService.value == "QRZCQ") { + if (lookupService.value == "QRZCQ") + { lookupLogin.value = g_appSettings.lookupLoginCq; lookupPassword.value = g_appSettings.lookupPasswordCq; } - if (lookupService.value == "HAMQTH") { + if (lookupService.value == "HAMQTH") + { lookupLogin.value = g_appSettings.lookupLoginQth; lookupPassword.value = g_appSettings.lookupPasswordQth; } ValidateText(lookupLogin); ValidateText(lookupPassword); if (lookupService.value == "CALLOOK") - lookupCredentials.style.display = "none"; + { lookupCredentials.style.display = "none"; } else lookupCredentials.style.display = "block"; } -function lookupValueChanged(what) { - if (g_appSettings.lookupService != lookupService.value) { +function lookupValueChanged(what) +{ + if (g_appSettings.lookupService != lookupService.value) + { g_lastLookupCallsign = ""; - if (lookupService.value == "QRZ") { + if (lookupService.value == "QRZ") + { lookupLogin.value = g_appSettings.lookupLoginQrz; lookupPassword.value = g_appSettings.lookupPasswordQrz; } - if (lookupService.value == "QRZCQ") { + if (lookupService.value == "QRZCQ") + { lookupLogin.value = g_appSettings.lookupLoginCq; lookupPassword.value = g_appSettings.lookupPasswordCq; } - if (lookupService.value == "HAMQTH") { + if (lookupService.value == "HAMQTH") + { lookupLogin.value = g_appSettings.lookupLoginQth; lookupPassword.value = g_appSettings.lookupPasswordQth; } @@ -12137,18 +14014,22 @@ function lookupValueChanged(what) { lookupQrzTestResult.innerHTML = ""; g_qrzLookupSessionId = null; if (lookupService.value == "CALLOOK") - lookupCredentials.style.display = "none"; + { lookupCredentials.style.display = "none"; } else lookupCredentials.style.display = "block"; - if (ValidateText(lookupLogin) && ValidateText(lookupPassword)) { - if (lookupService.value == "QRZ") { + if (ValidateText(lookupLogin) && ValidateText(lookupPassword)) + { + if (lookupService.value == "QRZ") + { g_appSettings.lookupLoginQrz = lookupLogin.value; g_appSettings.lookupPasswordQrz = lookupPassword.value; } - if (lookupService.value == "QRZCQ") { + if (lookupService.value == "QRZCQ") + { g_appSettings.lookupLoginCq = lookupLogin.value; g_appSettings.lookupPasswordCq = lookupPassword.value; } - if (lookupService.value == "HAMQTH") { + if (lookupService.value == "HAMQTH") + { g_appSettings.lookupLoginQth = lookupLogin.value; g_appSettings.lookupPasswordQth = lookupPassword.value; } @@ -12157,58 +14038,73 @@ function lookupValueChanged(what) { var g_lastLookupCallsign = ""; var g_lookupTimeout = null; -function lookupCallsign(callsign, gridPass, useCache = true) { +function lookupCallsign(callsign, gridPass, useCache = true) +{ if (g_mapSettings.offlineMode == true && useCache == false) return; g_lastLookupCallsign = callsign; - if (g_lookupWindowHandle) { + if (g_lookupWindowHandle) + { g_lookupWindowHandle.window.lookupCallsignInput.value = callsign; lookupValidateCallByElement("lookupCallsignInput"); } - if (g_lookupTimeout != null) { + if (g_lookupTimeout != null) + { window.clearTimeout(g_lookupTimeout); g_lookupTimeout = null; } g_lookupTimeout = setTimeout(searchLogForCallsign, 500, callsign); if (useCache) + { getLookupCachedObject( callsign, gridPass, cacheLookupObject, continueWithLookup ); + } else continueWithLookup(callsign, gridPass); } -function continueWithLookup(callsign, gridPass) { +function continueWithLookup(callsign, gridPass) +{ setLookupDiv( "lookupInfoDiv", "Looking up " + callsign + ", please wait..." ); - if (g_appSettings.lookupService != "CALLOOK") { + if (g_appSettings.lookupService != "CALLOOK") + { g_qrzLookupCallsign = callsign; g_qrzLookupGrid = gridPass; if ( g_qrzLookupSessionId == null || timeNowSec() - g_sinceLastLookup > 3600 - ) { + ) + { g_qrzLookupSessionId = null; g_sinceLastLookup = timeNowSec(); GetSessionID(null, true); - } else { + } + else + { g_sinceLastLookup = timeNowSec(); GetLookup(true); } - } else { + } + else + { var dxcc = callsignToDxcc(callsign); var where; var ccode = 0; - if (dxcc in g_dxccToAltName) { + if (dxcc in g_dxccToAltName) + { where = g_dxccToAltName[dxcc]; ccode = g_worldGeoData[g_dxccToGeoData[dxcc]].ccode; - } else where = "Unknown"; - if (ccode == 840) { + } + else where = "Unknown"; + if (ccode == 840) + { getBuffer( "https://callook.info/" + callsign + "/json", callookResults, @@ -12217,7 +14113,9 @@ function continueWithLookup(callsign, gridPass) { 443, true ); - } else { + } + else + { var worker = "
C A L L O O K
NO-NONSENSE AMATEUR RADIO U.S.A. CALLSIGN LOOKUPS
are limited to United States and United States Territories Only
"; worker += @@ -12235,58 +14133,68 @@ function continueWithLookup(callsign, gridPass) { } } } -function callookResults(buffer, gridPass) { +function callookResults(buffer, gridPass) +{ var results = JSON.parse(buffer); - if (typeof results.status != "undefined") { - if (results.status == "VALID") { + if (typeof results.status != "undefined") + { + if (results.status == "VALID") + { var callObject = {}; var dxcc = callsignToDxcc(results.current.callsign); - if (dxcc in g_dxccToAltName) callObject["land"] = g_dxccToAltName[dxcc]; - callObject["type"] = results.type; - callObject["call"] = results.current.callsign; - callObject["dxcc"] = dxcc; - callObject["email"] = ""; - callObject["class"] = results.current.operClass; - callObject["aliases"] = results.previous.callsign; - callObject["trustee"] = + if (dxcc in g_dxccToAltName) callObject.land = g_dxccToAltName[dxcc]; + callObject.type = results.type; + callObject.call = results.current.callsign; + callObject.dxcc = dxcc; + callObject.email = ""; + callObject.class = results.current.operClass; + callObject.aliases = results.previous.callsign; + callObject.trustee = results.trustee.callsign + (results.trustee.name.length > 0 ? "; " + results.trustee.name : ""); - callObject["name"] = results.name; - callObject["fname"] = ""; - callObject["addr1"] = results.address.line1; - callObject["addr2"] = results.address.line2; - callObject["addrAttn"] = results.address.attn; - callObject["lat"] = results.location.latitude; - callObject["lon"] = results.location.longitude; - callObject["grid"] = results.location.gridsquare; - callObject["efdate"] = results.otherInfo.grantDate; - callObject["expdate"] = results.otherInfo.expiryDate; - callObject["frn"] = results.otherInfo.frn; - callObject["bio"] = 0; - callObject["image"] = ""; - callObject["country"] = "United States"; - if (gridPass) callObject["gtGrid"] = gridPass; - callObject["source"] = + callObject.name = results.name; + callObject.fname = ""; + callObject.addr1 = results.address.line1; + callObject.addr2 = results.address.line2; + callObject.addrAttn = results.address.attn; + callObject.lat = results.location.latitude; + callObject.lon = results.location.longitude; + callObject.grid = results.location.gridsquare; + callObject.efdate = results.otherInfo.grantDate; + callObject.expdate = results.otherInfo.expiryDate; + callObject.frn = results.otherInfo.frn; + callObject.bio = 0; + callObject.image = ""; + callObject.country = "United States"; + if (gridPass) callObject.gtGrid = gridPass; + callObject.source = "
"; cacheLookupObject(callObject, gridPass, true); - } else if (results.status == "INVALID") { + } + else if (results.status == "INVALID") + { setLookupDiv("lookupInfoDiv", "Invalid Lookup"); - } else { + } + else + { setLookupDiv("lookupInfoDiv", "Server is down for maintenance"); } - } else setLookupDiv("lookupInfoDiv", "Unknown Lookup Error"); + } + else setLookupDiv("lookupInfoDiv", "Unknown Lookup Error"); } var g_qrzLookupSessionId = null; var g_qrzLookupCallsign = ""; var g_qrzLookupGrid = ""; var g_sinceLastLookup = 0; -function GetSessionID(resultTd, useCache) { +function GetSessionID(resultTd, useCache) +{ if (g_mapSettings.offlineMode == true) return; if (resultTd != null) resultTd.innerHTML = "Testing"; if (g_appSettings.lookupService == "QRZCQ") + { getBuffer( "https://ssl.qrzcq.com/xml?username=" + g_appSettings.lookupLoginCq + @@ -12299,7 +14207,9 @@ function GetSessionID(resultTd, useCache) { 443, useCache ); + } else if (g_appSettings.lookupService == "QRZ") + { getBuffer( "https://xmldata.qrz.com/xml/current/?username=" + g_appSettings.lookupLoginQrz + @@ -12311,7 +14221,9 @@ function GetSessionID(resultTd, useCache) { 443, useCache ); + } else + { getBuffer( "https://www.hamqth.com/xml.php?u=" + g_appSettings.lookupLoginQth + @@ -12323,78 +14235,110 @@ function GetSessionID(resultTd, useCache) { 443, useCache ); + } } -function hamQthGetSessionCallback(buffer, resultTd) { +function hamQthGetSessionCallback(buffer, resultTd) +{ var oParser = new DOMParser(); var oDOM = oParser.parseFromString(buffer, "text/xml"); var result = ""; - if (oDOM != null) { + if (oDOM != null) + { var json = XML2jsobj(oDOM.documentElement); - if (json.hasOwnProperty("session")) { - if (json.session.hasOwnProperty("session_id")) { + if (json.hasOwnProperty("session")) + { + if (json.session.hasOwnProperty("session_id")) + { result = "Valid"; g_qrzLookupSessionId = json.session.session_id; - } else { + } + else + { result = "" + json.session.error + ""; g_qrzLookupSessionId = null; } - } else { + } + else + { result = "Invalid Response"; g_qrzLookupSessionId = null; } - } else { + } + else + { result = "Unknown Error"; g_qrzLookupSessionId = null; } - if (resultTd == null) { + if (resultTd == null) + { // It's a true session Request SessionResponse(g_qrzLookupSessionId, result); - } else { + } + else + { g_qrzLookupSessionId = null; resultTd.innerHTML = result; } } -function qrzGetSessionCallback(buffer, resultTd, useCache) { +function qrzGetSessionCallback(buffer, resultTd, useCache) +{ var oParser = new DOMParser(); var oDOM = oParser.parseFromString(buffer, "text/xml"); var result = ""; - if (oDOM != null) { + if (oDOM != null) + { var json = XML2jsobj(oDOM.documentElement); - if (json.hasOwnProperty("Session")) { - if (json.Session.hasOwnProperty("Key")) { + if (json.hasOwnProperty("Session")) + { + if (json.Session.hasOwnProperty("Key")) + { result = "Valid"; g_qrzLookupSessionId = json.Session.Key; - } else { + } + else + { result = "" + json.Session.Error + ""; g_qrzLookupSessionId = null; } - } else { + } + else + { result = "Invalid Response"; g_qrzLookupSessionId = null; } - } else { + } + else + { result = "Unknown Error"; g_qrzLookupSessionId = null; } - if (resultTd == null) { + if (resultTd == null) + { // It's a true session Request SessionResponse(g_qrzLookupSessionId, result, useCache); - } else resultTd.innerHTML = result; + } + else resultTd.innerHTML = result; } -function SessionResponse(newKey, result, useCache) { +function SessionResponse(newKey, result, useCache) +{ // for QRZCQ.com as well - if (newKey == null) { + if (newKey == null) + { setLookupDiv("lookupInfoDiv", result, useCache); - } else { + } + else + { GetLookup(useCache); } } -function GetLookup(useCache) { +function GetLookup(useCache) +{ if (g_appSettings.lookupService == "QRZCQ") + { getBuffer( "https://ssl.qrzcq.com/xml?s=" + g_qrzLookupSessionId + @@ -12407,7 +14351,9 @@ function GetLookup(useCache) { 443, useCache ); + } else if (g_appSettings.lookupService == "QRZ") + { getBuffer( "http://xmldata.qrz.com/xml/current/?s=" + g_qrzLookupSessionId + @@ -12419,7 +14365,9 @@ function GetLookup(useCache) { 80, useCache ); + } else + { getBuffer( "https://www.hamqth.com/xml.php?id=" + g_qrzLookupSessionId + @@ -12432,15 +14380,19 @@ function GetLookup(useCache) { 443, useCache ); + } } -function qthHamLookupResults(buffer, gridPass, useCache) { +function qthHamLookupResults(buffer, gridPass, useCache) +{ var oParser = new DOMParser(); var oDOM = oParser.parseFromString(buffer, "text/xml"); var result = ""; - if (oDOM != null) { + if (oDOM != null) + { var json = XML2jsobj(oDOM.documentElement); - if (json.hasOwnProperty("search")) { + if (json.hasOwnProperty("search")) + { if (gridPass) json.search.gtGrid = gridPass; json.search.source = ""; cacheLookupObject(json.search, gridPass, true); - } else { + } + else + { g_qrzLookupSessionId = null; setLookupDiv( "lookupInfoDiv", "
No result for callsign

" ); } - } else { + } + else + { setLookupDiv("lookupInfoDiv", buffer); g_qrzLookupSessionId = null; } } -function qrzLookupResults(buffer, gridPass, useCache) { +function qrzLookupResults(buffer, gridPass, useCache) +{ var oParser = new DOMParser(); var oDOM = oParser.parseFromString(buffer, "text/xml"); var result = ""; - if (oDOM != null) { + if (oDOM != null) + { var json = XML2jsobj(oDOM.documentElement); - if (json.hasOwnProperty("Callsign")) { + if (json.hasOwnProperty("Callsign")) + { var call = ""; - if (json.Callsign.hasOwnProperty("callsign")) { + if (json.Callsign.hasOwnProperty("callsign")) + { json.Callsign.call = lookup.callsign; delete json.Callsign.callsign; } if (json.Callsign.hasOwnProperty("call")) call = json.Callsign.call; if (g_appSettings.lookupService == "QRZ") + { json.Callsign.source = ""; + } else + { json.Callsign.source = ""; + } if (gridPass) json.Callsign.gtGrid = gridPass; cacheLookupObject(json.Callsign, gridPass, true); - } else { + } + else + { setLookupDiv( "lookupInfoDiv", "
No result for callsign

" ); g_qrzLookupSessionId = null; } - } else { + } + else + { setLookupDiv("lookupInfoDiv", buffer); g_qrzLookupSessionId = null; } @@ -12504,10 +14472,12 @@ var g_lastLookupAddress = null; var g_Idb = null; var g_Irequest = null; -function initialDatabases() { +function initialDatabases() +{ g_Irequest = window.indexedDB.open("GridTracker", 1); - g_Irequest.onerror = function (event) { + g_Irequest.onerror = function (event) + { alert( "Database error: " + event.target.errorCode + @@ -12515,30 +14485,36 @@ function initialDatabases() { ); }; - g_Irequest.onsuccess = function (event) { + g_Irequest.onsuccess = function (event) + { g_Idb = g_Irequest.result; - if (!g_Idb.objectStoreNames.contains("lookups")) { + if (!g_Idb.objectStoreNames.contains("lookups")) + { g_Idb.createObjectStore("lookups", { keyPath: "call" }); } init(); }; - g_Irequest.onupgradeneeded = function (event) { + g_Irequest.onupgradeneeded = function (event) + { g_Idb = g_Irequest.result; - if (!g_Idb.objectStoreNames.contains("lookups")) { + if (!g_Idb.objectStoreNames.contains("lookups")) + { g_Idb.createObjectStore("lookups", { keyPath: "call" }); } init(); }; } -function addLookupObjectToIndexedDB(lookupObject) { +function addLookupObjectToIndexedDB(lookupObject) +{ var request = g_Idb .transaction(["lookups"], "readwrite") .objectStore("lookups") .put(lookupObject); - request.onerror = function (event) { + request.onerror = function (event) + { addLastTraffic("Lookup Write Issue"); }; } @@ -12549,17 +14525,20 @@ function getLookupCachedObject( resultFunction = null, noResultFunction = null, callObject = null -) { +) +{ var request = g_Idb .transaction(["lookups"], "readwrite") .objectStore("lookups") .get(call); - request.onsuccess = function (event) { + request.onsuccess = function (event) + { if ( request.result && parseInt(request.result.cached) + 604800 > timeNowSec() - ) { + ) + { // 7 days, should an option Tag! I know right?! delete request.result; request.result = null; @@ -12568,12 +14547,15 @@ function getLookupCachedObject( .objectStore("lookups") .delete(call); } - if (callObject != null) { - if (request.result != null) { + if (callObject != null) + { + if (request.result != null) + { callObject.cnty = request.result.cnty; if (callObject.cnty in g_countyData) callObject.qual = true; - else { + else + { callObject.cnty = null; callObject.qual = false; } @@ -12581,156 +14563,193 @@ function getLookupCachedObject( return; } if (request.result != null && resultFunction) - resultFunction(request.result, gridPass, false); + { resultFunction(request.result, gridPass, false); } else if (noResultFunction) noResultFunction(call, gridPass); }; - request.onerror = function (event) { + request.onerror = function (event) + { if (noResultFunction) noResultFunction(call, gridPass); }; } -function cacheLookupObject(lookup, gridPass, cacheable = false) { +function cacheLookupObject(lookup, gridPass, cacheable = false) +{ if (!("cnty" in lookup)) lookup.cnty = null; - if (lookup.hasOwnProperty("callsign")) { + if (lookup.hasOwnProperty("callsign")) + { lookup.call = lookup.callsign; delete lookup.callsign; } lookup.call = lookup.call.toUpperCase(); - if (lookup.hasOwnProperty("latitude")) { + if (lookup.hasOwnProperty("latitude")) + { lookup.lat = lookup.latitude; delete lookup.latitude; } - if (lookup.hasOwnProperty("longitude")) { + if (lookup.hasOwnProperty("longitude")) + { lookup.lon = lookup.longitude; delete lookup.longitude; } - if (lookup.hasOwnProperty("locator")) { + if (lookup.hasOwnProperty("locator")) + { lookup.grid = lookup.locator; delete lookup.locator; } - if (lookup.hasOwnProperty("website")) { + if (lookup.hasOwnProperty("website")) + { lookup.url = lookup.website; delete lookup.website; } - if (lookup.hasOwnProperty("web")) { + if (lookup.hasOwnProperty("web")) + { lookup.url = lookup.web; delete lookup.web; } - if (lookup.hasOwnProperty("qslpic")) { + if (lookup.hasOwnProperty("qslpic")) + { lookup.image = lookup.qslpic; delete lookup.qslpic; } - if (lookup.hasOwnProperty("picture")) { + if (lookup.hasOwnProperty("picture")) + { lookup.image = lookup.picture; delete lookup.picture; } - if (lookup.hasOwnProperty("address")) { + if (lookup.hasOwnProperty("address")) + { lookup.addr1 = lookup.address; delete lookup.address; } - if (lookup.hasOwnProperty("adr_city")) { + if (lookup.hasOwnProperty("adr_city")) + { lookup.addr2 = lookup.adr_city; delete lookup.adr_city; } - if (lookup.hasOwnProperty("city")) { + if (lookup.hasOwnProperty("city")) + { lookup.addr2 = lookup.city; delete lookup.city; } - if (lookup.hasOwnProperty("itu")) { + if (lookup.hasOwnProperty("itu")) + { lookup.ituzone = lookup.itu; delete lookup.itu; } - if (lookup.hasOwnProperty("cq")) { + if (lookup.hasOwnProperty("cq")) + { lookup.cqzone = lookup.cq; delete lookup.cq; } - if (lookup.hasOwnProperty("adif")) { + if (lookup.hasOwnProperty("adif")) + { lookup.dxcc = lookup.adif; delete lookup.adif; } - if (!lookup.hasOwnProperty("dxcc")) { + if (!lookup.hasOwnProperty("dxcc")) + { lookup.dxcc = callsignToDxcc(lookup.call.toUpperCase()); } - if (lookup.hasOwnProperty("adr_name")) { + if (lookup.hasOwnProperty("adr_name")) + { lookup.name = lookup.adr_name; delete lookup.adr_name; } - if (lookup.hasOwnProperty("adr_street1")) { + if (lookup.hasOwnProperty("adr_street1")) + { lookup.addr1 = lookup.adr_street1; delete lookup.adr_street1; } - if (lookup.hasOwnProperty("us_state")) { + if (lookup.hasOwnProperty("us_state")) + { lookup.state = lookup.us_state; delete lookup.us_state; } - if (lookup.hasOwnProperty("oblast")) { + if (lookup.hasOwnProperty("oblast")) + { lookup.state = lookup.oblast; delete lookup.oblast; } - if (lookup.hasOwnProperty("district")) { + if (lookup.hasOwnProperty("district")) + { lookup.state = lookup.district; delete lookup.district; } - if (lookup.hasOwnProperty("adr_zip")) { + if (lookup.hasOwnProperty("adr_zip")) + { lookup.zip = lookup.adr_zip; delete lookup.adr_zip; } - if (lookup.hasOwnProperty("adr_country")) { + if (lookup.hasOwnProperty("adr_country")) + { lookup.country = lookup.adr_country; delete lookup.adr_country; } - if (lookup.hasOwnProperty("us_county")) { + if (lookup.hasOwnProperty("us_county")) + { lookup.county = lookup.us_county; delete lookup.us_county; } - if (lookup.hasOwnProperty("qsldirect")) { + if (lookup.hasOwnProperty("qsldirect")) + { lookup.mqsl = lookup.qsldirect; delete lookup.qsldirect; } - if (lookup.hasOwnProperty("qsl")) { + if (lookup.hasOwnProperty("qsl")) + { lookup.bqsl = lookup.qsl; delete lookup.qsl; } - if (lookup.hasOwnProperty("utc_offset")) { + if (lookup.hasOwnProperty("utc_offset")) + { lookup.GMTOffset = lookup.utc_offset; delete lookup.utc_offset; } - if (lookup.hasOwnProperty("land")) { + if (lookup.hasOwnProperty("land")) + { lookup.country = lookup.land; delete lookup.land; } if ("grid" in lookup) lookup.grid = lookup.grid.toUpperCase(); - if (lookup.hasOwnProperty("state") && lookup.hasOwnProperty("county")) { + if (lookup.hasOwnProperty("state") && lookup.hasOwnProperty("county")) + { var foundCounty = false; - if (lookup.cnty == null) { + if (lookup.cnty == null) + { lookup.county = lookup.state + ", " + lookup.county; lookup.cnty = lookup.county.toUpperCase().replaceAll(" ", ""); } - if (lookup.cnty in g_countyData) { - for (var hash in g_liveCallsigns) { + if (lookup.cnty in g_countyData) + { + for (var hash in g_liveCallsigns) + { if ( g_liveCallsigns[hash].DEcall == lookup.call && g_liveCallsigns[hash].state == "US-" + lookup.state - ) { + ) + { g_liveCallsigns[hash].cnty = lookup.cnty; g_liveCallsigns[hash].qual = true; foundCounty = true; } } - if (foundCounty) { + if (foundCounty) + { goProcessRoster(); } - } else { - //console.log( "bad county: " + lookup.cnty); + } + else + { + // console.log( "bad county: " + lookup.cnty); lookup.cnty = null; } } @@ -12741,7 +14760,8 @@ function cacheLookupObject(lookup, gridPass, cacheable = false) { ); lookup.fname = ""; - if (cacheable) { + if (cacheable) + { lookup.cached = timeNowSec(); addLookupObjectToIndexedDB(lookup); } @@ -12749,7 +14769,8 @@ function cacheLookupObject(lookup, gridPass, cacheable = false) { displayLookupObject(lookup, gridPass, cacheable); } -function displayLookupObject(lookup, gridPass, fromCache = false) { +function displayLookupObject(lookup, gridPass, fromCache = false) +{ var worker = ""; var thisCall = getLookProp(lookup, "call").toUpperCase(); @@ -12762,23 +14783,28 @@ function displayLookupObject(lookup, gridPass, fromCache = false) { worker += ""; worker += ""; worker += ""; worker += ""; g_lastLookupAddress = ""; - if (getLookProp(lookup, "addrAttn").length > 0) { + if (getLookProp(lookup, "addrAttn").length > 0) + { worker += ""; worker += ""; worker += ""; - if (getLookProp(lookup, "url").length > 0) { + if (getLookProp(lookup, "url").length > 0) + { worker += ""; worker += ""; worker += ""; worker += ""; } - if (Number(getLookProp(lookup, "bio")) > 0) { + if (Number(getLookProp(lookup, "bio")) > 0) + { worker += ""; worker += ""; worker += ""; } var Aliases = joinCommaIf( getLookProp(lookup, "aliases"), getLookProp(lookup, "p_call") ); - if (Aliases.length > 0) { + if (Aliases.length > 0) + { worker += ""; if (test == "N") return ""; @@ -13030,10 +15072,13 @@ function makeYesNoRow(first, object, key) { return ""; } -function makeRow(first, object, key, clip = false) { +function makeRow(first, object, key, clip = false) +{ var value = getLookProp(object, key); - if (value.length > 0) { - if (clip) { + if (value.length > 0) + { + if (clip) + { return ( "" ); - } else { + } + else + { return ( "
" + keys[key] + @@ -8876,8 +10152,10 @@ function createStatTable(title, infoObject, awardName) { wc1Table += ""; - for (var key in keys) { - if (keys[key] in infoObject.confirmed_types) { + for (var key in keys) + { + if (keys[key] in infoObject.confirmed_types) + { wc1Table += ""; - } else wc1Table += ""; + } + else wc1Table += ""; } wc1Table += "
" + keys[key] + @@ -8885,7 +10163,8 @@ function createStatTable(title, infoObject, awardName) { infoObject.confirmed_types[keys[key]] + ") " + "
 
 
Source
C A L L O O K
Source
HamQTH
Source
QRZ.com
Source
QRZCQ.com
"; if (lookup.dxcc > 0 && lookup.dxcc in g_dxccToGeoData) + { worker += ""; + } worker += ""; var image = getLookProp(lookup, "image"); if (image.length > 0) + { worker += ""; + } worker += "
"; worker += getLookProp(lookup, "addrAttn"); @@ -12822,7 +14848,8 @@ function displayLookupObject(lookup, gridPass, fromCache = false) { worker += "
"; var email = getLookProp(lookup, "email"); - if (email.length > 0) { + if (email.length > 0) + { worker += "
"; worker += "
Details
Website"; @@ -12853,7 +14881,8 @@ function displayLookupObject(lookup, gridPass, fromCache = false) { worker += "
Biography"; @@ -12872,14 +14901,16 @@ function displayLookupObject(lookup, gridPass, fromCache = false) { getLookProp(lookup, "efdate"), getLookProp(lookup, "expdate") ); - if (dates.length > 0) { + if (dates.length > 0) + { worker += "
Effective Dates" + dates + "
Clear
Clear
0 && country != getLookProp(lookup, "land") ) - country = getLookProp(lookup, "land"); + { country = getLookProp(lookup, "land"); } if (country == "United States") country = ""; tryToWriteAdifToDocFolder( @@ -13012,9 +15052,11 @@ function saveToCsv(lookup) { ); } -function makeYesNoRow(first, object, key) { +function makeYesNoRow(first, object, key) +{ var value = getLookProp(object, key); - if (value.length > 0) { + if (value.length > 0) + { var test = value.toUpperCase(); if (test == "Y") return "
" + first + "Yes
" + first + "No
" + first + @@ -13043,7 +15088,9 @@ function makeRow(first, object, key, clip = false) { object[key].substr(0, 45) + "
" + first + @@ -13056,19 +15103,23 @@ function makeRow(first, object, key, clip = false) { return ""; } -function getLookProp(object, key) { +function getLookProp(object, key) +{ return object.hasOwnProperty(key) ? object[key] : ""; } -function joinSpaceIf(camera1, camera2) { +function joinSpaceIf(camera1, camera2) +{ if (camera1.length > 0 && camera2.length > 0) return camera1 + " " + camera2; if (camera1.length > 0) return camera1; if (camera2.length > 0) return camera2; return ""; } -function joinCommaIf(camera1, camera2) { - if (camera1.length > 0 && camera2.length > 0) { +function joinCommaIf(camera1, camera2) +{ + if (camera1.length > 0 && camera2.length > 0) + { if (camera1.indexOf(",") > -1) return camera1 + " " + camera2; else return camera1 + ", " + camera2; } @@ -13077,13 +15128,15 @@ function joinCommaIf(camera1, camera2) { return ""; } -function joinIfBothWithDash(camera1, camera2) { +function joinIfBothWithDash(camera1, camera2) +{ if (camera1.length > 0 && camera2.length > 0) - return camera1 + " / " + camera2; + { return camera1 + " / " + camera2; } return ""; } -function startLookup(call, grid) { +function startLookup(call, grid) +{ if (call == "-") return; if (grid == "-") grid = ""; @@ -13092,51 +15145,63 @@ function startLookup(call, grid) { lookupCallsign(call, grid); } -function searchLogForCallsign(call) { +function searchLogForCallsign(call) +{ setLookupDiv("lookupLocalDiv", ""); var list = Object.values(g_QSOhash) - .filter(function (value) { + .filter(function (value) + { return value.DEcall == call; }) .sort(myBandCompare); - if (list.length > 0) { + if (list.length > 0) + { var work = {}; var conf = {}; var lastTime = 0; var lastRow = null; var dxcc = list[0].dxcc; - for (row in list) { + for (row in list) + { var what = list[row].band + "," + list[row].mode; - if (list[row].time > lastTime) { + if (list[row].time > lastTime) + { lastRow = row; lastTime = list[row].time; } - if (list[row].confirmed) { + if (list[row].confirmed) + { conf[what] = g_pskColors[list[row].band]; if (what in work) delete work[what]; - } else if (!(what in conf)) work[what] = g_pskColors[list[row].band]; + } + else if (!(what in conf)) work[what] = g_pskColors[list[row].band]; } var worker = "
"; - if (Object.keys(work).length > 0) { + if (Object.keys(work).length > 0) + { worker += ""; } - if (Object.keys(conf).length > 0) { + if (Object.keys(conf).length > 0) + { worker += ""; } - if (lastRow) { + if (lastRow) + { worker += "
Worked"; var k = Object.keys(work).sort(); - for (var key in k) { + for (var key in k) + { worker += "" + k[key] + " "; } worker += "
Confirmed"; var k = Object.keys(conf).sort(); - for (var key in k) { + for (var key in k) + { worker += "" + k[key] + " "; } worker += "
Last QSO"; worker += " { - if (systemFiles.includes(filename)) { + userFiles.forEach((filename) => + { + if (systemFiles.includes(filename)) + { var userPath = path.join(userDir, filename); var systemPath = path.join(systemDir, filename); console.log(userPath + " -- " + systemPath); - if (fs.statSync(userPath).size == fs.statSync(systemPath).size) { + if (fs.statSync(userPath).size == fs.statSync(systemPath).size) + { console.log("removing duplicate user media " + filename); - try { + try + { fs.unlinkSync(userPath); - } catch (e) { + } + catch (e) + { console.log(e); } } @@ -13221,18 +15300,23 @@ function purgeUserFiles(userDir, systemDir) { }); } -function mediaCheck() { +function mediaCheck() +{ var homeDir = g_platform == "windows" ? process.env.USERPROFILE : process.env.HOME; g_appData = path.join(homeDir, "Dokumente"); - if (!is_dir(g_appData)) { + if (!is_dir(g_appData)) + { g_appData = path.join(homeDir, "Documents"); - if (!is_dir(g_appData)) { - if (g_appSettings.savedAppData != null) { + if (!is_dir(g_appData)) + { + if (g_appSettings.savedAppData != null) + { g_appData = g_appSettings.savedAppData; if (!is_dir(g_appData)) return false; - } else return false; + } + else return false; } } @@ -13244,20 +15328,25 @@ function mediaCheck() { g_NWappData = path.join(nw.App.dataPath, "Ginternal"); - try { + try + { var userdirs = [ g_appData, g_NWappData, g_screenshotDir, g_scriptDir, - g_userMediaDir, + g_userMediaDir ]; - for (var dir of userdirs) { - if (!fs.existsSync(dir)) { + for (var dir of userdirs) + { + if (!fs.existsSync(dir)) + { fs.mkdirSync(dir); } } - } catch (e) { + } + catch (e) + { alert( "Unable to create or access " + g_appData + @@ -13293,7 +15382,8 @@ function mediaCheck() { fs.readdirSync(g_userMediaDir), fs.readdirSync(g_gtMediaDir) ); - mediaFiles.forEach((filename) => { + mediaFiles.forEach((filename) => + { var noExt = path.parse(filename).name; logEventMedia.appendChild(newOption(filename, noExt)); alertMediaSelect.appendChild(newOption(filename, noExt)); @@ -13309,7 +15399,8 @@ function mediaCheck() { var modeData = fs.readFileSync("./data/modes.json"); g_modes = JSON.parse(modeData); - for (var key in g_modes) { + for (var key in g_modes) + { gtModeFilter.appendChild(newOption(key)); } @@ -13324,45 +15415,55 @@ function mediaCheck() { // Old log filename, no longer referenced tryToDeleteLog("lotw.adif"); - try { - if (fs.existsSync(g_NWappData + "internal_qso.json")) { + try + { + if (fs.existsSync(g_NWappData + "internal_qso.json")) + { var data = JSON.parse(fs.readFileSync(g_NWappData + "internal_qso.json")); - if (typeof data.version != "undefined" && data.version == gtVersion) { + if (typeof data.version != "undefined" && data.version == gtVersion) + { g_tracker = data.tracker; - if (typeof g_tracker.worked.px == "undefined") { + if (typeof g_tracker.worked.px == "undefined") + { g_tracker.worked.px = {}; g_tracker.confirmed.px = {}; } g_QSOhash = data.g_QSOhash; - for (var i in g_QSOhash) { + for (var i in g_QSOhash) + { if ( typeof g_QSOhash[i].px == "undefined" || g_QSOhash[i].px == null - ) { + ) + { if (g_QSOhash[i].dxcc != -1) - g_QSOhash[i].px = getWpx(g_QSOhash[i].DEcall); + { g_QSOhash[i].px = getWpx(g_QSOhash[i].DEcall); } else g_QSOhash[i].px = null; } g_QSOcount++; if (g_QSOhash[i].confirmed) g_QSLcount++; } - } else { + } + else + { clearLogFilesAndCounts(); } fs.unlinkSync(g_NWappData + "internal_qso.json"); } loadReceptionReports(); - } catch (e) {} + } + catch (e) {} return true; } -function newOption(value, text) { +function newOption(value, text) +{ if (typeof text == "undefined") text = value; var option = document.createElement("option"); option.value = value; @@ -13371,47 +15472,58 @@ function newOption(value, text) { } var g_rosterSpot = false; -function setRosterSpot(enabled) { +function setRosterSpot(enabled) +{ g_rosterSpot = enabled; } -function saveReceptionReports() { - try { +function saveReceptionReports() +{ + try + { fs.writeFileSync( g_NWappData + "spots.json", JSON.stringify(g_receptionReports) ); - } catch (e) {} + } + catch (e) {} } -function loadReceptionReports() { - try { +function loadReceptionReports() +{ + try + { var clear = true; - if (fs.existsSync(g_NWappData + "spots.json")) { + if (fs.existsSync(g_NWappData + "spots.json")) + { g_receptionReports = JSON.parse( fs.readFileSync(g_NWappData + "spots.json") ); if (timeNowSec() - g_receptionReports.lastDownloadTimeSec <= 86400) - clear = false; + { clear = false; } } - if (clear == true) { + if (clear == true) + { g_receptionReports = { lastDownloadTimeSec: 0, lastSequenceNumber: "0", - spots: {}, + spots: {} }; } - } catch (e) { + } + catch (e) + { g_receptionReports = { lastDownloadTimeSec: 0, lastSequenceNumber: "0", - spots: {}, + spots: {} }; } } -function pskSpotCheck(timeSec) { +function pskSpotCheck(timeSec) +{ if (g_mapSettings.offlineMode == true) return; if (myDEcall == null || myDEcall == "NOCALL" || myDEcall == "") return; @@ -13419,7 +15531,8 @@ function pskSpotCheck(timeSec) { if ( timeSec - g_receptionReports.lastDownloadTimeSec > 120 && (g_spotsEnabled == 1 || g_rosterSpot) - ) { + ) + { g_receptionReports.lastDownloadTimeSec = timeSec; localStorage.receptionSettings = JSON.stringify(g_receptionSettings); spotRefreshDiv.innerHTML = "..refreshing.."; @@ -13435,28 +15548,36 @@ function pskSpotCheck(timeSec) { "https", 443 ); - } else if (g_spotsEnabled == 1) { + } + else if (g_spotsEnabled == 1) + { spotRefreshDiv.innerHTML = "Refresh: " + Number(120 - (timeSec - g_receptionReports.lastDownloadTimeSec)).toDHMS(); } } -function pskSpotResults(buffer, flag) { +function pskSpotResults(buffer, flag) +{ var oParser = new DOMParser(); var oDOM = oParser.parseFromString(buffer, "text/xml"); var result = ""; - if (oDOM != null) { + if (oDOM != null) + { var json = XML2jsobj(oDOM.documentElement); - if (typeof json.lastSequenceNumber != "undefined") { + if (typeof json.lastSequenceNumber != "undefined") + { g_receptionReports.lastSequenceNumber = json.lastSequenceNumber.value; - if (typeof json.receptionReport != "undefined") { - for (var key in json.receptionReport) { + if (typeof json.receptionReport != "undefined") + { + for (var key in json.receptionReport) + { if ( typeof json.receptionReport[key].frequency != "undefined" && typeof json.receptionReport[key].sNR != "undefined" - ) { + ) + { var report; var call = json.receptionReport[key].receiverCallsign; var mode = json.receptionReport[key].mode; @@ -13466,14 +15587,17 @@ function pskSpotResults(buffer, flag) { ).formatBand(); var hash = call + mode + band + grid.substr(0, 4); - if (hash in g_receptionReports.spots) { + if (hash in g_receptionReports.spots) + { report = g_receptionReports.spots[hash]; if ( parseInt(json.receptionReport[key].flowStartSeconds) < report.when ) - continue; - } else { + { continue; } + } + else + { report = g_receptionReports.spots[hash] = {}; report.call = call; report.band = band; @@ -13483,9 +15607,11 @@ function pskSpotResults(buffer, flag) { if ( typeof json.receptionReport[key].receiverCallsign != "undefined" ) + { report.dxcc = callsignToDxcc( json.receptionReport[key].receiverCallsign ); + } else report.dxcc = -1; report.when = parseInt(json.receptionReport[key].flowStartSeconds); report.snr = json.receptionReport[key].sNR; @@ -13511,9 +15637,12 @@ function pskSpotResults(buffer, flag) { var g_oamsSpotTimeout = null; -function addNewOAMSSpot(cid, db) { - if (cid in g_gtFlagPins) { - if (g_oamsSpotTimeout !== null) { +function addNewOAMSSpot(cid, db) +{ + if (cid in g_gtFlagPins) + { + if (g_oamsSpotTimeout !== null) + { clearTimeout(g_oamsSpotTimeout); g_oamsSpotTimeout = null; } @@ -13524,9 +15653,12 @@ function addNewOAMSSpot(cid, db) { var band = g_gtFlagPins[cid].band; var hash = call + mode + band + grid.substr(0, 4); - if (hash in g_receptionReports.spots) { + if (hash in g_receptionReports.spots) + { report = g_receptionReports.spots[hash]; - } else { + } + else + { report = g_receptionReports.spots[hash] = {}; report.call = call; report.band = band; @@ -13548,7 +15680,8 @@ function addNewOAMSSpot(cid, db) { } } -function spotFeature(center) { +function spotFeature(center) +{ return new ol.Feature( ol.geom.Polygon.circular(center, 30000, 63).transform( "EPSG:4326", @@ -13559,7 +15692,8 @@ function spotFeature(center) { var g_spotTotalCount = 0; -function createSpot(report, key, fromPoint, addToLayer = true) { +function createSpot(report, key, fromPoint, addToLayer = true) +{ var LL = squareToLatLongAll(report.grid); var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; @@ -13576,26 +15710,27 @@ function createSpot(report, key, fromPoint, addToLayer = true) { ? g_receptionSettings.pathNightColor : g_receptionSettings.pathColor; - if (workingColor != -1) { + if (workingColor != -1) + { var testColor = workingColor < 1 ? "#0000000" : workingColor == 361 - ? "#FFFFFF" - : "hsla(" + workingColor + ", 100%, 50%," + report.color / 255 + ")"; + ? "#FFFFFF" + : "hsla(" + workingColor + ", 100%, 50%," + report.color / 255 + ")"; if (workingColor < 1 || workingColor == 361) - spotColor = intAlphaToRGB(testColor.substr(0, 7), report.color); + { spotColor = intAlphaToRGB(testColor.substr(0, 7), report.color); } else spotColor = testColor; } featureStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: spotColor, + color: spotColor }), stroke: new ol.style.Stroke({ color: "#000000FF", - width: 0.25, - }), + width: 0.25 + }) }); spot.setStyle(featureStyle); spot.spot = key; @@ -13608,34 +15743,36 @@ function createSpot(report, key, fromPoint, addToLayer = true) { var pointFeature = new ol.Feature({ geometry: lonLat, - weight: report.color / 255, // e.g. temperature + weight: report.color / 255 // e.g. temperature }); g_layerSources["psk-heat"].addFeature(pointFeature); - if (g_receptionSettings.viewPaths && g_receptionSettings.spotWidth > 0) { + if (g_receptionSettings.viewPaths && g_receptionSettings.spotWidth > 0) + { var strokeWeight = g_receptionSettings.spotWidth; var flightColor = workingColor == -1 ? colorNoAlpha + "BB" : g_mapSettings.nightMapEnable && g_nightTime - ? g_spotNightFlightColor - : g_spotFlightColor; + ? g_spotNightFlightColor + : g_spotFlightColor; var feature = flightFeature( [fromPoint, toPoint], { weight: strokeWeight, color: flightColor, - steps: 75, + steps: 75 }, "psk-flights", false ); } } -function redrawSpots() { +function redrawSpots() +{ var shouldSave = false; var now = timeNowSec(); g_spotTotalCount = 0; @@ -13646,17 +15783,20 @@ function redrawSpots() { var fromPoint = getPoint(myRawGrid); - if (g_receptionSettings.mergeSpots == false) { + if (g_receptionSettings.mergeSpots == false) + { var spot = iconFeature(fromPoint, g_gtFlagIcon, 100); g_layerSources["psk-spots"].addFeature(spot); g_layerSources["psk-heat"].addFeature(spot); } - for (var key in g_receptionReports.spots) { + for (var key in g_receptionReports.spots) + { report = g_receptionReports.spots[key]; - if (now - report.when > 86400) { + if (now - report.when > 86400) + { delete g_receptionReports.spots[key]; shouldSave = true; continue; @@ -13668,37 +15808,45 @@ function redrawSpots() { ? 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) + { createSpot(report, key, fromPoint); g_spotTotalCount++; } } } - if (shouldSave) { + if (shouldSave) + { saveReceptionReports(); } updateSpotCountDiv(); } -function updateSpotCountDiv() { +function updateSpotCountDiv() +{ spotCountDiv.innerHTML = "Spots: " + g_spotTotalCount; } var g_spotFlightColor = "#FFFFFFBB"; var g_spotNightFlightColor = "#FFFFFFBB"; -function changeSpotValues() { +function changeSpotValues() +{ g_receptionSettings.viewHistoryTimeSec = parseInt(spotHistoryTimeValue.value) * 60; spotHistoryTimeTd.innerHTML = "Max Age: " + Number(g_receptionSettings.viewHistoryTimeSec).toDHM(); g_receptionSettings.viewPaths = spotPathsValue.checked; - if (g_receptionSettings.viewPaths) { + if (g_receptionSettings.viewPaths) + { spotPathWidthDiv.style.display = "inline-block"; - } else { + } + else + { spotPathWidthDiv.style.display = "none"; } @@ -13710,7 +15858,8 @@ function changeSpotValues() { if (g_rosterSpot) goProcessRoster(); } -function mapTransChange() { +function mapTransChange() +{ g_mapSettings.mapTrans = mapTransValue.value; mapTransTd.innerHTML = @@ -13719,95 +15868,110 @@ function mapTransChange() { "rgba(0,0,0, " + g_mapSettings.mapTrans + ")"; } -function spotPathChange() { +function spotPathChange() +{ g_receptionSettings.pathColor = spotPathColorValue.value; var pathColor = g_receptionSettings.pathColor < 1 ? "#000" : g_receptionSettings.pathColor == 361 - ? "#FFF" - : "hsl(" + g_receptionSettings.pathColor + ", 100%, 50%)"; - if (g_receptionSettings.pathColor > 0) { + ? "#FFF" + : "hsl(" + g_receptionSettings.pathColor + ", 100%, 50%)"; + if (g_receptionSettings.pathColor > 0) + { spotPathColorDiv.style.color = "#000"; spotPathColorDiv.style.backgroundColor = pathColor; - } else { + } + else + { spotPathColorDiv.style.color = "#FFF"; spotPathColorDiv.style.backgroundColor = pathColor; } if (g_receptionSettings.pathColor == -1) - spotPathInfoTd.innerHTML = "PSK-Reporter Palette"; + { spotPathInfoTd.innerHTML = "PSK-Reporter Palette"; } else spotPathInfoTd.innerHTML = ""; g_spotFlightColor = g_receptionSettings.pathColor < 1 ? "#0000000BB" : g_receptionSettings.pathColor == 361 - ? "#FFFFFFBB" - : "hsla(" + g_receptionSettings.pathColor + ", 100%, 50%,0.73)"; + ? "#FFFFFFBB" + : "hsla(" + g_receptionSettings.pathColor + ", 100%, 50%,0.73)"; g_receptionSettings.pathNightColor = spotNightPathColorValue.value; var pathNightColor = g_receptionSettings.pathNightColor < 1 ? "#000" : g_receptionSettings.pathNightColor == 361 - ? "#FFF" - : "hsl(" + g_receptionSettings.pathNightColor + ", 100%, 50%)"; - if (g_receptionSettings.pathNightColor > 0) { + ? "#FFF" + : "hsl(" + g_receptionSettings.pathNightColor + ", 100%, 50%)"; + if (g_receptionSettings.pathNightColor > 0) + { spotNightPathColorDiv.style.color = "#000"; spotNightPathColorDiv.style.backgroundColor = pathNightColor; - } else { + } + else + { spotNightPathColorDiv.style.color = "#FFF"; spotNightPathColorDiv.style.backgroundColor = pathNightColor; } if (g_receptionSettings.pathNightColor == -1) - spotNightPathInfoTd.innerHTML = "PSK-Reporter Palette"; + { spotNightPathInfoTd.innerHTML = "PSK-Reporter Palette"; } else spotNightPathInfoTd.innerHTML = ""; g_spotNightFlightColor = g_receptionSettings.pathNightColor < 1 ? "#0000000BB" : g_receptionSettings.pathNightColor == 361 - ? "#FFFFFFBB" - : "hsla(" + g_receptionSettings.pathNightColor + ", 100%, 50%,0.73)"; + ? "#FFFFFFBB" + : "hsla(" + g_receptionSettings.pathNightColor + ", 100%, 50%,0.73)"; spotWidthTd.innerHTML = g_receptionSettings.spotWidth = spotWidthValue.value; localStorage.receptionSettings = JSON.stringify(g_receptionSettings); } -function toggleSpotOverGrids() { - spotMergeValue.checked = spotMergeValue.checked == true ? false : true; +function toggleSpotOverGrids() +{ + spotMergeValue.checked = spotMergeValue.checked != true; changeSpotValues(); redrawSpots(); } -function toggleMergeOverlay() { - mergeOverlayValue.checked = mergeOverlayValue.checked == true ? false : true; +function toggleMergeOverlay() +{ + mergeOverlayValue.checked = mergeOverlayValue.checked != true; changeMergeOverlayValue(); } -function toggleSpotPaths() { +function toggleSpotPaths() +{ var spotPaths = spotPathsValue.checked == true ? 1 : 0; spotPaths ^= 1; - spotPathsValue.checked = spotPaths == 1 ? true : false; + spotPathsValue.checked = spotPaths == 1; g_receptionSettings.viewPaths = spotPathsValue.checked; localStorage.receptionSettings = JSON.stringify(g_receptionSettings); - if (g_receptionSettings.viewPaths) { + if (g_receptionSettings.viewPaths) + { spotPathWidthDiv.style.display = "inline-block"; - } else { + } + else + { spotPathWidthDiv.style.display = "none"; } redrawSpots(); } -function toggleHeatSpots() { +function toggleHeatSpots() +{ g_heatEnabled ^= 1; g_appSettings.heatEnabled = g_heatEnabled; updateSpotView(); } -function togglePskSpots() { +function togglePskSpots() +{ g_spotsEnabled ^= 1; g_appSettings.spotsEnabled = g_spotsEnabled; pskSpotsImg.style.filter = g_spotsEnabled == 1 ? "" : "grayscale(1)"; @@ -13815,33 +15979,45 @@ function togglePskSpots() { updateSpotView(); } -function toggleCRScript() { +function toggleCRScript() +{ g_crScript ^= 1; g_appSettings.crScript = g_crScript; if (g_crScript == 1) + { addLastTraffic( "Call Roster Script Enabled" ); + } else + { addLastTraffic( "Call Roster Script Disabled" ); + } goProcessRoster(); } -function updateSpotView(leaveCount = true) { - if (g_spotsEnabled == 1) { - if (g_receptionSettings.mergeSpots == false) { - for (var key in g_layerVectors) { +function updateSpotView(leaveCount = true) +{ + if (g_spotsEnabled == 1) + { + if (g_receptionSettings.mergeSpots == false) + { + for (var key in g_layerVectors) + { g_layerVectors[key].setVisible(false); } } - if (g_heatEnabled == 0) { + if (g_heatEnabled == 0) + { g_layerVectors["psk-spots"].setVisible(true); g_layerVectors["psk-flights"].setVisible(true); g_layerVectors["psk-hop"].setVisible(true); g_layerVectors["psk-heat"].setVisible(false); - } else { + } + else + { g_layerVectors["psk-spots"].setVisible(false); g_layerVectors["psk-flights"].setVisible(false); g_layerVectors["psk-hop"].setVisible(false); @@ -13850,7 +16026,9 @@ function updateSpotView(leaveCount = true) { SpotsDiv.style.display = "block"; if (leaveCount == false) spotRefreshDiv.innerHTML = " "; - } else { + } + else + { g_layerVectors["psk-spots"].setVisible(false); g_layerVectors["psk-flights"].setVisible(false); g_layerVectors["psk-hop"].setVisible(false); @@ -13858,53 +16036,66 @@ function updateSpotView(leaveCount = true) { SpotsDiv.style.display = "none"; spotRefreshDiv.innerHTML = " "; } - g_layerVectors["strikes"].setVisible(true); + g_layerVectors.strikes.setVisible(true); } -function gotoDonate() { +function gotoDonate() +{ var gui = require("nw.gui"); gui.Shell.openExternal("https://gridtracker.org/donations/"); } -function changeRosterTime() { +function changeRosterTime() +{ g_mapSettings.rosterTime = rosterTime.value; setRosterTimeView(); saveMapSettings(); goProcessRoster(); } -function changeRosterTop(butt) { +function changeRosterTop(butt) +{ g_appSettings.rosterAlwaysOnTop = butt.checked; setRosterTop(); } -function setRosterTop() { - if (g_callRosterWindowHandle) { - try { +function setRosterTop() +{ + if (g_callRosterWindowHandle) + { + try + { g_callRosterWindowHandle.setAlwaysOnTop(g_appSettings.rosterAlwaysOnTop); - } catch (e) {} + } + catch (e) {} } } -function setRosterTimeView() { +function setRosterTimeView() +{ rosterTime.value = g_mapSettings.rosterTime; rosterTimeTd.innerHTML = Number(rosterTime.value).toDHMS(); } -function getSpotTime(hash) { - if (hash in g_receptionReports.spots) { +function getSpotTime(hash) +{ + if (hash in g_receptionReports.spots) + { return g_receptionReports.spots[hash]; - } else return null; + } + else return null; } -function setGridOpacity() { +function setGridOpacity() +{ opacityValue.value = g_mapSettings.gridAlpha; showOpacityTd.innerHTML = parseInt((g_mapSettings.gridAlpha / 255) * 100) + "%"; g_gridAlpha = parseInt(g_mapSettings.gridAlpha).toString(16); } -function changeGridOpacity() { +function changeGridOpacity() +{ g_mapSettings.gridAlpha = opacityValue.value; showOpacityTd.innerHTML = parseInt((g_mapSettings.gridAlpha / 255) * 100) + "%"; @@ -13912,7 +16103,8 @@ function changeGridOpacity() { saveMapSettings(); } -function currentTimeStampString() { +function currentTimeStampString() +{ var now = new Date(); return ( now.getFullYear() + @@ -13929,15 +16121,18 @@ function currentTimeStampString() { ); } -function showNativeFolder(fn) { +function showNativeFolder(fn) +{ nw.Shell.showItemInFolder(decodeURI(fn)); } -function makeScreenshots() { +function makeScreenshots() +{ var win = gui.Window.get(); win.capturePage( - function (buffer) { + function (buffer) + { var clipboard = nw.Clipboard.get(); clipboard.set(buffer, "png", true); }, @@ -13945,8 +16140,10 @@ function makeScreenshots() { ); win.capturePage( - function (buffer) { - try { + function (buffer) + { + try + { var fn = g_screenshotDir + "Screenshot " + currentTimeStampString() + ".png"; fs.writeFileSync(fn, buffer); @@ -13955,7 +16152,9 @@ function makeScreenshots() { encodeURI(fn).trim() + "\");''>Saved Screenshot" ); - } catch (e) { + } + catch (e) + { addLastTraffic( "Screenshot write failed" ); @@ -13965,10 +16164,11 @@ function makeScreenshots() { ); } -window.addEventListener("load", function () { +window.addEventListener("load", function () +{ picker.attach({ target: "workingDateValue", container: "pick-inline", - fire: "workingDateChanged", + fire: "workingDateChanged" }); }); diff --git a/package.nw/lib/gtws.js b/package.nw/lib/gtws.js index 30386717..4fbca48d 100644 --- a/package.nw/lib/gtws.js +++ b/package.nw/lib/gtws.js @@ -9,7 +9,7 @@ var g_chatRecvFunctions = { info: gtChatUpdateCall, drop: gtChatRemoveCall, mesg: gtChatMessage, - o: gtSpotMessage, + o: gtSpotMessage }; var ChatState = Object(); @@ -30,7 +30,7 @@ var g_gtStateToFunction = { 3: gtChatSendUUID, 4: gtStatusCheck, 5: gtInError, - 6: gtClosedSocket, + 6: gtClosedSocket }; var g_gtChatSocket = null; @@ -55,66 +55,84 @@ var myRoom = 0; var g_gtChatlistChangeCount = 0; var g_gtCurrentMessageCount = 0; -function gtConnectChat() { - if (g_gtChatSocket != null) { +function gtConnectChat() +{ + if (g_gtChatSocket != null) + { // we should start over g_gtState = ChatState.error; return; } var rnd = parseInt(Math.random() * 10) + 18260; - try { + try + { g_gtState = ChatState.connecting; g_gtChatSocket = new WebSocket("wss://tagloomis.com:" + rnd); - } catch (e) { + } + catch (e) + { g_gtState = ChatState.error; return; } - g_gtChatSocket.onopen = function () { + g_gtChatSocket.onopen = function () + { g_gtState = ChatState.connected; }; - g_gtChatSocket.onmessage = function (evt) { - if (g_appSettings.gtShareEnable == true) { + g_gtChatSocket.onmessage = function (evt) + { + if (g_appSettings.gtShareEnable == true) + { var jsmesg = false; - try { + try + { jsmesg = JSON.parse(evt.data); - } catch (err) { + } + catch (err) + { // bad message, dumping client g_gtState = ChatState.error; return; } - if (typeof jsmesg.type == "undefined") { + if (typeof jsmesg.type == "undefined") + { g_gtState = ChatState.error; return; } - if (jsmesg.type in g_chatRecvFunctions) { + if (jsmesg.type in g_chatRecvFunctions) + { g_chatRecvFunctions[jsmesg.type](jsmesg); - } else { + } + else + { g_gtState = ChatState.error; - return; } } }; - g_gtChatSocket.onerror = function () { + g_gtChatSocket.onerror = function () + { g_gtState = ChatState.error; }; - g_gtChatSocket.onclose = function () { + g_gtChatSocket.onclose = function () + { g_gtState = ChatState.closed; }; } function gtConnecting() {} -function gtInError() { +function gtInError() +{ closeGtSocket(); } -function gtChatSendClose() { +function gtChatSendClose() +{ msg = Object(); msg.type = "close"; msg.uuid = g_appSettings.chatUUID; @@ -122,69 +140,91 @@ function gtChatSendClose() { sendGtJson(JSON.stringify(msg)); } -function closeGtSocket() { - if (g_gtChatSocket != null) { +function closeGtSocket() +{ + if (g_gtChatSocket != null) + { gtChatSendClose(); if (g_gtChatSocket.readyState != WebSocket.CLOSED) g_gtChatSocket.close(); - if (g_gtChatSocket.readyState === WebSocket.CLOSED) { + if (g_gtChatSocket.readyState === WebSocket.CLOSED) + { g_gtChatSocket = null; g_gtState = ChatState.none; } - } else g_gtState = ChatState.none; + } + else g_gtState = ChatState.none; } -function gtClosedSocket() { +function gtClosedSocket() +{ g_gtChatSocket = null; g_gtState = ChatState.none; } -function gtCanConnect() { +function gtCanConnect() +{ g_gtState = ChatState.connect; } -function gtSetIdle() { +function gtSetIdle() +{ g_gtStatusCount = 0; g_gtNeedUsersList = true; g_gtState = ChatState.idle; g_lastGtStatus = ""; } -function gtStatusCheck() { - if (g_gtStatusCount > 0) { +function gtStatusCheck() +{ + if (g_gtStatusCount > 0) + { g_gtStatusCount--; } - if (g_gtStatusCount == 0 || g_gtLiveStatusUpdate == true) { - if (g_gtLiveStatusUpdate == true) { + if (g_gtStatusCount == 0 || g_gtLiveStatusUpdate == true) + { + if (g_gtLiveStatusUpdate == true) + { g_gtLiveStatusUpdate = false; - } else { + } + else + { g_lastGtStatus = ""; g_gtStatusCount = g_gtStatusTime; } gtChatSendStatus(); } - if (g_gtNeedUsersList == true) { + if (g_gtNeedUsersList == true) + { g_gtNeedUsersList = false; gtChatGetList(); } } -function sendGtJson(json) { - if (g_gtChatSocket != null) { - if (g_gtChatSocket.readyState === WebSocket.OPEN) { +function sendGtJson(json) +{ + if (g_gtChatSocket != null) + { + if (g_gtChatSocket.readyState === WebSocket.OPEN) + { g_gtChatSocket.send(json); - } else { - if (g_gtChatSocket.readyState === WebSocket.CLOSED) { + } + else + { + if (g_gtChatSocket.readyState === WebSocket.CLOSED) + { g_gtState = ChatState.closed; } } - } else g_gtState = ChatState.closed; + } + else g_gtState = ChatState.closed; } var g_lastGtStatus = ""; -function gtChatSendStatus() { +function gtChatSendStatus() +{ var msg = Object(); msg.type = "status"; msg.uuid = g_appSettings.chatUUID; @@ -198,13 +238,15 @@ function gtChatSendStatus() { msg.o = g_appSettings.gtSpotEnable == true ? 1 : 0; msg = JSON.stringify(msg); - if (msg != g_lastGtStatus) { + if (msg != g_lastGtStatus) + { sendGtJson(msg); g_lastGtStatus = msg; } } -function gtChatSendSpots(spotsObject) { +function gtChatSendSpots(spotsObject) +{ var msg = Object(); msg.type = "o"; msg.uuid = g_appSettings.chatUUID; @@ -213,23 +255,29 @@ function gtChatSendSpots(spotsObject) { sendGtJson(msg); } -function gtChatRemoveCall(jsmesg) { +function gtChatRemoveCall(jsmesg) +{ var id = jsmesg.id; - if (id in g_gtIdToCid) { + if (id in g_gtIdToCid) + { var cid = g_gtIdToCid[id]; - if (cid in g_gtFlagPins) { + if (cid in g_gtFlagPins) + { delete g_gtFlagPins[cid].ids[id]; - if (Object.keys(g_gtFlagPins[cid].ids).length == 0) { - if (g_gtFlagPins[cid].pin != null) { + if (Object.keys(g_gtFlagPins[cid].ids).length == 0) + { + if (g_gtFlagPins[cid].pin != null) + { // remove pin from map here - if (g_layerSources["gtflags"].hasFeature(g_gtFlagPins[cid].pin)) - g_layerSources["gtflags"].removeFeature(g_gtFlagPins[cid].pin); + if (g_layerSources.gtflags.hasFeature(g_gtFlagPins[cid].pin)) + { g_layerSources.gtflags.removeFeature(g_gtFlagPins[cid].pin); } delete g_gtFlagPins[cid].pin; g_gtFlagPins[cid].pin = null; } g_gtFlagPins[cid].live = false; notifyNoChat(cid); - if (!(cid in g_gtMessages)) { + if (!(cid in g_gtMessages)) + { delete g_gtCallsigns[g_gtFlagPins[cid].call]; delete g_gtFlagPins[cid]; } @@ -241,21 +289,26 @@ function gtChatRemoveCall(jsmesg) { } } -function gtChatUpdateCall(jsmesg) { +function gtChatUpdateCall(jsmesg) +{ var id = jsmesg.id; var cid = jsmesg.cid; - if (cid in g_gtFlagPins) { + if (cid in g_gtFlagPins) + { g_gtFlagPins[cid].ids[id] = true; // Did they move grid location? - if (g_gtFlagPins[cid].pin != null) { + if (g_gtFlagPins[cid].pin != null) + { // remove pin from map here - if (g_layerSources["gtflags"].hasFeature(g_gtFlagPins[cid].pin)) - g_layerSources["gtflags"].removeFeature(g_gtFlagPins[cid].pin); + if (g_layerSources.gtflags.hasFeature(g_gtFlagPins[cid].pin)) + { g_layerSources.gtflags.removeFeature(g_gtFlagPins[cid].pin); } delete g_gtFlagPins[cid].pin; g_gtFlagPins[cid].pin = null; } - } else { + } + else + { g_gtFlagPins[cid] = Object(); g_gtFlagPins[cid].pin = null; @@ -275,17 +328,19 @@ function gtChatUpdateCall(jsmesg) { g_gtFlagPins[cid].dxcc = callsignToDxcc(jsmesg.call); g_gtFlagPins[cid].live = true; // Make a pin here - if (g_gtFlagPins[cid].pin == null) { + if (g_gtFlagPins[cid].pin == null) + { makeGtPin(g_gtFlagPins[cid]); if (g_gtFlagPins[cid].pin != null) - g_layerSources["gtflags"].addFeature(g_gtFlagPins[cid].pin); + { g_layerSources.gtflags.addFeature(g_gtFlagPins[cid].pin); } } g_gtChatlistChangeCount++; g_gtCallsigns[g_gtFlagPins[cid].call] = cid; updateChatWindow(); } -function gtChatGetList() { +function gtChatGetList() +{ msg = Object(); msg.type = "list"; msg.uuid = g_appSettings.chatUUID; @@ -293,10 +348,13 @@ function gtChatGetList() { sendGtJson(JSON.stringify(msg)); } -function redrawPins() { +function redrawPins() +{ clearGtFlags(); - for (cid in g_gtFlagPins) { - if (g_gtFlagPins[cid].pin != null) { + for (cid in g_gtFlagPins) + { + if (g_gtFlagPins[cid].pin != null) + { delete g_gtFlagPins[cid].pin; g_gtFlagPins[cid].pin = null; } @@ -304,15 +362,18 @@ function redrawPins() { makeGtPin(g_gtFlagPins[cid]); if (g_gtFlagPins[cid].pin != null) - g_layerSources["gtflags"].addFeature(g_gtFlagPins[cid].pin); + { g_layerSources.gtflags.addFeature(g_gtFlagPins[cid].pin); } } } -function makeGtPin(obj) { - try { - if (obj.pin) { - if (g_layerSources["gtflags"].hasFeature(obj.pin)) - g_layerSources["gtflags"].removeFeature(obj.pin); +function makeGtPin(obj) +{ + try + { + if (obj.pin) + { + if (g_layerSources.gtflags.hasFeature(obj.pin)) + { g_layerSources.gtflags.removeFeature(obj.pin); } delete obj.pin; obj.pin = null; } @@ -327,38 +388,47 @@ function makeGtPin(obj) { g_appSettings.gtFlagImgSrc == 2 && (obj.mode != myMode || obj.band != myBand) ) - return; + { return; } var LL = squareToLatLongAll(obj.grid); var myLonLat = [ LL.lo2 - (LL.lo2 - LL.lo1) / 2, - LL.la2 - (LL.la2 - LL.la1) / 2, + LL.la2 - (LL.la2 - LL.la1) / 2 ]; obj.pin = iconFeature(ol.proj.fromLonLat(myLonLat), g_gtFlagIcon, 100); obj.pin.key = obj.cid; obj.pin.isGtFlag = true; obj.pin.size = 1; - } catch (e) {} + } + catch (e) {} } -function gtChatNewList(jsmesg) { +function gtChatNewList(jsmesg) +{ clearGtFlags(); - for (var cid in g_gtFlagPins) { + for (var cid in g_gtFlagPins) + { g_gtFlagPins[cid].live = false; - if (!(cid in g_gtMessages)) { + if (!(cid in g_gtMessages)) + { delete g_gtFlagPins[cid]; } } - for (var key in jsmesg.data.calls) { + for (var key in jsmesg.data.calls) + { var cid = jsmesg.data.cid[key]; var id = jsmesg.data.id[key]; - if (id != myChatId) { - if (cid in g_gtFlagPins) { + if (id != myChatId) + { + if (cid in g_gtFlagPins) + { g_gtFlagPins[cid].ids[id] = true; - } else { + } + else + { g_gtFlagPins[cid] = Object(); g_gtFlagPins[cid].ids = Object(); g_gtFlagPins[cid].ids[id] = true; @@ -379,7 +449,7 @@ function gtChatNewList(jsmesg) { g_gtCallsigns[g_gtFlagPins[cid].call] = cid; makeGtPin(g_gtFlagPins[cid]); if (g_gtFlagPins[cid].pin != null) - g_layerSources["gtflags"].addFeature(g_gtFlagPins[cid].pin); + { g_layerSources.gtflags.addFeature(g_gtFlagPins[cid].pin); } } } g_gtChatlistChangeCount++; @@ -387,19 +457,23 @@ function gtChatNewList(jsmesg) { updateChatWindow(); } -function appendToHistory(cid, jsmesg) { - if (!(cid in g_gtMessages)) { +function appendToHistory(cid, jsmesg) +{ + if (!(cid in g_gtMessages)) + { g_gtMessages[cid] = Object(); g_gtMessages[cid].history = Array(); } g_gtMessages[cid].history.push(jsmesg); - while (g_gtMessages[cid].history.length > g_gtMaxChatMessages) { + while (g_gtMessages[cid].history.length > g_gtMaxChatMessages) + { g_gtMessages[cid].history.shift(); } } -function htmlEntities(str) { +function htmlEntities(str) +{ return String(str) .replace(/&/g, "&") .replace(/ 0 && now % 2 == 0) { + if (Object.keys(g_gtUnread).length > 0 && now % 2 == 0) + { msgImg.style.webkitFilter = "invert(1)"; - } else msgImg.style.webkitFilter = ""; + } + else msgImg.style.webkitFilter = ""; if ( g_msgSettings.msgFrequencySelect > 0 && Object.keys(g_gtUnread).length > 0 - ) { - if (now - g_lastChatMsgAlert > g_msgSettings.msgFrequencySelect * 60) { + ) + { + if (now - g_lastChatMsgAlert > g_msgSettings.msgFrequencySelect * 60) + { alertChatMessage(); } } - } else { + } + else + { closeGtSocket(); g_gtChatlistChangeCount = 0; g_lastGtStatus = ""; } } -function gtSpotMessage(jsmesg) { +function gtSpotMessage(jsmesg) +{ addNewOAMSSpot(jsmesg.cid, jsmesg.db); } -function gtChatSystemInit() { +function gtChatSystemInit() +{ g_gtEngineInterval = setInterval(gtChatStateMachine, 1000); } -function showGtFlags() { - if (g_appSettings.gtFlagImgSrc > 0) { - if (g_mapSettings.offlineMode == false) { +function showGtFlags() +{ + if (g_appSettings.gtFlagImgSrc > 0) + { + if (g_mapSettings.offlineMode == false) + { redrawPins(); - g_layerVectors["gtflags"].setVisible(true); - } else { - g_layerVectors["gtflags"].setVisible(false); + g_layerVectors.gtflags.setVisible(true); } - } else g_layerVectors["gtflags"].setVisible(false); + else + { + g_layerVectors.gtflags.setVisible(false); + } + } + else g_layerVectors.gtflags.setVisible(false); } -function clearGtFlags() { - g_layerSources["gtflags"].clear(); +function clearGtFlags() +{ + g_layerSources.gtflags.clear(); } -function toggleGtMap() { +function toggleGtMap() +{ g_appSettings.gtFlagImgSrc += 1; g_appSettings.gtFlagImgSrc %= 3; gtFlagImg.src = g_gtFlagImageArray[g_appSettings.gtFlagImgSrc]; if (g_spotsEnabled == 1 && g_receptionSettings.mergeSpots == false) return; - if (g_appSettings.gtFlagImgSrc > 0) { + if (g_appSettings.gtFlagImgSrc > 0) + { redrawPins(); - g_layerVectors["gtflags"].setVisible(true); - } else { - g_layerVectors["gtflags"].setVisible(false); + g_layerVectors.gtflags.setVisible(true); + } + else + { + g_layerVectors.gtflags.setVisible(false); } } -function notifyNoChat(id) { - if (g_chatWindowHandle != null) { - try { +function notifyNoChat(id) +{ + if (g_chatWindowHandle != null) + { + try + { g_chatWindowHandle.window.notifyNoChat(id); - } catch (e) {} + } + catch (e) {} } } -function updateChatWindow() { - if (g_chatWindowHandle != null) { - try { +function updateChatWindow() +{ + if (g_chatWindowHandle != null) + { + try + { g_chatWindowHandle.window.updateEverything(); - } catch (e) {} + } + catch (e) {} } } -function newChatMessage(id, jsmesg) { +function newChatMessage(id, jsmesg) +{ var hasFocus = false; if (g_msgSettings.msgActionSelect == 1) showMessaging(); - if (g_chatWindowHandle != null) { - try { + if (g_chatWindowHandle != null) + { + try + { hasFocus = g_chatWindowHandle.window.newChatMessage(id, jsmesg); - } catch (e) {} + } + catch (e) {} updateChatWindow(); } return hasFocus; @@ -561,12 +678,15 @@ function newChatMessage(id, jsmesg) { var g_lastChatMsgAlert = 0; -function alertChatMessage() { - if (g_msgSettings.msgAlertSelect == 1) { +function alertChatMessage() +{ + if (g_msgSettings.msgAlertSelect == 1) + { // Text to speech speakAlertString(g_msgSettings.msgAlertWord); } - if (g_msgSettings.msgAlertSelect == 2) { + if (g_msgSettings.msgAlertSelect == 2) + { // Audible playAlertMediaFile(g_msgSettings.msgAlertMedia); } diff --git a/package.nw/lib/protos.js b/package.nw/lib/protos.js index a7ac176a..ce9de4ca 100644 --- a/package.nw/lib/protos.js +++ b/package.nw/lib/protos.js @@ -3,7 +3,8 @@ // See LICENSE for more information. // Incoming is already float fixed ( 14.037 ) for 14,037,000hz -Number.prototype.formatBand = function () { +Number.prototype.formatBand = function () +{ var freq = this; var bands = [ "OOB", @@ -73,7 +74,7 @@ Number.prototype.formatBand = function () { 224, "1.5m", 225, - "1.5m", + "1.5m" ]; var newFreq = parseInt(freq); @@ -87,12 +88,14 @@ Number.prototype.formatBand = function () { else return "OOB"; }; -Number.prototype.formatMhz = function (n, x) { +Number.prototype.formatMhz = function (n, x) +{ var re = "\\d(?=(\\d{" + (x || 3) + "})+" + (n > 0 ? "\\." : "$") + ")"; return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, "g"), "$&."); }; -Number.prototype.formatSignalReport = function () { +Number.prototype.formatSignalReport = function () +{ var val = this; var report = String(); @@ -101,12 +104,14 @@ Number.prototype.formatSignalReport = function () { return report; }; -String.prototype.formatCallsign = function () { +String.prototype.formatCallsign = function () +{ var re = new RegExp("0", "g"); return this.replace(re, "Ø"); }; -Number.prototype.toDHMS = function () { +Number.prototype.toDHMS = function () +{ var seconds = this; var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -124,7 +129,8 @@ Number.prototype.toDHMS = function () { return val; }; -Number.prototype.toDHM = function () { +Number.prototype.toDHM = function () +{ var seconds = this; var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -140,7 +146,8 @@ Number.prototype.toDHM = function () { return val; }; -Number.prototype.toYM = function () { +Number.prototype.toYM = function () +{ var months = this; var years = parseInt(Math.floor(months / 12)); months -= years * 12; @@ -151,7 +158,8 @@ Number.prototype.toYM = function () { return total == "" ? "any" : total; }; -Number.prototype.toHMS = function () { +Number.prototype.toHMS = function () +{ var seconds = this; var days = Math.floor(seconds / (3600 * 24)); seconds -= days * 3600 * 24; @@ -167,20 +175,25 @@ Number.prototype.toHMS = function () { return val; }; -String.prototype.toProperCase = function () { - return this.replace(/\w\S*/g, function (txt) { +String.prototype.toProperCase = function () +{ + return this.replace(/\w\S*/g, function (txt) + { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); }; -Number.prototype.pad = function (size) { +Number.prototype.pad = function (size) +{ var s = String(this); - while (s.length < (size || 2)) { + while (s.length < (size || 2)) + { s = "0" + s; } return s; }; -String.prototype.replaceAll = function (str1, str2) { +String.prototype.replaceAll = function (str1, str2) +{ return this.split(str1).join(str2); }; diff --git a/package.nw/lib/roster.js b/package.nw/lib/roster.js index 181cd82a..2aab10c1 100644 --- a/package.nw/lib/roster.js +++ b/package.nw/lib/roster.js @@ -47,13 +47,13 @@ var g_callsignDatabaseUSplus = {}; var g_developerMode = process.versions["nw-flavor"] == "sdk"; var g_modeColors = {}; -g_modeColors["FT4"] = "1111FF"; -g_modeColors["FT8"] = "11FF11"; -g_modeColors["JT4"] = "EE1111"; -g_modeColors["JT9"] = "7CFC00"; -g_modeColors["JT65"] = "E550E5"; -g_modeColors["QRA64"] = "FF00FF"; -g_modeColors["MSK144"] = "4949FF"; +g_modeColors.FT4 = "1111FF"; +g_modeColors.FT8 = "11FF11"; +g_modeColors.JT4 = "EE1111"; +g_modeColors.JT9 = "7CFC00"; +g_modeColors.JT65 = "E550E5"; +g_modeColors.QRA64 = "FF00FF"; +g_modeColors.MSK144 = "4949FF"; var g_defaultSettings = { callsign: "all", @@ -95,7 +95,7 @@ var g_defaultSettings = { huntCont: false, huntPX: false, huntQRZ: true, - huntOAMS: false, + huntOAMS: false }, columns: { Band: false, @@ -121,7 +121,7 @@ var g_defaultSettings = { Spot: false, Life: false, OAMS: true, - Age: true, + Age: true }, reference: 0, controls: true, @@ -129,24 +129,28 @@ var g_defaultSettings = { compact: false, settingProfiles: false, lastSortIndex: 6, - lastSortReverse: 1, + lastSortReverse: 1 }; -document.addEventListener("dragover", function (event) { +document.addEventListener("dragover", function (event) +{ event.preventDefault(); }); -document.addEventListener("drop", function (event) { +document.addEventListener("drop", function (event) +{ event.preventDefault(); }); window.addEventListener("message", receiveMessage, false); -if (typeof localStorage.blockedCQ == "undefined") { +if (typeof localStorage.blockedCQ == "undefined") +{ localStorage.blockedCQ = "{}"; } -if (typeof localStorage.awardTracker == "undefined") { +if (typeof localStorage.awardTracker == "undefined") +{ localStorage.awardTracker = "{}"; g_rosterSettings = {}; writeRosterSettings(); @@ -154,25 +158,30 @@ if (typeof localStorage.awardTracker == "undefined") { g_awardTracker = JSON.parse(localStorage.awardTracker); -if (typeof localStorage.blockedCalls != "undefined") { +if (typeof localStorage.blockedCalls != "undefined") +{ g_blockedCalls = JSON.parse(localStorage.blockedCalls); g_blockedCQ = JSON.parse(localStorage.blockedCQ); g_blockedDxcc = JSON.parse(localStorage.blockedDxcc); } -function storeBlocks() { +function storeBlocks() +{ localStorage.blockedCalls = JSON.stringify(g_blockedCalls); localStorage.blockedCQ = JSON.stringify(g_blockedCQ); localStorage.blockedDxcc = JSON.stringify(g_blockedDxcc); } -function storeAwardTracker() { +function storeAwardTracker() +{ localStorage.awardTracker = JSON.stringify(g_awardTracker); } -function loadSettings() { +function loadSettings() +{ var readSettings = {}; - if (typeof localStorage.rosterSettings != "undefined") { + if (typeof localStorage.rosterSettings != "undefined") + { readSettings = JSON.parse(localStorage.rosterSettings); } g_rosterSettings = deepmerge(g_defaultSettings, readSettings); @@ -182,45 +191,55 @@ function loadSettings() { writeRosterSettings(); } -function writeRosterSettings() { +function writeRosterSettings() +{ localStorage.rosterSettings = JSON.stringify(g_rosterSettings); } -function isKnownCallsignDXCC(dxcc) { +function isKnownCallsignDXCC(dxcc) +{ if (dxcc in g_callsignDatabaseDXCC) return true; return false; } -function isKnownCallsignUS(dxcc) { +function isKnownCallsignUS(dxcc) +{ if (dxcc in g_callsignDatabaseUS) return true; return false; } -function isKnownCallsignUSplus(dxcc) { +function isKnownCallsignUSplus(dxcc) +{ if (dxcc in g_callsignDatabaseUSplus) return true; return false; } -function timeNowSec() { +function timeNowSec() +{ return parseInt(Date.now() / 1000); } -function lockNewWindows() { - if (typeof nw != "undefined") { +function lockNewWindows() +{ + if (typeof nw != "undefined") + { var gui = require("nw.gui"); var win = gui.Window.get(); - win.on("new-win-policy", function (frame, url, policy) { + win.on("new-win-policy", function (frame, url, policy) + { gui.Shell.openExternal(url); policy.ignore(); }); } } -function myCallCompare(a, b) { +function myCallCompare(a, b) +{ return a.DEcall.localeCompare(b.DEcall); } -function myGridCompare(a, b) { +function myGridCompare(a, b) +{ var gridA = a.grid ? a.grid : "0"; var gridB = b.grid ? b.grid : "0"; @@ -229,59 +248,69 @@ function myGridCompare(a, b) { return 0; } -function myDxccCompare(a, b) { +function myDxccCompare(a, b) +{ return window.opener.myDxccCompare(a, b); } -function myTimeCompare(a, b) { +function myTimeCompare(a, b) +{ if (a.age > b.age) return 1; if (a.age < b.age) return -1; return 0; } -function myLifeCompare(a, b) { +function myLifeCompare(a, b) +{ if (a.life > b.life) return 1; if (a.life < b.life) return -1; return 0; } -function mySpotCompare(a, b) { +function mySpotCompare(a, b) +{ if (a.spot.when > b.spot.when) return 1; if (a.spot.when < b.spot.when) return -1; return 0; } -function myDbCompare(a, b) { +function myDbCompare(a, b) +{ if (a.RSTsent > b.RSTsent) return 1; if (a.RSTsent < b.RSTsent) return -1; return 0; } -function myFreqCompare(a, b) { +function myFreqCompare(a, b) +{ if (a.delta > b.delta) return 1; if (a.delta < b.delta) return -1; return 0; } -function myDTCompare(a, b) { +function myDTCompare(a, b) +{ if (a.dt > b.dt) return 1; if (a.dt < b.dt) return -1; return 0; } -function myDistanceCompare(a, b) { +function myDistanceCompare(a, b) +{ if (a.distance > b.distance) return 1; if (a.distance < b.distance) return -1; return 0; } -function myHeadingCompare(a, b) { +function myHeadingCompare(a, b) +{ if (a.heading > b.heading) return 1; if (a.heading < b.heading) return -1; return 0; } -function myStateCompare(a, b) { +function myStateCompare(a, b) +{ if (a.state == null) return 1; if (b.state == null) return -1; if (a.state > b.state) return 1; @@ -289,11 +318,13 @@ function myStateCompare(a, b) { return 0; } -function myCQCompare(a, b) { +function myCQCompare(a, b) +{ return a.DXcall.localeCompare(b.DXcall); } -function myWPXCompare(a, b) { +function myWPXCompare(a, b) +{ if (a.px == null) return 1; if (b.px == null) return -1; if (a.px > b.px) return 1; @@ -301,7 +332,8 @@ function myWPXCompare(a, b) { return 0; } -function myCntyCompare(a, b) { +function myCntyCompare(a, b) +{ if (a.cnty == null) return 1; if (b.cnty == null) return -1; if (a.cnty.substr(3) > b.cnty.substr(3)) return 1; @@ -309,14 +341,16 @@ function myCntyCompare(a, b) { return 0; } -function myContCompare(a, b) { +function myContCompare(a, b) +{ if (a.cont == null) return 1; if (b.cont == null) return -1; if (a.cont > b.cont) return 1; if (a.cont < b.cont) return -1; return 0; } -function myGTCompare(a, b) { +function myGTCompare(a, b) +{ if (a.style.gt != 0 && b.style.gt == 0) return 1; if (a.style.gt == 0 && b.style.gt != 0) return -1; return 0; @@ -339,14 +373,18 @@ var r_sortFunction = [ mySpotCompare, myGTCompare, myCntyCompare, - myContCompare, + myContCompare ]; -function showRosterBox(sortIndex) { - if (g_rosterSettings.lastSortIndex != sortIndex) { +function showRosterBox(sortIndex) +{ + if (g_rosterSettings.lastSortIndex != sortIndex) + { g_rosterSettings.lastSortIndex = sortIndex; g_rosterSettings.lastSortReverse = 0; - } else { + } + else + { g_rosterSettings.lastSortReverse ^= 1; } @@ -355,33 +393,36 @@ function showRosterBox(sortIndex) { window.opener.goProcessRoster(); } -function hashMaker(band, mode) { - //"Current Band & Mode" +function hashMaker(band, mode) +{ + // "Current Band & Mode" if (g_rosterSettings.reference == 0 || g_rosterSettings.reference == 6) - return band + mode; + { return band + mode; } - //"Current Band, Any Mode" + // "Current Band, Any Mode" if (g_rosterSettings.reference == 1) return band; - //"Current Band, Any Digi Mode" + // "Current Band, Any Digi Mode" if (g_rosterSettings.reference == 2) return band + "dg"; - //"Current Mode, Any Band" + // "Current Mode, Any Band" if (g_rosterSettings.reference == 3) return mode; - //"Any Band, Any Mode" + // "Any Band, Any Mode" if (g_rosterSettings.reference == 4) return ""; - //"Any Band, Any Digi Mode" + // "Any Band, Any Digi Mode" if (g_rosterSettings.reference == 5) return "dg"; } -function processRoster(roster) { +function processRoster(roster) +{ callRoster = roster; viewRoster(); } -function viewRoster() { +function viewRoster() +{ var bands = Object(); var modes = Object(); @@ -391,11 +432,13 @@ function viewRoster() { document.title = window.opener.makeTitleInfo(false); - if (callMode == "hits") { + if (callMode == "hits") + { callMode = "all"; onlyHits = true; } - if (referenceNeed.value == 6) { + if (referenceNeed.value == 6) + { callMode = "all"; onlyHits = false; isAwardTracker = true; @@ -407,38 +450,45 @@ function viewRoster() { window.opener.g_appSettings.gtShareEnable == "true" && window.opener.g_appSettings.gtMsgEnable == "true"; - if (window.opener.g_callsignLookups.lotwUseEnable == true) { + if (window.opener.g_callsignLookups.lotwUseEnable == true) + { usesLoTWDiv.style.display = "inline-block"; - if (g_rosterSettings.usesLoTW == true) { + if (g_rosterSettings.usesLoTW == true) + { maxLoTW.style.display = "inline-block"; maxLoTWView.style.display = "inline-block"; - } else { + } + else + { maxLoTW.style.display = "none"; maxLoTWView.style.display = "none"; } - } else { + } + else + { usesLoTWDiv.style.display = "none"; maxLoTW.style.display = "none"; maxLoTWView.style.display = "none"; } if (window.opener.g_callsignLookups.eqslUseEnable == true) - useseQSLDiv.style.display = "block"; + { useseQSLDiv.style.display = "block"; } else useseQSLDiv.style.display = "none"; if (window.opener.g_callsignLookups.oqrsUseEnable == true) - usesOQRSDiv.style.display = "block"; + { usesOQRSDiv.style.display = "block"; } else usesOQRSDiv.style.display = "none"; if (g_rosterSettings.columns.Spot == true) - onlySpotDiv.style.display = "block"; + { onlySpotDiv.style.display = "block"; } else onlySpotDiv.style.display = "none"; if (callMode == "all") allOnlyNewDiv.style.display = "block"; else allOnlyNewDiv.style.display = "none"; var now = timeNowSec(); - for (var callHash in callRoster) { + for (var callHash in callRoster) + { var call = callRoster[callHash].DEcall; callRoster[callHash].tx = true; @@ -449,7 +499,8 @@ function viewRoster() { if ( now - callRoster[callHash].callObj.age > window.opener.g_mapSettings.rosterTime - ) { + ) + { callRoster[callHash].tx = false; callRoster[callHash].alerted = false; callRoster[callHash].callObj.qrz = false; @@ -459,11 +510,13 @@ function viewRoster() { if ( window.opener.g_instances[callRoster[callHash].callObj.instance] .crEnable == false - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (call in g_blockedCalls) { + if (call in g_blockedCalls) + { callRoster[callHash].tx = false; continue; } @@ -473,96 +526,121 @@ function viewRoster() { " from " + window.opener.g_dxccToAltName[callRoster[callHash].callObj.dxcc] in g_blockedCQ - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (callRoster[callHash].callObj.dxcc in g_blockedDxcc) { + if (callRoster[callHash].callObj.dxcc in g_blockedDxcc) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.cqOnly == true && callRoster[callHash].callObj.CQ == false - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.useRegex && g_rosterSettings.callsignRegex.length > 0 - ) { - try { - if (!call.match(g_rosterSettings.callsignRegex)) { + ) + { + try + { + if (!call.match(g_rosterSettings.callsignRegex)) + { callRoster[callHash].tx = false; continue; } - } catch (e) {} + } + catch (e) {} } if ( g_rosterSettings.requireGrid == true && callRoster[callHash].callObj.grid.length != 4 - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.wantMinDB == true && callRoster[callHash].message.SR < g_rosterSettings.minDb - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.wantMaxDT == true && Math.abs(callRoster[callHash].message.DT) > g_rosterSettings.maxDT - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.wantMinFreq == true && callRoster[callHash].message.DF < g_rosterSettings.minFreq - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.wantMaxFreq == true && callRoster[callHash].message.DF > g_rosterSettings.maxFreq - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (g_rosterSettings.noMsg == true) { - try { + if (g_rosterSettings.noMsg == true) + { + try + { if ( callRoster[callHash].callObj.msg.match(g_rosterSettings.noMsgValue) - ) { + ) + { callRoster[callHash].tx = false; continue; } - } catch (e) {} + } + catch (e) {} } - if (g_rosterSettings.onlyMsg == true) { - try { + if (g_rosterSettings.onlyMsg == true) + { + try + { if ( !callRoster[callHash].callObj.msg.match(g_rosterSettings.onlyMsgValue) - ) { + ) + { callRoster[callHash].tx = false; continue; } - } catch (e) {} + } + catch (e) {} } - if (callRoster[callHash].callObj.dxcc == window.opener.g_myDXCC) { - if (g_rosterSettings.noMyDxcc == true) { + if (callRoster[callHash].callObj.dxcc == window.opener.g_myDXCC) + { + if (g_rosterSettings.noMyDxcc == true) + { callRoster[callHash].tx = false; continue; } - } else { - if (g_rosterSettings.onlyMyDxcc == true) { + } + else + { + if (g_rosterSettings.onlyMyDxcc == true) + { callRoster[callHash].tx = false; continue; } @@ -571,14 +649,18 @@ function viewRoster() { if ( window.opener.g_callsignLookups.lotwUseEnable == true && g_rosterSettings.usesLoTW == true - ) { - if (!(call in window.opener.g_lotwCallsigns)) { + ) + { + if (!(call in window.opener.g_lotwCallsigns)) + { callRoster[callHash].tx = false; continue; } - if (g_rosterSettings.maxLoTW < 27) { + if (g_rosterSettings.maxLoTW < 27) + { var months = (g_day - window.opener.g_lotwCallsigns[call]) / 30; - if (months > g_rosterSettings.maxLoTW) { + if (months > g_rosterSettings.maxLoTW) + { callRoster[callHash].tx = false; continue; } @@ -588,8 +670,10 @@ function viewRoster() { if ( window.opener.g_callsignLookups.eqslUseEnable == true && g_rosterSettings.useseQSL == true - ) { - if (!(call in window.opener.g_eqslCallsigns)) { + ) + { + if (!(call in window.opener.g_eqslCallsigns)) + { callRoster[callHash].tx = false; continue; } @@ -598,18 +682,22 @@ function viewRoster() { if ( window.opener.g_callsignLookups.oqrsUseEnable == true && g_rosterSettings.usesOQRS == true - ) { - if (!(call in window.opener.g_oqrsCallsigns)) { + ) + { + if (!(call in window.opener.g_oqrsCallsigns)) + { callRoster[callHash].tx = false; continue; } } - if (callMode != "all") { + if (callMode != "all") + { if ( callRoster[callHash].DXcall == "CQ DX" && callRoster[callHash].callObj.dxcc == window.opener.g_myDXCC - ) { + ) + { callRoster[callHash].tx = false; continue; } @@ -620,40 +708,47 @@ function viewRoster() { callRoster[callHash].callObj.band, callRoster[callHash].callObj.mode ); - if (callMode == "worked" && hash in g_worked.call) { + if (callMode == "worked" && hash in g_worked.call) + { callRoster[callHash].tx = false; continue; } - if (callMode == "confirmed" && hash in g_confirmed.call) { + if (callMode == "confirmed" && hash in g_confirmed.call) + { callRoster[callHash].tx = false; continue; } - if (g_rosterSettings.hunting == "grid") { + if (g_rosterSettings.hunting == "grid") + { var hash = callRoster[callHash].callObj.grid.substr(0, 4) + hashMaker( callRoster[callHash].callObj.band, callRoster[callHash].callObj.mode ); - if (g_rosterSettings.huntNeed == "worked" && hash in g_worked.grid) { + if (g_rosterSettings.huntNeed == "worked" && hash in g_worked.grid) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_confirmed.grid - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (callRoster[callHash].callObj.grid.length == 0) { + if (callRoster[callHash].callObj.grid.length == 0) + { callRoster[callHash].tx = false; continue; } continue; } - if (g_rosterSettings.hunting == "dxcc") { + if (g_rosterSettings.hunting == "dxcc") + { var hash = String(callRoster[callHash].callObj.dxcc) + hashMaker( @@ -661,7 +756,8 @@ function viewRoster() { callRoster[callHash].callObj.mode ); - if ((g_rosterSettings.huntNeed == "worked") & (hash in g_worked.dxcc)) { + if ((g_rosterSettings.huntNeed == "worked") & (hash in g_worked.dxcc)) + { callRoster[callHash].tx = false; continue; } @@ -669,7 +765,8 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_confirmed.dxcc - ) { + ) + { callRoster[callHash].tx = false; continue; } @@ -677,15 +774,19 @@ function viewRoster() { continue; } - if (g_rosterSettings.hunting == "dxccs" && r_currentDXCCs != -1) { - if (callRoster[callHash].callObj.dxcc != r_currentDXCCs) { + if (g_rosterSettings.hunting == "dxccs" && r_currentDXCCs != -1) + { + if (callRoster[callHash].callObj.dxcc != r_currentDXCCs) + { callRoster[callHash].tx = false; continue; } } - if (g_rosterSettings.hunting == "wpx") { - if (String(callRoster[callHash].callObj.px) == null) { + if (g_rosterSettings.hunting == "wpx") + { + if (String(callRoster[callHash].callObj.px) == null) + { callRoster[callHash].tx = false; continue; } @@ -696,7 +797,8 @@ function viewRoster() { callRoster[callHash].callObj.mode ); - if ((g_rosterSettings.huntNeed == "worked") & (hash in g_worked.px)) { + if ((g_rosterSettings.huntNeed == "worked") & (hash in g_worked.px)) + { callRoster[callHash].tx = false; continue; } @@ -704,7 +806,8 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_confirmed.px - ) { + ) + { callRoster[callHash].tx = false; continue; } @@ -712,15 +815,18 @@ function viewRoster() { continue; } - if (g_rosterSettings.hunting == "cq") { + if (g_rosterSettings.hunting == "cq") + { var workedTotal = (confirmedTotal = callRoster[callHash].callObj.cqza.length); - if (workedTotal == 0) { + if (workedTotal == 0) + { callRoster[callHash].tx = false; continue; } var workedFound = (confirmedFound = 0); - for (index in callRoster[callHash].callObj.cqza) { + for (index in callRoster[callHash].callObj.cqza) + { var hash = callRoster[callHash].callObj.cqza[index] + hashMaker( @@ -734,14 +840,16 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "worked" && workedFound == workedTotal - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.huntNeed == "confirmed" && confirmedFound == confirmedTotal - ) { + ) + { callRoster[callHash].tx = false; continue; } @@ -749,15 +857,18 @@ function viewRoster() { continue; } - if (g_rosterSettings.hunting == "itu") { + if (g_rosterSettings.hunting == "itu") + { var workedTotal = (confirmedTotal = callRoster[callHash].callObj.ituza.length); - if (workedTotal == 0) { + if (workedTotal == 0) + { callRoster[callHash].tx = false; continue; } var workedFound = (confirmedFound = 0); - for (index in callRoster[callHash].callObj.ituza) { + for (index in callRoster[callHash].callObj.ituza) + { var hash = callRoster[callHash].callObj.ituza[index] + hashMaker( @@ -771,18 +882,21 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "worked" && workedFound == workedTotal - ) { + ) + { callRoster[callHash].tx = false; continue; } if ( g_rosterSettings.huntNeed == "confirmed" && confirmedFound == confirmedTotal - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (callRoster[callHash].callObj.grid.length == 0) { + if (callRoster[callHash].callObj.grid.length == 0) + { callRoster[callHash].tx = false; continue; } @@ -792,11 +906,14 @@ function viewRoster() { if ( g_rosterSettings.hunting == "usstates" && window.opener.g_callsignLookups.ulsUseEnable == true - ) { + ) + { var state = callRoster[callHash].callObj.state; var finalDxcc = callRoster[callHash].callObj.dxcc; - if (finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6) { - if (state in window.opener.g_StateData) { + if (finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6) + { + if (state in window.opener.g_StateData) + { var hash = state + hashMaker( @@ -807,7 +924,8 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "worked" && hash in g_worked.state - ) { + ) + { callRoster[callHash].tx = false; continue; } @@ -815,36 +933,47 @@ function viewRoster() { if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_confirmed.state - ) { + ) + { callRoster[callHash].tx = false; continue; } - } else callRoster[callHash].tx = false; - } else callRoster[callHash].tx = false; + } + else callRoster[callHash].tx = false; + } + else callRoster[callHash].tx = false; continue; } - if (g_rosterSettings.hunting == "usstate" && g_currentUSCallsigns) { - if (call in g_currentUSCallsigns) { + if (g_rosterSettings.hunting == "usstate" && g_currentUSCallsigns) + { + if (call in g_currentUSCallsigns) + { // Do Nothing - } else { + } + else + { callRoster[callHash].tx = false; continue; } continue; } } - if (isAwardTracker) { + if (isAwardTracker) + { var tx = false; var baseHash = hashMaker( callRoster[callHash].callObj.band, callRoster[callHash].callObj.mode ); - for (var award in g_awardTracker) { - if (g_awardTracker[award].enable) { + for (var award in g_awardTracker) + { + if (g_awardTracker[award].enable) + { tx = testAward(award, callRoster[callHash].callObj, baseHash); - if (tx) { + if (tx) + { var x = g_awardTracker[award]; callRoster[callHash].callObj.awardReason = g_awards[x.sponsor].awards[x.name].tooltip + @@ -867,17 +996,20 @@ function viewRoster() { var row = "#000000"; var bold = "#000000;text-shadow: 0px 0px 1px black;"; var unconf = "background-clip:content-box;box-shadow: 0 0 8px 3px inset "; - for (var callHash in callRoster) { + for (var callHash in callRoster) + { // Special case check for called station if ( callRoster[callHash].callObj.qrz == true && callRoster[callHash].tx == false - ) { + ) + { // The instance has to be enabled if ( window.opener.g_instances[callRoster[callHash].callObj.instance] .crEnable == true - ) { + ) + { // Calling us, but we wouldn't normally display // If they are not ignored or we're in a QSO with them, var it through @@ -886,7 +1018,8 @@ function viewRoster() { !(callRoster[callHash].callObj.dxcc in g_blockedDxcc)) || window.opener.g_instances[callRoster[callHash].callObj.instance] .status.DXcall == callRoster[callHash].DEcall - ) { + ) + { callRoster[callHash].tx = true; } } @@ -895,7 +1028,8 @@ function viewRoster() { if ( callRoster[callHash].callObj.dxcc != -1 && callRoster[callHash].tx == true - ) { + ) + { var workHash = hashMaker( callRoster[callHash].callObj.band, callRoster[callHash].callObj.mode @@ -949,11 +1083,13 @@ function viewRoster() { callConf = gridConf = callingConf = dxccConf = stateConf = cntyConf = contConf = cqzConf = ituzConf = wpxConf = ""; - if (testHash in g_worked.call) { + if (testHash in g_worked.call) + { didWork = true; callConf = unconf + callsign + inversionAlpha + ";"; - if (testHash in g_confirmed.call) { + if (testHash in g_confirmed.call) + { callPointer = "text-decoration: line-through; "; callConf = ""; } @@ -964,24 +1100,30 @@ function viewRoster() { window.opener.g_gtCallsigns[call] in window.opener.g_gtFlagPins && window.opener.g_gtFlagPins[window.opener.g_gtCallsigns[call]].canmsg == true - ) { + ) + { // grab the CID colorObject.gt = window.opener.g_gtCallsigns[call]; hasGtPin = true; - } else colorObject.gt = 0; + } + else colorObject.gt = 0; - if (callMode == "all") { + if (callMode == "all") + { if ( allOnlyNew.checked == true && didWork && callRoster[callHash].callObj.qrz == false - ) { + ) + { callRoster[callHash].tx = false; continue; } - if (huntCallsign.checked == true) { - if (g_rosterSettings.huntNeed == "worked" && didWork) { + if (huntCallsign.checked == true) + { + if (g_rosterSettings.huntNeed == "worked" && didWork) + { callRoster[callHash].callObj.reason.push("call"); callConf = unconf + callsign + inversionAlpha + ";"; } @@ -989,17 +1131,22 @@ function viewRoster() { didWork && g_rosterSettings.huntNeed == "confirmed" && !(testHash in g_confirmed.call) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("call"); callConf = unconf + callsign + inversionAlpha + ";"; - } else if ( + } + else if ( didWork && g_rosterSettings.huntNeed == "confirmed" && testHash in g_confirmed.call - ) { + ) + { callConf = ""; - } else if (!didWork) { + } + else if (!didWork) + { shouldAlert = true; callConf = ""; callsignBg = callsign + inversionAlpha; @@ -1010,12 +1157,14 @@ function viewRoster() { if ( huntQRZ.checked == true && callRoster[callHash].callObj.qrz == true - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("qrz"); } - if (huntOAMS.checked == true && hasGtPin == true) { + if (huntOAMS.checked == true && hasGtPin == true) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("oams"); } @@ -1023,45 +1172,55 @@ function viewRoster() { if ( huntGrid.checked == true && callRoster[callHash].callObj.grid.length > 1 - ) { + ) + { var hash = callRoster[callHash].callObj.grid.substr(0, 4) + workHash; if ( (g_rosterSettings.huntNeed == "worked" && !(hash in g_worked.grid)) || (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.grid)) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("grid"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.grid - ) { + ) + { gridConf = unconf + grid + inversionAlpha + ";"; - } else { + } + else + { gridBg = grid + inversionAlpha; grid = bold; } } } - if (huntDXCC.checked == true) { + if (huntDXCC.checked == true) + { var hash = String(callRoster[callHash].callObj.dxcc) + workHash; if ( (g_rosterSettings.huntNeed == "worked" && !(hash in g_worked.dxcc)) || (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.dxcc)) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("dxcc"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.dxcc - ) { + ) + { dxccConf = unconf + dxcc + inversionAlpha + ";"; - } else { + } + else + { dxccBg = dxcc + inversionAlpha; dxcc = bold; } @@ -1070,27 +1229,34 @@ function viewRoster() { if ( huntState.checked == true && window.opener.g_callsignLookups.ulsUseEnable == true - ) { + ) + { var stateSearch = callRoster[callHash].callObj.state; var finalDxcc = callRoster[callHash].callObj.dxcc; - if (finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6) { - if (stateSearch in window.opener.g_StateData) { + if (finalDxcc == 291 || finalDxcc == 110 || finalDxcc == 6) + { + if (stateSearch in window.opener.g_StateData) + { var hash = stateSearch + workHash; if ( (g_rosterSettings.huntNeed == "worked" && !(hash in g_worked.state)) || (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.state)) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("usstates"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.state - ) { + ) + { stateConf = unconf + state + inversionAlpha + ";"; - } else { + } + else + { stateBg = state + inversionAlpha; state = bold; } @@ -1101,7 +1267,8 @@ function viewRoster() { if ( huntCounty.checked == true && window.opener.g_callsignLookups.ulsUseEnable == true - ) { + ) + { var finalDxcc = callRoster[callHash].callObj.dxcc; if ( callRoster[callHash].callObj.cnty && @@ -1110,7 +1277,8 @@ function viewRoster() { finalDxcc == 6 || finalDxcc == 202) && callRoster[callHash].callObj.cnty.length > 0 - ) { + ) + { var hash = callRoster[callHash].callObj.cnty + workHash; if ( @@ -1119,45 +1287,56 @@ function viewRoster() { (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.cnty)) || callRoster[callHash].callObj.qual == false - ) { - if (callRoster[callHash].callObj.qual == false) { + ) + { + if (callRoster[callHash].callObj.qual == false) + { var counties = window.opener.g_zipToCounty[ callRoster[callHash].callObj.zipcode ]; var foundHit = false; - for (var cnt in counties) { + for (var cnt in counties) + { var hh = counties[cnt] + workHash; callRoster[callHash].callObj.cnty = counties[cnt]; if ( g_rosterSettings.huntNeed == "worked" && !(hh in g_worked.cnty) - ) { + ) + { foundHit = true; break; } if ( g_rosterSettings.huntNeed == "confirmed" && !(hh in g_confirmed.cnty) - ) { + ) + { foundHit = true; break; } } if (foundHit) shouldAlert = true; - } else { + } + else + { shouldAlert = true; } - if (shouldAlert) { + if (shouldAlert) + { callRoster[callHash].callObj.reason.push("uscnty"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.cnty - ) { + ) + { cntyConf = unconf + cnty + inversionAlpha + ";"; - } else { + } + else + { cntyBg = cnty + inversionAlpha; cnty = bold; } @@ -1165,11 +1344,13 @@ function viewRoster() { } } } - if (huntCQz.checked == true) { + if (huntCQz.checked == true) + { var workedTotal = (confirmedTotal = callRoster[callHash].callObj.cqza.length); var workedFound = (confirmedFound = 0); - for (index in callRoster[callHash].callObj.cqza) { + for (index in callRoster[callHash].callObj.cqza) + { var hash = callRoster[callHash].callObj.cqza[index] + workHash; if (hash in g_worked.cqz) workedFound++; @@ -1180,26 +1361,32 @@ function viewRoster() { workedFound != workedTotal) || (g_rosterSettings.huntNeed == "confirmed" && confirmedFound != confirmedTotal) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("cq"); if ( g_rosterSettings.huntNeed == "confirmed" && workedFound == workedTotal - ) { + ) + { cqzConf = unconf + cqz + inversionAlpha + ";"; - } else { + } + else + { cqzBg = cqz + inversionAlpha; cqz = bold; } } } - if (huntITUz.checked == true) { + if (huntITUz.checked == true) + { var workedTotal = (confirmedTotal = callRoster[callHash].callObj.ituza.length); var workedFound = (confirmedFound = 0); - for (index in callRoster[callHash].callObj.ituza) { + for (index in callRoster[callHash].callObj.ituza) + { var hash = callRoster[callHash].callObj.ituza[index] + workHash; if (hash in g_worked.ituz) workedFound++; @@ -1210,56 +1397,70 @@ function viewRoster() { workedFound != workedTotal) || (g_rosterSettings.huntNeed == "confirmed" && confirmedFound != confirmedTotal) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("itu"); if ( g_rosterSettings.huntNeed == "confirmed" && workedFound == workedTotal - ) { + ) + { ituzConf = unconf + ituz + inversionAlpha + ";"; - } else { + } + else + { ituzBg = ituz + inversionAlpha; ituz = bold; } } } - if (huntPX.checked == true && callRoster[callHash].callObj.px) { + if (huntPX.checked == true && callRoster[callHash].callObj.px) + { var hash = String(callRoster[callHash].callObj.px) + workHash; if ( (g_rosterSettings.huntNeed == "worked" && !(hash in g_worked.px)) || (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.px)) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("wpx"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.px - ) { + ) + { wpxConf = unconf + wpx + inversionAlpha + ";"; - } else { + } + else + { wpxBg = wpx + inversionAlpha; wpx = bold; } } } - if (huntCont.checked == true && callRoster[callHash].callObj.cont) { + if (huntCont.checked == true && callRoster[callHash].callObj.cont) + { var hash = String(callRoster[callHash].callObj.cont) + workHash; if ( (g_rosterSettings.huntNeed == "worked" && !(hash in g_worked.cont)) || (g_rosterSettings.huntNeed == "confirmed" && !(hash in g_confirmed.cont)) - ) { + ) + { shouldAlert = true; callRoster[callHash].callObj.reason.push("cont"); if ( g_rosterSettings.huntNeed == "confirmed" && hash in g_worked.cont - ) { + ) + { contConf = unconf + cont + inversionAlpha + ";"; - } else { + } + else + { contBg = cont + inversionAlpha; cont = bold; } @@ -1267,13 +1468,16 @@ function viewRoster() { } } - if (callRoster[callHash].callObj.DXcall == window.opener.myDEcall) { + if (callRoster[callHash].callObj.DXcall == window.opener.myDEcall) + { callingBg = "#0000FF" + inversionAlpha; calling = "#FFFF00;text-shadow: 0px 0px 2px #FFFF00"; - } else if ( + } + else if ( callRoster[callHash].callObj.CQ == true && g_rosterSettings.cqOnly == false - ) { + ) + { callingBg = calling + inversionAlpha; calling = bold; } @@ -1366,17 +1570,20 @@ function viewRoster() { callRoster[callHash].callObj.style = colorObject; - if (g_rosterSettings.columns.Spot) { + if (g_rosterSettings.columns.Spot) + { callRoster[callHash].callObj.spot = window.opener.getSpotTime( callRoster[callHash].callObj.DEcall + callRoster[callHash].callObj.mode + callRoster[callHash].callObj.band + callRoster[callHash].callObj.grid ); - if (callRoster[callHash].callObj.spot == null) { + if (callRoster[callHash].callObj.spot == null) + { callRoster[callHash].callObj.spot = { when: 0, snr: 0 }; } - } else callRoster[callHash].callObj.spot = { when: 0, snr: 0 }; + } + else callRoster[callHash].callObj.spot = { when: 0, snr: 0 }; modes[callRoster[callHash].callObj.mode] = true; bands[callRoster[callHash].callObj.band] = true; @@ -1385,131 +1592,174 @@ function viewRoster() { } } - if (g_rosterSettings.compact == false) { + if (g_rosterSettings.compact == false) + { newCallList.sort(r_sortFunction[g_rosterSettings.lastSortIndex]); - if (g_rosterSettings.lastSortReverse == 1) { + if (g_rosterSettings.lastSortReverse == 1) + { newCallList.reverse(); } - } else { + } + else + { // Age sort for now... make this happen Tag newCallList.sort(r_sortFunction[6]).reverse(); } var showBands = - (Object.keys(bands).length > 1 ? true : false) || + (Object.keys(bands).length > 1) || g_rosterSettings.columns.Band; var showModes = - (Object.keys(modes).length > 1 ? true : false) || + (Object.keys(modes).length > 1) || g_rosterSettings.columns.Mode; var worker = ""; - if (g_rosterSettings.compact == false) { + if (g_rosterSettings.compact == false) + { worker = ""; worker += ""; - if (showBands) { + if (showBands) + { worker += ""; } - if (showModes) { + if (showModes) + { worker += ""; } worker += ""; if (g_rosterSettings.columns.Calling) + { worker += ""; + } if (g_rosterSettings.columns.Msg) worker += ""; if (g_rosterSettings.columns.DXCC) + { worker += ""; + } if (g_rosterSettings.columns.Flag) + { worker += ""; + } if (g_rosterSettings.columns.State) + { worker += ""; + } if (g_rosterSettings.columns.County) + { worker += ""; + } if (g_rosterSettings.columns.Cont) + { worker += ""; + } if (g_rosterSettings.columns.dB) + { worker += ""; + } if (g_rosterSettings.columns.Freq) + { worker += ""; + } if (g_rosterSettings.columns.DT) + { worker += ""; + } if (g_rosterSettings.columns.Dist) + { worker += ""; + } if (g_rosterSettings.columns.Azim) + { worker += ""; + } if (g_rosterSettings.columns.CQz) worker += ""; if (g_rosterSettings.columns.ITUz) worker += ""; if (g_rosterSettings.columns.PX) + { worker += ""; + } if ( window.opener.g_callsignLookups.lotwUseEnable == true && g_rosterSettings.columns.LoTW ) - worker += ""; + { worker += ""; } if ( window.opener.g_callsignLookups.eqslUseEnable == true && g_rosterSettings.columns.eQSL ) - worker += ""; + { worker += ""; } if ( window.opener.g_callsignLookups.oqrsUseEnable == true && g_rosterSettings.columns.OQRS ) - worker += ""; + { worker += ""; } if (g_rosterSettings.columns.Spot) + { worker += ""; + } if (g_rosterSettings.columns.Life) + { worker += ""; + } if (g_rosterSettings.columns.OAMS) + { worker += ""; + } if (g_rosterSettings.columns.Age) + { worker += ""; - } else { + } + } + else + { worker = - '
'; + "
"; } var shouldAlert = 0; - for (var x in newCallList) { + for (var x in newCallList) + { if ( newCallList[x].shouldAlert == false && onlyHits == true && newCallList[x].qrz == false ) - continue; + { continue; } var spotString = ""; var spotSnr = null; - if (g_rosterSettings.columns.Spot && newCallList[x].qrz == false) { + if (g_rosterSettings.columns.Spot && newCallList[x].qrz == false) + { spotString = getSpotString(newCallList[x]); if (spotString != "") spotSnr = newCallList[x].spot.snr; if (g_rosterSettings.onlySpot && spotString == "") continue; @@ -1532,21 +1782,26 @@ function viewRoster() { var thisCall = newCallList[x].DEcall; if (thisCall.match("^[A-Z][0-9][A-Z](/w+)?$")) - newCallList[x].style.callsign = "class='oneByOne'"; + { newCallList[x].style.callsign = "class='oneByOne'"; } if ( thisCall == window.opener.g_instances[newCallList[x].instance].status.DXcall - ) { + ) + { if ( window.opener.g_instances[newCallList[x].instance].status.TxEnabled == 1 - ) { + ) + { newCallList[x].style.callsign = "class='dxCalling'"; - } else { + } + else + { newCallList[x].style.callsign = "class='dxCaller'"; } } - if (g_rosterSettings.compact == false) { + if (g_rosterSettings.compact == false) + { var thisHash = thisCall + newCallList[x].band + newCallList[x].mode; worker += "
"; @@ -1563,7 +1818,8 @@ function viewRoster() { thisCall.formatCallsign() + ""; - if (showBands) { + if (showBands) + { worker += ""; } @@ -1587,7 +1844,8 @@ function viewRoster() { "\")' >" + grid + ""; - if (g_rosterSettings.columns.Calling) { + if (g_rosterSettings.columns.Calling) + { var lookString = newCallList[x].CQ ? "name='CQ'" : "name='Calling'"; worker += ""; + { worker += ""; } if (g_rosterSettings.columns.DXCC) + { worker += ""; + } if (g_rosterSettings.columns.State) + { worker += ""; + } if (g_rosterSettings.columns.County) + { worker += ""; + } if (g_rosterSettings.columns.dB) + { worker += ""; + } if (g_rosterSettings.columns.Freq) - worker += ""; + { worker += ""; } if (g_rosterSettings.columns.DT) - worker += ""; + { worker += ""; } if (g_rosterSettings.columns.Dist) + { worker += ""; + } if (g_rosterSettings.columns.Azim) + { worker += ""; + } if (g_rosterSettings.columns.CQz) + { worker += ""; + } if (g_rosterSettings.columns.ITUz) + { worker += ""; + } if (g_rosterSettings.columns.PX) + { worker += ""; + } if ( window.opener.g_callsignLookups.lotwUseEnable == true && g_rosterSettings.columns.LoTW - ) { - if (thisCall in window.opener.g_lotwCallsigns) { - if (g_rosterSettings.maxLoTW < 27) { + ) + { + if (thisCall in window.opener.g_lotwCallsigns) + { + if (g_rosterSettings.maxLoTW < 27) + { var months = (g_day - window.opener.g_lotwCallsigns[thisCall]) / 30; if (months > g_rosterSettings.maxLoTW) + { worker += ""; + } else + { worker += ""; - } else + } + } + else + { worker += ""; - } else worker += ""; + } + } + else worker += ""; } if ( window.opener.g_callsignLookups.eqslUseEnable == true && g_rosterSettings.columns.eQSL ) + { worker += ""; + } if ( window.opener.g_callsignLookups.oqrsUseEnable == true && g_rosterSettings.columns.OQRS ) + { worker += ""; + } if (g_rosterSettings.columns.Spot) + { worker += ""; + } - if (g_rosterSettings.columns.OAMS) { - if (newCallList[x].style.gt != 0) { - if (newCallList[x].reason.includes("oams")) { + if (g_rosterSettings.columns.OAMS) + { + if (newCallList[x].style.gt != 0) + { + if (newCallList[x].reason.includes("oams")) + { worker += ""; - } else { + } + else + { worker += ""; } - } else worker += ""; + } + else worker += ""; } if (g_rosterSettings.columns.Age) + { worker += ""; + } worker += ""; - } else { + } + else + { var tt = newCallList[x].RSTsent + "㏈, " + @@ -1837,7 +2146,8 @@ function viewRoster() { worker += ""; } - if (g_rosterSettings.realtime == false) { + if (g_rosterSettings.realtime == false) + { var call = newCallList[x].DEcall; g_scriptReport[call] = Object.assign({}, newCallList[x]); g_scriptReport[call].dxccName = @@ -1855,7 +2165,8 @@ function viewRoster() { delete g_scriptReport[call].qso; delete g_scriptReport[call].instance; - if (callMode != "all") { + if (callMode != "all") + { g_scriptReport[call].shouldAlert = true; g_scriptReport[call].reason.push(g_rosterSettings.hunting); } @@ -1865,10 +2176,13 @@ function viewRoster() { newCallList[x].alerted == false && callMode == "all" && newCallList[x].shouldAlert == true - ) { + ) + { newCallList[x].alerted = true; shouldAlert++; - } else if (newCallList[x].alerted == false && callMode != "all") { + } + else if (newCallList[x].alerted == false && callMode != "all") + { newCallList[x].alerted = true; shouldAlert++; } @@ -1876,11 +2190,14 @@ function viewRoster() { newCallList[x].shouldAlert = false; } - if (g_rosterSettings.compact == false) { + if (g_rosterSettings.compact == false) + { worker += "
CallsignBandModeGridCallingMsgDXCCFlagStateCountyContdBFreqDTDist(" + window.opener.distanceUnit.value.toLowerCase() + ")AzimCQzITUzPXLoTWLoTWeQSLeQSLOQRSOQRSSpotLifeOAMAge
" + newCallList[x].mode + ""; } if (g_rosterSettings.columns.Msg) - worker += "" + newCallList[x].msg + "" + newCallList[x].msg + "" + (newCallList[x].state ? newCallList[x].state.substr(3) : "") + ""; + } if (g_rosterSettings.columns.Cont) + { worker += "" + (newCallList[x].cont ? newCallList[x].cont : "") + "" + newCallList[x].RSTsent + "" + newCallList[x].delta + "" + newCallList[x].delta + "" + newCallList[x].dt + "" + newCallList[x].dt + "" + parseInt( @@ -1672,81 +1943,106 @@ function viewRoster() { MyCircle.validateRadius(window.opener.distanceUnit.value) ) + "" + parseInt(newCallList[x].heading) + "" + newCallList[x].cqza.join(",") + "" + newCallList[x].ituza.join(",") + "" + (newCallList[x].px ? newCallList[x].px : "") + "?" + (thisCall in window.opener.g_eqslCallsigns ? "✔" : "") + "" + (thisCall in window.opener.g_oqrsCallsigns ? "✔" : "") + "" + (timeNowSec() - newCallList[x].life).toDHMS() + "" + (timeNowSec() - newCallList[x].age).toDHMS() + "
"; RosterTable.innerHTML = worker; callTable.style.width = parseInt(window.innerWidth) - 6 + "px"; - } else { + } + else + { RosterTable.innerHTML = worker + ""; buttonsDiv.style.width = parseInt(window.innerWidth) - 6 + "px"; } @@ -1889,15 +2206,19 @@ function viewRoster() { var scriptExists = false; var script = "cr-alert.sh"; - try { - if (fs.existsSync(dirPath)) { - if (window.opener.g_platform == "windows") { + try + { + if (fs.existsSync(dirPath)) + { + if (window.opener.g_platform == "windows") + { script = "cr-alert.bat"; } if ( fs.existsSync(dirPath + script) && g_rosterSettings.realtime == false - ) { + ) + { scriptExists = true; scriptIcon.innerHTML = "
" + @@ -1906,19 +2227,27 @@ function viewRoster() { : "Script Disabled") + "
"; scriptIcon.style.display = "block"; - } else { + } + else + { scriptIcon.style.display = "none"; } } - } catch (e) {} + } + catch (e) {} - if (shouldAlert > 0) { - if (window.opener.g_classicAlerts.huntRoster == true) { + if (shouldAlert > 0) + { + if (window.opener.g_classicAlerts.huntRoster == true) + { var notify = window.opener.huntRosterNotify.value; - if (notify == "0") { + if (notify == "0") + { var media = window.opener.huntRosterNotifyMedia.value; if (media != "none") window.opener.playAlertMediaFile(media); - } else if (notify == "1") { + } + else if (notify == "1") + { window.opener.speakAlertString( window.opener.huntRosterNotifyWord.value ); @@ -1929,8 +2258,10 @@ function viewRoster() { g_rosterSettings.realtime == false && scriptExists && window.opener.g_crScript == 1 - ) { - try { + ) + { + try + { fs.writeFileSync( dirPath + "cr-alert.json", JSON.stringify(g_scriptReport, null, 2) @@ -1941,45 +2272,57 @@ function viewRoster() { var child = cp.spawn(thisProc, [], { detached: true, cwd: dirPath.slice(0, -1), - stdio: ["ignore", "ignore", "ignore"], + stdio: ["ignore", "ignore", "ignore"] }); child.unref(); - } catch (e) { + } + catch (e) + { conosle.log(e); } g_scriptReport = Object(); - } else g_scriptReport = Object(); + } + else g_scriptReport = Object(); } } -function realtimeRoster() { +function realtimeRoster() +{ var now = timeNowSec(); g_day = now / 86400; if (g_rosterSettings.realtime == false) return; var timeCols = document.getElementsByClassName("timeCol"); - for (var x in timeCols) { - if (typeof timeCols[x].id != "undefined") { + for (var x in timeCols) + { + if (typeof timeCols[x].id != "undefined") + { var when = now - callRoster[timeCols[x].id.substr(2)].callObj.age; timeCols[x].innerHTML = when.toDHMS(); } } var lifeCols = document.getElementsByClassName("lifeCol"); - for (var x in lifeCols) { - if (typeof lifeCols[x].id != "undefined") { + for (var x in lifeCols) + { + if (typeof lifeCols[x].id != "undefined") + { var when = now - callRoster[lifeCols[x].id.substr(2)].callObj.life; lifeCols[x].innerHTML = when.toDHMS(); } } - if (g_rosterSettings.columns.Spot) { + if (g_rosterSettings.columns.Spot) + { var spotCols = document.getElementsByClassName("spotCol"); - for (var x in spotCols) { - if (typeof spotCols[x].id != "undefined") { + for (var x in spotCols) + { + if (typeof spotCols[x].id != "undefined") + { spotCols[x].innerHTML = getSpotString( callRoster[spotCols[x].id.substr(2)].callObj ); - if (g_rosterSettings.onlySpot && spotCols[x].innerHTML == "") { + if (g_rosterSettings.onlySpot && spotCols[x].innerHTML == "") + { viewRoster(); return; } @@ -1988,73 +2331,87 @@ function realtimeRoster() { } } -function getSpotString(callObj) { - if (callObj.spot && callObj.spot.when > 0) { +function getSpotString(callObj) +{ + if (callObj.spot && callObj.spot.when > 0) + { when = timeNowSec() - callObj.spot.when; if (when <= window.opener.g_receptionSettings.viewHistoryTimeSec) - return parseInt(when).toDHMS(); + { return parseInt(when).toDHMS(); } } return ""; } -function openChatToCid(cid) { +function openChatToCid(cid) +{ window.opener.showMessaging(true, cid); } -function initiateQso(thisHash) { +function initiateQso(thisHash) +{ window.opener.initiateQso(thisHash); } -function callLookup(thisHash, grid) { +function callLookup(thisHash, grid) +{ window.opener.startLookup( callRoster[thisHash].DEcall, callRoster[thisHash].grid ); } -function callingLookup(thisHash, grid) { +function callingLookup(thisHash, grid) +{ var thisCall = callRoster[thisHash].DXcall; window.opener.startLookup(thisCall, grid); } -function callGenMessage(thisHash, grid) { +function callGenMessage(thisHash, grid) +{ var thisCall = callRoster[thisHash].DEcall; var instance = callRoster[thisHash].callObj.instance; window.opener.startGenMessages(thisCall, grid, instance); } -function callingGenMessage(thisHash, grid) { +function callingGenMessage(thisHash, grid) +{ var thisCall = callRoster[thisHash].DXcall; var instance = callRoster[thisHash].callObj.instance; window.opener.startGenMessages(thisCall, grid, instance); } -function centerOn(grid) { +function centerOn(grid) +{ window.opener.centerOn(grid); } -function instanceChange(what) { +function instanceChange(what) +{ window.opener.g_instances[what.id].crEnable = what.checked; window.opener.goProcessRoster(); } -function updateInstances() { - if (window.opener.g_instancesIndex.length > 1) { +function updateInstances() +{ + if (window.opener.g_instancesIndex.length > 1) + { var instances = window.opener.g_instances; var worker = ""; var keys = Object.keys(instances).sort(); - for (var key in keys) { + for (var key in keys) + { var inst = keys[key]; var sp = inst.split(" - "); var shortInst = sp[sp.length - 1].substring(0, 18); var color = "blue"; - if (instances[inst].open == false) { + if (instances[inst].open == false) + { color = "purple"; } worker += @@ -2070,36 +2427,47 @@ function updateInstances() { } instancesDiv.innerHTML = worker; instancesDiv.style.display = "block"; - } else instancesDiv.style.display = "none"; + } + else instancesDiv.style.display = "none"; } -function processStatus(newMessage) { - if (newMessage.Transmitting == 0) { +function processStatus(newMessage) +{ + if (newMessage.Transmitting == 0) + { // Not Transmitting - if (newMessage.Decoding == 1) { + if (newMessage.Decoding == 1) + { // Decoding txrxdec.style.backgroundColor = "Blue"; txrxdec.style.borderColor = "Cyan"; txrxdec.innerHTML = "DECODE"; - } else { + } + else + { txrxdec.style.backgroundColor = "Green"; txrxdec.style.borderColor = "GreenYellow"; txrxdec.innerHTML = "RECEIVE"; } - } else { + } + else + { txrxdec.style.backgroundColor = "Red"; txrxdec.style.borderColor = "Orange"; txrxdec.innerHTML = "TRANSMIT"; } } -function toTitleCase(str) { - return str.replace(/\w\S*/g, function (txt) { +function toTitleCase(str) +{ + return str.replace(/\w\S*/g, function (txt) + { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } -function newOption(value, text) { +function newOption(value, text) +{ if (typeof text == "undefined") text = value; var option = document.createElement("option"); option.value = value; @@ -2114,7 +2482,8 @@ function createSelectOptions( altName = null, defaultValue = null, checkSponsor = null -) { +) +{ var selector = document.getElementById(selectElementString); selector.innerHTML = ""; @@ -2127,22 +2496,25 @@ function createSelectOptions( selector.appendChild(option); var obj = null; - if (forObject) { + if (forObject) + { obj = Object.keys(forObject).sort(); } - for (var k in obj) { + for (var k in obj) + { var opt = obj[k]; var option = document.createElement("option"); option.value = opt; option.text = altName ? forObject[opt][altName] : opt; if (checkSponsor && opt + "-" + checkSponsor in g_awardTracker) - option.disabled = true; + { option.disabled = true; } selector.appendChild(option); } } -function awardSponsorChanged() { +function awardSponsorChanged() +{ awardName.style.display = ""; createSelectOptions( "awardName", @@ -2154,7 +2526,8 @@ function awardSponsorChanged() { ); } -function awardNameChanged() { +function awardNameChanged() +{ var awardToAdd = newAwardTrackerObject( awardSponsor.value, awardName.value, @@ -2162,7 +2535,8 @@ function awardNameChanged() { ); var hash = awardToAdd.name + "-" + awardToAdd.sponsor; - if (!(hash in g_awardTracker)) { + if (!(hash in g_awardTracker)) + { g_awardTracker[hash] = awardToAdd; storeAwardTracker(); processAward(hash); @@ -2179,9 +2553,10 @@ function awardNameChanged() { ); } -function updateAwardList(target = null) { +function updateAwardList(target = null) +{ var worker = - ''; + "
"; worker += ""; worker += ""; if (Object.keys(g_blockedCalls).length > 0) + { clearString = ""; + } worker += "
" + key + @@ -2832,8 +3312,10 @@ function openIgnoreEdit() { clearString = "
"; if (Object.keys(g_blockedCQ).length > 0) + { clearString = ""; + } worker += "
" + key + @@ -2854,8 +3337,10 @@ function openIgnoreEdit() { clearString = "
"; if (Object.keys(g_blockedDxcc).length > 0) + { clearString = ""; + } worker += "
" + window.opener.g_dxccToAltName[key] + @@ -2879,25 +3365,31 @@ function openIgnoreEdit() { editTables.innerHTML = worker; } -function onMyKeyDown(event) { - if (!g_regFocus) { +function onMyKeyDown(event) +{ + if (!g_regFocus) + { window.opener.onMyKeyDown(event); } } -function checkForEnter(ele) { - if (event.key === "Enter") { +function checkForEnter(ele) +{ + if (event.key === "Enter") + { ele.blur(); } } -function resize() { +function resize() +{ if (editView.style.display == "inline-block") openIgnoreEdit(); window.opener.goProcessRoster(); } -function init() { +function init() +{ g_callsignDatabaseDXCC = window.opener.g_callsignDatabaseDXCC; g_callsignDatabaseUS = window.opener.g_callsignDatabaseUS; g_callsignDatabaseUSplus = window.opener.g_callsignDatabaseUSplus; @@ -2906,13 +3398,14 @@ function init() { updateWorked(); - //addAllAwards(); + // addAllAwards(); window.addEventListener("message", receiveMessage, false); lockNewWindows(); if (window.opener.g_mapSettings.offlineMode == false) + { getBuffer( "http://app.gridtracker.org/callsigns/manifest.json", manifestResult, @@ -2920,14 +3413,16 @@ function init() { "http", 80 ); + } loadSettings(); window.opener.setRosterSpot(g_rosterSettings.columns.Spot); - for (var key in g_rosterSettings.wanted) { + for (var key in g_rosterSettings.wanted) + { if (document.getElementById(key)) - document.getElementById(key).checked = g_rosterSettings.wanted[key]; + { document.getElementById(key).checked = g_rosterSettings.wanted[key]; } } g_menu = new nw.Menu(); @@ -2936,11 +3431,15 @@ function init() { var item = new nw.MenuItem({ type: "normal", label: g_rosterSettings.controls ? "Hide Controls" : "Show Controls", - click: function () { - if (this.label == "Hide Controls") { + click: function () + { + if (this.label == "Hide Controls") + { this.label = "Show Controls"; g_rosterSettings.controls = false; - } else { + } + else + { this.label = "Hide Controls"; g_rosterSettings.controls = true; } @@ -2949,18 +3448,22 @@ function init() { : "Show Controls"; localStorage.rosterSettings = JSON.stringify(g_rosterSettings); setVisual(); - }, + } }); g_menu.append(item); item = new nw.MenuItem({ type: "normal", label: g_rosterSettings.controls ? "Hide Controls" : "Show Controls", - click: function () { - if (this.label == "Hide Controls") { + click: function () + { + if (this.label == "Hide Controls") + { this.label = "Show Controls"; g_rosterSettings.controls = false; - } else { + } + else + { this.label = "Hide Controls"; g_rosterSettings.controls = true; } @@ -2969,29 +3472,31 @@ function init() { : "Show Controls"; localStorage.rosterSettings = JSON.stringify(g_rosterSettings); setVisual(); - }, + } }); g_compactMenu.append(item); item = new nw.MenuItem({ type: "normal", label: "Compact Mode", - click: function () { + click: function () + { g_rosterSettings.compact = true; localStorage.rosterSettings = JSON.stringify(g_rosterSettings); resize(); - }, + } }); g_menu.append(item); item = new nw.MenuItem({ type: "normal", label: "Roster Mode", - click: function () { + click: function () + { g_rosterSettings.compact = false; localStorage.rosterSettings = JSON.stringify(g_rosterSettings); resize(); - }, + } }); g_compactMenu.append(item); @@ -3000,9 +3505,10 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Lookup", - click: function () { + click: function () + { callLookup(g_targetHash, ""); - }, + } }); g_callMenu.append(item); @@ -3010,9 +3516,10 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Gen Msgs", - click: function () { + click: function () + { callGenMessage(g_targetHash, ""); - }, + } }); g_callMenu.append(item); @@ -3024,12 +3531,13 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Ignore Call", - click: function () { + click: function () + { var thisCall = callRoster[g_targetHash].DEcall; g_blockedCalls[thisCall] = true; storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_callMenu.append(item); @@ -3039,9 +3547,10 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Lookup", - click: function () { + click: function () + { callingLookup(g_targetHash, ""); - }, + } }); g_callingMenu.append(item); @@ -3049,9 +3558,10 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Gen Msgs", - click: function () { + click: function () + { callingGenMessage(g_targetHash, ""); - }, + } }); g_callingMenu.append(item); @@ -3063,30 +3573,33 @@ function init() { type: "checkbox", label: "Realtime", checked: g_rosterSettings.realtime, - click: function () { + click: function () + { g_rosterSettings.realtime = this.checked; writeRosterSettings(); window.opener.goProcessRoster(); - }, + } }); g_menu.append(item); item = new nw.MenuItem({ type: "separator" }); g_menu.append(item); - for (var key in g_rosterSettings.columns) { + for (var key in g_rosterSettings.columns) + { var itemx = new nw.MenuItem({ type: "checkbox", label: key, checked: g_rosterSettings.columns[key], - click: function () { + click: function () + { g_rosterSettings.columns[this.label] = this.checked; if (this.label == "Spot") - window.opener.setRosterSpot(g_rosterSettings.columns.Spot); + { window.opener.setRosterSpot(g_rosterSettings.columns.Spot); } writeRosterSettings(); window.opener.goProcessRoster(); resize(); - }, + } }); g_menu.append(itemx); @@ -3099,11 +3612,12 @@ function init() { type: "normal", label: "Clear Call Ignore", enabled: false, - click: function () { + click: function () + { g_blockedCalls = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_menu.append(g_clearIgnores); @@ -3111,11 +3625,12 @@ function init() { type: "normal", label: "Clear Ignore", enabled: false, - click: function () { + click: function () + { g_blockedCalls = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_callMenu.append(g_clearIgnoresCall); @@ -3124,7 +3639,8 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Ignore CQ from DXCC", - click: function () { + click: function () + { g_blockedCQ[ callRoster[g_targetCQ].DXcall + " from " + @@ -3132,7 +3648,7 @@ function init() { ] = true; storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_CQMenu.append(item); @@ -3140,11 +3656,12 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Ignore CQ from All", - click: function () { + click: function () + { g_blockedCQ[callRoster[g_targetCQ].DXcall + " from All"] = true; storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_CQMenu.append(item); @@ -3153,11 +3670,12 @@ function init() { type: "normal", label: "Clear CQ Ignore", enabled: false, - click: function () { + click: function () + { g_blockedCQ = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_menu.append(g_clearCQIgnoreMainMenu); @@ -3165,11 +3683,12 @@ function init() { type: "normal", label: "Clear Ignore", enabled: false, - click: function () { + click: function () + { g_blockedCQ = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_CQMenu.append(g_clearCQIgnore); @@ -3177,9 +3696,10 @@ function init() { type: "normal", label: "Edit Ignores", enabled: true, - click: function () { + click: function () + { openIgnoreEdit(); - }, + } }); g_CQMenu.append(item); @@ -3188,11 +3708,12 @@ function init() { item = new nw.MenuItem({ type: "normal", label: "Ignore DXCC", - click: function () { + click: function () + { g_blockedDxcc[g_targetDxcc] = true; storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_dxccMenu.append(item); @@ -3201,11 +3722,12 @@ function init() { type: "normal", label: "Clear DXCC Ignore", enabled: false, - click: function () { + click: function () + { g_blockedDxcc = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_menu.append(g_clearDxccIgnoreMainMenu); @@ -3213,11 +3735,12 @@ function init() { type: "normal", label: "Clear Ignore", enabled: false, - click: function () { + click: function () + { g_blockedDxcc = Object(); storeBlocks(); window.opener.goProcessRoster(); - }, + } }); g_dxccMenu.append(g_clearDxccIgnore); @@ -3225,9 +3748,10 @@ function init() { type: "normal", label: "Edit Ignores", enabled: true, - click: function () { + click: function () + { openIgnoreEdit(); - }, + } }); g_menu.append(item); @@ -3235,9 +3759,10 @@ function init() { type: "normal", label: "Edit Ignores", enabled: true, - click: function () { + click: function () + { openIgnoreEdit(); - }, + } }); g_callMenu.append(item); @@ -3245,9 +3770,10 @@ function init() { type: "normal", label: "Edit Ignores", enabled: true, - click: function () { + click: function () + { openIgnoreEdit(); - }, + } }); g_dxccMenu.append(item); @@ -3299,143 +3825,176 @@ function init() { updateInstances(); } -function handleContextMenu(ev) { +function handleContextMenu(ev) +{ if (editView.style.display == "inline-block") return false; var mouseX = Math.round(ev.x); var mouseY = Math.round(ev.y); var len = Object.keys(g_blockedCalls).length; - if (len > 0) { + if (len > 0) + { g_clearIgnores.enabled = true; g_clearIgnores.label = "Clear Call Ignore" + (len > 1 ? "s (" + len + ")" : ""); g_clearIgnoresCall.enabled = true; g_clearIgnoresCall.label = "Clear Ignore" + (len > 1 ? "s (" + len + ")" : ""); - } else { + } + else + { g_clearIgnores.label = "Clear Call Ignore"; g_clearIgnores.enabled = false; g_clearIgnoresCall.label = "Clear Ignore"; g_clearIgnoresCall.enabled = false; } len = Object.keys(g_blockedDxcc).length; - if (len > 0) { + if (len > 0) + { g_clearDxccIgnoreMainMenu.enabled = true; g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore" + (len > 1 ? "s (" + len + ")" : ""); g_clearDxccIgnore.enabled = true; g_clearDxccIgnore.label = "Clear Ignore" + (len > 1 ? "s (" + len + ")" : ""); - } else { + } + else + { g_clearDxccIgnoreMainMenu.label = "Clear DXCC Ignore"; g_clearDxccIgnoreMainMenu.enabled = false; g_clearDxccIgnore.label = "Clear Ignore"; g_clearDxccIgnore.enabled = false; } len = Object.keys(g_blockedCQ).length; - if (len > 0) { + if (len > 0) + { g_clearCQIgnoreMainMenu.enabled = true; g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore" + (len > 1 ? "s (" + len + ")" : ""); g_clearCQIgnore.enabled = true; g_clearCQIgnore.label = "Clear Ignore" + (len > 1 ? "s (" + len + ")" : ""); - } else { + } + else + { g_clearCQIgnoreMainMenu.label = "Clear CQ Ignore"; g_clearCQIgnoreMainMenu.enabled = false; g_clearCQIgnore.label = "Clear Ignore"; g_clearCQIgnore.enabled = false; } - if (typeof ev.target != "undefined") { + if (typeof ev.target != "undefined") + { var name = ev.target.getAttribute("name"); - if (name == "Callsign") { + if (name == "Callsign") + { g_targetHash = ev.target.parentNode.id; g_callMenu.popup(mouseX, mouseY); - } else if (name == "Calling") { + } + else if (name == "Calling") + { g_targetHash = ev.target.parentNode.id; g_callingMenu.popup(mouseX, mouseY); - } else if (name == "CQ") { - if (callRoster[ev.target.parentNode.id].DXcall != "CQ") { + } + else if (name == "CQ") + { + if (callRoster[ev.target.parentNode.id].DXcall != "CQ") + { g_targetCQ = ev.target.parentNode.id; g_CQMenu.popup(mouseX, mouseY); } - } else if (name && name.startsWith("DXCC")) { + } + else if (name && name.startsWith("DXCC")) + { var dxcca = name.split("("); var dxcc = parseInt(dxcca[1]); g_targetDxcc = dxcc; g_dxccMenu.popup(mouseX, mouseY); - } else { - if (g_rosterSettings.compact == false) { + } + else + { + if (g_rosterSettings.compact == false) + { g_menu.popup(mouseX, mouseY); - } else { + } + else + { g_compactMenu.popup(mouseX, mouseY); } } - } else { - if (g_rosterSettings.compact == false) { + } + else + { + if (g_rosterSettings.compact == false) + { g_menu.popup(mouseX, mouseY); - } else { + } + else + { g_compactMenu.popup(mouseX, mouseY); } } - if (!g_developerMode) { + if (!g_developerMode) + { ev.preventDefault(); } return false; } -function getTypeFromMode(mode) { - if (mode in g_modes) { +function getTypeFromMode(mode) +{ + if (mode in g_modes) + { if (g_modes[mode] == true) return "Digital"; else if (g_modes_phone[mode] == true) return "Phone"; } return ""; } -function testAward(awardName, obj, baseHash) { +function testAward(awardName, obj, baseHash) +{ if ( g_awardTracker[awardName].test.dxcc && g_awardTracker[awardName].rule.dxcc.indexOf(obj.dxcc) == -1 ) - return false; + { return false; } if ( g_awardTracker[awardName].test.mode && g_awardTracker[awardName].rule.mode.indexOf(obj.mode) == -1 ) - return false; + { return false; } if ( g_awardTracker[awardName].test.band && g_awardTracker[awardName].rule.band.indexOf(obj.band) == -1 ) - return false; + { return false; } if ( g_awardTracker[awardName].test.DEcall && g_awardTracker[awardName].rule.call.indexOf(obj.DEcall) == -1 ) - return false; + { return false; } if ( g_awardTracker[awardName].test.cont && g_awardTracker[awardName].rule.cont.indexOf(obj.cont) == -1 ) - return false; + { return false; } if ( g_awardTracker[awardName].test.prop && g_awardTracker[awardName].rule.propMode != obj.propMode ) - return false; + { return false; } if ( g_awardTracker[awardName].test.sat && g_awardTracker[awardName].rule.satName.indexOf(obj.satName) == -1 ) - return false; + { return false; } return g_awardTypes[g_awardTracker[awardName].rule.type].test( g_awardTracker[awardName], @@ -3444,7 +4003,8 @@ function testAward(awardName, obj, baseHash) { ); } -function processAward(awardName) { +function processAward(awardName) +{ var award = g_awards[g_awardTracker[awardName].sponsor].awards[ g_awardTracker[awardName].name @@ -3495,7 +4055,8 @@ function processAward(awardName) { g_awardTracker[awardName].stat = {}; - for (var i in window.opener.g_QSOhash) { + for (var i in window.opener.g_QSOhash) + { var obj = window.opener.g_QSOhash[i]; if (test.confirmed && !obj.confirmed) continue; @@ -3526,36 +4087,41 @@ function processAward(awardName) { g_awardTracker[awardName].stat = {}; } -function newAwardCountObject() { +function newAwardCountObject() +{ var statCountObject = {}; statCountObject.bands = {}; - statCountObject.bands["Mixed"] = {}; - statCountObject.bands["Digital"] = {}; - statCountObject.bands["Phone"] = {}; + statCountObject.bands.Mixed = {}; + statCountObject.bands.Digital = {}; + statCountObject.bands.Phone = {}; statCountObject.modes = {}; - statCountObject.modes["Mixed"] = {}; - statCountObject.modes["Digital"] = {}; - statCountObject.modes["Phone"] = {}; + statCountObject.modes.Mixed = {}; + statCountObject.modes.Digital = {}; + statCountObject.modes.Phone = {}; statCountObject.unique = null; return statCountObject; } -function workAwardObject(obj, band, mode, isDigital, isPhone, unique = null) { - obj.bands["Mixed"][band] = ~~obj.bands["Mixed"][band] + 1; +function workAwardObject(obj, band, mode, isDigital, isPhone, unique = null) +{ + obj.bands.Mixed[band] = ~~obj.bands.Mixed[band] + 1; if (!(mode in obj.bands)) obj.bands[mode] = {}; obj.bands[mode][band] = ~~obj.bands[mode][band] + 1; - obj.modes["Mixed"][mode] = ~~obj.modes["Mixed"][mode] + 1; + obj.modes.Mixed[mode] = ~~obj.modes.Mixed[mode] + 1; - if (isDigital) { - obj.bands["Digital"][band] = ~~obj.bands["Digital"][band] + 1; - obj.modes["Digital"][mode] = ~~obj.modes["Digital"][mode] + 1; + if (isDigital) + { + obj.bands.Digital[band] = ~~obj.bands.Digital[band] + 1; + obj.modes.Digital[mode] = ~~obj.modes.Digital[mode] + 1; } - if (isPhone) { - obj.bands["Phone"][band] = ~~obj.bands["Phone"][band] + 1; - obj.modes["Phone"][mode] = ~~obj.modes["Phone"][mode] + 1; + if (isPhone) + { + obj.bands.Phone[band] = ~~obj.bands.Phone[band] + 1; + obj.modes.Phone[mode] = ~~obj.modes.Phone[mode] + 1; } - if (unique) { + if (unique) + { if (obj.unique == null) obj.unique = {}; if (!(unique in obj.unique)) obj.unique[unique] = newAwardCountObject(); workAwardObject(obj.unique[unique], band, mode, isDigital, isPhone); @@ -3563,7 +4129,8 @@ function workAwardObject(obj, band, mode, isDigital, isPhone, unique = null) { return true; } -function buildAwardTypeHandlers() { +function buildAwardTypeHandlers() +{ g_awardTypes = { IOTA: { name: "Islands On The Air" }, call: { name: "Callsign" }, @@ -3585,80 +4152,82 @@ function buildAwardTypeHandlers() { cont2band: { name: "Continents per Band" }, calls2band: { name: "Stations per Band" }, dxcc2band: { name: "DXCC per Band" }, - states2band: { name: "States per Band" }, + states2band: { name: "States per Band" } }; - g_awardTypes["IOTA"].score = scoreAIOTA; - g_awardTypes["call"].score = scoreAcall; - g_awardTypes["callarea"].score = scoreAcallarea; - g_awardTypes["calls2dxcc"].score = scoreAcalls2dxcc; - g_awardTypes["cnty"].score = scoreAcnty; - g_awardTypes["cont"].score = scoreAcont; - g_awardTypes["cont5"].score = scoreAcont5; - g_awardTypes["cont52band"].score = scoreAcont52band; - g_awardTypes["cqz"].score = scoreAcqz; - g_awardTypes["dxcc"].score = scoreAdxcc; - g_awardTypes["grids"].score = scoreAgrids; - g_awardTypes["numsfx"].score = scoreAnumsfx; - g_awardTypes["px"].score = scoreApx; - g_awardTypes["pxa"].score = scoreApxa; - g_awardTypes["pxplus"].score = scoreApxplus; - g_awardTypes["sfx"].score = scoreAsfx; - g_awardTypes["states"].score = scoreAstates; - g_awardTypes["cont2band"].score = scoreAcont2band; - g_awardTypes["calls2band"].score = scoreAcalls2band; - g_awardTypes["dxcc2band"].score = scoreAdxcc2band; - g_awardTypes["states2band"].score = scoreAstates2band; + g_awardTypes.IOTA.score = scoreAIOTA; + g_awardTypes.call.score = scoreAcall; + g_awardTypes.callarea.score = scoreAcallarea; + g_awardTypes.calls2dxcc.score = scoreAcalls2dxcc; + g_awardTypes.cnty.score = scoreAcnty; + g_awardTypes.cont.score = scoreAcont; + g_awardTypes.cont5.score = scoreAcont5; + g_awardTypes.cont52band.score = scoreAcont52band; + g_awardTypes.cqz.score = scoreAcqz; + g_awardTypes.dxcc.score = scoreAdxcc; + g_awardTypes.grids.score = scoreAgrids; + g_awardTypes.numsfx.score = scoreAnumsfx; + g_awardTypes.px.score = scoreApx; + g_awardTypes.pxa.score = scoreApxa; + g_awardTypes.pxplus.score = scoreApxplus; + g_awardTypes.sfx.score = scoreAsfx; + g_awardTypes.states.score = scoreAstates; + g_awardTypes.cont2band.score = scoreAcont2band; + g_awardTypes.calls2band.score = scoreAcalls2band; + g_awardTypes.dxcc2band.score = scoreAdxcc2band; + g_awardTypes.states2band.score = scoreAstates2band; - g_awardTypes["IOTA"].test = testAIOTA; - g_awardTypes["call"].test = testAcall; - g_awardTypes["callarea"].test = testAcallarea; - g_awardTypes["calls2dxcc"].test = testAcalls2dxcc; - g_awardTypes["cnty"].test = testAcnty; - g_awardTypes["cont"].test = testAcont; - g_awardTypes["cont5"].test = testAcont5; - g_awardTypes["cont52band"].test = testAcont52band; - g_awardTypes["cqz"].test = testAcqz; - g_awardTypes["dxcc"].test = testAdxcc; - g_awardTypes["grids"].test = testAgrids; - g_awardTypes["numsfx"].test = testAnumsfx; - g_awardTypes["px"].test = testApx; - g_awardTypes["pxa"].test = testApxa; - g_awardTypes["pxplus"].test = testApxplus; - g_awardTypes["sfx"].test = testAsfx; - g_awardTypes["states"].test = testAstates; - g_awardTypes["cont2band"].test = testAcont2band; - g_awardTypes["calls2band"].test = testAcalls2band; - g_awardTypes["dxcc2band"].test = testAdxcc2band; - g_awardTypes["states2band"].test = testAstates2band; + g_awardTypes.IOTA.test = testAIOTA; + g_awardTypes.call.test = testAcall; + g_awardTypes.callarea.test = testAcallarea; + g_awardTypes.calls2dxcc.test = testAcalls2dxcc; + g_awardTypes.cnty.test = testAcnty; + g_awardTypes.cont.test = testAcont; + g_awardTypes.cont5.test = testAcont5; + g_awardTypes.cont52band.test = testAcont52band; + g_awardTypes.cqz.test = testAcqz; + g_awardTypes.dxcc.test = testAdxcc; + g_awardTypes.grids.test = testAgrids; + g_awardTypes.numsfx.test = testAnumsfx; + g_awardTypes.px.test = testApx; + g_awardTypes.pxa.test = testApxa; + g_awardTypes.pxplus.test = testApxplus; + g_awardTypes.sfx.test = testAsfx; + g_awardTypes.states.test = testAstates; + g_awardTypes.cont2band.test = testAcont2band; + g_awardTypes.calls2band.test = testAcalls2band; + g_awardTypes.dxcc2band.test = testAdxcc2band; + g_awardTypes.states2band.test = testAstates2band; - g_awardTypes["IOTA"].compile = singleCompile; - g_awardTypes["call"].compile = singleCompile; - g_awardTypes["callarea"].compile = singleCompile; - g_awardTypes["calls2dxcc"].compile = doubleCompile; - g_awardTypes["cnty"].compile = singleCompile; - g_awardTypes["cont"].compile = singleCompile; - g_awardTypes["cont5"].compile = singleCompile; - g_awardTypes["cont52band"].compile = doubleCompile; - g_awardTypes["cqz"].compile = singleCompile; - g_awardTypes["dxcc"].compile = singleCompile; - g_awardTypes["grids"].compile = singleCompile; - g_awardTypes["numsfx"].compile = singleCompile; - g_awardTypes["px"].compile = singleCompile; - g_awardTypes["pxa"].compile = singleCompile; - g_awardTypes["pxplus"].compile = singleCompile; - g_awardTypes["sfx"].compile = singleCompile; - g_awardTypes["states"].compile = singleCompile; - g_awardTypes["cont2band"].compile = doubleCompile; - g_awardTypes["calls2band"].compile = doubleCompile; - g_awardTypes["dxcc2band"].compile = doubleCompile; - g_awardTypes["states2band"].compile = doubleCompile; + g_awardTypes.IOTA.compile = singleCompile; + g_awardTypes.call.compile = singleCompile; + g_awardTypes.callarea.compile = singleCompile; + g_awardTypes.calls2dxcc.compile = doubleCompile; + g_awardTypes.cnty.compile = singleCompile; + g_awardTypes.cont.compile = singleCompile; + g_awardTypes.cont5.compile = singleCompile; + g_awardTypes.cont52band.compile = doubleCompile; + g_awardTypes.cqz.compile = singleCompile; + g_awardTypes.dxcc.compile = singleCompile; + g_awardTypes.grids.compile = singleCompile; + g_awardTypes.numsfx.compile = singleCompile; + g_awardTypes.px.compile = singleCompile; + g_awardTypes.pxa.compile = singleCompile; + g_awardTypes.pxplus.compile = singleCompile; + g_awardTypes.sfx.compile = singleCompile; + g_awardTypes.states.compile = singleCompile; + g_awardTypes.cont2band.compile = doubleCompile; + g_awardTypes.calls2band.compile = doubleCompile; + g_awardTypes.dxcc2band.compile = doubleCompile; + g_awardTypes.states2band.compile = doubleCompile; } -function scoreAstates(award, obj) { - if (obj.state) { +function scoreAstates(award, obj) +{ + if (obj.state) + { if (!(obj.state in award.stat)) - award.stat[obj.state] = newAwardCountObject(); + { award.stat[obj.state] = newAwardCountObject(); } return workAwardObject( award.stat[obj.state], obj.band, @@ -3670,15 +4239,19 @@ function scoreAstates(award, obj) { return false; } -function testAstates(award, obj, baseHash) { - if (obj.state && obj.state + baseHash in g_tracker[award.test.look].state) { +function testAstates(award, obj, baseHash) +{ + if (obj.state && obj.state + baseHash in g_tracker[award.test.look].state) + { return false; } return true; } -function scoreAstates2band(award, obj) { - if (obj.state) { +function scoreAstates2band(award, obj) +{ + if (obj.state) + { if (!(obj.band in award.stat)) award.stat[obj.band] = newAwardCountObject(); return workAwardObject( award.stat[obj.band], @@ -3692,14 +4265,17 @@ function scoreAstates2band(award, obj) { return false; } -function testAstates2band(award, obj, baseHash) { - if (obj.state && obj.state + baseHash in g_tracker[award.test.look].state) { +function testAstates2band(award, obj, baseHash) +{ + if (obj.state && obj.state + baseHash in g_tracker[award.test.look].state) + { return false; } return true; } -function scoreAdxcc(award, obj) { +function scoreAdxcc(award, obj) +{ if (!(obj.dxcc in award.stat)) award.stat[obj.dxcc] = newAwardCountObject(); return workAwardObject( award.stat[obj.dxcc], @@ -3710,15 +4286,19 @@ function scoreAdxcc(award, obj) { ); } -function testAdxcc(award, obj, baseHash) { - if (String(obj.dxcc) + baseHash in g_tracker[award.test.look].dxcc) { +function testAdxcc(award, obj, baseHash) +{ + if (String(obj.dxcc) + baseHash in g_tracker[award.test.look].dxcc) + { return false; } return true; } -function scoreAcont(award, obj) { - if (obj.cont) { +function scoreAcont(award, obj) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "AN") cont = "OC"; if (!(cont in award.stat)) award.stat[cont] = newAwardCountObject(); @@ -3733,20 +4313,25 @@ function scoreAcont(award, obj) { return false; } -function testAcont(award, obj, baseHash) { - if (obj.cont) { +function testAcont(award, obj, baseHash) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "AN") cont = "OC"; - if (cont + baseHash in g_tracker[award.test.look].cont) { + if (cont + baseHash in g_tracker[award.test.look].cont) + { return false; } } return true; } -function scoreAcont5(award, obj, baseHash) { - if (obj.cont) { +function scoreAcont5(award, obj, baseHash) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "NA" || cont == "SA") cont = "AM"; if (cont == "AN") cont = "OC"; @@ -3763,20 +4348,24 @@ function scoreAcont5(award, obj, baseHash) { return false; } -function testAcont5(award, obj, baseHash) { - if (obj.cont) { +function testAcont5(award, obj, baseHash) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "NA" || cont == "SA") cont = "AM"; if (cont == "AN") cont = "OC"; - if (cont + baseHash in g_tracker[award.test.look].cont) { + if (cont + baseHash in g_tracker[award.test.look].cont) + { return false; } } return true; } -function scoreAcont2band(award, obj) { +function scoreAcont2band(award, obj) +{ if (!(obj.band in award.stat)) award.stat[obj.band] = newAwardCountObject(); return workAwardObject( @@ -3789,20 +4378,25 @@ function scoreAcont2band(award, obj) { ); } -function testAcont2band(award, obj, baseHash) { - if (obj.cont) { +function testAcont2band(award, obj, baseHash) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "AN") cont = "OC"; - if (cont + baseHash in g_tracker[award.test.look].cont) { + if (cont + baseHash in g_tracker[award.test.look].cont) + { return false; } } return true; } -function scoreAcont52band(award, obj) { - if (obj.cont) { +function scoreAcont52band(award, obj) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "NA" || cont == "SA") cont = "AM"; if (cont == "AN") cont = "OC"; @@ -3820,21 +4414,26 @@ function scoreAcont52band(award, obj) { return false; } -function testAcont52band(award, obj, baseHash) { - if (obj.cont) { +function testAcont52band(award, obj, baseHash) +{ + if (obj.cont) + { var cont = obj.cont; if (cont == "NA" || cont == "SA") cont = "AM"; if (cont == "AN") cont = "OC"; - if (cont + baseHash in g_tracker[award.test.look].cont) { + if (cont + baseHash in g_tracker[award.test.look].cont) + { return false; } } return true; } -function scoreAgrids(award, obj) { - if (obj.grid) { +function scoreAgrids(award, obj) +{ + if (obj.grid) + { var grid = obj.grid.substr(0, 4); if (!(grid in award.stat)) award.stat[grid] = newAwardCountObject(); @@ -3849,15 +4448,19 @@ function scoreAgrids(award, obj) { return false; } -function testAgrids(award, obj, baseHash) { - if (obj.grid && obj.grid + baseHash in g_tracker[award.test.look].grid) { +function testAgrids(award, obj, baseHash) +{ + if (obj.grid && obj.grid + baseHash in g_tracker[award.test.look].grid) + { return false; } return true; } -function scoreAcnty(award, obj) { - if (obj.cnty) { +function scoreAcnty(award, obj) +{ + if (obj.cnty) + { if (!(obj.cnty in award.stat)) award.stat[obj.cnty] = newAwardCountObject(); return workAwardObject( award.stat[obj.cnty], @@ -3870,17 +4473,21 @@ function scoreAcnty(award, obj) { return false; } -function testAcnty(award, obj, baseHash) { - if (obj.cnty && obj.cnty + baseHash in g_tracker[award.test.look].cnty) { +function testAcnty(award, obj, baseHash) +{ + if (obj.cnty && obj.cnty + baseHash in g_tracker[award.test.look].cnty) + { return false; } return true; } -function scoreAcall(award, obj) { +function scoreAcall(award, obj) +{ var call = obj.DEcall; - if (call.indexOf("/") > -1) { + if (call.indexOf("/") > -1) + { if (call.endsWith("/MM")) return false; call = call.replace("/P", "").replace("/R", "").replace("/QRP"); } @@ -3895,21 +4502,25 @@ function scoreAcall(award, obj) { ); } -function testAcall(award, obj, baseHash) { +function testAcall(award, obj, baseHash) +{ if (obj.DEcall.indexOf("/") > -1 && obj.DEcall.endsWith("/MM")) return false; - if (obj.DEcall + baseHash in g_tracker[award.test.look].call) { + if (obj.DEcall + baseHash in g_tracker[award.test.look].call) + { return false; } return true; } -function scoreAIOTA(award, obj) { - if (obj.IOTA) { +function scoreAIOTA(award, obj) +{ + if (obj.IOTA) + { var test = g_awards[award.sponsor].awards[award.name]; if ("IOTA" in test.rule && test.rule.IOTA.indexOf(obj.IOTA) == -1) - return false; + { return false; } if (!(obj.IOTA in award.stat)) award.stat[obj.IOTA] = newAwardCountObject(); return workAwardObject( @@ -3924,25 +4535,28 @@ function scoreAIOTA(award, obj) { } // NO IOTA YET -function testAIOTA(award, obj, baseHash) { - /*if ( obj.IOTA ) +function testAIOTA(award, obj, baseHash) +{ + /* if ( obj.IOTA ) { var test = g_awards[award.sponsor].awards[award.name]; if ( "IOTA" in test.rule && test.rule.IOTA.indexOf(obj.IOTA) == -1 ) return false; - }*/ + } */ return false; } -function scoreAcallarea(award, obj) { - if (obj.zone != null) { +function scoreAcallarea(award, obj) +{ + if (obj.zone != null) + { var test = g_awards[award.sponsor].awards[award.name]; if ("zone" in test.rule && test.rule.zone.indexOf(obj.zone) == -1) - return false; + { return false; } if (!(obj.zone in award.stat)) award.stat[obj.zone] = newAwardCountObject(); return workAwardObject( @@ -3956,21 +4570,26 @@ function scoreAcallarea(award, obj) { return false; } -function testAcallarea(award, obj, baseHash) { - if (obj.zone != null) { +function testAcallarea(award, obj, baseHash) +{ + if (obj.zone != null) + { var test = g_awards[award.sponsor].awards[award.name]; if ("zone" in test.rule && test.rule.zone.indexOf(obj.zone) == -1) - return false; + { return false; } } return true; } -function scoreApx(award, obj) { - if (obj.px) { +function scoreApx(award, obj) +{ + if (obj.px) + { var test = g_awards[award.sponsor].awards[award.name]; var px = obj.px; - if ("px" in test.rule) { + if ("px" in test.rule) + { px = px.substr(0, test.rule.px[0].length); if (test.rule.px.indexOf(px) == -1) return false; } @@ -3987,27 +4606,35 @@ function scoreApx(award, obj) { return false; } -function testApx(award, obj, baseHash) { - if (obj.px) { +function testApx(award, obj, baseHash) +{ + if (obj.px) + { var test = g_awards[award.sponsor].awards[award.name]; var px = obj.px; - if ("px" in test.rule) { + if ("px" in test.rule) + { px = px.substr(0, test.rule.px[0].length); if (test.rule.px.indexOf(px) == -1) return false; } - if (String(obj.px) + baseHash in g_tracker[award.test.look].px) { + if (String(obj.px) + baseHash in g_tracker[award.test.look].px) + { return false; } } return true; } -function scoreApxa(award, obj) { - if (obj.px) { +function scoreApxa(award, obj) +{ + if (obj.px) + { var test = g_awards[award.sponsor].awards[award.name]; - for (var i in test.rule.pxa) { - if (test.rule.pxa[i].indexOf(obj.px) > -1) { + for (var i in test.rule.pxa) + { + if (test.rule.pxa[i].indexOf(obj.px) > -1) + { if (!(i in award.stat)) award.stat[i] = newAwardCountObject(); return workAwardObject( award.stat[i], @@ -4022,14 +4649,21 @@ function scoreApxa(award, obj) { return false; } -function testApxa(award, obj, baseHash) { - if (obj.px) { +function testApxa(award, obj, baseHash) +{ + if (obj.px) + { var test = g_awards[award.sponsor].awards[award.name]; - for (var i in test.rule.pxa) { - if (test.rule.pxa[i].indexOf(obj.px) > -1) { - if (String(obj.px) + baseHash in g_tracker[award.test.look].px) { + for (var i in test.rule.pxa) + { + if (test.rule.pxa[i].indexOf(obj.px) > -1) + { + if (String(obj.px) + baseHash in g_tracker[award.test.look].px) + { return false; - } else { + } + else + { return true; } } @@ -4038,12 +4672,16 @@ function testApxa(award, obj, baseHash) { return false; } -function scoreAsfx(award, obj) { +function scoreAsfx(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; var suf = obj.DEcall.replace(obj.px, ""); - for (var i in test.rule.sfx) { - for (var s in test.rule.sfx[i]) { - if (suf.indexOf(test.rule.sfx[i][s]) == 0) { + for (var i in test.rule.sfx) + { + for (var s in test.rule.sfx[i]) + { + if (suf.indexOf(test.rule.sfx[i][s]) == 0) + { if (!(i in award.stat)) award.stat[i] = newAwardCountObject(); return workAwardObject( award.stat[i], @@ -4059,12 +4697,16 @@ function scoreAsfx(award, obj) { return false; } -function testAsfx(award, obj, baseHash) { +function testAsfx(award, obj, baseHash) +{ var test = g_awards[award.sponsor].awards[award.name]; var suf = obj.DEcall.replace(obj.px, ""); - for (var i in test.rule.sfx) { - for (var s in test.rule.sfx[i]) { - if (suf.indexOf(test.rule.sfx[i][s]) == 0) { + for (var i in test.rule.sfx) + { + for (var s in test.rule.sfx[i]) + { + if (suf.indexOf(test.rule.sfx[i][s]) == 0) + { return false; } } @@ -4073,7 +4715,8 @@ function testAsfx(award, obj, baseHash) { return true; } -function scoreAcalls2dxcc(award, obj) { +function scoreAcalls2dxcc(award, obj) +{ if (!(obj.dxcc in award.stat)) award.stat[obj.dxcc] = newAwardCountObject(); return workAwardObject( @@ -4086,14 +4729,17 @@ function scoreAcalls2dxcc(award, obj) { ); } -function testAcalls2dxcc(award, obj, baseHash) { - if (obj.DEcall + baseHash in g_tracker[award.test.look].call) { +function testAcalls2dxcc(award, obj, baseHash) +{ + if (obj.DEcall + baseHash in g_tracker[award.test.look].call) + { return false; } return true; } -function scoreAcalls2band(award, obj) { +function scoreAcalls2band(award, obj) +{ if (!(obj.band in award.stat)) award.stat[obj.band] = newAwardCountObject(); return workAwardObject( @@ -4106,14 +4752,17 @@ function scoreAcalls2band(award, obj) { ); } -function testAcalls2band(award, obj, baseHash) { - if (obj.DEcall + baseHash in g_tracker[award.test.look].call) { +function testAcalls2band(award, obj, baseHash) +{ + if (obj.DEcall + baseHash in g_tracker[award.test.look].call) + { return false; } return true; } -function scoreAdxcc2band(award, obj) { +function scoreAdxcc2band(award, obj) +{ if (!(obj.band in award.stat)) award.stat[obj.band] = newAwardCountObject(); return workAwardObject( @@ -4126,15 +4775,19 @@ function scoreAdxcc2band(award, obj) { ); } -function testAdxcc2band(award, obj, baseHash) { - if (String(obj.dxcc) + baseHash in g_tracker[award.test.look].dxcc) { +function testAdxcc2band(award, obj, baseHash) +{ + if (String(obj.dxcc) + baseHash in g_tracker[award.test.look].dxcc) + { return false; } return true; } -function scoreAcqz(award, obj) { - if (obj.cqz) { +function scoreAcqz(award, obj) +{ + if (obj.cqz) + { if (!(obj.cqz in award.stat)) award.stat[obj.cqz] = newAwardCountObject(); return workAwardObject( @@ -4148,10 +4801,13 @@ function scoreAcqz(award, obj) { return false; } -function testAcqz(award, obj, baseHash) { - if (obj.cqza) { +function testAcqz(award, obj, baseHash) +{ + if (obj.cqza) + { var x = 0; - for (var z in obj.cqza) { + for (var z in obj.cqza) + { if (obj.cqza[z] + baseHash in g_tracker[award.test.look].cqz) x++; } if (obj.cqza.length == x) return false; @@ -4159,14 +4815,18 @@ function testAcqz(award, obj, baseHash) { return true; } -function scoreAnumsfx(award, obj) { +function scoreAnumsfx(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; var px = obj.px.substr(0, obj.px.length - 1); var suf = obj.DEcall.replace(px, ""); suf = suf.substr(0, test.rule.numsfx[0][0].length); - for (var i in test.rule.numsfx) { - for (var s in test.rule.numsfx[i]) { - if (suf.indexOf(test.rule.numsfx[i][s]) == 0) { + for (var i in test.rule.numsfx) + { + for (var s in test.rule.numsfx[i]) + { + if (suf.indexOf(test.rule.numsfx[i][s]) == 0) + { if (!(i in award.stat)) award.stat[i] = newAwardCountObject(); return workAwardObject( award.stat[i], @@ -4182,14 +4842,18 @@ function scoreAnumsfx(award, obj) { return false; } -function testAnumsfx(award, obj) { +function testAnumsfx(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; var px = obj.px.substr(0, obj.px.length - 1); var suf = obj.DEcall.replace(px, ""); suf = suf.substr(0, test.rule.numsfx[0][0].length); - for (var i in test.rule.numsfx) { - for (var s in test.rule.numsfx[i]) { - if (suf.indexOf(test.rule.numsfx[i][s]) == 0) { + for (var i in test.rule.numsfx) + { + for (var s in test.rule.numsfx[i]) + { + if (suf.indexOf(test.rule.numsfx[i][s]) == 0) + { return false; } } @@ -4198,12 +4862,16 @@ function testAnumsfx(award, obj) { return true; } -function scoreApxplus(award, obj) { +function scoreApxplus(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; - if (test.rule.pxplus) { - for (var i in test.rule.pxplus) { - if (obj.DEcall.indexOf(test.rule.pxplus[i]) == 0) { + if (test.rule.pxplus) + { + for (var i in test.rule.pxplus) + { + if (obj.DEcall.indexOf(test.rule.pxplus[i]) == 0) + { if (!(i in award.stat)) award.stat[i] = newAwardCountObject(); return workAwardObject( award.stat[i], @@ -4218,12 +4886,16 @@ function scoreApxplus(award, obj) { return false; } -function testApxplus(award, obj) { +function testApxplus(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; - if (test.rule.pxplus) { - for (var i in test.rule.pxplus) { - if (obj.DEcall.indexOf(test.rule.pxplus[i]) == 0) { + if (test.rule.pxplus) + { + for (var i in test.rule.pxplus) + { + if (obj.DEcall.indexOf(test.rule.pxplus[i]) == 0) + { return false; } } @@ -4231,36 +4903,46 @@ function testApxplus(award, obj) { return true; } -function loadAwardJson() { +function loadAwardJson() +{ g_awards = {}; var fs = require("fs"); - if (fs.existsSync("./data/awards.json")) { + if (fs.existsSync("./data/awards.json")) + { fileBuf = fs.readFileSync("./data/awards.json"); - try { + try + { g_awards = JSON.parse(fileBuf); - //fs.writeFileSync("./data/awards.json", JSON.stringify(g_awards,null,2)); + // fs.writeFileSync("./data/awards.json", JSON.stringify(g_awards,null,2)); - for (var sp in g_awards) { - for (var aw in g_awards[sp].awards) { + for (var sp in g_awards) + { + for (var aw in g_awards[sp].awards) + { if (!("unique" in g_awards[sp].awards[aw].rule)) - g_awards[sp].awards[aw].rule.unique = 1; + { g_awards[sp].awards[aw].rule.unique = 1; } - if (g_awards[sp].awards[aw].rule.band[0] == "Mixed") { + if (g_awards[sp].awards[aw].rule.band[0] == "Mixed") + { g_awards[sp].awards[aw].rule.band.shift(); } - if (g_awards[sp].awards[aw].rule.band.length == 0) { + if (g_awards[sp].awards[aw].rule.band.length == 0) + { g_awards[sp].awards[aw].rule.band = []; - for (var key in g_awards[sp].mixed) { + for (var key in g_awards[sp].mixed) + { g_awards[sp].awards[aw].rule.band.push(g_awards[sp].mixed[key]); } } if ( g_awards[sp].awards[aw].rule.endorse.length == 1 && g_awards[sp].awards[aw].rule.endorse[0] == "Mixed" - ) { + ) + { g_awards[sp].awards[aw].rule.endorse = []; - for (var key in g_awards[sp].mixed) { + for (var key in g_awards[sp].mixed) + { g_awards[sp].awards[aw].rule.endorse.push( g_awards[sp].mixed[key] ); @@ -4270,16 +4952,22 @@ function loadAwardJson() { } buildAwardTypeHandlers(); - } catch (e) { + } + catch (e) + { alert("Core awards.json : " + e); g_awards = {}; } - } else alert("Missing core awards.json"); + } + else alert("Missing core awards.json"); } -function processAllAwardTrackers() { - for (var tracker in g_awardTracker) { - if (!(g_awardTracker[tracker].sponsor in g_awards)) { +function processAllAwardTrackers() +{ + for (var tracker in g_awardTracker) + { + if (!(g_awardTracker[tracker].sponsor in g_awards)) + { delete g_awardTracker[tracker]; continue; } @@ -4288,7 +4976,8 @@ function processAllAwardTrackers() { g_awardTracker[tracker].name in g_awards[g_awardTracker[tracker].sponsor].awards ) - ) { + ) + { delete g_awardTracker[tracker]; continue; } @@ -4297,7 +4986,8 @@ function processAllAwardTrackers() { updateAwardList(); } -function newAwardTrackerObject(sponsor, award, enable) { +function newAwardTrackerObject(sponsor, award, enable) +{ var newAward = {}; newAward.sponsor = sponsor; newAward.name = award; @@ -4311,13 +5001,17 @@ function newAwardTrackerObject(sponsor, award, enable) { return newAward; } -function addAllAwards() { - for (var sponsor in g_awards) { - for (var award in g_awards[sponsor].awards) { +function addAllAwards() +{ + for (var sponsor in g_awards) + { + for (var award in g_awards[sponsor].awards) + { var awardToAdd = newAwardTrackerObject(sponsor, award, true); var hash = awardToAdd.name + "-" + awardToAdd.sponsor; - if (!(hash in g_awardTracker)) { + if (!(hash in g_awardTracker)) + { g_awardTracker[hash] = awardToAdd; processAward(hash); storeAwardTracker(); @@ -4328,14 +5022,16 @@ function addAllAwards() { window.opener.goProcessRoster(); } -function delAllAwards() { +function delAllAwards() +{ g_awardTracker = {}; storeAwardTracker(); updateAwardList(); window.opener.goProcessRoster(); } -function newCompileCountObject() { +function newCompileCountObject() +{ var compileCountObject = {}; compileCountObject.bands = {}; compileCountObject.modes = {}; @@ -4344,47 +5040,57 @@ function newCompileCountObject() { return compileCountObject; } -function singleCompile(award, obj) { +function singleCompile(award, obj) +{ var test = g_awards[award.sponsor].awards[award.name]; var rule = test.rule; var comp = newCompileCountObject(); - for (var mode in rule.mode) { + for (var mode in rule.mode) + { comp.modes[rule.mode[mode]] = 0; comp.bands[rule.mode[mode]] = {}; - for (var band in rule.band) { + for (var band in rule.band) + { comp.bands[rule.mode[mode]][rule.band[band]] = 0; } - for (var key in obj) { + for (var key in obj) + { if ( rule.mode[mode] in obj[key].bands && Object.keys(obj[key].bands[rule.mode[mode]]).length - ) { + ) + { comp.modes[rule.mode[mode]] += 1; - for (var band in rule.band) { + for (var band in rule.band) + { if (rule.band[band] in obj[key].bands[rule.mode[mode]]) - comp.bands[rule.mode[mode]][rule.band[band]] += 1; + { comp.bands[rule.mode[mode]][rule.band[band]] += 1; } } } } } - for (var mode in comp.modes) { + for (var mode in comp.modes) + { comp.endorse[mode] = {}; comp.counts[mode] = {}; - for (var cnts in rule.count) { + for (var cnts in rule.count) + { comp.counts[mode][rule.count[cnts]] = { num: comp.modes[mode], per: parseInt( Math.min(100, (comp.modes[mode] / rule.count[cnts]) * 100.0) - ), + ) }; } - for (var endorse in rule.endorse) { + for (var endorse in rule.endorse) + { comp.endorse[mode][rule.endorse[endorse]] = {}; - for (var cnts in rule.count) { + for (var cnts in rule.count) + { comp.endorse[mode][rule.endorse[endorse]][rule.count[cnts]] = comp.bands[mode][rule.endorse[endorse]] >= rule.count[cnts]; } @@ -4394,34 +5100,43 @@ function singleCompile(award, obj) { return comp; } -function doubleCompile(award, firstLevel) { +function doubleCompile(award, firstLevel) +{ var test = g_awards[award.sponsor].awards[award.name]; var rule = test.rule; - for (var k in firstLevel) { + for (var k in firstLevel) + { firstLevel[k].bands = {}; - //firstLevel[k].modes = {}; + // firstLevel[k].modes = {}; var obj = singleCompile(award, firstLevel[k].unique); - for (var mode in obj.bands) { - for (var cnt in test.rule.count) { + for (var mode in obj.bands) + { + for (var cnt in test.rule.count) + { if (obj.counts[mode][test.rule.count[cnt]].num >= test.rule.unique) - for (var band in obj.bands[mode]) { + { + for (var band in obj.bands[mode]) + { if (!(mode in firstLevel[k].bands)) firstLevel[k].bands[mode] = {}; if (obj.bands[mode][band] > 0) + { firstLevel[k].bands[mode][band] = ~~firstLevel[k].bands[mode][band] + 1; + } } + } } } - /*for ( var mode in obj.modes ) + /* for ( var mode in obj.modes ) { if ( !(mode in firstLevel[k].modes) ) firstLevel[k].modes[mode] = 0; if ( obj.modes[mode] > 0 ) firstLevel[k].modes[mode] += 1; - }*/ + } */ delete firstLevel[k].unique; firstLevel[k].unique = null; diff --git a/package.nw/lib/screens.js b/package.nw/lib/screens.js index e7d92c2d..2a842819 100644 --- a/package.nw/lib/screens.js +++ b/package.nw/lib/screens.js @@ -8,7 +8,8 @@ var g_screenLost = false; var g_windowInfo = {}; var g_initialScreenCount = nw.Screen.screens.length; -function setWindowInfo() { +function setWindowInfo() +{ // if we've lost a screen, stop saving our info if (g_screenLost) return; var win = nw.Window.get(); @@ -20,24 +21,29 @@ function setWindowInfo() { g_windowInfo = windowInfo; } -function clearAllScreenTimers() { - if (g_windowMoveTimer != null) { +function clearAllScreenTimers() +{ + if (g_windowMoveTimer != null) + { clearTimeout(g_windowMoveTimer); g_windowMoveTimer = null; } - if (g_windowResizeTimer != null) { + if (g_windowResizeTimer != null) + { clearTimeout(g_windowResizeTimer); g_windowResizeTimer = null; } } var screenCB = { - onDisplayAdded: function (screen) { + onDisplayAdded: function (screen) + { clearAllScreenTimers(); if ( g_screenLost == true && g_initialScreenCount == nw.Screen.screens.length - ) { + ) + { // Lets restore the position now var win = nw.Window.get(); win.x = g_windowInfo.x; @@ -48,15 +54,18 @@ var screenCB = { } }, - onDisplayRemoved: function (screen) { + onDisplayRemoved: function (screen) + { clearAllScreenTimers(); - if (g_initialScreenCount != nw.Screen.screens.length) { + if (g_initialScreenCount != nw.Screen.screens.length) + { g_screenLost = true; } - }, + } }; -function saveScreenSettings() { +function saveScreenSettings() +{ var setting = { showing: g_isShowing, zoomLevel: s_zoomLevel }; s_screenSettings = JSON.parse(localStorage.screenSettings); @@ -71,18 +80,22 @@ nw.Screen.on("displayRemoved", screenCB.onDisplayRemoved); var g_isShowing = false; -nw.Window.get().on("loaded", function () { +nw.Window.get().on("loaded", function () +{ s_title = document.title.substr(0, 16).trim(); g_isShowing = false; - if (typeof localStorage.screenSettings == "undefined") { + if (typeof localStorage.screenSettings == "undefined") + { localStorage.screenSettings = "{}"; } s_screenSettings = JSON.parse(localStorage.screenSettings); - if (!(s_title in s_screenSettings)) { + if (!(s_title in s_screenSettings)) + { saveScreenSettings(); } - if (!("zoomLevel" in s_screenSettings[s_title])) { + if (!("zoomLevel" in s_screenSettings[s_title])) + { saveScreenSettings(); } g_isShowing = s_screenSettings[s_title].showing; @@ -98,16 +111,20 @@ nw.Window.get().on("loaded", function () { }); var g_windowMoveTimer = null; -nw.Window.get().on("move", function (x, y) { - if (g_windowMoveTimer != null) { +nw.Window.get().on("move", function (x, y) +{ + if (g_windowMoveTimer != null) + { clearTimeout(g_windowMoveTimer); } g_windowMoveTimer = setTimeout(setWindowInfo, 1000); }); var g_windowResizeTimer = null; -nw.Window.get().on("resize", function (w, h) { - if (g_windowResizeTimer != null) { +nw.Window.get().on("resize", function (w, h) +{ + if (g_windowResizeTimer != null) + { clearTimeout(g_windowResizeTimer); } g_windowResizeTimer = setTimeout(setWindowInfo, 1000); @@ -119,31 +136,37 @@ var g_zoomKeys = { NumpadAdd: increaseZoom, Equal: increaseZoom, Numpad0: resetZoom, - Digit0: resetZoom, + Digit0: resetZoom }; -function onZoomControlDown(event) { - if (event.ctrlKey) { - if (event.code in g_zoomKeys) { +function onZoomControlDown(event) +{ + if (event.ctrlKey) + { + if (event.code in g_zoomKeys) + { g_zoomKeys[event.code](); } } } -function reduceZoom() { +function reduceZoom() +{ s_zoomLevel -= 0.2; nw.Window.get().zoomLevel = s_zoomLevel; saveScreenSettings(); } -function increaseZoom() { +function increaseZoom() +{ s_zoomLevel += 0.2; nw.Window.get().zoomLevel = s_zoomLevel; saveScreenSettings(); } -function resetZoom() { +function resetZoom() +{ s_zoomLevel = 0; nw.Window.get().zoomLevel = s_zoomLevel; saveScreenSettings(); diff --git a/package.nw/lib/shadow.js b/package.nw/lib/shadow.js index eb2019e5..8c37cd31 100644 --- a/package.nw/lib/shadow.js +++ b/package.nw/lib/shadow.js @@ -1,23 +1,27 @@ /** **/ -(function (global, factory) { +(function (global, factory) +{ typeof exports === "object" && typeof module !== "undefined" ? (module.exports = factory()) : typeof define === "function" && define.amd - ? define(factory) - : (global.GeoJSONTerminator = factory()); -})(this, function () { + ? define(factory) + : (global.GeoJSONTerminator = factory()); +})(this, function () +{ "use strict"; - function julian(date) { + function julian(date) + { /* Calculate the present UTC Julian Date. Function is valid after * the beginning of the UNIX epoch 1970-01-01 and ignores leap * seconds. */ return date / 86400000 + 2440587.5; } - function GMST(julianDay) { + function GMST(julianDay) + { /* Calculate Greenwich Mean Sidereal Time according to http://aa.usno.navy.mil/faq/docs/GAST.php */ var d = julianDay - 2451545.0; @@ -25,25 +29,29 @@ return (18.697374558 + 24.06570982441908 * d) % 24; } - class Terminator { - constructor(options = { resolution: 1 }) { + class Terminator + { + constructor(options = { resolution: 1 }) + { this.options = options; this.version = "0.1.0"; this._R2D = 180 / Math.PI; this._D2R = Math.PI / 180; - //this.options.resolution = options.resolution || this.options.resolution; + // this.options.resolution = options.resolution || this.options.resolution; // this.options.time = options.time; var latLngs = this._compute(this.options.time); return this._toGeoJSON(latLngs); } - setTime(date) { + setTime(date) + { this.options.time = date; var latLngs = this._compute(date); return this._toGeoJSON(latLngs); } - _toGeoJSON(latLngs) { + _toGeoJSON(latLngs) + { /* Return 'pseudo' GeoJSON representation of the coordinates Why 'pseudo'? Coordinates longitude range go from -360 to 360 @@ -61,19 +69,21 @@ type: "Polygon", coordinates: [ [ - ...latLngs.map((latLng) => { + ...latLngs.map((latLng) => + { return [latLng[1], latLng[0]]; }), - [latLngs[0][1], latLngs[0][0]], + [latLngs[0][1], latLngs[0][0]] ] .slice() - .reverse(), - ], - }, + .reverse() + ] + } }; } - _sunEclipticPosition(julianDay) { + _sunEclipticPosition(julianDay) + { /* Compute the position of the Sun in ecliptic coordinates at julianDay. Following http://en.wikipedia.org/wiki/Position_of_the_Sun */ @@ -94,7 +104,8 @@ return { lambda: lambda }; } - _eclipticObliquity(julianDay) { + _eclipticObliquity(julianDay) + { // Following the short term expression in // http://en.wikipedia.org/wiki/Axial_tilt#Obliquity_of_the_ecliptic_.28Earth.27s_axial_tilt.29 var n = julianDay - 2451545.0; @@ -111,10 +122,14 @@ T * (0.576e-6 / 3600 - (T * 4.34e-8) / 3600)))); return epsilon; } - _jday(date) { + + _jday(date) + { return date.getTime() / 86400000.0 + 2440587.5; } - _calculatePositionOfSun(date) { + + _calculatePositionOfSun(date) + { date = date instanceof Date ? date : new Date(); var rad = 0.017453292519943295; @@ -175,7 +190,8 @@ return [lng, lat]; } - _sunEquatorialPosition(sunEclLng, eclObliq) { + _sunEquatorialPosition(sunEclLng, eclObliq) + { /* Compute the Sun's equatorial position from its ecliptic * position. Inputs are expected in degrees. Outputs are in * degrees as well. */ @@ -195,14 +211,16 @@ return { alpha: alpha, delta: delta }; } - _hourAngle(lng, sunPos, gst) { + _hourAngle(lng, sunPos, gst) + { /* Compute the hour angle of the sun for a longitude on * Earth. Return the hour angle in degrees. */ var lst = gst + lng / 15; return lst * 15 - sunPos.alpha; } - _latitude(ha, sunPos) { + _latitude(ha, sunPos) + { /* For a given hour angle and sun position, compute the * latitude of the terminator in degrees. */ var lat = @@ -212,7 +230,8 @@ return lat; } - _compute(time) { + _compute(time) + { var today = time ? new Date(time) : new Date(); var julianDay = julian(today); var gst = GMST(julianDay); @@ -222,22 +241,27 @@ var sunEclPos = this._sunEclipticPosition(julianDay); var eclObliq = this._eclipticObliquity(julianDay); var sunEqPos = this._sunEquatorialPosition(sunEclPos.lambda, eclObliq); - for (var i = 0; i <= 720 * this.options.resolution; i++) { + for (var i = 0; i <= 720 * this.options.resolution; i++) + { var lng = startMinus + i / this.options.resolution; var ha = this._hourAngle(lng, sunEqPos, gst); latLng[i + 1] = [this._latitude(ha, sunEqPos), lng]; } - if (sunEqPos.delta < 0) { + if (sunEqPos.delta < 0) + { latLng[0] = [90, startMinus]; latLng[latLng.length] = [90, 360]; - } else { + } + else + { latLng[0] = [-90, startMinus]; latLng[latLng.length] = [-90, 360]; } return latLng; } } - function terminator(options) { + function terminator(options) + { return new Terminator(options); } @@ -248,35 +272,37 @@ var dayNight = { map: null, vectorLayer: null, - init: function (map) { + init: function (map) + { this.map = map; var geoJSON = new GeoJSONTerminator(); this.vectorSource = new ol.source.Vector({ features: new ol.format.GeoJSON().readFeatures(geoJSON, { - featureProjection: "EPSG:3857", - }), + featureProjection: "EPSG:3857" + }) }); this.vectorLayer = new ol.layer.Vector({ source: this.vectorSource, style: new ol.style.Style({ fill: new ol.style.Fill({ - color: "rgb(0,0,0)", + color: "rgb(0,0,0)" }), - stroke: null, + stroke: null }), opacity: Number(g_mapSettings.shadow), - zIndex: 0, + zIndex: 0 }); this.map.getLayers().insertAt(1, this.vectorLayer); }, - refresh: function () { + refresh: function () + { var circleStyle = new ol.style.Style({ fill: new ol.style.Fill({ - color: "rgb(0,0,0)", - }), + color: "rgb(0,0,0)" + }) }); this.vectorLayer.setStyle(circleStyle); this.vectorLayer.setOpacity(Number(g_mapSettings.shadow)); @@ -284,24 +310,27 @@ var dayNight = { this.vectorSource.addFeature( new ol.format.GeoJSON().readFeature(new GeoJSONTerminator(), { - featureProjection: "EPSG:3857", + featureProjection: "EPSG:3857" }) ); var point = ol.proj.fromLonLat([g_myLon, g_myLat]); var arr = this.vectorSource.getFeaturesAtCoordinate(point); - return arr.length > 0 ? true : false; + return arr.length > 0; }, - show: function () { + show: function () + { this.vectorLayer.setVisible(true); return this.refresh(); }, - hide: function () { + hide: function () + { this.vectorLayer.setVisible(false); }, - isVisible: function () { + isVisible: function () + { return this.vectorLayer.getVisible(); - }, + } }; var moonLayer = { @@ -309,7 +338,8 @@ var moonLayer = { vectorLayer: null, icon: null, pin: null, - init: function (map) { + init: function (map) + { this.map = map; this.icon = new ol.style.Icon({ @@ -318,7 +348,7 @@ var moonLayer = { anchorXUnits: "pixels", anchor: [255, 255], scale: 0.1, - opacity: 0.5, + opacity: 0.5 }); this.pin = iconFeature( @@ -331,16 +361,18 @@ var moonLayer = { this.vectorLayer = new ol.layer.Vector({ source: this.vectorSource, - zIndex: 30, + zIndex: 30 }); this.map.getLayers().insertAt(1, this.vectorLayer); }, - future: function (now) { + future: function (now) + { var r = 0; var x = 25; var i = 3600; var data = Array(); - for (r = 0; r < x; r++) { + for (r = 0; r < x; r++) + { data.push(subLunar(now + r * i).ll); } line = []; @@ -348,16 +380,22 @@ var moonLayer = { var lonOff = 0; var lastc = 0; - for (var i = 0; i < data.length; i++) { + for (var i = 0; i < data.length; i++) + { var c = data[i]; - if (isNaN(c[0])) { + if (isNaN(c[0])) + { continue; } - if (Math.abs(lastc - c[0]) > 270) { + if (Math.abs(lastc - c[0]) > 270) + { // Wrapped - if (c[0] < lastc) { + if (c[0] < lastc) + { lonOff += 360; - } else { + } + else + { lonOff -= 360; } } @@ -365,7 +403,8 @@ var moonLayer = { line.push(ol.proj.fromLonLat([c[0] + lonOff, c[1]])); } - if (line.length == 0) { + if (line.length == 0) + { line.push(ol.proj.fromLonLat(start)); } @@ -374,18 +413,20 @@ var moonLayer = { feature.setStyle( new ol.style.Style({ - stroke: new ol.style.Stroke({ color: "#FFF", width: 1 }), + stroke: new ol.style.Stroke({ color: "#FFF", width: 1 }) }) ); return feature; }, - refresh: function () { + refresh: function () + { this.vectorSource.clear(); - if (g_appSettings.moonTrack == 1) { + if (g_appSettings.moonTrack == 1) + { now = timeNowSec(); if (g_appSettings.moonPath == 1) - this.vectorSource.addFeature(this.future(now)); + { this.vectorSource.addFeature(this.future(now)); } this.pin = iconFeature( ol.proj.fromLonLat(subLunar(now).ll), this.icon, @@ -396,16 +437,19 @@ var moonLayer = { } }, - show: function () { + show: function () + { this.refresh(); this.vectorLayer.setVisible(true); lunaButonImg.style.webkitFilter = "brightness(100%)"; }, - hide: function () { + hide: function () + { this.vectorLayer.setVisible(false); lunaButonImg.style.webkitFilter = "brightness(50%)"; }, - isVisible: function () { + isVisible: function () + { return this.vectorLayer.getVisible(); - }, + } }; diff --git a/package.nw/lib/stats.js b/package.nw/lib/stats.js index f25358ee..fde5218f 100644 --- a/package.nw/lib/stats.js +++ b/package.nw/lib/stats.js @@ -2,29 +2,35 @@ // All rights reserved. // See LICENSE for more information. -document.oncontextmenu = function (event) { +document.oncontextmenu = function (event) +{ event.preventDefault(); }; -document.addEventListener("dragover", function (event) { +document.addEventListener("dragover", function (event) +{ event.preventDefault(); }); -document.addEventListener("drop", function (event) { +document.addEventListener("drop", function (event) +{ event.preventDefault(); }); -function openInfoTab(evt, tabName, callFunc, callObj) { +function openInfoTab(evt, tabName, callFunc, callObj) +{ // Declare all variables var i, infoTabcontent, infoTablinks; // Get all elements with class="infoTabcontent" and hide them infoTabcontent = document.getElementsByClassName("infoTabcontent"); - for (i = 0; i < infoTabcontent.length; i++) { + for (i = 0; i < infoTabcontent.length; i++) + { infoTabcontent[i].style.display = "none"; } // Get all elements with class="infoTablinks" and remove the class "active" infoTablinks = document.getElementsByClassName("infoTablinks"); - for (i = 0; i < infoTablinks.length; i++) { + for (i = 0; i < infoTablinks.length; i++) + { infoTablinks[i].className = infoTablinks[i].className.replace( " active", "" @@ -34,13 +40,16 @@ function openInfoTab(evt, tabName, callFunc, callObj) { document.getElementById(tabName).style.display = "block"; if (typeof evt.currentTarget != "undefined") - evt.currentTarget.className += " active"; + { evt.currentTarget.className += " active"; } else evt.className += " active"; - if (callFunc) { - if (typeof window.opener.window[callFunc] != "undefined") { + if (callFunc) + { + if (typeof window.opener.window[callFunc] != "undefined") + { var caller = window.opener.window[callFunc]; - if (caller) { + if (caller) + { if (callObj) caller(callObj); else caller(); } @@ -48,47 +57,60 @@ function openInfoTab(evt, tabName, callFunc, callObj) { } } -function resetSearch() { +function resetSearch() +{ window.opener.resetSearch(); } -function lookupCallsign(callsign) { +function lookupCallsign(callsign) +{ window.opener.lookupCallsign(callsign); } -function appendToChild(elementString, object, onInputString, defaultValue) { +function appendToChild(elementString, object, onInputString, defaultValue) +{ window[elementString].appendChild(object); object.oninput = window.opener[onInputString]; object.value = defaultValue; } -function statsFocus(selection) { +function statsFocus(selection) +{ var which = document.getElementById(selection); - if (which != null) { + if (which != null) + { which.focus(); which.selectionStart = which.selectionEnd = which.value.length; } } -function ValidateCallsign(inputText, validDiv) { - if (inputText.value.length > 0) { +function ValidateCallsign(inputText, validDiv) +{ + if (inputText.value.length > 0) + { var passed = false; inputText.value = inputText.value.toUpperCase(); - if (/\d/.test(inputText.value) || /[A-Z]/.test(inputText.value)) { + if (/\d/.test(inputText.value) || /[A-Z]/.test(inputText.value)) + { passed = true; } - if (passed) { + if (passed) + { inputText.style.color = "#FF0"; inputText.style.backgroundColor = "green"; if (validDiv) validDiv.innerHTML = "Valid!"; return true; - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; if (validDiv) validDiv.innerHTML = "Invalid!"; return false; } - } else { + } + else + { inputText.style.color = "#000"; inputText.style.backgroundColor = "yellow"; if (validDiv) validDiv.innerHTML = "Invalid!"; @@ -96,79 +118,103 @@ function ValidateCallsign(inputText, validDiv) { } } -function validateCallByElement(elementString) { +function validateCallByElement(elementString) +{ ValidateCallsign(window[elementString], null); } -function init() { +function init() +{ openInfoTab(event, "workedBoxDiv", "showWorkedBox"); } -function addTextToClipboard(data) { +function addTextToClipboard(data) +{ navigator.clipboard.writeText(data); } -function setClipboardFromLookup() { - if (window.opener.g_lastLookupAddress) { +function setClipboardFromLookup() +{ + if (window.opener.g_lastLookupAddress) + { addTextToClipboard(window.opener.g_lastLookupAddress); } } -function resizeWorked() { +function resizeWorked() +{ workedListDiv.style.height = window.innerHeight - 63 - 6 + "px"; } -function Resize() { - if (statBoxDiv.style.display == "block") { +function Resize() +{ + if (statBoxDiv.style.display == "block") + { window.opener.showStatBox(true); } - if (workedBoxDiv.style.display == "block") { + if (workedBoxDiv.style.display == "block") + { resizeWorked(); } - if (callsignBoxDiv.style.display == "block") { + if (callsignBoxDiv.style.display == "block") + { window.opener.showCallsignBox(true); } - if (dxccBoxDiv.style.display == "block") { + if (dxccBoxDiv.style.display == "block") + { window.opener.showDXCCsBox(); } - if (cqzoneBoxDiv.style.display == "block") { + if (cqzoneBoxDiv.style.display == "block") + { window.opener.showCQzoneBox(); } - if (ituzoneBoxDiv.style.display == "block") { + if (ituzoneBoxDiv.style.display == "block") + { window.opener.showITUzoneBox(); } - if (waswaczoneBoxDiv.style.display == "block") { + if (waswaczoneBoxDiv.style.display == "block") + { window.opener.showWASWACzoneBox(); } - if (wpxBoxDiv.style.display == "block") { + if (wpxBoxDiv.style.display == "block") + { window.opener.showWPXBox(true); } - if (decodeLastDiv.style.display == "block") { + if (decodeLastDiv.style.display == "block") + { decodeLastListDiv.style.height = window.innerHeight - 63 + 26 + "px"; } } -function reloadInfo(bandOrMode) { - if (statBoxDiv.style.display == "block") { +function reloadInfo(bandOrMode) +{ + if (statBoxDiv.style.display == "block") + { window.opener.showStatBox(false); } - if (callsignBoxDiv.style.display == "block") { + if (callsignBoxDiv.style.display == "block") + { window.opener.showCallsignBox(false); } - if (dxccBoxDiv.style.display == "block") { + if (dxccBoxDiv.style.display == "block") + { window.opener.showDXCCsBox(); } - if (wpxBoxDiv.style.display == "block") { + if (wpxBoxDiv.style.display == "block") + { window.opener.showWPXBox(); } - if (cqzoneBoxDiv.style.display == "block") { + if (cqzoneBoxDiv.style.display == "block") + { window.opener.showCQzoneBox(); } - if (ituzoneBoxDiv.style.display == "block") { + if (ituzoneBoxDiv.style.display == "block") + { window.opener.showITUzoneBox(); } - if (waswaczoneBoxDiv.style.display == "block") { + if (waswaczoneBoxDiv.style.display == "block") + { window.opener.showWASWACzoneBox(); } }
"; worker += "Name"; @@ -2203,7 +2578,8 @@ function updateAwardList(target = null) { var keys = Object.keys(g_awardTracker).sort(); - for (var key in keys) { + for (var key in keys) + { var award = g_awardTracker[keys[key]]; var rule = g_awards[award.sponsor].awards[award.name].rule; var row = awardTable.insertRow(); @@ -2221,16 +2597,19 @@ function updateAwardList(target = null) { g_awards[award.sponsor].sponsor + ")\n"; tooltip += toTitleCase(award.test.qsl_req) + " QSO\n"; - for (var mode in award.comp.counts) { + for (var mode in award.comp.counts) + { tooltip += mode + "\n"; - for (var count in award.comp.counts[mode]) { + for (var count in award.comp.counts[mode]) + { endorseTotal++; - if (award.comp.counts[mode][count].per == 100) { + if (award.comp.counts[mode][count].per == 100) + { baseAward = true; endorseCount++; } if (award.comp.counts[mode][count].num > baseCount) - baseCount = award.comp.counts[mode][count].num; + { baseCount = award.comp.counts[mode][count].num; } tooltip += "\t" + @@ -2241,16 +2620,20 @@ function updateAwardList(target = null) { award.comp.counts[mode][count].per + "%)\n"; var wrk = ""; - if (Object.keys(award.comp.endorse).length > 0) { - for (var band in award.comp.endorse[mode]) { + if (Object.keys(award.comp.endorse).length > 0) + { + for (var band in award.comp.endorse[mode]) + { endorseTotal++; - if (award.comp.endorse[mode][band][count] == true) { + if (award.comp.endorse[mode][band][count] == true) + { endorseCount++; wrk += band + " "; } } } - if (wrk.length > 0) { + if (wrk.length > 0) + { tooltip += "\t\t" + wrk + "\n"; } } @@ -2270,10 +2653,10 @@ function updateAwardList(target = null) { (allEndorse ? "" : baseAward - ? "" - : baseCount > 0 - ? "" - : ""), + ? "" + : baseCount > 0 + ? "" + : ""), tooltip ); createCell( @@ -2291,7 +2674,8 @@ function updateAwardList(target = null) { } } -function deleteAwardTracker(sender) { +function deleteAwardTracker(sender) +{ var id = sender.parentNode.parentNode.id; delete g_awardTracker[id]; storeAwardTracker(); @@ -2300,7 +2684,8 @@ function deleteAwardTracker(sender) { window.opener.goProcessRoster(); } -function awardCheckboxChanged(sender) { +function awardCheckboxChanged(sender) +{ var awardId = sender.target.parentNode.parentNode.id; g_awardTracker[sender.target.parentNode.parentNode.id][sender.target.name] = sender.target.checked; @@ -2308,7 +2693,8 @@ function awardCheckboxChanged(sender) { window.opener.goProcessRoster(); } -function awardValueChanged(sender) { +function awardValueChanged(sender) +{ var awardId = sender.target.parentNode.parentNode.id; g_awardTracker[sender.target.parentNode.parentNode.id][sender.target.name] = sender.target.value; @@ -2323,24 +2709,29 @@ function createCell( data = null, title = null, checkbox = false -) { +) +{ var cell = row.insertCell(); if (data == null) cell.innerHTML = value; if (title) cell.title = title; - if (checkbox) { + if (checkbox) + { var x = document.createElement("INPUT"); x.setAttribute("type", "checkbox"); x.checked = value; x.name = target; x.addEventListener("change", awardCheckboxChanged); cell.appendChild(x); - } else if (data) { + } + else if (data) + { cell.appendChild(createAwardSelector(cell, target, value, data)); } return cell; } -function createCellHtml(row, html, title = null) { +function createCellHtml(row, html, title = null) +{ var cell = row.insertCell(); cell.innerHTML = html; if (title) cell.title = title; @@ -2348,16 +2739,18 @@ function createCellHtml(row, html, title = null) { return cell; } -function createAwardSelector(cell, target, value, forObject) { +function createAwardSelector(cell, target, value, forObject) +{ var selector = document.createElement("select"); selector.name = target; selector.value = value; - selector.disabled = forObject.length == 1 ? true : false; + selector.disabled = forObject.length == 1; selector.style.margin = "0px"; selector.style.padding = "1px"; if (selector.disabled) selector.style.cursor = "auto"; selector.addEventListener("change", awardValueChanged); - for (var opt in forObject) { + for (var opt in forObject) + { var option = document.createElement("option"); option.value = forObject[opt]; if (option.value == "Phone" || option.value == "CW") option.disabled = true; @@ -2367,46 +2760,58 @@ function createAwardSelector(cell, target, value, forObject) { return selector; } -function resetAwardAdd() { +function resetAwardAdd() +{ awardName.style.display = "none"; createSelectOptions("awardName", "Select Award", null); createSelectOptions("awardSponsor", "Select Sponsor", g_awards, "sponsor"); } -function openAwardPopup() { +function openAwardPopup() +{ awardHunterDiv.style.zIndex = 100; resetAwardAdd(); } -function closeAwardPopup() { +function closeAwardPopup() +{ awardHunterDiv.style.zIndex = -1; resetAwardAdd(); } -function toggleMoreControls() { +function toggleMoreControls() +{ g_rosterSettings.controlsExtended = !g_rosterSettings.controlsExtended; localStorage.rosterSettings = JSON.stringify(g_rosterSettings); setVisual(); } -function setVisual() { +function setVisual() +{ HuntNeedControls.style.display = "none"; HuntStateControls.style.display = "none"; HuntDXCCsControls.style.display = "none"; - if (g_rosterSettings.controls) { - if (g_rosterSettings.controlsExtended) { + if (g_rosterSettings.controls) + { + if (g_rosterSettings.controlsExtended) + { RosterControls.className = "extended"; - } else { + } + else + { RosterControls.className = "normal"; } - } else { + } + else + { RosterControls.className = "hidden"; } // Award Hunter - if (referenceNeed.value == 6) { + if (referenceNeed.value == 6) + { /* for ( key in g_rosterSettings.wanted ) { document.getElementById(key).checked = true; @@ -2420,21 +2825,27 @@ function setVisual() { AwardTrackerControls.style.display = ""; huntingMatrixDiv.style.display = ""; updateAwardList(); - } else { - for (var key in g_rosterSettings.wanted) { + } + else + { + for (var key in g_rosterSettings.wanted) + { if (document.getElementById(key)) - document.getElementById(key).checked = g_rosterSettings.wanted[key]; + { document.getElementById(key).checked = g_rosterSettings.wanted[key]; } } AwardTrackerControls.style.display = "none"; HuntingControls.style.display = ""; CallsignsControls.style.display = ""; closeAwardPopup(); - if (callsignNeed.value == "all" || callsignNeed.value == "hits") { + if (callsignNeed.value == "all" || callsignNeed.value == "hits") + { huntingMatrixDiv.style.display = ""; HuntNeedControls.style.display = "block"; HuntModeControls.style.display = "none"; - } else { + } + else + { huntingMatrixDiv.style.display = "none"; HuntModeControls.style.display = "block"; @@ -2442,104 +2853,133 @@ function setVisual() { huntMode.value != "callsign" && huntMode.value != "usstate" && huntMode.value != "dxccs" - ) { + ) + { HuntNeedControls.style.display = "block"; } - if (huntMode.value == "usstate") { + if (huntMode.value == "usstate") + { HuntStateControls.style.display = "block"; } - if (huntMode.value == "usstates") { + if (huntMode.value == "usstates") + { HuntNeedControls.style.display = "block"; } - if (huntMode.value == "dxccs") { + if (huntMode.value == "dxccs") + { HuntDXCCsControls.style.display = "block"; } } } - if (wantMaxDT.checked == true) { + if (wantMaxDT.checked == true) + { maxDT.style.display = "block"; maxDTView.style.display = "block"; - } else { + } + else + { maxDT.style.display = "none"; maxDTView.style.display = "none"; } - if (wantMinDB.checked == true) { + if (wantMinDB.checked == true) + { minDb.style.display = "block"; minDbView.style.display = "block"; - } else { + } + else + { minDb.style.display = "none"; minDbView.style.display = "none"; } - if (wantMinFreq.checked == true) { + if (wantMinFreq.checked == true) + { minFreq.style.display = "block"; minFreqView.style.display = "block"; - } else { + } + else + { minFreq.style.display = "none"; minFreqView.style.display = "none"; } - if (wantMaxFreq.checked == true) { + if (wantMaxFreq.checked == true) + { maxFreq.style.display = "block"; maxFreqView.style.display = "block"; - } else { + } + else + { maxFreq.style.display = "none"; maxFreqView.style.display = "none"; } - if (useRegex.checked == true) { + if (useRegex.checked == true) + { callsignRegex.style.display = "inline-block"; - } else { + } + else + { callsignRegex.style.display = "none"; } - if (window.opener.g_callsignLookups.lotwUseEnable == true) { + if (window.opener.g_callsignLookups.lotwUseEnable == true) + { usesLoTWDiv.style.display = "inline-block"; - if (g_rosterSettings.usesLoTW == true) { + if (g_rosterSettings.usesLoTW == true) + { maxLoTW.style.display = "inline-block"; maxLoTWView.style.display = "inline-block"; - } else { + } + else + { maxLoTW.style.display = "none"; maxLoTWView.style.display = "none"; } - } else { + } + else + { usesLoTWDiv.style.display = "none"; maxLoTW.style.display = "none"; maxLoTWView.style.display = "none"; } if (window.opener.g_callsignLookups.eqslUseEnable == true) - useseQSLDiv.style.display = "block"; + { useseQSLDiv.style.display = "block"; } else useseQSLDiv.style.display = "none"; if (window.opener.g_callsignLookups.oqrsUseEnable == true) - usesOQRSDiv.style.display = "block"; + { usesOQRSDiv.style.display = "block"; } else usesOQRSDiv.style.display = "none"; if (g_rosterSettings.columns.Spot == true) - onlySpotDiv.style.display = "block"; + { onlySpotDiv.style.display = "block"; } else onlySpotDiv.style.display = "none"; if (g_rosterSettings.callsign == "all" || g_rosterSettings.callsign == "hits") - allOnlyNewDiv.style.display = "block"; + { allOnlyNewDiv.style.display = "block"; } else allOnlyNewDiv.style.display = "none"; resize(); } -function wantedChanged(element) { +function wantedChanged(element) +{ g_rosterSettings.wanted[element.id] = element.checked; - if (element.checked == true) { + if (element.checked == true) + { var t = element.id.replace("hunt", ""); - if (t in g_rosterSettings.columns) { + if (t in g_rosterSettings.columns) + { g_rosterSettings.columns[t] = true; - for (var i = 0; i < g_menu.items.length; ++i) { + for (var i = 0; i < g_menu.items.length; ++i) + { if ( typeof g_menu.items[i].checked != "undefined" && g_menu.items[i].label == t ) - g_menu.items[i].checked = true; + { g_menu.items[i].checked = true; } } } } @@ -2547,13 +2987,15 @@ function wantedChanged(element) { writeRosterSettings(); g_scriptReport = Object(); - for (var callHash in window.opener.g_callRoster) { + for (var callHash in window.opener.g_callRoster) + { window.opener.g_callRoster[callHash].callObj.alerted = false; } window.opener.goProcessRoster(); } -function valuesChanged() { +function valuesChanged() +{ setVisual(); g_rosterSettings.callsign = callsignNeed.value; @@ -2583,7 +3025,8 @@ function valuesChanged() { noMsg.checked && onlyMsg.checked && noMsgValue.value == onlyMsgValue.value - ) { + ) + { if (g_rosterSettings.noMsg) noMsg.checked = false; else onlyMsg.checked = false; } @@ -2604,43 +3047,51 @@ function valuesChanged() { g_scriptReport = Object(); for (var callHash in window.opener.g_callRoster) - window.opener.g_callRoster[callHash].callObj.alerted = false; + { window.opener.g_callRoster[callHash].callObj.alerted = false; } window.opener.goProcessRoster(); } -function getBuffer(file_url, callback, flag, mode, port, cookie) { +function getBuffer(file_url, callback, flag, mode, port, cookie) +{ var url = require("url"); var http = require(mode); var fileBuffer = null; var options = null; - if (cookie != null) { + if (cookie != null) + { options = { host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api port: port, path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api headers: { - Cookie: cookie, - }, + Cookie: cookie + } }; - } else { + } + else + { options = { host: url.parse(file_url).host, // eslint-disable-line node/no-deprecated-api port: port, - path: url.parse(file_url).path, // eslint-disable-line node/no-deprecated-api + path: url.parse(file_url).path // eslint-disable-line node/no-deprecated-api }; } - http.get(options, function (res) { + http.get(options, function (res) + { var fsize = res.headers["content-length"]; var cookies = null; if (typeof res.headers["set-cookie"] != "undefined") - cookies = res.headers["set-cookie"]; + { cookies = res.headers["set-cookie"]; } res - .on("data", function (data) { + .on("data", function (data) + { if (fileBuffer == null) fileBuffer = data; else fileBuffer += data; }) - .on("end", function () { - if (typeof callback === "function") { + .on("end", function () + { + if (typeof callback === "function") + { // Call it, since we have confirmed it is callable callback(fileBuffer, flag, cookies); } @@ -2649,7 +3100,8 @@ function getBuffer(file_url, callback, flag, mode, port, cookie) { }); } -function callsignResult(buffer, flag) { +function callsignResult(buffer, flag) +{ var rawData = JSON.parse(buffer); r_currentUSState = flag; @@ -2659,11 +3111,14 @@ function callsignResult(buffer, flag) { window.opener.goProcessRoster(); } -function stateChangedValue(what) { - if (r_currentUSState != stateSelect.value && stateSelect.value != "") { +function stateChangedValue(what) +{ + if (r_currentUSState != stateSelect.value && stateSelect.value != "") + { r_currentUSState = stateSelect.value; - if (window.opener.g_mapSettings.offlineMode == false) { + if (window.opener.g_mapSettings.offlineMode == false) + { var callState = r_currentUSState.replace("CN-", ""); getBuffer( "http://app.gridtracker.org/callsigns/" + callState + ".callsigns.json", @@ -2672,7 +3127,9 @@ function stateChangedValue(what) { "http", 80 ); - } else { + } + else + { window.opener.goProcessRoster(); r_currentUSState = ""; g_currentUSCallsigns = null; @@ -2682,7 +3139,8 @@ function stateChangedValue(what) { } } - if (stateSelect.value == "") { + if (stateSelect.value == "") + { r_currentUSState = ""; g_currentUSCallsigns = null; @@ -2690,26 +3148,31 @@ function stateChangedValue(what) { } } -function DXCCsChangedValue(what) { +function DXCCsChangedValue(what) +{ r_currentDXCCs = DXCCsSelect.value; window.opener.goProcessRoster(); } -function initDXCCSelector() { - var items = Object.keys(window.opener.g_dxccToAltName).sort(function (a, b) { +function initDXCCSelector() +{ + var items = Object.keys(window.opener.g_dxccToAltName).sort(function (a, b) + { return window.opener.g_dxccToAltName[a].localeCompare( window.opener.g_dxccToAltName[b] ); }); var newSelect = document.getElementById("DXCCsSelect"); - for (var i in items) { + for (var i in items) + { var key = items[i]; if ( window.opener.g_worldGeoData[window.opener.g_dxccToGeoData[key]].geo != "deleted" - ) { + ) + { var option = document.createElement("option"); option.value = key; option.text = @@ -2724,16 +3187,21 @@ function initDXCCSelector() { newSelect.oninput = DXCCsChangedValue; } -function manifestResult(buffer, flag) { +function manifestResult(buffer, flag) +{ r_callsignManifest = JSON.parse(buffer); var newSelect = document.getElementById("stateSelect"); - for (var key in r_callsignManifest.cnt) { + for (var key in r_callsignManifest.cnt) + { var option = document.createElement("option"); - if (window.opener.g_enums[key]) { + if (window.opener.g_enums[key]) + { option.value = key; option.text = window.opener.g_enums[key]; - } else { + } + else + { option.value = "CN-" + key; option.text = window.opener.g_enums["CN-" + key]; } @@ -2746,7 +3214,8 @@ function receiveMessage(event) {} var g_tracker = {}; -function updateWorked() { +function updateWorked() +{ g_worked = window.opener.g_tracker.worked; g_confirmed = window.opener.g_tracker.confirmed; g_modes = window.opener.g_modes; @@ -2756,62 +3225,72 @@ function updateWorked() { processAllAwardTrackers(); } -function deleteCallsignIgnore(key) { +function deleteCallsignIgnore(key) +{ delete g_blockedCalls[key]; storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function deleteDxccIgnore(key) { +function deleteDxccIgnore(key) +{ delete g_blockedDxcc[key]; storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function deleteCQIgnore(key) { +function deleteCQIgnore(key) +{ delete g_blockedCQ[key]; storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function clearAllCallsignIgnores() { +function clearAllCallsignIgnores() +{ g_blockedCalls = Object(); storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function clearAllDxccIgnores() { +function clearAllDxccIgnores() +{ g_blockedDxcc = Object(); storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function clearAllCQIgnores() { +function clearAllCQIgnores() +{ g_blockedCQ = Object(); storeBlocks(); openIgnoreEdit(); window.opener.goProcessRoster(); } -function closeEditIgnores() { +function closeEditIgnores() +{ mainCallRoster.style.display = "block"; editView.style.display = "none"; } -function openIgnoreEdit() { +function openIgnoreEdit() +{ mainCallRoster.style.display = "none"; editView.style.display = "inline-block"; var worker = ""; var clearString = "noneClear AllnoneClear AllnoneClear All