Skip to content

Commit a6a78b5

Browse files
authored
Merge pull request #76 from int2001/fix/consistent-variable-declarations
Fix inconsistent declarations
2 parents 17e82aa + fac7fb7 commit a6a78b5

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

advanced.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {ipcRenderer} = require('electron');
22

3-
var cfg = {};
3+
let cfg = {};
44

55
const bt_save=document.querySelector("#save");
66

main.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const DemoAdif='<call:5>DJ7NT <gridsquare:4>JO30 <mode:3>FT8 <rst_sent:3>-15 <rs
1717

1818
if (require('electron-squirrel-startup')) app.quit();
1919

20-
var udp = require('dgram');
20+
const udp = require('dgram');
2121

22-
var q={};
23-
var defaultcfg = {
22+
let q={};
23+
let defaultcfg = {
2424
wavelog_url: "https://log.jo30.de/index.php",
2525
wavelog_key: "mykey",
2626
wavelog_id: "0",
@@ -112,8 +112,8 @@ ipcMain.on("resize", async (event,arg) => {
112112
});
113113

114114
ipcMain.on("get_config", async (event, arg) => {
115-
var storedcfg = storage.getSync('basic');
116-
var realcfg={};
115+
let storedcfg = storage.getSync('basic');
116+
let realcfg={};
117117
if (!(storedcfg.wavelog_url) && !(storedcfg.profiles)) { storedcfg=defaultcfg; } // Old config not present, add default-cfg
118118
if (!(storedcfg.profiles)) { // Old Config without array? Convert it
119119
(realcfg.profiles = realcfg.profiles || []).push(storedcfg);
@@ -295,13 +295,13 @@ function send2wavelog(o_cfg,adif, dryrun = false) {
295295
clpayload.station_profile_id=o_cfg.wavelog_id.trim();
296296
clpayload.type='adif';
297297
clpayload.string=adif;
298-
postData=JSON.stringify(clpayload);
298+
const postData=JSON.stringify(clpayload);
299299
let httpmod='http';
300300
if (o_cfg.wavelog_url.toLowerCase().startsWith('https')) {
301301
httpmod='https';
302302
}
303303
const https = require(httpmod);
304-
var options = {
304+
const options = {
305305
method: 'POST',
306306
timeout: 5000,
307307
rejectUnauthorized: false,
@@ -313,7 +313,7 @@ function send2wavelog(o_cfg,adif, dryrun = false) {
313313
};
314314

315315
return new Promise((resolve, reject) => {
316-
rej=false;
316+
let rej=false;
317317
let result={};
318318
let url=o_cfg.wavelog_url + '/api/qso';
319319
if (dryrun) { url+='/true'; }
@@ -327,7 +327,7 @@ function send2wavelog(o_cfg,adif, dryrun = false) {
327327
const body = [];
328328
res.on('data', (chunk) => body.push(chunk));
329329
res.on('end', () => {
330-
var resString = Buffer.concat(body).toString();
330+
const resString = Buffer.concat(body).toString();
331331
if (rej) {
332332
if (resString.indexOf('html>')>0) {
333333
resString='{"status":"failed","reason":"wrong URL"}';
@@ -370,15 +370,15 @@ ports.forEach(port => {
370370
});
371371

372372
WServer.on('message',async function(msg,info){
373-
parsedXML={};
374-
adobject={};
373+
let parsedXML={};
374+
let adobject={};
375375
if (msg.toString().includes("xml")) { // detect if incoming String is XML
376376
try {
377377
xml.parseString(msg.toString(), function (err,dat) {
378378
parsedXML=dat;
379379
});
380380
let qsodatum = new Date(Date.parse(parsedXML.contactinfo.timestamp[0]+"Z")); // Added Z to make it UTC
381-
qsodat=fmt(qsodatum);
381+
const qsodat=fmt(qsodatum);
382382
if (parsedXML.contactinfo.mode[0] == 'USB' || parsedXML.contactinfo.mode[0] == 'LSB') { // TCADIF lib is not capable of using USB/LSB
383383
parsedXML.contactinfo.mode[0]='SSB';
384384
}
@@ -414,11 +414,11 @@ ports.forEach(port => {
414414
return;
415415
}
416416
}
417-
var plainret='';
417+
let plainret='';
418418
if (adobject.qsos.length>0) {
419419
let x={};
420420
try {
421-
outadif=writeADIF(adobject);
421+
const outadif=writeADIF(adobject);
422422
plainret=await send2wavelog(defaultcfg.profiles[defaultcfg.profile ?? 0],outadif.stringify());
423423
x.state=plainret.statusCode;
424424
x.payload = JSON.parse(plainret.resString);
@@ -470,9 +470,9 @@ function startserver() {
470470
res.setHeader('Access-Control-Allow-Origin', '*');
471471
res.writeHead(200, {'Content-Type': 'text/plain'});
472472
res.end('');
473-
let parts = req.url.substr(1).split('/');
474-
let qrg = parts[0];
475-
let mode = parts[1] || '';
473+
const parts = req.url.substr(1).split('/');
474+
const qrg = parts[0];
475+
const mode = parts[1] || '';
476476
if (Number.isInteger(Number.parseInt(qrg))) {
477477
settrx(qrg,mode);
478478
}
@@ -523,7 +523,7 @@ async function settrx(qrg, mode = '') {
523523
avail_modes=await get_modes();
524524
} catch(e) {
525525
avail_modes=[];
526-
}
526+
}
527527
let to={};
528528
to.qrg=qrg;
529529
if (mode == 'cw') {
@@ -536,22 +536,22 @@ async function settrx(qrg, mode = '') {
536536
}
537537
}
538538
if (defaultcfg.profiles[defaultcfg.profile ?? 0].flrig_ena) {
539-
postData= '<?xml version="1.0"?>';
539+
let postData= '<?xml version="1.0"?>';
540540
postData+='<methodCall><methodName>main.set_frequency</methodName><params><param><value><double>' + to.qrg + '</double></value></param></params></methodCall>';
541-
var options = {
541+
let options = {
542542
method: 'POST',
543543
headers: {
544544
'User-Agent': 'SW2WL_v' + app.getVersion(),
545545
'Content-Length': postData.length
546546
}
547547
};
548548
let url="http://"+defaultcfg.profiles[defaultcfg.profile ?? 0].flrig_host+':'+defaultcfg.profiles[defaultcfg.profile ?? 0].flrig_port+'/';
549-
x=await httpPost(url,options,postData);
549+
let x=await httpPost(url,options,postData);
550550

551551
if (defaultcfg.profiles[defaultcfg.profile ?? 0].wavelog_pmode) {
552552
postData= '<?xml version="1.0"?>';
553553
postData+='<methodCall><methodName>rig.set_modeA</methodName><params><param><value>' + to.mode + '</value></param></params></methodCall>';
554-
var options = {
554+
options = {
555555
method: 'POST',
556556
headers: {
557557
'User-Agent': 'SW2WL_v' + app.getVersion(),
@@ -579,13 +579,13 @@ async function settrx(qrg, mode = '') {
579579

580580
function httpPost(url,options,postData) {
581581
return new Promise((resolve, reject) => {
582-
rej=false;
582+
let rej=false;
583583
let result={};
584584
const req = http.request(url,options, (res) => {
585585
let body=[];
586586
res.on('data', (chunk) => body.push(chunk));
587587
res.on('end', () => {
588-
var resString = Buffer.concat(body).toString();
588+
const resString = Buffer.concat(body).toString();
589589
if (rej) {
590590
reject(resString);
591591
} else {
@@ -612,13 +612,13 @@ function httpPost(url,options,postData) {
612612
}
613613

614614
function fmt(spotDate) {
615-
retstr={};
616-
d=spotDate.getUTCDate().toString();
617-
y=spotDate.getUTCFullYear().toString();
618-
m=(1+spotDate.getUTCMonth()).toString();
619-
h=spotDate.getUTCHours().toString();
620-
i=spotDate.getUTCMinutes().toString();
621-
s=spotDate.getUTCSeconds().toString();
615+
const retstr={};
616+
const d=spotDate.getUTCDate().toString();
617+
const y=spotDate.getUTCFullYear().toString();
618+
const m=(1+spotDate.getUTCMonth()).toString();
619+
const h=spotDate.getUTCHours().toString();
620+
const i=spotDate.getUTCMinutes().toString();
621+
const s=spotDate.getUTCSeconds().toString();
622622
retstr.d=y.padStart(4,'0')+m.padStart(2,'0')+d.padStart(2,'0');
623623
retstr.t=h.padStart(2,'0')+i.padStart(2,'0')+s.padStart(2,'0');
624624
return retstr;

renderer.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88

99
// Shorthand for document.querySelector.
10-
var cfg={};
11-
var active_cfg=0;
12-
var trxpoll=undefined;
10+
let cfg={};
11+
let active_cfg=0;
12+
let trxpoll=undefined;
1313

1414
const {ipcRenderer} = require('electron')
1515
const net = require('net');
@@ -21,8 +21,8 @@ const bt_test=select("#test");
2121
const input_key=select("#wavelog_key");
2222
const input_url=select("#wavelog_url");
2323

24-
var oldCat={ vfo: 0, mode: "SSB" };
25-
var lastCat=0;
24+
let oldCat={ vfo: 0, mode: "SSB" };
25+
let lastCat=0;
2626

2727
$(document).ready(function() {
2828

@@ -73,7 +73,7 @@ $(document).ready(function() {
7373
cfg.profiles[active_cfg].wavelog_key=$("#wavelog_key").val().trim();
7474
cfg.profiles[active_cfg].wavelog_id=$("#wavelog_id").val().trim();
7575
cfg.profiles[active_cfg].wavelog_radioname=$("#wavelog_radioname").val().trim();
76-
x=(ipcRenderer.sendSync("test", cfg.profiles[active_cfg]));
76+
const x=(ipcRenderer.sendSync("test", cfg.profiles[active_cfg]));
7777
if (x.payload.status == 'created') {
7878
$("#test").removeClass('btn-primary');
7979
$("#test").removeClass('btn-danger');
@@ -103,15 +103,15 @@ $(document).ready(function() {
103103
window.onload = updateUtcTime;
104104

105105
$("#config-tab").on("click",function() {
106-
obj={};
106+
const obj={};
107107
obj.width=430;
108108
obj.height=550;
109109
obj.ani=false;
110110
resizeme(obj);
111111
});
112112

113113
$("#status-tab").on("click",function() {
114-
obj={};
114+
const obj={};
115115
obj.width=430;
116116
obj.height=250;
117117
obj.ani=false;
@@ -253,7 +253,7 @@ async function getInfo(which) {
253253
async function getsettrx() {
254254
if ($("#flrig_ena").is(':checked') || cfg.profiles[active_cfg].hamlib_ena) {
255255
console.log('Polling TRX '+trxpoll);
256-
x=get_trx();
256+
const x=get_trx();
257257
}
258258
trxpoll = setTimeout(() => {
259259
getsettrx();
@@ -267,7 +267,7 @@ const isDeepEqual = (object1, object2) => {
267267

268268
if (objKeys1.length !== objKeys2.length) return false;
269269

270-
for (var key of objKeys1) {
270+
for (const key of objKeys1) {
271271
const value1 = object1[key];
272272
const value2 = object2[key];
273273

@@ -335,11 +335,11 @@ function updateUtcTime() {
335335
}
336336

337337
async function getStations() {
338-
let select = $('#wavelog_id');
338+
const select = $('#wavelog_id');
339339
select.empty();
340340
select.prop('disabled', true);
341341
try {
342-
let x = await fetch($('#wavelog_url').val().trim() + '/api/station_info/' + $('#wavelog_key').val().trim(), {
342+
const x = await fetch($('#wavelog_url').val().trim() + '/api/station_info/' + $('#wavelog_key').val().trim(), {
343343
method: 'GET',
344344
rejectUnauthorized: false,
345345
headers: {
@@ -352,7 +352,7 @@ async function getStations() {
352352
throw new Error(`HTTP error! Status: ${x.status}`);
353353
}
354354

355-
let data = await x.json();
355+
const data = await x.json();
356356
fillDropdown(data);
357357

358358
} catch (error) {
@@ -362,13 +362,13 @@ async function getStations() {
362362
}
363363

364364
function fillDropdown(data) {
365-
let select = $('#wavelog_id');
365+
const select = $('#wavelog_id');
366366
select.empty();
367367
select.prop('disabled', false);
368368

369369
data.forEach(function(station) {
370-
let optionText = station.station_profile_name + " (" + station.station_callsign + ", ID: " + station.station_id + ")";
371-
let optionValue = station.station_id;
370+
const optionText = station.station_profile_name + " (" + station.station_callsign + ", ID: " + station.station_id + ")";
371+
const optionValue = station.station_id;
372372
select.append(new Option(optionText, optionValue));
373373
});
374374

0 commit comments

Comments
 (0)