2021-06-28 22:26:44 +00:00
|
|
|
function sendAlerts(callRoster, rosterSettings)
|
|
|
|
{
|
|
|
|
var dirPath = window.opener.g_scriptDir;
|
|
|
|
var scriptExists = false;
|
|
|
|
var script = "cr-alert.sh";
|
|
|
|
|
|
|
|
var shouldAlert = 0;
|
|
|
|
|
2021-07-01 00:37:27 +00:00
|
|
|
for (entry in callRoster)
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-07-01 00:37:27 +00:00
|
|
|
var callObj = callRoster[entry].callObj;
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-07-01 00:37:27 +00:00
|
|
|
// chrbayer: what does the tx field mean? no alerts are generated (at all) if this is in place...
|
|
|
|
// if (!callObj.tx) continue;
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-07-01 00:37:27 +00:00
|
|
|
// TODO: Get rid of realtime
|
|
|
|
if (g_rosterSettings.realtime == false)
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-07-01 00:37:27 +00:00
|
|
|
var call = callObj.DEcall;
|
|
|
|
g_scriptReport[call] = Object.assign({}, callObj);
|
|
|
|
g_scriptReport[call].dxccName =
|
|
|
|
window.opener.g_dxccToAltName[callObj.dxcc];
|
|
|
|
g_scriptReport[call].distance = parseInt(
|
|
|
|
callObj.distance *
|
|
|
|
MyCircle.validateRadius(window.opener.distanceUnit.value)
|
|
|
|
);
|
|
|
|
|
|
|
|
delete g_scriptReport[call].DEcall;
|
|
|
|
g_scriptReport[call].rect = null;
|
|
|
|
delete g_scriptReport[call].rect;
|
|
|
|
delete g_scriptReport[call].style;
|
|
|
|
delete g_scriptReport[call].wspr;
|
|
|
|
delete g_scriptReport[call].qso;
|
|
|
|
delete g_scriptReport[call].instance;
|
|
|
|
|
|
|
|
if (rosterSettings.callMode != "all")
|
|
|
|
{
|
|
|
|
g_scriptReport[call].shouldAlert = true;
|
|
|
|
g_scriptReport[call].reason.push(g_rosterSettings.hunting);
|
|
|
|
}
|
2021-06-28 22:26:44 +00:00
|
|
|
}
|
|
|
|
|
2021-07-01 00:37:27 +00:00
|
|
|
if (
|
|
|
|
callObj.alerted == false &&
|
|
|
|
rosterSettings.callMode == "all" &&
|
|
|
|
callObj.shouldAlert == true
|
|
|
|
)
|
|
|
|
{
|
|
|
|
callObj.alerted = true;
|
|
|
|
shouldAlert++;
|
|
|
|
}
|
|
|
|
else if (callObj.alerted == false && rosterSettings.callMode != "all")
|
|
|
|
{
|
|
|
|
callObj.alerted = true;
|
|
|
|
shouldAlert++;
|
|
|
|
}
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-07-01 00:37:27 +00:00
|
|
|
callObj.shouldAlert = false;
|
|
|
|
}
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-06-29 00:19:26 +00:00
|
|
|
// NOTE: Ring alerts if needed
|
|
|
|
try
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-06-29 00:19:26 +00:00
|
|
|
if (fs.existsSync(dirPath))
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-06-29 00:19:26 +00:00
|
|
|
if (window.opener.g_platform == "windows")
|
|
|
|
{
|
|
|
|
script = "cr-alert.bat";
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
fs.existsSync(dirPath + script) &&
|
2021-06-28 22:26:44 +00:00
|
|
|
g_rosterSettings.realtime == false
|
2021-06-29 00:19:26 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
scriptExists = true;
|
|
|
|
scriptIcon.innerHTML =
|
2021-06-28 22:26:44 +00:00
|
|
|
"<div class='buttonScript' onclick='window.opener.toggleCRScript();'>" +
|
|
|
|
(window.opener.g_crScript == 1
|
2022-09-22 02:30:52 +00:00
|
|
|
? `<font color='lightgreen'>${$.i18n("sendAlerts.scriptEnabled")}</font>`
|
|
|
|
: `<font color='yellow'>${$.i18n("sendAlerts.scriptDisabled")}</font>`) +
|
2021-06-28 22:26:44 +00:00
|
|
|
"</div>";
|
2021-06-29 00:19:26 +00:00
|
|
|
scriptIcon.style.display = "block";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scriptIcon.style.display = "none";
|
|
|
|
}
|
2021-06-28 22:26:44 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-29 00:19:26 +00:00
|
|
|
catch (e) {}
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-06-29 00:19:26 +00:00
|
|
|
if (shouldAlert > 0)
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-06-29 00:19:26 +00:00
|
|
|
if (window.opener.g_classicAlerts.huntRoster == true)
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-06-29 00:19:26 +00:00
|
|
|
var notify = window.opener.huntRosterNotify.value;
|
|
|
|
if (notify == "0")
|
|
|
|
{
|
|
|
|
var media = window.opener.huntRosterNotifyMedia.value;
|
|
|
|
if (media != "none") window.opener.playAlertMediaFile(media);
|
|
|
|
}
|
|
|
|
else if (notify == "1")
|
|
|
|
{
|
|
|
|
window.opener.speakAlertString(
|
|
|
|
window.opener.huntRosterNotifyWord.value
|
|
|
|
);
|
|
|
|
}
|
2021-06-28 22:26:44 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 00:19:26 +00:00
|
|
|
if (
|
|
|
|
g_rosterSettings.realtime == false &&
|
2021-06-28 22:26:44 +00:00
|
|
|
scriptExists &&
|
|
|
|
window.opener.g_crScript == 1
|
2021-06-29 00:19:26 +00:00
|
|
|
)
|
2021-06-28 22:26:44 +00:00
|
|
|
{
|
2021-06-29 00:19:26 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
fs.writeFileSync(
|
|
|
|
dirPath + "cr-alert.json",
|
|
|
|
JSON.stringify(g_scriptReport, null, 2)
|
|
|
|
);
|
2021-06-28 22:26:44 +00:00
|
|
|
|
2021-06-29 00:19:26 +00:00
|
|
|
var thisProc = dirPath + script;
|
|
|
|
var cp = require("child_process");
|
|
|
|
var child = cp.spawn(thisProc, [], {
|
|
|
|
detached: true,
|
|
|
|
cwd: dirPath.slice(0, -1),
|
|
|
|
stdio: ["ignore", "ignore", "ignore"]
|
|
|
|
});
|
|
|
|
child.unref();
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
conosle.log(e);
|
|
|
|
}
|
|
|
|
g_scriptReport = Object();
|
2021-06-28 22:26:44 +00:00
|
|
|
}
|
2021-06-29 00:19:26 +00:00
|
|
|
else g_scriptReport = Object();
|
2021-06-28 22:26:44 +00:00
|
|
|
}
|
2022-09-22 02:30:52 +00:00
|
|
|
}
|