`npm run lint-fix`

merge-requests/43/head
Sebastian Delmont 2020-12-13 21:10:27 -05:00
rodzic 4c8db9fa50
commit 813ed47a70
14 zmienionych plików z 8387 dodań i 4357 usunięć

Plik diff jest za duży Load Diff

Plik diff jest za duży Load Diff

Wyświetl plik

@ -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;

Wyświetl plik

@ -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 = "<b><i>Downloading...</i></b>";
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 = "<b><i>Downloading...</i></b>";
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 = "<b><i>Downloading...</i></b>";
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 = "<b><i>Downloading...</i></b>";
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 = "<b><i>Processing...</i></b>";
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);
};

Wyświetl plik

@ -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<startDay; i++) { squares.push("B"); }
if (parent.dataset.startmon == "1" && startDay != 1)
{
for (var i = 1; i < startDay; i++) { squares.push("B"); }
}
if (parent.dataset.startmon=="0" && startDay!=7) {
for (var i=0; i<startDay; i++) { squares.push("B"); }
if (parent.dataset.startmon == "0" && startDay != 7)
{
for (var i = 0; i < startDay; i++) { squares.push("B"); }
}
// (C2) Days of month
// All days enabled, just add
if (disableday==null) {
for (var i=1; i<=daysInMonth; i++) { squares.push([i, false]); }
if (disableday == null)
{
for (var i = 1; i <= daysInMonth; i++) { squares.push([i, false]); }
}
// Some days disabled
else {
else
{
var thisday = startDay;
for (var i=1; i<=daysInMonth; i++) {
for (var i = 1; i <= daysInMonth; i++)
{
// Check if day is disabled
var disabled = disableday.includes(thisday);
// Day of month, disabled
squares.push([i, disabled]);
// Next day
thisday++;
if (thisday==8) { thisday = 1; }
if (thisday == 8) { thisday = 1; }
}
}
// (C2) Empty squares after last day of month
if (parent.dataset.startmon=="1" && endDay!=7) {
for (var i=endDay; i<7; i++) { squares.push("B"); }
if (parent.dataset.startmon == "1" && endDay != 7)
{
for (var i = endDay; i < 7; i++) { squares.push("B"); }
}
if (parent.dataset.startmon=="0" && endDay!=6) {
for (var i=endDay; i<(endDay==7?13:6); i++) { squares.push("B"); }
if (parent.dataset.startmon == "0" && endDay != 6)
{
for (var i = endDay; i < (endDay == 7 ? 13 : 6); i++) { squares.push("B"); }
}
// (D) Draw HTML
var daynames = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat"];
if (parent.dataset.startmon=="1") { daynames.push("Sun"); }
if (parent.dataset.startmon == "1") { daynames.push("Sun"); }
else { daynames.unshift("Sun"); }
// (D1) Header
var table = document.createElement("table"),
row = table.insertRow()
cell = null;
row = table.insertRow()
cell = null;
row.classList.add("picker-d-h");
for (let d of daynames) {
for (let d of daynames)
{
cell = row.insertCell();
cell.innerHTML = d;
}
@ -177,21 +197,27 @@ var picker = {
// (D2) Date cells
var total = squares.length;
row = table.insertRow();
for (var i=0; i<total; i++) {
if (i!=total && i%7==0) { row = table.insertRow(); }
for (var i = 0; i < total; i++)
{
if (i != total && i % 7 == 0) { row = table.insertRow(); }
cell = row.insertCell();
if (squares[i] == "B") {
if (squares[i] == "B")
{
cell.classList.add("picker-d-b");
} else {
}
else
{
cell.innerHTML = squares[i][0];
// Not allowed to choose this day
if (squares[i][1]) {
if (squares[i][1])
{
cell.classList.add("picker-d-dd");
}
// Allowed to choose this day
else {
else
{
cell.classList.add("picker-d-d");
cell.addEventListener("click", function(){ picker.pick(this); });
cell.addEventListener("click", function() { picker.pick(this); });
}
}
}
@ -201,38 +227,41 @@ var picker = {
days.appendChild(table);
},
pick : function (el) {
pick: function (el)
{
// pick() : choose a date
// el : HTML reference to selected date cell
// (A) Get all components
var parent = el.parentElement;
while (!parent.classList.contains("picker")) {
while (!parent.classList.contains("picker"))
{
parent = parent.parentElement;
}
// (B) Get full selected year month day
var year = parent.getElementsByClassName("picker-y")[0].value,
month = parent.getElementsByClassName("picker-m")[0].value,
day = el.innerHTML;
month = parent.getElementsByClassName("picker-m")[0].value,
day = el.innerHTML;
// YYYY-MM-DD Format
// ! CHANGE FORMAT HERE IF YOU WANT !
if (parseInt(month)<10) { month = "0" + month; }
if (parseInt(day)<10) { day = "0" + day; }
if (parseInt(month) < 10) { month = "0" + month; }
if (parseInt(day) < 10) { day = "0" + day; }
var fullDate = year + "-" + month + "-" + day;
// (C) Update selected date
document.getElementById(parent.dataset.target).value = fullDate;
if ( parent.dataset.fire.length > 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");
}
}
};
};

Wyświetl plik

@ -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: {}
};

Wyświetl plik

@ -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;
}

Plik diff jest za duży Load Diff

Wyświetl plik

@ -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, "&amp;")
.replace(/</g, "&lt;")
@ -407,25 +481,32 @@ function htmlEntities(str) {
.replace(/"/g, "&quot;");
}
function gtChatMessage(jsmesg) {
if (g_appSettings.gtMsgEnable == true) {
function gtChatMessage(jsmesg)
{
if (g_appSettings.gtMsgEnable == true)
{
var cid = jsmesg.cid;
jsmesg.when = Date.now();
try {
try
{
jsmesg.msg = new Buffer.from(jsmesg.msg, "base64").toString("utf8"); // eslint-disable-line new-cap
jsmesg.msg = htmlEntities(jsmesg.msg);
} catch (e) {
}
catch (e)
{
jsmesg.msg = "Corrupt message recieved";
}
if (jsmesg.call != null && jsmesg.call != "" && jsmesg.call != "NOCALL") {
if (jsmesg.call != null && jsmesg.call != "" && jsmesg.call != "NOCALL")
{
appendToHistory(cid, jsmesg);
g_gtUnread[cid] = true;
g_gtCurrentMessageCount++;
if (newChatMessage(cid, jsmesg) == false) alertChatMessage();
if (g_msgSettings.msgAwaySelect == 1 && !(cid in g_gtSentAwayToCid)) {
if (g_msgSettings.msgAwaySelect == 1 && !(cid in g_gtSentAwayToCid))
{
g_gtSentAwayToCid[cid] = true;
gtSendMessage(
"Away message [ " + g_msgSettings.msgAwayText + " ]",
@ -436,7 +517,8 @@ function gtChatMessage(jsmesg) {
}
}
function gtSendMessage(message, who) {
function gtSendMessage(message, who)
{
msg = Object();
msg.type = "mesg";
msg.uuid = g_appSettings.chatUUID;
@ -449,7 +531,8 @@ function gtSendMessage(message, who) {
appendToHistory(who, msg);
}
function gtChatSendUUID() {
function gtChatSendUUID()
{
var msg = Object();
msg.type = "uuid";
if (g_appSettings.chatUUID != "") msg.uuid = g_appSettings.chatUUID;
@ -458,7 +541,8 @@ function gtChatSendUUID() {
sendGtJson(JSON.stringify(msg));
}
function gtChatSetUUID(jsmesg) {
function gtChatSetUUID(jsmesg)
{
g_appSettings.chatUUID = jsmesg.uuid;
myChatId = jsmesg.id;
@ -467,93 +551,126 @@ function gtChatSetUUID(jsmesg) {
g_gtState = ChatState.status;
}
function gtChatStateMachine() {
function gtChatStateMachine()
{
if (
g_appSettings.gtShareEnable == true &&
g_mapSettings.offlineMode == false
) {
)
{
var now = timeNowSec();
g_gtStateToFunction[g_gtState]();
if (Object.keys(g_gtUnread).length > 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);
}

Wyświetl plik

@ -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);
};

Plik diff jest za duży Load Diff

Wyświetl plik

@ -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();

Wyświetl plik

@ -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();
},
}
};

Wyświetl plik

@ -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();
}
}