From c4ffe9801c695ce222cba47c8154aa0f275736ae Mon Sep 17 00:00:00 2001 From: Matthew Chambers Date: Mon, 13 Dec 2021 19:03:46 -0600 Subject: [PATCH] Fix #76 --- package.nw/lib/roster.js | 253 ++++++++++++++++++ .../lib/roster/processRosterFiltering.js | 10 + package.nw/lib/roster/renderNormalRoster.js | 4 +- 3 files changed, 265 insertions(+), 2 deletions(-) diff --git a/package.nw/lib/roster.js b/package.nw/lib/roster.js index d6655605..4a9298b1 100644 --- a/package.nw/lib/roster.js +++ b/package.nw/lib/roster.js @@ -8,6 +8,8 @@ var callRoster = {}; var g_blockedCalls = {}; var g_blockedCQ = {}; var g_blockedDxcc = {}; +var g_blockedCQz = {}; +var g_blockedITUz = {}; var g_scriptReport = {}; var g_worked = {}; var g_confirmed = {}; @@ -35,6 +37,10 @@ var g_CQMenu = null; var g_targetCQ = ""; var g_clearCQIgnore = null; var g_clearCQIgnoreMainMenu = null; +var g_clearCQzIgnore = null; +var g_clearCQzIgnoreMainMenu = null; +var g_clearITUzIgnore = null; +var g_clearITUzIgnoreMainMenu = null; var g_timerInterval = null; var g_regFocus = false; var g_awards = {}; @@ -162,6 +168,16 @@ if (typeof localStorage.blockedCQ == "undefined") localStorage.blockedCQ = "{}"; } +if (typeof localStorage.blockedCQz == "undefined") +{ + localStorage.blockedCQz = "{}"; +} + +if (typeof localStorage.blockedITUz == "undefined") +{ + localStorage.blockedITUz = "{}"; +} + if (typeof localStorage.awardTracker == "undefined") { localStorage.awardTracker = "{}"; @@ -176,6 +192,8 @@ if (typeof localStorage.blockedCalls != "undefined") g_blockedCalls = JSON.parse(localStorage.blockedCalls); g_blockedCQ = JSON.parse(localStorage.blockedCQ); g_blockedDxcc = JSON.parse(localStorage.blockedDxcc); + g_blockedCQz = JSON.parse(localStorage.blockedCQz); + g_blockedITUz = JSON.parse(localStorage.blockedITUz); } function storeBlocks() @@ -183,6 +201,8 @@ function storeBlocks() localStorage.blockedCalls = JSON.stringify(g_blockedCalls); localStorage.blockedCQ = JSON.stringify(g_blockedCQ); localStorage.blockedDxcc = JSON.stringify(g_blockedDxcc); + localStorage.blockedCQz = JSON.stringify(g_blockedCQz); + localStorage.blockedITUz = JSON.stringify(g_blockedITUz); } function storeAwardTracker() @@ -1416,6 +1436,22 @@ function deleteCQIgnore(key) window.opener.goProcessRoster(); } +function deleteCQzIgnore(key) +{ + delete g_blockedCQz[key]; + storeBlocks(); + openIgnoreEdit(); + window.opener.goProcessRoster(); +} + +function deleteITUzIgnore(key) +{ + delete g_blockedITUz[key]; + storeBlocks(); + openIgnoreEdit(); + window.opener.goProcessRoster(); +} + function clearAllCallsignIgnores() { g_blockedCalls = Object(); @@ -1440,6 +1476,22 @@ function clearAllCQIgnores() window.opener.goProcessRoster(); } +function clearAllCQzIgnores() +{ + g_blockedCQz = Object(); + storeBlocks(); + openIgnoreEdit(); + window.opener.goProcessRoster(); +} + +function clearAllITUzIgnores() +{ + g_blockedITUz = Object(); + storeBlocks(); + openIgnoreEdit(); + window.opener.goProcessRoster(); +} + function closeEditIgnores() { MainCallRoster.style.display = "block"; @@ -1529,6 +1581,54 @@ function openIgnoreEdit() }); worker += ""; + if (Object.keys(g_blockedCQz).length > 0) + { + clearString = + "Clear All"; + } + worker += + "
" + + clearString + + ""; + Object.keys(g_blockedCQz) + .sort() + .forEach(function (key, i) + { + worker += + ""; + }); + worker += "
CQ Zones
" + + key + + "
"; + + if (Object.keys(g_blockedITUz).length > 0) + { + clearString = + "Clear All"; + } + worker += + "
" + + clearString + + ""; + Object.keys(g_blockedITUz) + .sort() + .forEach(function (key, i) + { + worker += + ""; + }); + worker += "
ITU Zones
" + + key + + "
"; + editTables.innerHTML = worker; } @@ -1870,6 +1970,115 @@ function init() }); g_CQMenu.append(item); + g_CQzMenu = new nw.Menu(); + + item = new nw.MenuItem({ + type: "normal", + label: "Ignore CQ Zone", + click: function () + { + g_blockedCQz[callRoster[g_targetCQz].callObj.cqza] = true; + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + + g_CQzMenu.append(item); + + g_clearCQzIgnoreMainMenu = new nw.MenuItem({ + type: "normal", + label: "Clear CQ Zone Ignore", + enabled: false, + click: function () + { + g_blockedCQz = Object(); + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + + g_clearCQzIgnore = new nw.MenuItem({ + type: "normal", + label: "Clear Ignore", + enabled: false, + click: function () + { + g_blockedCQz = Object(); + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + g_CQzMenu.append(g_clearCQzIgnore); + + g_CQzMenu.append(g_clearCQzIgnoreMainMenu); + + item = new nw.MenuItem({ + type: "normal", + label: "Edit Ignores", + enabled: true, + click: function () + { + openIgnoreEdit(); + } + }); + + g_CQzMenu.append(item); + + g_ITUzMenu = new nw.Menu(); + + item = new nw.MenuItem({ + type: "normal", + label: "Ignore ITU Zone", + click: function () + { + g_blockedITUz[callRoster[g_targetITUz].callObj.ituza] = true; + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + + g_ITUzMenu.append(item); + + g_clearITUzIgnoreMainMenu = new nw.MenuItem({ + type: "normal", + label: "Clear ITU Zone Ignore", + enabled: false, + click: function () + { + g_blockedITUz = Object(); + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + + g_ITUzMenu.append(g_clearITUzIgnoreMainMenu); + + g_clearITUzIgnore = new nw.MenuItem({ + type: "normal", + label: "Clear Ignore", + enabled: false, + click: function () + { + g_blockedITUz = Object(); + storeBlocks(); + window.opener.goProcessRoster(); + } + }); + + g_ITUzMenu.append(g_clearITUzIgnore); + + item = new nw.MenuItem({ + type: "normal", + label: "Edit Ignores", + enabled: true, + click: function () + { + openIgnoreEdit(); + } + }); + + g_ITUzMenu.append(item); + g_dxccMenu = new nw.Menu(); item = new nw.MenuItem({ @@ -2052,6 +2261,40 @@ function handleContextMenu(ev) g_clearCQIgnore.enabled = false; } + len = Object.keys(g_blockedCQz).length; + if (len > 0) + { + g_clearCQzIgnoreMainMenu.enabled = true; + g_clearCQzIgnoreMainMenu.label = + "Clear CQ Zone Ignore" + (len > 1 ? "s (" + len + ")" : ""); + g_clearCQzIgnore.enabled = true; + g_clearCQzIgnore.label = "Clear Ignore" + (len > 1 ? "s (" + len + ")" : ""); + } + else + { + g_clearCQzIgnoreMainMenu.label = "Clear CQ Zone Ignore"; + g_clearCQzIgnoreMainMenu.enabled = false; + g_clearCQzIgnore.label = "Clear Ignore"; + g_clearCQzIgnore.enabled = false; + } + + len = Object.keys(g_blockedITUz).length; + if (len > 0) + { + g_clearITUzIgnoreMainMenu.enabled = true; + g_clearITUzIgnoreMainMenu.label = + "Clear ITU Zone Ignore" + (len > 1 ? "s (" + len + ")" : ""); + g_clearITUzIgnore.enabled = true; + g_clearITUzIgnore.label = "Clear Ignore" + (len > 1 ? "s (" + len + ")" : ""); + } + else + { + g_clearITUzIgnoreMainMenu.label = "Clear ITU Zone Ignore"; + g_clearITUzIgnoreMainMenu.enabled = false; + g_clearITUzIgnore.label = "Clear Ignore"; + g_clearITUzIgnore.enabled = false; + } + if (typeof ev.target != "undefined") { if (g_developerMode) @@ -2084,6 +2327,16 @@ function handleContextMenu(ev) g_CQMenu.popup(mouseX, mouseY); } } + else if (name == "CQz") + { + g_targetCQz = ev.target.parentNode.id; + g_CQzMenu.popup(mouseX, mouseY); + } + else if (name == "ITUz") + { + g_targetITUz = ev.target.parentNode.id; + g_ITUzMenu.popup(mouseX, mouseY); + } else if (name && name.startsWith("DXCC")) { let dxcca = name.split("("); diff --git a/package.nw/lib/roster/processRosterFiltering.js b/package.nw/lib/roster/processRosterFiltering.js index 05363c04..3595946c 100644 --- a/package.nw/lib/roster/processRosterFiltering.js +++ b/package.nw/lib/roster/processRosterFiltering.js @@ -45,6 +45,16 @@ function processRosterFiltering(callRoster, rosterSettings) entry.tx = false; continue; } + if (callObj.ituza in g_blockedITUz) + { + entry.tx = false; + continue; + } + if (callObj.cqza in g_blockedCQz) + { + entry.tx = false; + continue; + } if (callObj.dxcc in g_blockedDxcc) { entry.tx = false; diff --git a/package.nw/lib/roster/renderNormalRoster.js b/package.nw/lib/roster/renderNormalRoster.js index 55ad3f0d..f71f8b96 100644 --- a/package.nw/lib/roster/renderNormalRoster.js +++ b/package.nw/lib/roster/renderNormalRoster.js @@ -259,7 +259,7 @@ function renderNormalRosterRow(callObj, showBands, showModes) if (g_rosterSettings.columns.CQz) { worker += - "" + callObj.cqza.join(",") + @@ -268,7 +268,7 @@ function renderNormalRosterRow(callObj, showBands, showModes) if (g_rosterSettings.columns.ITUz) { worker += - "" + callObj.ituza.join(",") +