Speed improvement

Removed unnessecary type comparisons
merge-requests/237/merge
Tag 2023-02-25 13:41:32 -08:00
rodzic 5b2cd39c4e
commit 0a717a664b
14 zmienionych plików z 77 dodań i 54 usunięć

Wyświetl plik

@ -2559,7 +2559,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntCallsignNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value); }"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value); }"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntCallsignNotifyMedia" onchange="wantedChanged(this);"></select>
</td>
@ -2583,7 +2583,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntGridNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntGridNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2607,7 +2607,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntDXCCNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntDXCCNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2631,7 +2631,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntCQzNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntCQzNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2655,7 +2655,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntITUzNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntITUzNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2679,7 +2679,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntStatesNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntStatesNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2704,7 +2704,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</td>
<td>
<input id="huntRosterNotifyWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) { speakAlertString(this.value);}"
onkeyup="if (event.keyCode == 13) { speakAlertString(this.value);}"
oninput="ValidateText(this);wantedChanged(this);" />
<select id="huntRosterNotifyMedia" style="display: block" onchange="wantedChanged(this);"></select>
</td>
@ -2970,7 +2970,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<tr>
<td>
<input id="msgAlertWord" type="text" class="inputTextValue" size="14"
onkeyup="if (event.keyCode === 13) {newMessageSetting(this); alertChatMessage(); }"
onkeyup="if (event.keyCode == 13) {newMessageSetting(this); alertChatMessage(); }"
oninput="ValidateText(this);newMessageSetting(this);" />
<select id="msgAlertMedia" onchange="newMessageSetting(this); alertChatMessage();"></select>
</td>

Wyświetl plik

