mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
code cleanup
This commit is contained in:
parent
e70c2ccb0e
commit
231ca24c41
|
@ -39,20 +39,35 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
document.getElementById('hamlib_serialspeed').value = config.serialspeed
|
document.getElementById('hamlib_serialspeed').value = config.serialspeed
|
||||||
document.getElementById('hamlib_ptt').value = config.ptt
|
document.getElementById('hamlib_ptt').value = config.ptt
|
||||||
|
|
||||||
|
if (config.spectrum == 'waterfall') {
|
||||||
|
document.getElementById("waterfall-scatter-switch1").checked = true
|
||||||
|
document.getElementById("waterfall-scatter-switch2").checked = false
|
||||||
|
document.getElementById("scatter").style.visibility = 'hidden';
|
||||||
|
document.getElementById("waterfall").style.visibility = 'visible';
|
||||||
|
document.getElementById("waterfall").style.height = '350px';
|
||||||
|
} else {
|
||||||
|
|
||||||
|
document.getElementById("waterfall-scatter-switch1").checked = false
|
||||||
|
document.getElementById("waterfall-scatter-switch2").checked = true
|
||||||
|
document.getElementById("scatter").style.visibility = 'visible';
|
||||||
|
document.getElementById("waterfall").style.visibility = 'hidden';
|
||||||
|
document.getElementById("waterfall").style.height = '0px';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
/*
|
||||||
// Create spectrum object on canvas with ID "waterfall"
|
// Create spectrum object on canvas with ID "waterfall"
|
||||||
global.spectrum = new Spectrum(
|
global.spectrum = new Spectrum(
|
||||||
"waterfall", {
|
"waterfall", {
|
||||||
spectrumPercent: 20
|
spectrumPercent: 20
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// SETUP OF SCATTER DIAGRAM
|
// SETUP OF SCATTER DIAGRAM
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Scatter Dataset',
|
label: 'Scatter Dataset',
|
||||||
data: [{
|
data: [{
|
||||||
|
@ -61,11 +76,11 @@ var data = {
|
||||||
}],
|
}],
|
||||||
backgroundColor: 'rgb(255, 99, 132)'
|
backgroundColor: 'rgb(255, 99, 132)'
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var ctx = document.getElementById('myChart').getContext('2d');
|
var ctx = document.getElementById('scatter').getContext('2d');
|
||||||
global.myChart = new Chart(ctx, {
|
global.myChart = new Chart(ctx, {
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
data: data,
|
data: data,
|
||||||
options: {
|
options: {
|
||||||
|
@ -92,12 +107,26 @@ global.myChart = new Chart(ctx, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// on click waterfall scatter toggle view
|
||||||
|
// waterfall
|
||||||
|
document.getElementById("waterfall-scatter-switch1").addEventListener("click", () => {
|
||||||
|
document.getElementById("scatter").style.visibility = 'hidden';
|
||||||
|
document.getElementById("waterfall").style.visibility = 'visible';
|
||||||
|
document.getElementById("waterfall").style.height = '350px';
|
||||||
|
config.spectrum = 'waterfall'
|
||||||
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
|
});
|
||||||
|
// scatter
|
||||||
|
document.getElementById("waterfall-scatter-switch2").addEventListener("click", () => {
|
||||||
|
document.getElementById("scatter").style.visibility = 'visible';
|
||||||
|
document.getElementById("waterfall").style.visibility = 'hidden';
|
||||||
|
document.getElementById("waterfall").style.height = '0px';
|
||||||
|
config.spectrum = 'scatter'
|
||||||
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// on change port and host
|
// on change port and host
|
||||||
|
|
||||||
document.getElementById("tnc_adress").addEventListener("change", () => {
|
document.getElementById("tnc_adress").addEventListener("change", () => {
|
||||||
console.log(document.getElementById("tnc_adress").value)
|
console.log(document.getElementById("tnc_adress").value)
|
||||||
config.tnc_host = document.getElementById("tnc_adress").value
|
config.tnc_host = document.getElementById("tnc_adress").value
|
||||||
|
@ -185,21 +214,21 @@ global.myChart = new Chart(ctx, {
|
||||||
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
|
|
||||||
// SCATTER DIAGRAM PLOTTING
|
// SCATTER DIAGRAM PLOTTING
|
||||||
global.myChart.destroy();
|
global.myChart.destroy();
|
||||||
|
|
||||||
var data = arg.scatter
|
var data = arg.scatter
|
||||||
var data = {
|
var data = {
|
||||||
datasets: [{
|
datasets: [{
|
||||||
//label: false,
|
//label: false,
|
||||||
data: data,
|
data: data,
|
||||||
backgroundColor: 'rgb(255, 99, 132)'
|
backgroundColor: 'rgb(255, 99, 132)'
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var ctx = document.getElementById('myChart').getContext('2d');
|
var ctx = document.getElementById('scatter').getContext('2d');
|
||||||
global.myChart = new Chart(ctx, {
|
global.myChart = new Chart(ctx, {
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
data: data,
|
data: data,
|
||||||
options: {
|
options: {
|
||||||
|
@ -389,49 +418,49 @@ ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on('action-update-heard-stations', (event, arg) => {
|
ipcRenderer.on('action-update-heard-stations', (event, arg) => {
|
||||||
//console.log(arg.stations)
|
//console.log(arg.stations)
|
||||||
//console.log(arg.stations[0]['DXGRID'])
|
//console.log(arg.stations[0]['DXGRID'])
|
||||||
|
|
||||||
var tbl = document.getElementById("heardstations");
|
var tbl = document.getElementById("heardstations");
|
||||||
document.getElementById("heardstations").innerHTML = ''
|
document.getElementById("heardstations").innerHTML = ''
|
||||||
|
|
||||||
for (i = 0; i < arg.stations.length; i++) {
|
for (i = 0; i < arg.stations.length; i++) {
|
||||||
|
|
||||||
|
|
||||||
// first we update the PING window
|
// first we update the PING window
|
||||||
console.log(document.getElementById("dxCall").value)
|
console.log(document.getElementById("dxCall").value)
|
||||||
if (arg.stations[i]['DXCALLSIGN'] == document.getElementById("dxCall").value){
|
if (arg.stations[i]['DXCALLSIGN'] == document.getElementById("dxCall").value) {
|
||||||
document.getElementById("pingDistance").innerHTML = arg.stations[i]['DXGRID']
|
document.getElementById("pingDistance").innerHTML = arg.stations[i]['DXGRID']
|
||||||
document.getElementById("pingDB").innerHTML = arg.stations[i]['SNR']
|
document.getElementById("pingDB").innerHTML = arg.stations[i]['SNR']
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// now we update the heard stations list
|
// now we update the heard stations list
|
||||||
|
|
||||||
var row = document.createElement("tr");
|
var row = document.createElement("tr");
|
||||||
//https://stackoverflow.com/q/51421470
|
//https://stackoverflow.com/q/51421470
|
||||||
|
|
||||||
//https://stackoverflow.com/a/847196
|
//https://stackoverflow.com/a/847196
|
||||||
timestampRaw = arg.stations[i]['TIMESTAMP']
|
timestampRaw = arg.stations[i]['TIMESTAMP']
|
||||||
var date = new Date(timestampRaw * 1000);
|
var date = new Date(timestampRaw * 1000);
|
||||||
var hours = date.getHours();
|
var hours = date.getHours();
|
||||||
var minutes = "0" + date.getMinutes();
|
var minutes = "0" + date.getMinutes();
|
||||||
var seconds = "0" + date.getSeconds();
|
var seconds = "0" + date.getSeconds();
|
||||||
var datetime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
|
var datetime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
|
||||||
|
|
||||||
var timestamp = document.createElement("td");
|
var timestamp = document.createElement("td");
|
||||||
var timestampText = document.createElement('span');
|
var timestampText = document.createElement('span');
|
||||||
timestampText.innerText = datetime
|
timestampText.innerText = datetime
|
||||||
timestamp.appendChild(timestampText);
|
timestamp.appendChild(timestampText);
|
||||||
|
|
||||||
var dxCall = document.createElement("td");
|
var dxCall = document.createElement("td");
|
||||||
var dxCallText = document.createElement('span');
|
var dxCallText = document.createElement('span');
|
||||||
dxCallText.innerText = arg.stations[i]['DXCALLSIGN']
|
dxCallText.innerText = arg.stations[i]['DXCALLSIGN']
|
||||||
dxCall.appendChild(dxCallText);
|
dxCall.appendChild(dxCallText);
|
||||||
|
|
||||||
var dxGrid = document.createElement("td");
|
var dxGrid = document.createElement("td");
|
||||||
var dxGridText = document.createElement('span');
|
var dxGridText = document.createElement('span');
|
||||||
dxGridText.innerText = arg.stations[i]['DXGRID']
|
dxGridText.innerText = arg.stations[i]['DXGRID']
|
||||||
dxGrid.appendChild(dxGridText);
|
dxGrid.appendChild(dxGridText);
|
||||||
|
@ -444,12 +473,12 @@ var dxGrid = document.createElement("td");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
row.appendChild(timestamp);
|
row.appendChild(timestamp);
|
||||||
row.appendChild(dxCall);
|
row.appendChild(dxCall);
|
||||||
row.appendChild(dxGrid);
|
row.appendChild(dxGrid);
|
||||||
row.appendChild(dataType);
|
row.appendChild(dataType);
|
||||||
|
|
||||||
tbl.appendChild(row);
|
tbl.appendChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -457,12 +486,6 @@ tbl.appendChild(row);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('run-tnc-command', (event, arg) => {
|
ipcRenderer.on('run-tnc-command', (event, arg) => {
|
||||||
if (arg.command == 'saveMyCall') {
|
if (arg.command == 'saveMyCall') {
|
||||||
sock.saveMyCall(arg.callsign)
|
sock.saveMyCall(arg.callsign)
|
||||||
|
|
Loading…
Reference in a new issue