@ -80,7 +80,7 @@
function handleKey(event)
{
if (event.key === "Enter")
if (event.key == "Enter")
{
// Do work
var msg = messageInput.value.replace(/[\n\r]/g, '');

Wyświetl plik

@ -120,7 +120,7 @@
<div>
<label data-i18n="lookup.callsign.label" for="lookupCallsignInput">Callsign</label>
<input
id="lookupCallsignInput" type="text" class="inputTextValue" size="12" onkeyup="if (event.keyCode === 13) lookupButtonID.click();" oninput="ValidateCallsign(this,null);"/>
id="lookupCallsignInput" type="text" class="inputTextValue" size="12" onkeyup="if (event.keyCode == 13) lookupButtonID.click();" oninput="ValidateCallsign(this,null);"/>
<div
data-i18n="lookup.callsign.button"
id="lookupButtonID"

Wyświetl plik

@ -21,7 +21,7 @@ function dropHandler(ev)
{
// If dropped items aren't files, reject them
Entry = ev.dataTransfer.items[i].webkitGetAsEntry();
if (Entry && "isFile" in Entry && Entry.isFile === true)
if (Entry && "isFile" in Entry && Entry.isFile == true)
{
var filename = ev.dataTransfer.items[i].getAsFile().path;
var test = filename.toLowerCase();
@ -1524,7 +1524,7 @@ function getABuffer(
imgToGray.parentNode.style.background = "";
imgToGray.style.webkitFilter = "";
}
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cookies, file_url);
@ -1634,7 +1634,7 @@ function getAPostBuffer(
})
.on("end", function ()
{
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cookies);
@ -2941,7 +2941,7 @@ function getPostJSONBuffer(
})
.on("end", function ()
{
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cookies);
@ -2961,7 +2961,7 @@ function getPostJSONBuffer(
});
req.on("error", function (err) // eslint-disable-line node/handle-callback-err
{
if (typeof timeoutCallback === "function")
if (typeof timeoutCallback == "function")
{
timeoutCallback(
file_url,

Wyświetl plik

@ -85,7 +85,7 @@ Arc.prototype.wkt = function ()
};
for (var i = 0; i < this.geometries.length; i++)
{
if (this.geometries[i].coords.length === 0)
if (this.geometries[i].coords.length == 0)
{
return "LINESTRING(empty)";
}
@ -105,13 +105,13 @@ Arc.prototype.wkt = function ()
*/
var GreatCircle = function (start, end, properties)
{
if (!start || start.x === undefined || start.y === undefined)
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"

Wyświetl plik

@ -1927,7 +1927,7 @@ function splitNoParen(s)
switch (s[i])
{
case ",":
if (left === right)
if (left == right)
{
keepResult();
left = right = 0;
@ -6374,7 +6374,7 @@ function handleWsjtxStatus(newMessage)
setStatsDiv("decodeLastListDiv", worker);
setStatsDivHeight("decodeLastListDiv", getStatsWindowHeight() + 26 + "px");
if (GT.appSettings.gtShareEnable === true && Object.keys(GT.spotCollector).length > 0)
if (GT.appSettings.gtShareEnable == true && Object.keys(GT.spotCollector).length > 0)
{
gtChatSendSpots(GT.spotCollector, GT.spotDetailsCollector);
GT.spotCollector = {};
@ -6572,6 +6572,29 @@ GT.spotDetailsCollector = {};
GT.decodeCollector = {};
function handleWsjtxDecode(newMessage)
{
// eg: "YK7DAQ RR73; 3O5GAS <JI1BXD> +14"
if (newMessage.Msg.indexOf(" RR73; ") > -1)
{
let parts = newMessage.Msg.split("RR73; ");
// parts[0] is "YK7DAQ " includes space
// parts[1] is "3O5GAS <JI1BXD> +14" no leading space, a useable message
let caller = parts[1].split(" ")[1];
// caller is "<JI1BXD>"
let first = parts[0] + caller + " RR73";
// first is "YK7DAQ <JI1BXD> RR73"
finalWsjtxDecode(newMessage, true, parts[1]);
// Send the RR73 last as it's more important to us
finalWsjtxDecode(newMessage, true, first);
}
else
{
// A classic mode 0 decoded messages
finalWsjtxDecode(newMessage);
}
}
function finalWsjtxDecode(newMessage, isFox = false, foxMessage)
{
var didAlert = false;
var didCustomAlert = false;
@ -6593,7 +6616,7 @@ function handleWsjtxDecode(newMessage)
}
var theTimeStamp = timeNowSec() - (timeNowSec() % 86400) + parseInt(newMessage.TM / 1000);
var theMessage = newMessage.Msg;
var theMessage = (isFox == true ? foxMessage : newMessage.Msg);
// Break up the decoded message
var decodeWords = theMessage.split(" ").slice(0, 5);
@ -8430,7 +8453,7 @@ function showDXCCsBox()
{
var onMousedown = function (e)
{
if (e.which === 1)
if (e.which == 1)
{
if (GT.popupWindowHandle == null)
{
@ -12261,7 +12284,7 @@ function getBuffer(file_url, callback, flag, mode, port, cache = null)
})
.on("end", function ()
{
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cache);
@ -12316,7 +12339,7 @@ function getPostBuffer(
})
.on("end", function ()
{
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cookies);
@ -12324,7 +12347,7 @@ function getPostBuffer(
})
.on("error", function ()
{
if (typeof errorCallback === "function")
if (typeof errorCallback == "function")
{
errorCallback();
}
@ -12364,7 +12387,7 @@ function getPostBuffer(
function colorToHex(color)
{
if (color.substr(0, 1) === "#")
if (color.substr(0, 1) == "#")
{
return color;
}
@ -12797,7 +12820,7 @@ function gotAudioDevices(deviceInfos)
for (var i = 0; i !== deviceInfos.length; ++i)
{
var deviceInfo = deviceInfos[i];
if (deviceInfo.kind === "audiooutput")
if (deviceInfo.kind == "audiooutput")
{
var option = document.createElement("option");
option.value = deviceInfo.deviceId;

Wyświetl plik

@ -222,13 +222,13 @@ function sendGtJson(json, isUUIDrequest = false)
{
if (GT.appSettings.gtShareEnable == true && GT.gtChatSocket != null)
{
if (GT.gtChatSocket.readyState === WebSocket.OPEN && (isUUIDrequest || GT.gtUuidValid))
if (GT.gtChatSocket.readyState == WebSocket.OPEN && (isUUIDrequest || GT.gtUuidValid))
{
GT.gtChatSocket.send(json);
}
else
{
if (GT.gtChatSocket.readyState === WebSocket.CLOSED)
if (GT.gtChatSocket.readyState == WebSocket.CLOSED)
{
GT.gtState = ChatState.closed;
}

Wyświetl plik

@ -1244,7 +1244,7 @@ function getBuffer(file_url, callback, flag, mode, port, cookie)
})
.on("end", function ()
{
if (typeof callback === "function")
if (typeof callback == "function")
{
// Call it, since we have confirmed it is callable
callback(fileBuffer, flag, cookies);
@ -1635,7 +1635,7 @@ function onMyKeyDown(event)
function blurOnEnter(ele)
{
if (event.key === "Enter")
if (event.key == "Enter")
{
ele.blur();
}
@ -2471,9 +2471,9 @@ function handleContextMenu(ev)
{
if (CR.developerMode)
{
if ((ev.target.id === "ShowMoreControlsLink") ||
(ev.target.id === "ShowFewerControlsLink") ||
(ev.target.id === "txrxdec"))
if ((ev.target.id == "ShowMoreControlsLink") ||
(ev.target.id == "ShowFewerControlsLink") ||
(ev.target.id == "txrxdec"))
{
// Allow event to bubble up so that NWJS will show the developer menu
return true;

Wyświetl plik

@ -53,7 +53,7 @@ function processRosterFiltering(callRoster, rosterSettings)
entry.tx = false;
continue;
}
if (CR.rosterSettings.noUnknownDXCC && callObj.dxcc === -1)
if (CR.rosterSettings.noUnknownDXCC && callObj.dxcc == -1)
{
entry.tx = false;
continue;

Wyświetl plik

@ -15,7 +15,7 @@ function processRosterHunting(callRoster, rosterSettings, awardTracker)
const currentYear = new Date().getFullYear();
const currentYearSuffix = `&rsquo;${currentYear - 2000}`;
const potaEnabled = (window.opener.GT.appSettings.potaEnabled === 1);
const potaEnabled = (window.opener.GT.appSettings.potaEnabled == 1);
// TODO: Hunting results might be used to filter, based on the "Callsigns: Only Wanted" option,
// so maybe we can move this loop first, and add a check to the filtering loop?

Wyświetl plik

@ -43,7 +43,7 @@ function renderRoster(callRoster, rosterSettings)
columnOverrides.OAMS = false;
}
if (window.opener.GT.appSettings.potaEnabled === 1)
if (window.opener.GT.appSettings.potaEnabled == 1)
{
huntingMatrixPotaDiv.style.display = "";
}

Wyświetl plik

@ -2,7 +2,7 @@ function rosterColumnList(settings = {}, overrides = {})
{
return CR.rosterSettings.columnOrder.filter(column =>
{
return column && (settings[column] || overrides[column]) && !(overrides[column] === false)
return column && (settings[column] || overrides[column]) && !(overrides[column] == false)
})
}
@ -53,7 +53,7 @@ function renderRosterTableHTML(tag, attrs)
function setRosterSorting(column)
{
if (CR.rosterSettings.sortColumn === column)
if (CR.rosterSettings.sortColumn == column)
{
CR.rosterSettings.sortReverse = !CR.rosterSettings.sortReverse
}

Wyświetl plik

@ -3,9 +3,9 @@
**/
(function (global, factory)
{
typeof exports === "object" && typeof module !== "undefined"
typeof exports == "object" && typeof module !== "undefined"
? (module.exports = factory())
: typeof define === "function" && define.amd
: typeof define == "function" && define.amd
? define(factory)
: (global.GeoJSONTerminator = factory());
})(this, function ()

Wyświetl plik

@ -23,13 +23,13 @@ function latLonToGridSquare(param1,param2, width = 4){
// other objects with lat/lon properties
// properties could be getter functions, numbers, or strings
function toNum(x){
if (typeof(x) === 'number') return x;
if (typeof(x) === 'string') return parseFloat(x);
if (typeof(x) === 'function') return parseFloat(x());
if (typeof(x) == 'number') return x;
if (typeof(x) == 'string') return parseFloat(x);
if (typeof(x) == 'function') return parseFloat(x());
throw "HamGridSquare -- toNum -- can not convert input: "+x;
}
if (typeof(param1)==='object'){
if (param1.length === 2){
if (typeof(param1)=='object'){
if (param1.length == 2){
lat = toNum(param1[0]);
lon = toNum(param1[1]);
} else if (('lat' in param1) && ('lon' in param1)){
@ -47,7 +47,7 @@ function latLonToGridSquare(param1,param2, width = 4){
}
if (isNaN(lat)) throw "lat is NaN";
if (isNaN(lon)) throw "lon is NaN";
if (Math.abs(lat) === 90.0) throw "grid g_grids invalid at N/S poles";
if (Math.abs(lat) == 90.0) throw "grid g_grids invalid at N/S poles";
if (Math.abs(lat) > 90) throw "invalid latitude: "+lat;
if (Math.abs(lon) > 180)
{
@ -147,7 +147,7 @@ var MyCircle = {
},
distance: function(lat1, lon1, lat2, lon2, unit) {
if ( unit === undefined ) unit = 'KM';
if ( unit == undefined ) unit = 'KM';
var r = this.validateRadius(unit);
lat1 *= Math.PI / 180;
lon1 *= Math.PI / 180;
@ -178,7 +178,7 @@ var MyCircle = {
},
destination: function(lat1, lon1, brng, dt, unit) {
if ( unit === undefined ) unit = 'KM';
if ( unit == undefined ) unit = 'KM';
var r = this.validateRadius(unit);
lat1 *= Math.PI / 180;
lon1 *= Math.PI / 180;
@ -527,7 +527,7 @@ function convert(ra, dec, lmst,lat) {
}
function isMergeableObject(val) {
var nonNullObject = val && typeof val === 'object'
var nonNullObject = val && typeof val == 'object'
return nonNullObject
&& Object.prototype.toString.call(val) !== '[object RegExp]'
@ -539,18 +539,18 @@ function emptyTarget(val) {
}
function cloneIfNecessary(value, optionsArgument) {
var clone = optionsArgument && optionsArgument.clone === true
var clone = optionsArgument && optionsArgument.clone == true
return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
}
function defaultArrayMerge(target, source, optionsArgument) {
var destination = target.slice()
source.forEach(function(e, i) {
if (typeof destination[i] === 'undefined') {
if (typeof destination[i] == 'undefined') {
destination[i] = cloneIfNecessary(e, optionsArgument)
} else if (isMergeableObject(e)) {
destination[i] = deepmerge(target[i], e, optionsArgument)
} else if (target.indexOf(e) === -1) {
} else if (target.indexOf(e) == -1) {
destination.push(cloneIfNecessary(e, optionsArgument))
}
})
@ -600,7 +600,7 @@ deepmerge.all = function deepmergeAll(array, optionsArgument) {
// https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
function pickTextColorBasedOnBgColorAdvanced(bgColor, lightColor, darkColor) {
var color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
var color = (bgColor.charAt(0) == '#') ? bgColor.substring(1, 7) : bgColor;
var r = parseInt(color.substring(0, 2), 16); // hexToR
var g = parseInt(color.substring(2, 4), 16); // hexToG
var b = parseInt(color.substring(4, 6), 16); // hexToB