FreeDATA/gui/preload-main.js

1768 lines
72 KiB
JavaScript
Raw Normal View History

const path = require('path');
2021-07-24 07:06:22 +00:00
const {
ipcRenderer
} = require('electron');
2021-09-04 18:23:58 +00:00
const sock = require('./sock.js');
const daemon = require('./daemon.js');
2021-07-23 15:40:44 +00:00
const fs = require('fs');
2021-09-04 18:23:58 +00:00
const {
locatorToLatLng,
distance,
bearingDistance,
latLngToLocator
} = require('qth-locator');
2021-12-20 17:05:00 +00:00
const os = require('os');
2021-09-04 18:23:58 +00:00
// split character used for appending addiotional data to files
2022-02-12 15:34:47 +00:00
const split_char = '\0;';
2021-09-04 18:23:58 +00:00
// https://stackoverflow.com/a/26227660
var appDataFolder = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + "/.config");
2021-09-13 16:27:50 +00:00
var configFolder = path.join(appDataFolder, "FreeDATA");
var configPath = path.join(configFolder, 'config.json');
2021-09-04 18:23:58 +00:00
const config = require(configPath);
2021-07-23 15:40:44 +00:00
// START INTERVALL COMMAND EXECUTION FOR STATES
setInterval(sock.getRxBuffer, 1000);
setInterval(sock.getMsgRxBuffer, 1000);
2021-07-24 07:06:22 +00:00
// WINDOW LISTENER
2021-07-23 15:40:44 +00:00
window.addEventListener('DOMContentLoaded', () => {
/*
// ENABLE BOOTSTRAP POPOVERS EVERYWHERE
// https://getbootstrap.com/docs/5.0/components/popovers/#example-enable-popovers-everywhere
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
*/
// DISABLE HAMLIB DIRECT AND RIGCTL ON WINDOWS
if(os.platform()=='win32' || os.platform()=='win64'){
document.getElementById("radio-control-switch1").style.disabled = true;
document.getElementById("radio-control-switch2").style.disabled = true;
}
// ENABLE TOOLTIPS EVERYWHERE
// https://getbootstrap.com/docs/5.1/components/tooltips/
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
})
2021-07-24 07:06:22 +00:00
// LOAD SETTINGS
document.getElementById("tnc_adress").value = config.tnc_host;
document.getElementById("tnc_port").value = config.tnc_port;
callsign_and_ssid = config.mycall.split("-");
callsign = callsign_and_ssid[0];
ssid = callsign_and_ssid[1];
document.getElementById("myCall").value = callsign;
document.getElementById("myCallSSID").value = ssid;
document.getElementById("myGrid").value = config.mygrid;
document.getElementById('hamlib_deviceid').value = config.deviceid;
document.getElementById('hamlib_serialspeed').value = config.serialspeed_direct;
document.getElementById('hamlib_ptt_protocol').value = config.pttprotocol_direct;
2021-07-25 16:19:51 +00:00
document.getElementById("hamlib_rigctld_ip").value = config.rigctld_ip;
document.getElementById("hamlib_rigctld_port").value = config.rigctld_port;
document.getElementById("hamlib_deviceid_rigctl").value = config.deviceid_rigctl;
document.getElementById("hamlib_serialspeed_rigctl").value = config.serialspeed_rigctl;
document.getElementById("hamlib_ptt_protocol_rigctl").value = config.pttprotocol_rigctl;
document.getElementById('hamlib_serialspeed_advanced').value = config.serialspeed_direct;
document.getElementById('hamlib_ptt_protocol_advanced').value = config.pttprotocol_direct;
document.getElementById('hamlib_databits_advanced').value = config.data_bits_direct;
document.getElementById('hamlib_stopbits_advanced').value = config.stop_bits_direct;
document.getElementById('hamlib_handshake_advanced').value = config.handshake_direct;
document.getElementById("beaconInterval").value = config.beacon_interval;
document.getElementById("scatterSwitch").value = config.enable_scatter;
document.getElementById("fftSwitch").value = config.enable_fft;
document.getElementById("500HzModeSwitch").value = config.low_bandwith_mode;
if(config.enable_scatter == 'True'){
document.getElementById("scatterSwitch").checked = true;
} else {
document.getElementById("scatterSwitch").checked = false;
}
if(config.enable_fft == 'True'){
document.getElementById("fftSwitch").checked = true;
} else {
document.getElementById("fftSwitch").checked = false;
}
if(config.low_bandwith_mode == 'True'){
document.getElementById("500HzModeSwitch").checked = true;
} else {
document.getElementById("500HzModeSwitch").checked = false;
}
// theme selector
if(config.theme != 'default'){
var theme_path = "../node_modules/bootswatch/dist/"+ config.theme +"/bootstrap.min.css";
document.getElementById("theme_selector").value = config.theme;
document.getElementById("bootstrap_theme").href = theme_path;
} else {
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
document.getElementById("theme_selector").value = 'default';
document.getElementById("bootstrap_theme").href = theme_path;
}
// Update channel selector
document.getElementById("update_channel_selector").value = config.update_channel;
2021-08-07 08:54:34 +00:00
if (config.spectrum == 'waterfall') {
document.getElementById("waterfall-scatter-switch1").checked = true;
document.getElementById("waterfall-scatter-switch2").checked = false;
2021-08-07 08:54:34 +00:00
document.getElementById("scatter").style.visibility = 'hidden';
document.getElementById("waterfall").style.visibility = 'visible';
document.getElementById("waterfall").style.height = '100%';
2021-08-07 08:54:34 +00:00
} else {
2021-07-25 16:19:51 +00:00
document.getElementById("waterfall-scatter-switch1").checked = false;
document.getElementById("waterfall-scatter-switch2").checked = true;
2021-08-07 08:54:34 +00:00
document.getElementById("scatter").style.visibility = 'visible';
document.getElementById("waterfall").style.visibility = 'hidden';
document.getElementById("waterfall").style.height = '0px';
}
2021-07-25 16:19:51 +00:00
// radio control element
if (config.radiocontrol == 'direct') {
document.getElementById("radio-control-switch0").checked = false;
document.getElementById("radio-control-switch1").checked = true;
document.getElementById("radio-control-switch2").checked = false;
document.getElementById("radio-control-switch3").checked = false;
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-direct").style.display = 'block';
document.getElementById("radio-control-direct").style.visibility = 'visible';
document.getElementById("radio-control-direct").style.height = '100%';
} else if (config.radiocontrol == 'rigctl') {
document.getElementById("radio-control-switch0").checked = false;
document.getElementById("radio-control-switch1").checked = false;
document.getElementById("radio-control-switch2").checked = true;
document.getElementById("radio-control-switch3").checked = false;
document.getElementById("radio-control-direct").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-direct").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-rigctl").style.display = 'block';
document.getElementById("radio-control-rigctl").style.visibility = 'visible';
document.getElementById("radio-control-rigctl").style.height = '100%';
} else if (config.radiocontrol == 'rigctld') {
document.getElementById("radio-control-switch0").checked = false;
document.getElementById("radio-control-switch1").checked = false;
document.getElementById("radio-control-switch2").checked = false;
document.getElementById("radio-control-switch3").checked = true;
document.getElementById("radio-control-direct").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-direct").style.display = 'none';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'block';
document.getElementById("radio-control-rigctld").style.visibility = 'visible';
document.getElementById("radio-control-rigctld").style.height = '100%';
} else {
document.getElementById("radio-control-switch0").checked = true;
document.getElementById("radio-control-switch1").checked = false;
document.getElementById("radio-control-switch2").checked = false;
document.getElementById("radio-control-switch3").checked = false;
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-direct").style.display = 'block';
document.getElementById("radio-control-direct").style.visibility = 'visible';
document.getElementById("radio-control-direct").style.height = '100%';
}
2021-09-13 16:27:50 +00:00
// remote tnc
2021-09-04 14:33:17 +00:00
if (config.tnclocation == 'remote') {
document.getElementById("local-remote-switch1").checked = false;
document.getElementById("local-remote-switch2").checked = true;
2021-09-04 14:33:17 +00:00
document.getElementById("remote-tnc-field").style.visibility = 'visible';
} else {
document.getElementById("local-remote-switch1").checked = true;
document.getElementById("local-remote-switch2").checked = false;
2021-09-04 18:23:58 +00:00
document.getElementById("remote-tnc-field").style.visibility = 'hidden';
2021-09-04 14:33:17 +00:00
}
2021-09-04 18:23:58 +00:00
// Create spectrum object on canvas with ID "waterfall"
global.spectrum = new Spectrum(
"waterfall", {
spectrumPercent: 0
2021-09-04 18:23:58 +00:00
});
2021-08-07 08:54:34 +00:00
// on click radio control toggle view
// disabled
document.getElementById("radio-control-switch0").addEventListener("click", () => {
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-direct").style.display = 'block';
document.getElementById("radio-control-direct").style.visibility = 'visible';
document.getElementById("radio-control-direct").style.height = '100%';
config.radiocontrol = 'disabled'
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// direct
document.getElementById("radio-control-switch1").addEventListener("click", () => {
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-direct").style.display = 'block';
document.getElementById("radio-control-direct").style.visibility = 'visible';
document.getElementById("radio-control-direct").style.height = '100%';
config.radiocontrol = 'direct';
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2021-08-07 08:54:34 +00:00
});
// rigctl
document.getElementById("radio-control-switch2").addEventListener("click", () => {
document.getElementById("radio-control-direct").style.visibility = 'hidden';
document.getElementById("radio-control-rigctld").style.visibility = 'hidden';
document.getElementById("radio-control-direct").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'none';
document.getElementById("radio-control-rigctl").style.display = 'block';
document.getElementById("radio-control-rigctl").style.visibility = 'visible';
document.getElementById("radio-control-rigctl").style.height = '100%';
config.radiocontrol = 'rigctl';
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// rigctld
document.getElementById("radio-control-switch3").addEventListener("click", () => {
document.getElementById("radio-control-direct").style.visibility = 'hidden';
document.getElementById("radio-control-rigctl").style.visibility = 'hidden';
document.getElementById("radio-control-direct").style.display = 'none';
document.getElementById("radio-control-rigctl").style.display = 'none';
document.getElementById("radio-control-rigctld").style.display = 'block';
document.getElementById("radio-control-rigctld").style.visibility = 'visible';
document.getElementById("radio-control-rigctld").style.height = '100%';
config.radiocontrol = 'rigctld';
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
2021-08-07 08:54:34 +00:00
// 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 = '100%';
config.spectrum = 'waterfall';
2021-08-07 08:54:34 +00:00
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';
2021-08-07 08:54:34 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
2021-07-17 07:03:40 +00:00
2021-09-04 14:33:17 +00:00
// on click remote tnc toggle view
document.getElementById("local-remote-switch1").addEventListener("click", () => {
document.getElementById("local-remote-switch1").checked = true;
document.getElementById("local-remote-switch2").checked = false;
2021-09-04 14:33:17 +00:00
document.getElementById("remote-tnc-field").style.visibility = 'hidden';
config.tnclocation = 'localhost';
2021-09-04 18:23:58 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
document.getElementById("local-remote-switch2").addEventListener("click", () => {
document.getElementById("local-remote-switch1").checked = false;
document.getElementById("local-remote-switch2").checked = true;
2021-09-04 14:33:17 +00:00
document.getElementById("remote-tnc-field").style.visibility = 'visible';
config.tnclocation = 'remote';
2021-09-04 18:23:58 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
2021-07-24 07:06:22 +00:00
// on change port and host
document.getElementById("tnc_adress").addEventListener("change", () => {
console.log(document.getElementById("tnc_adress").value);
config.tnc_host = document.getElementById("tnc_adress").value;
config.daemon_host = document.getElementById("tnc_adress").value;
2021-07-24 07:06:22 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2021-07-23 15:40:44 +00:00
});
2021-09-24 14:43:45 +00:00
// on change ping callsign
document.getElementById("dxCall").addEventListener("change", () => {
document.getElementById("dataModalDxCall").value = document.getElementById("dxCall").value;
2021-09-24 14:43:45 +00:00
});
// on change ping callsign
document.getElementById("dataModalDxCall").addEventListener("change", () => {
document.getElementById("dxCall").value = document.getElementById("dataModalDxCall").value;
2021-09-24 14:43:45 +00:00
});
2021-07-24 07:06:22 +00:00
document.getElementById("tnc_port").addEventListener("change", () => {
config.tnc_port = document.getElementById("tnc_port").value;
config.daemon_port = parseInt(document.getElementById("tnc_port").value) + 1;
2021-07-24 07:06:22 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2021-07-17 07:03:40 +00:00
2021-07-24 07:06:22 +00:00
});
2021-07-17 07:03:40 +00:00
2021-09-13 16:27:50 +00:00
// saveMyCall button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("saveMyCall").addEventListener("click", () => {
callsign = document.getElementById("myCall").value;
ssid = document.getElementById("myCallSSID").value;
callsign_ssid = callsign.toUpperCase() + '-' + ssid;
config.mycall = callsign_ssid;
2021-07-23 15:40:44 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
daemon.saveMyCall(callsign_ssid);
2021-07-24 07:06:22 +00:00
});
2021-09-13 16:27:50 +00:00
// saveMyGrid button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("saveMyGrid").addEventListener("click", () => {
grid = document.getElementById("myGrid").value;
config.mygrid = grid;
2021-07-23 15:40:44 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
daemon.saveMyGrid(grid);
2021-07-24 07:06:22 +00:00
2021-07-23 15:40:44 +00:00
});
2021-07-24 07:06:22 +00:00
2021-09-13 16:27:50 +00:00
// startPing button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("sendPing").addEventListener("click", () => {
var dxcallsign = document.getElementById("dxCall").value;
dxcallsign = dxcallsign.toUpperCase();
sock.sendPing(dxcallsign);
2021-08-15 14:48:48 +00:00
});
2021-09-04 18:23:58 +00:00
2021-09-13 16:27:50 +00:00
// dataModalstartPing button clicked
2021-08-15 14:48:48 +00:00
document.getElementById("dataModalSendPing").addEventListener("click", () => {
var dxcallsign = document.getElementById("dataModalDxCall").value;
dxcallsign = dxcallsign.toUpperCase();
sock.sendPing(dxcallsign);
2021-07-24 07:06:22 +00:00
});
// open arq session
document.getElementById("openARQSession").addEventListener("click", () => {
var dxcallsign = document.getElementById("dataModalDxCall").value;
dxcallsign = dxcallsign.toUpperCase();
sock.connectARQ(dxcallsign);
});
// close arq session
document.getElementById("closeARQSession").addEventListener("click", () => {
sock.disconnectARQ();
});
2021-07-24 07:06:22 +00:00
2021-09-13 16:27:50 +00:00
// sendCQ button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("sendCQ").addEventListener("click", () => {
sock.sendCQ();
2021-07-24 07:06:22 +00:00
});
// Start beacon button clicked
document.getElementById("startBeacon").addEventListener("click", () => {
interval = document.getElementById("beaconInterval").value;
config.beacon_interval = interval;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
sock.startBeacon(interval);
});
// sendscatter Switch clicked
document.getElementById("scatterSwitch").addEventListener("click", () => {
console.log(document.getElementById("scatterSwitch").checked);
if(document.getElementById("scatterSwitch").checked == true){
config.enable_scatter = "True";
} else {
config.enable_scatter = "False";
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// sendfft Switch clicked
document.getElementById("fftSwitch").addEventListener("click", () => {
if(document.getElementById("fftSwitch").checked == true){
config.enable_fft = "True";
} else {
config.enable_fft = "False";
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// enable 500z Switch clicked
document.getElementById("500HzModeSwitch").addEventListener("click", () => {
if(document.getElementById("500HzModeSwitch").checked == true){
config.low_bandwith_mode = "True";
} else {
config.low_bandwith_mode = "False";
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// Theme selector clicked
document.getElementById("theme_selector").addEventListener("click", () => {
var theme = document.getElementById("theme_selector").value;
if(theme != 'default'){
var theme_path = "../node_modules/bootswatch/dist/"+ theme +"/bootstrap.min.css";
} else {
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
}
//update path to css file
document.getElementById("bootstrap_theme").href = theme_path
config.theme = theme;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// Update channel selector clicked
document.getElementById("update_channel_selector").addEventListener("click", () => {
config.update_channel = document.getElementById("update_channel_selector").value;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
2022-02-10 14:05:04 +00:00
//screen size
window.addEventListener('resize',() => {
config.screen_height = window.innerHeight;
config.screen_width = window.innerWidth;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// Stop beacon button clicked
document.getElementById("stopBeacon").addEventListener("click", () => {
sock.stopBeacon();
});
2021-09-13 16:27:50 +00:00
// startTNC button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("startTNC").addEventListener("click", () => {
var deviceid_rigctl = document.getElementById("hamlib_deviceid_rigctl").value;
var deviceport_rigctl = document.getElementById("hamlib_deviceport_rigctl").value;
var serialspeed_rigctl = document.getElementById("hamlib_serialspeed_rigctl").value;
var pttprotocol_rigctl = document.getElementById("hamlib_ptt_protocol_rigctl").value;
var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value;
var rigctld_port = document.getElementById("hamlib_rigctld_port").value;
var deviceid = document.getElementById("hamlib_deviceid").value;
var deviceport = document.getElementById("hamlib_deviceport").value;
var serialspeed = document.getElementById("hamlib_serialspeed").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value;
var mycall = document.getElementById("myCall").value;
var ssid = document.getElementById("myCallSSID").value;
callsign_ssid = mycall.toUpperCase() + '-' + ssid;
var mygrid = document.getElementById("myGrid").value;
var rx_audio = document.getElementById("audio_input_selectbox").value;
var tx_audio = document.getElementById("audio_output_selectbox").value;
var pttport = document.getElementById("hamlib_ptt_port_advanced").value;
var data_bits = document.getElementById('hamlib_databits_advanced').value;
var stop_bits = document.getElementById('hamlib_stopbits_advanced').value;
var handshake = document.getElementById('hamlib_handshake_advanced').value;
if (document.getElementById("scatterSwitch").checked == true){
var enable_scatter = "True";
} else {
var enable_scatter = "False";
}
if (document.getElementById("fftSwitch").checked == true){
var enable_fft = "True";
} else {
var enable_fft = "False";
}
if (document.getElementById("500HzModeSwitch").checked == true){
var low_bandwith_mode = "True";
} else {
var low_bandwith_mode = "False";
}
2021-12-27 14:28:58 +00:00
// loop through audio device list and select
for(i = 0; i < document.getElementById("audio_input_selectbox").length; i++) {
device = document.getElementById("audio_input_selectbox")[i];
if (device.value == rx_audio) {
console.log(device.text);
config.rx_audio = device.text;
2021-12-27 14:28:58 +00:00
}
}
// loop through audio device list and select
for(i = 0; i < document.getElementById("audio_output_selectbox").length; i++) {
device = document.getElementById("audio_output_selectbox")[i];
if (device.value == tx_audio) {
console.log(device.text);
config.tx_audio = device.text;
2021-12-27 14:28:58 +00:00
}
}
// overriding settings for rigctl / direct
if (document.getElementById("radio-control-switch2").checked){
var radiocontrol = 'rigctl';
var deviceid = document.getElementById("hamlib_deviceid_rigctl").value;
var deviceport = document.getElementById("hamlib_deviceport_rigctl").value;
var serialspeed = document.getElementById("hamlib_serialspeed_rigctl").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol_rigctl").value;
} else if (document.getElementById("radio-control-switch3").checked) {
var radiocontrol = 'rigctld';
} else if (document.getElementById("radio-control-switch1").checked) {
var radiocontrol = 'direct';
} else {
var radiocontrol = 'disabled';
}
config.radiocontrol = radiocontrol;
config.mycall = callsign_ssid;
config.mygrid = mygrid;
config.deviceid = deviceid;
config.deviceport = deviceport;
config.serialspeed_direct = serialspeed;
config.pttprotocol_direct = pttprotocol;
config.pttport = pttport;
config.data_bits_direct = data_bits;
config.stop_bits_direct = stop_bits;
config.handshake_direct = handshake;
config.deviceid_rigctl = deviceid_rigctl;
config.serialspeed_rigctl = serialspeed_rigctl;
config.pttprotocol_rigctl = pttprotocol_rigctl;
config.rigctld_port = rigctld_port;
config.rigctld_ip = rigctld_ip;
config.deviceport_rigctl = deviceport_rigctl;
config.enable_scatter = enable_scatter;
config.enable_fft = enable_fft;
config.low_bandwith_mode = low_bandwith_mode;
2021-09-13 18:02:14 +00:00
2021-07-25 16:19:51 +00:00
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
// collapse settings screen
// deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay
/*
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
collapseFirstRow.hide()
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
2021-12-20 17:05:00 +00:00
collapseSecondRow.hide()
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
collapseThirdRow.show()
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.show()
*/
daemon.startTNC(callsign_ssid, mygrid, rx_audio, tx_audio, radiocontrol, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port, enable_fft, enable_scatter, low_bandwith_mode);
2021-07-24 07:06:22 +00:00
})
document.getElementById("tncLog").addEventListener("click", () => {
ipcRenderer.send('request-open-tnc-log');
})
2021-09-13 16:27:50 +00:00
// stopTNC button clicked
2021-07-24 07:06:22 +00:00
document.getElementById("stopTNC").addEventListener("click", () => {
daemon.stopTNC();
// collapse settings screen
// deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay
/*
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
collapseFirstRow.show()
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
2021-12-20 17:05:00 +00:00
collapseSecondRow.show()
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
2021-12-20 17:05:00 +00:00
collapseThirdRow.hide()
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.hide()
*/
2021-12-20 17:05:00 +00:00
2021-07-24 07:06:22 +00:00
})
2021-09-13 16:27:50 +00:00
// openDataModule button clicked
// not necessesary at this time beacuse bootstrap handles this
// document.getElementById("openDataModule").addEventListener("click", () => {
// var transmitFileSidebar = document.getElementById('transmitFileSidebar')
// var bstransmitFileSidebar = new bootstrap.Offcanvas(transmitFileSidebar)
// bstransmitFileSidebar.show()
//})
2021-07-17 07:03:40 +00:00
// openReceivedFiles button clicked
// not necessesary at this time beacuse bootstrap handles this
//document.getElementById("openReceivedFiles").addEventListener("click", () => {
// var transmitFileSidebar = document.getElementById('transmitFileSidebar')
// var bstransmitFileSidebar = new bootstrap.Offcanvas(transmitFileSidebar)
// bstransmitFileSidebar.show()
//})
// TEST HAMLIB
document.getElementById("testHamlib").addEventListener("click", () => {
var data_bits = document.getElementById("hamlib_databits_advanced").value;
var stop_bits = document.getElementById("hamlib_stopbits_advanced").value;
var handshake = document.getElementById("hamlib_handshake_advanced").value;
var pttport = document.getElementById("hamlib_ptt_port_advanced").value;
var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value;
var rigctld_port = document.getElementById("hamlib_rigctld_port").value;
var deviceid = document.getElementById("hamlib_deviceid").value;
var deviceport = document.getElementById("hamlib_deviceport").value;
var serialspeed = document.getElementById("hamlib_serialspeed").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value;
// overriding settings for rigctl / direct
if (document.getElementById("radio-control-switch2").checked){
var radiocontrol = 'rigctl';
var deviceid = document.getElementById("hamlib_deviceid_rigctl").value;
var deviceport = document.getElementById("hamlib_deviceport_rigctl").value;
var serialspeed = document.getElementById("hamlib_serialspeed_rigctl").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol_rigctl").value;
} else if (document.getElementById("radio-control-switch3").checked) {
var radiocontrol = 'rigctld';
} else if (document.getElementById("radio-control-switch1").checked) {
var radiocontrol = 'direct';
} else {
var radiocontrol = 'disabled';
}
daemon.testHamlib(radiocontrol, deviceid, deviceport, serialspeed, pttprotocol, pttport, data_bits, stop_bits, handshake, rigctld_ip, rigctld_port)
})
2021-09-13 16:27:50 +00:00
// START TRANSMISSION
2021-09-04 18:23:58 +00:00
document.getElementById("startTransmission").addEventListener("click", () => {
//document.getElementById("transmitFileSidebar").style.width = "0px";
/* not neccessary at this time because handled by bootstap inside html
var transmitFileSidebar = document.getElementById('transmitFileSidebar')
var bstransmitFileSidebar = new bootstrap.Offcanvas(transmitFileSidebar)
bstransmitFileSidebar.show()
*/
2021-09-04 18:23:58 +00:00
var fileList = document.getElementById("dataModalFile").files;
2021-09-04 18:23:58 +00:00
var reader = new FileReader();
reader.readAsBinaryString(fileList[0]);
//reader.readAsDataURL(fileList[0]);
2021-09-04 18:23:58 +00:00
reader.onload = function(e) {
// binary data
var data = e.target.result;
console.log(data);
2021-09-04 18:23:58 +00:00
let Data = {
command: "send_file",
dxcallsign: document.getElementById("dataModalDxCall").value.toUpperCase(),
2021-09-04 18:23:58 +00:00
mode: document.getElementById("datamode").value,
frames: document.getElementById("framesperburst").value,
filetype: fileList[0].type,
filename: fileList[0].name,
data: data,
checksum: '123123123',
};
ipcRenderer.send('run-tnc-command', Data);
};
reader.onerror = function(e) {
// error occurred
console.log('Error : ' + e.type);
};
})
// START TRANSMISSION
document.getElementById("stopTransmission").addEventListener("click", () => {
let Data = {
command: "stop_transmission"
};
ipcRenderer.send('run-tnc-command', Data);
})
2021-11-19 16:30:17 +00:00
// OPEN CHAT MODULE
document.getElementById("openRFChat").addEventListener("click", () => {
let Data = {
command: "openRFChat"
};
ipcRenderer.send('request-show-chat-window', Data);
})
2021-09-04 18:23:58 +00:00
})
2021-07-24 07:06:22 +00:00
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
2021-09-05 09:26:09 +00:00
// update FFT
if (typeof(arg.fft) !== 'undefined') {
var array = JSON.parse("[" + arg.fft + "]");
spectrum.addData(array[0]);
2021-09-13 16:27:50 +00:00
}
2021-09-05 09:26:09 +00:00
2021-08-08 09:43:50 +00:00
// TOE TIME OF EXECUTION --> How many time needs a command to be executed until data arrives
// deactivated this feature, beacuse its useless at this time. maybe it is getting more interesting, if we are working via network
// but for this we need to find a nice place for this on the screen
/*
2021-09-04 18:23:58 +00:00
if (typeof(arg.toe) == 'undefined') {
var toe = 0
2021-08-08 09:43:50 +00:00
} else {
2021-09-04 18:23:58 +00:00
var toe = arg.toe
}
2021-08-08 09:43:50 +00:00
document.getElementById("toe").innerHTML = toe + ' ms'
*/
2021-09-04 18:23:58 +00:00
// DATA STATE
global.rxBufferLengthTnc = arg.rx_buffer_length
2021-08-08 09:43:50 +00:00
2021-08-07 08:54:34 +00:00
// SCATTER DIAGRAM PLOTTING
//global.myChart.destroy();
2021-09-04 18:23:58 +00:00
//console.log(arg.scatter.length)
2021-09-05 07:26:14 +00:00
const config = {
plugins: {
legend: {
2021-09-13 16:27:50 +00:00
display: false,
},
tooltip: {
enabled: false
2021-09-13 16:27:50 +00:00
},
annotation: {
annotations: {
line1: {
type: 'line',
yMin: 0,
yMax: 0,
borderColor: 'rgb(255, 99, 132)',
borderWidth: 2,
},
line2: {
type: 'line',
xMin: 0,
xMax: 0,
borderColor: 'rgb(255, 99, 132)',
borderWidth: 2,
}
}
},
2021-09-05 07:26:14 +00:00
},
animations: false,
scales: {
x: {
type: 'linear',
position: 'bottom',
display: true,
min: -80,
max: 80,
ticks: {
display: false
}
2021-09-05 07:26:14 +00:00
},
y: {
display: true,
min: -80,
max: 80,
ticks: {
display: false,
}
2021-09-05 07:26:14 +00:00
}
}
}
2021-08-07 08:54:34 +00:00
var data = arg.scatter
var newdata = {
2021-08-07 08:54:34 +00:00
datasets: [{
//label: 'constellation diagram',
2021-08-07 08:54:34 +00:00
data: data,
2021-09-05 07:26:14 +00:00
options: config,
2021-08-07 08:54:34 +00:00
backgroundColor: 'rgb(255, 99, 132)'
}],
};
2021-09-04 18:23:58 +00:00
if (typeof(arg.scatter) == 'undefined') {
var scatterSize = 0;
} else {
var scatterSize = arg.scatter.length;
}
2021-09-04 18:23:58 +00:00
if (global.data != newdata && scatterSize > 0) {
try {
global.myChart.destroy();
} catch (e) {
// myChart not yet created
console.log(e);
2021-09-04 18:23:58 +00:00
}
global.data = newdata;
2021-09-04 18:23:58 +00:00
2021-09-05 07:26:14 +00:00
2021-09-04 18:23:58 +00:00
var ctx = document.getElementById('scatter').getContext('2d');
global.myChart = new Chart(ctx, {
type: 'scatter',
data: global.data,
2021-09-05 07:26:14 +00:00
options: config
2021-09-04 18:23:58 +00:00
});
}
2021-07-24 07:06:22 +00:00
// PTT STATE
if (arg.ptt_state == 'True') {
document.getElementById("ptt_state").className = "btn btn-sm btn-danger";
2021-07-24 07:06:22 +00:00
} else if (arg.ptt_state == 'False') {
document.getElementById("ptt_state").className = "btn btn-sm btn-success";
2021-07-24 07:06:22 +00:00
} else {
document.getElementById("ptt_state").className = "btn btn-sm btn-secondary";
2021-07-24 07:06:22 +00:00
}
2021-07-17 07:03:40 +00:00
2022-02-15 17:10:14 +00:00
// CHANNEL BUSY STATE
if (arg.channel_busy == 'True') {
document.getElementById("channel_busy").className = "btn btn-sm btn-danger";
} else if (arg.channel_busy == 'False') {
document.getElementById("channel_busy").className = "btn btn-sm btn-success";
} else {
document.getElementById("channel_busy").className = "btn btn-sm btn-secondary";
}
2021-07-24 07:06:22 +00:00
// BUSY STATE
if (arg.busy_state == 'BUSY') {
document.getElementById("busy_state").className = "btn btn-sm btn-danger";
document.getElementById("startTransmission").disabled = true;
//document.getElementById("stopTransmission").disabled = false;
2021-09-24 14:43:45 +00:00
2021-07-24 07:06:22 +00:00
} else if (arg.busy_state == 'IDLE') {
document.getElementById("busy_state").className = "btn btn-sm btn-success";
2021-09-24 14:43:45 +00:00
2021-07-24 07:06:22 +00:00
} else {
document.getElementById("busy_state").className = "btn btn-sm btn-secondary";
document.getElementById("startTransmission").disabled = true;
//document.getElementById("stopTransmission").disabled = false;
2021-07-24 07:06:22 +00:00
}
2021-07-17 07:03:40 +00:00
2021-07-24 07:06:22 +00:00
// ARQ STATE
if (arg.arq_state == 'True') {
document.getElementById("arq_state").className = "btn btn-sm btn-warning";
//document.getElementById("startTransmission").disabled = true;
document.getElementById("startTransmission").disabled = false;
//document.getElementById("stopTransmission").disabled = false;
} else if (arg.arq_state == 'False') {
document.getElementById("arq_state").className = "btn btn-sm btn-secondary";
document.getElementById("startTransmission").disabled = false;
//document.getElementById("stopTransmission").disabled = true;
2021-07-24 07:06:22 +00:00
} else {
document.getElementById("arq_state").className = "btn btn-sm btn-secondary";
//document.getElementById("startTransmission").disabled = true;
document.getElementById("startTransmission").disabled = false;
//document.getElementById("stopTransmission").disabled = false;
2021-07-24 07:06:22 +00:00
}
2021-07-17 07:03:40 +00:00
// ARQ SESSION
if (arg.arq_session == 'True') {
document.getElementById("arq_session").className = "btn btn-sm btn-warning";
} else if (arg.arq_session == 'False') {
document.getElementById("arq_session").className = "btn btn-sm btn-secondary";
} else {
document.getElementById("arq_session").className = "btn btn-sm btn-secondary";
}
// BEACON STATE
if (arg.beacon_state == 'True') {
document.getElementById("startBeacon").className = "btn btn-sm btn-success spinner-grow";
document.getElementById("startBeacon").disabled = true;
document.getElementById("beaconInterval").disabled = true;
document.getElementById("stopBeacon").disabled = false;
} else if (arg.beacon_state == 'False') {
document.getElementById("startBeacon").className = "btn btn-sm btn-success";
document.getElementById("startBeacon").disabled = false;
document.getElementById("beaconInterval").disabled = false;
document.getElementById("stopBeacon").disabled = true;
} else {
document.getElementById("startBeacon").className = "btn btn-sm btn-success";
document.getElementById("startBeacon").disabled = false;
document.getElementById("stopBeacon").disabled = true;
document.getElementById("beaconInterval").disabled = false;
}
2021-07-24 07:06:22 +00:00
// RMS
document.getElementById("rms_level").setAttribute("aria-valuenow", arg.rms_level);
document.getElementById("rms_level").setAttribute("style", "width:" + arg.rms_level + "%;");
2021-08-07 08:54:34 +00:00
2021-07-24 07:06:22 +00:00
// SET FREQUENCY
document.getElementById("frequency").innerHTML = arg.frequency;
2021-07-24 07:06:22 +00:00
// SET MODE
document.getElementById("mode").innerHTML = arg.mode;
2021-07-24 07:06:22 +00:00
// SET BANDWITH
document.getElementById("bandwith").innerHTML = arg.bandwith;
2021-09-04 18:23:58 +00:00
// SET BYTES PER MINUTE
if (typeof(arg.arq_bytes_per_minute) == 'undefined') {
var arq_bytes_per_minute = 0;
2021-08-15 14:48:48 +00:00
} else {
var arq_bytes_per_minute = arg.arq_bytes_per_minute;
2021-09-04 18:23:58 +00:00
}
document.getElementById("bytes_per_min").innerHTML = arq_bytes_per_minute;
2021-09-04 18:23:58 +00:00
// SET BYTES PER MINUTE COMPRESSED
if (typeof(arg.arq_bytes_per_minute) == 'undefined') {
var arq_bytes_per_minute_compressed = 0;
} else {
var arq_bytes_per_minute_compressed = Math.round(arg.arq_bytes_per_minute * arg.arq_compression_factor);
}
document.getElementById("bytes_per_min_compressed").innerHTML = arq_bytes_per_minute_compressed;
// SET SPEED LEVEL
if(arg.speed_level >= 0) {
document.getElementById("speed_level").className = "bi bi-reception-1";
}
if(arg.speed_level >= 1) {
document.getElementById("speed_level").className = "bi bi-reception-2";
}
if(arg.speed_level >= 2) {
document.getElementById("speed_level").className = "bi bi-reception-3";
}
if(arg.speed_level >= 3) {
document.getElementById("speed_level").className = "bi bi-reception-4";
}
if(arg.speed_level >= 4) {
document.getElementById("speed_level").className = "bi bi-reception-4";
}
2021-09-04 18:23:58 +00:00
// SET TOTAL BYTES
if (typeof(arg.total_bytes) == 'undefined') {
var total_bytes = 0;
2021-08-15 14:48:48 +00:00
} else {
var total_bytes = arg.total_bytes;
2021-09-04 18:23:58 +00:00
}
document.getElementById("total_bytes").innerHTML = total_bytes;
document.getElementById("transmission_progress").setAttribute("aria-valuenow", arg.arq_transmission_percent);
document.getElementById("transmission_progress").setAttribute("style", "width:" + arg.arq_transmission_percent + "%;");
2021-09-04 18:23:58 +00:00
2021-09-13 16:27:50 +00:00
// UPDATE HEARD STATIONS
2021-09-04 18:23:58 +00:00
var tbl = document.getElementById("heardstations");
document.getElementById("heardstations").innerHTML = '';
2021-08-07 18:57:36 +00:00
2021-09-04 18:23:58 +00:00
if (typeof(arg.stations) == 'undefined') {
var heardStationsLength = 0;
2021-08-08 09:09:18 +00:00
} else {
var heardStationsLength = arg.stations.length;
2021-08-08 09:09:18 +00:00
}
2021-08-07 18:57:36 +00:00
2021-09-04 18:23:58 +00:00
for (i = 0; i < heardStationsLength; i++) {
2021-08-07 18:57:36 +00:00
// first we update the PING window
if (arg.stations[i]['dxcallsign'] == document.getElementById("dxCall").value) {
var dxGrid = arg.stations[i]['dxgrid'];
var myGrid = document.getElementById("myGrid").value;
2021-09-04 18:23:58 +00:00
try {
var dist = parseInt(distance(myGrid, dxGrid)) + ' km';
document.getElementById("pingDistance").innerHTML = dist;
document.getElementById("dataModalPingDistance").innerHTML = dist;
2021-09-04 18:23:58 +00:00
} catch {
document.getElementById("pingDistance").innerHTML = '---';
document.getElementById("dataModalPingDistance").innerHTML = '---';
2021-09-04 18:23:58 +00:00
}
document.getElementById("pingDB").innerHTML = arg.stations[i]['snr'];
document.getElementById("dataModalPingDB").innerHTML = arg.stations[i]['snr'];
2021-08-07 18:57:36 +00:00
}
// now we update the heard stations list
var row = document.createElement("tr");
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/q/51421470
2021-08-07 18:57:36 +00:00
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/a/847196
timestampRaw = arg.stations[i]['timestamp'];
2021-08-07 18:57:36 +00:00
var date = new Date(timestampRaw * 1000);
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var seconds = "0" + date.getSeconds();
var datetime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
var timestamp = document.createElement("td");
var timestampText = document.createElement('span');
timestampText.innerText = datetime;
2021-08-07 18:57:36 +00:00
timestamp.appendChild(timestampText);
var frequency = document.createElement("td");
var frequencyText = document.createElement('span');
frequencyText.innerText = arg.stations[i]['frequency'];
frequency.appendChild(frequencyText);
2021-08-07 18:57:36 +00:00
var dxCall = document.createElement("td");
var dxCallText = document.createElement('span');
dxCallText.innerText = arg.stations[i]['dxcallsign'];
2021-08-07 18:57:36 +00:00
dxCall.appendChild(dxCallText);
var dxGrid = document.createElement("td");
var dxGridText = document.createElement('span');
dxGridText.innerText = arg.stations[i]['dxgrid'];
2021-08-07 18:57:36 +00:00
dxGrid.appendChild(dxGridText);
2021-08-08 17:29:18 +00:00
var gridDistance = document.createElement("td");
var gridDistanceText = document.createElement('span');
2021-09-04 18:23:58 +00:00
try {
gridDistanceText.innerText = parseInt(distance(document.getElementById("myGrid").value, arg.stations[i]['dxgrid'])) + ' km';
2021-08-08 17:29:18 +00:00
} catch {
gridDistanceText.innerText = '---';
2021-08-08 17:29:18 +00:00
}
2021-09-04 18:23:58 +00:00
gridDistance.appendChild(gridDistanceText);
2021-08-07 18:57:36 +00:00
var dataType = document.createElement("td");
var dataTypeText = document.createElement('span');
dataTypeText.innerText = arg.stations[i]['datatype'];
dataType.appendChild(dataTypeText);
if(arg.stations[i]['datatype'] == 'DATA-CHANNEL'){
dataTypeText.innerText = 'DATA-C';
dataType.appendChild(dataTypeText);
}
if(arg.stations[i]['datatype'] == 'SESSION-HB'){
dataTypeText.innerHTML = '<i class="bi bi-heart-pulse-fill"></i>';
dataType.appendChild(dataTypeText);
}
console.log(dataTypeText.innerText)
2021-09-04 18:23:58 +00:00
if (dataTypeText.innerText == 'CQ CQ CQ') {
2021-08-07 18:57:36 +00:00
row.classList.add("table-success");
2021-08-07 18:57:36 +00:00
}
2021-09-04 18:23:58 +00:00
if (dataTypeText.innerText == 'DATA-C') {
dataTypeText.innerHTML = '<i class="bi bi-file-earmark-binary-fill"></i>';
2021-08-07 18:57:36 +00:00
row.classList.add("table-warning");
}
2021-09-04 18:23:58 +00:00
if (dataTypeText.innerText == 'BEACON') {
2021-08-07 18:57:36 +00:00
row.classList.add("table-light");
}
2021-09-04 18:23:58 +00:00
if (dataTypeText.innerText == 'PING') {
2021-08-07 18:57:36 +00:00
row.classList.add("table-info");
}
2021-09-04 18:23:58 +00:00
if (dataTypeText.innerText == 'PING-ACK') {
row.classList.add("table-primary");
}
2021-08-07 18:57:36 +00:00
var snr = document.createElement("td");
var snrText = document.createElement('span');
snrText.innerText = arg.stations[i]['snr'];
2021-08-07 18:57:36 +00:00
snr.appendChild(snrText);
2021-09-04 18:23:58 +00:00
var offset = document.createElement("td");
var offsetText = document.createElement('span');
offsetText.innerText = arg.stations[i]['offset'];
offset.appendChild(offsetText);
2021-08-07 18:57:36 +00:00
row.appendChild(timestamp);
row.appendChild(frequency);
2021-08-07 18:57:36 +00:00
row.appendChild(dxCall);
row.appendChild(dxGrid);
2021-08-08 17:29:18 +00:00
row.appendChild(gridDistance);
2021-08-07 18:57:36 +00:00
row.appendChild(dataType);
row.appendChild(snr);
row.appendChild(offset);
2021-08-07 18:57:36 +00:00
tbl.appendChild(row);
}
// DISPLAY INFO TOASTS
if (typeof(arg.info) == 'undefined') {
var infoLength = 0;
} else {
var infoLength = arg.info.length;
}
2021-07-17 07:03:40 +00:00
for (i = 0; i < infoLength; i++) {
// SENDING CQ TOAST
if (arg.info[i] == "CQ;SENDING"){
var toastCQsending = document.getElementById('toastCQsending');
var toast = bootstrap.Toast.getOrCreateInstance(toastCQsending); // Returns a Bootstrap toast instance
toast.show();
}
// RECEIVING CQ TOAST
if (arg.info[i] == "CQ;RECEIVING"){
var toastCQreceiving = document.getElementById('toastCQreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastCQreceiving); // Returns a Bootstrap toast instance
toast.show();
}
// RECEIVING BEACON TOAST
if (arg.info[i] == "BEACON;RECEIVING"){
var toastBEACONreceiving = document.getElementById('toastBEACONreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastBEACONreceiving); // Returns a Bootstrap toast instance
toast.show();
}
// SENDING PING TOAST
if (arg.info[i] == "PING;SENDING"){
var toastPINGsending = document.getElementById('toastPINGsending');
var toast = bootstrap.Toast.getOrCreateInstance(toastPINGsending); // Returns a Bootstrap toast instance
toast.show();
}
// RECEIVING PING TOAST
if (arg.info[i] == "PING;RECEIVING"){
var toastPINGreceiving = document.getElementById('toastPINGreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastPINGreceiving); // Returns a Bootstrap toast instance
toast.show();
}
// RECEIVING PING ACK TOAST
if (arg.info[i] == "PING;RECEIVEDACK"){
var toastPINGreceivedACK = document.getElementById('toastPINGreceivedACK');
var toast = bootstrap.Toast.getOrCreateInstance(toastPINGreceivedACK); // Returns a Bootstrap toast instance
toast.show();
}
// DATACHANNEL OPENING TOAST
if (arg.info[i] == "DATACHANNEL;OPENING"){
var toastDATACHANNELopening = document.getElementById('toastDATACHANNELopening');
var toast = bootstrap.Toast.getOrCreateInstance(toastDATACHANNELopening); // Returns a Bootstrap toast instance
toast.show();
}
// DATACHANNEL OPEN TOAST
if (arg.info[i] == "DATACHANNEL;OPEN"){
var toastDATACHANNELopen = document.getElementById('toastDATACHANNELopen');
var toast = bootstrap.Toast.getOrCreateInstance(toastDATACHANNELopen); // Returns a Bootstrap toast instance
toast.show();
}
// DATACHANNEL RECEIVEDOPENER TOAST
if (arg.info[i] == "DATACHANNEL;RECEIVEDOPENER"){
var toastDATACHANNELreceivedopener = document.getElementById('toastDATACHANNELreceivedopener');
var toast = bootstrap.Toast.getOrCreateInstance(toastDATACHANNELreceivedopener); // Returns a Bootstrap toast instance
toast.show();
}
// TRANSMISSION STOPPED
if (arg.info[i] == "TRANSMISSION;STOPPED"){
var toastDATACHANNELreceivedopener = document.getElementById('toastTRANSMISSIONstopped');
var toast = bootstrap.Toast.getOrCreateInstance(toastDATACHANNELreceivedopener); // Returns a Bootstrap toast instance
toast.show();
}
// DATACHANNEL FAILED TOAST
if (arg.info[i] == "DATACHANNEL;FAILED"){
var toastDATACHANNELfailed = document.getElementById('toastDATACHANNELfailed');
var toast = bootstrap.Toast.getOrCreateInstance(toastDATACHANNELfailed); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ RECEIVING TOAST
if (arg.info[i] == "ARQ;RECEIVING"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped progress-bar-animated bg-primary";
var toastARQreceiving = document.getElementById('toastARQreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQreceiving); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ RECEIVING SUCCESS TOAST
console.log(arg.info[i])
if (arg.info[i] == "ARQ;RECEIVING;SUCCESS"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped bg-success";
var toastARQreceivingsuccess = document.getElementById('toastARQreceivingsuccess');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQreceivingsuccess); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ RECEIVING FAILED TOAST
if (arg.info[i] == "ARQ;RECEIVING;FAILED"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped bg-danger";
var toastARQreceivingfailed = document.getElementById('toastARQreceivingfailed');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQreceivingfailed); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ TRANSMITTING TOAST
if (arg.info[i] == "ARQ;TRANSMITTING"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped progress-bar-animated bg-primary";
var toastARQtransmitting = document.getElementById('toastARQtransmitting');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQtransmitting); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ TRANSMITTING SUCCESS TOAST
if (arg.info[i] == "ARQ;TRANSMITTING;SUCCESS"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped bg-success";
var toastARQtransmittingsuccess = document.getElementById('toastARQtransmittingsuccess');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQtransmittingsuccess); // Returns a Bootstrap toast instance
toast.show();
}
// ARQ TRANSMITTING FAILED TOAST
if (arg.info[i] == "ARQ;TRANSMITTING;FAILED"){
2022-01-05 12:03:29 +00:00
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped bg-danger";
var toast = bootstrap.Toast.getOrCreateInstance(toastARQtransmittingfailed); // Returns a Bootstrap toast instance
toast.show();
}
}
2021-09-04 18:23:58 +00:00
});
2021-07-17 07:03:40 +00:00
ipcRenderer.on('action-update-daemon-state', (event, arg) => {
/*
// deactivetd RAM und CPU view so we dont get errors. We need to find a new place for this feature
2021-07-25 14:18:29 +00:00
// RAM
document.getElementById("progressbar_ram").setAttribute("aria-valuenow", arg.ram_usage)
document.getElementById("progressbar_ram").setAttribute("style", "width:" + arg.ram_usage + "%;")
document.getElementById("progressbar_ram_value").innerHTML = arg.ram_usage + "%"
2021-08-07 08:54:34 +00:00
2021-07-25 14:18:29 +00:00
// CPU
document.getElementById("progressbar_cpu").setAttribute("aria-valuenow", arg.cpu_usage)
document.getElementById("progressbar_cpu").setAttribute("style", "width:" + arg.cpu_usage + "%;")
document.getElementById("progressbar_cpu_value").innerHTML = arg.cpu_usage + "%"
*/
/*
document.getElementById("ram_load").innerHTML = arg.ram_usage + "%"
document.getElementById("cpu_load").innerHTML = arg.cpu_usage + "%"
*/
2021-12-20 17:05:00 +00:00
// OPERATING SYSTEM
//document.getElementById("operating_system").innerHTML = "OS " + os.type()
2021-12-20 17:05:00 +00:00
/*
2021-12-20 17:05:00 +00:00
// PYTHON VERSION
document.getElementById("python_version").innerHTML = "Python " + arg.python_version
document.getElementById("python_version").className = "btn btn-sm btn-success";
*/
/*
2021-12-20 17:05:00 +00:00
// HAMLIB VERSION
document.getElementById("hamlib_version").innerHTML = "Hamlib " + arg.hamlib_version
document.getElementById("hamlib_version").className = "btn btn-sm btn-success";
*/
/*
2021-12-20 17:05:00 +00:00
// NODE VERSION
document.getElementById("node_version").innerHTML = "Node " + process.version
document.getElementById("node_version").className = "btn btn-sm btn-success";
*/
2021-12-20 17:05:00 +00:00
2021-07-24 07:06:22 +00:00
// UPDATE AUDIO INPUT
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("audio_input_selectbox").length != arg.input_devices.length) {
document.getElementById("audio_input_selectbox").innerHTML = "";
for (i = 0; i < arg.input_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.input_devices[i]['name'];
option.value = arg.input_devices[i]['id'];
// set device from config if available
2021-12-27 14:28:58 +00:00
if(config.rx_audio == option.text){
option.setAttribute('selected', true);
}
document.getElementById("audio_input_selectbox").add(option);
}
2021-07-17 07:03:40 +00:00
}
}
// UPDATE AUDIO OUTPUT
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("audio_output_selectbox").length != arg.output_devices.length) {
document.getElementById("audio_output_selectbox").innerHTML = "";
for (i = 0; i < arg.output_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.output_devices[i]['name'];
option.value = arg.output_devices[i]['id'];
// set device from config if available
if(config.tx_audio == option.text){
option.setAttribute('selected', true);
}
document.getElementById("audio_output_selectbox").add(option);
}
2021-07-17 07:03:40 +00:00
}
}
2021-07-24 07:06:22 +00:00
2021-09-04 20:27:01 +00:00
// UPDATE SERIAL DEVICES
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("hamlib_deviceport").length != arg.serial_devices.length) {
document.getElementById("hamlib_deviceport").innerHTML = "";
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['description'];
option.value = arg.serial_devices[i]['port'];
// set device from config if available
if(config.deviceport == option.value){
option.setAttribute('selected', true);
}
document.getElementById("hamlib_deviceport").add(option);
}
2021-09-04 20:27:01 +00:00
}
// advanced settings
if (document.getElementById("hamlib_deviceport_advanced").length != arg.serial_devices.length) {
document.getElementById("hamlib_deviceport_advanced").innerHTML = "";
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['description'];
option.value = arg.serial_devices[i]['port'];
// set device from config if available
if(config.deviceport == option.value){
option.setAttribute('selected', true);
}
document.getElementById("hamlib_deviceport_advanced").add(option);
}
}
// rigctl settings
if (document.getElementById("hamlib_deviceport_rigctl").length != arg.serial_devices.length) {
document.getElementById("hamlib_deviceport_rigctl").innerHTML = "";
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['description'];
option.value = arg.serial_devices[i]['port'];
// set device from config if available
if(config.deviceport == option.value){
option.setAttribute('selected', true);
}
document.getElementById("hamlib_deviceport_rigctl").add(option);
}
}
2021-09-04 20:27:01 +00:00
}
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("hamlib_ptt_port_advanced").length != arg.serial_devices.length) {
document.getElementById("hamlib_ptt_port_advanced").innerHTML = "";
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['description'];
option.value = arg.serial_devices[i]['port'];
// set device from config if available
if(config.pttport == option.value){
option.setAttribute('selected', true);
}
document.getElementById("hamlib_ptt_port_advanced").add(option);
}
}
2021-09-13 18:02:14 +00:00
}
2022-02-12 15:34:47 +00:00
});
// ACTION UPDATE HAMLIB TEST
ipcRenderer.on('action-update-hamlib-test', (event, arg) => {
console.log(arg.hamlib_result);
if (arg.hamlib_result == 'SUCCESS') {
document.getElementById("testHamlib").className = "btn btn-sm btn-success";
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-success";
}
if (arg.hamlib_result == 'NOSUCCESS') {
document.getElementById("testHamlib").className = "btn btn-sm btn-warning";
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-warning";
}
if (arg.hamlib_result == 'FAILED') {
document.getElementById("testHamlib").className = "btn btn-sm btn-danger";
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-danger";
}
});
ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
if (arg.daemon_connection == 'open') {
document.getElementById("daemon_connection_state").className = "btn btn-success";
//document.getElementById("blurdiv").style.webkitFilter = "blur(0px)";
}
if (arg.daemon_connection == 'opening') {
document.getElementById("daemon_connection_state").className = "btn btn-warning";
//document.getElementById("blurdiv").style.webkitFilter = "blur(10px)";
}
if (arg.daemon_connection == 'closed') {
document.getElementById("daemon_connection_state").className = "btn btn-danger";
//document.getElementById("blurdiv").style.webkitFilter = "blur(10px)";
}
});
ipcRenderer.on('action-update-tnc-connection', (event, arg) => {
if (arg.tnc_connection == "open") {
document.getElementById('hamlib_deviceid').disabled = true;
document.getElementById('hamlib_deviceport').disabled = true;
document.getElementById('advancedHamlibSettingsButton').disabled = true;
document.getElementById('testHamlib').disabled = true;
document.getElementById('hamlib_ptt_protocol').disabled = true;
document.getElementById('audio_input_selectbox').disabled = true;
document.getElementById('audio_output_selectbox').disabled = true;
2022-02-15 17:10:14 +00:00
//document.getElementById('stopTNC').disabled = false;
document.getElementById('startTNC').disabled = true;
document.getElementById('dxCall').disabled = false;
document.getElementById("hamlib_serialspeed").disabled = true;
document.getElementById("openDataModule").disabled = false;
2021-08-28 16:46:49 +00:00
// collapse settings screen
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
collapseFirstRow.hide();
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
collapseSecondRow.hide();
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
collapseThirdRow.show();
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.show();
2021-07-17 07:03:40 +00:00
} else {
document.getElementById('hamlib_deviceid').disabled = false;
document.getElementById('hamlib_deviceport').disabled = false;
document.getElementById('advancedHamlibSettingsButton').disabled = false;
document.getElementById('testHamlib').disabled = false;
document.getElementById('hamlib_ptt_protocol').disabled = false;
document.getElementById('audio_input_selectbox').disabled = false;
document.getElementById('audio_output_selectbox').disabled = false;
2022-02-15 17:10:14 +00:00
//document.getElementById('stopTNC').disabled = true;
document.getElementById('startTNC').disabled = false;
document.getElementById('dxCall').disabled = true;
document.getElementById("hamlib_serialspeed").disabled = false;
document.getElementById("openDataModule").disabled = true;
// collapse settings screen
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
collapseFirstRow.show();
var collapseSecondRow = new bootstrap.Collapse(document.getElementById('collapseSecondRow'), {toggle: false})
collapseSecondRow.show();
var collapseThirdRow = new bootstrap.Collapse(document.getElementById('collapseThirdRow'), {toggle: false})
collapseThirdRow.hide();
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.hide();
}
2021-07-25 14:35:50 +00:00
2021-07-17 07:03:40 +00:00
2021-07-24 07:06:22 +00:00
});
2021-07-17 07:03:40 +00:00
2021-08-22 15:00:18 +00:00
ipcRenderer.on('action-update-rx-buffer', (event, arg) => {
var data = arg.data["data"];
2021-08-22 15:00:18 +00:00
var tbl = document.getElementById("rx-data");
document.getElementById("rx-data").innerHTML = '';
2021-08-22 15:32:56 +00:00
2021-08-23 14:24:49 +00:00
for (i = 0; i < arg.data.length; i++) {
2021-08-22 15:32:56 +00:00
2021-08-07 08:54:34 +00:00
// first we update the PING window
if (arg.data[i]['dxcallsign'] == document.getElementById("dxCall").value) {
2021-09-24 14:43:45 +00:00
/*
// if we are sending data without doing a ping before, we don't have a grid locator available. This could be a future feature for the TNC!
if(arg.data[i]['DXGRID'] != ''){
document.getElementById("pingDistance").innerHTML = arg.stations[i]['DXGRID']
}
*/
document.getElementById("pingDB").innerHTML = arg.stations[i]['snr'];
2021-07-28 16:44:10 +00:00
2021-08-07 08:54:34 +00:00
}
2021-07-28 16:44:10 +00:00
2021-09-24 14:43:45 +00:00
// now we update the received files list
2021-08-07 08:54:34 +00:00
var row = document.createElement("tr");
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/q/51421470
2021-07-25 16:19:51 +00:00
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/a/847196
timestampRaw = arg.data[i]['timestamp']
2021-08-07 08:54:34 +00:00
var date = new Date(timestampRaw * 1000);
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var seconds = "0" + date.getSeconds();
var datetime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
2021-07-25 16:19:51 +00:00
2021-08-07 08:54:34 +00:00
var timestamp = document.createElement("td");
var timestampText = document.createElement('span');
timestampText.innerText = datetime;
2021-08-07 08:54:34 +00:00
timestamp.appendChild(timestampText);
2021-07-25 16:19:51 +00:00
2021-08-07 08:54:34 +00:00
var dxCall = document.createElement("td");
var dxCallText = document.createElement('span');
dxCallText.innerText = arg.data[i]['dxcallsign'];
2021-08-07 08:54:34 +00:00
dxCall.appendChild(dxCallText);
2021-07-25 16:19:51 +00:00
2021-09-04 18:23:58 +00:00
/*
var dxGrid = document.createElement("td");
var dxGridText = document.createElement('span');
dxGridText.innerText = arg.data[i]['DXGRID']
dxGrid.appendChild(dxGridText);
*/
2021-08-07 08:54:34 +00:00
console.log(arg.data);
var encoded_data = atob(arg.data[i]['data']);
var splitted_data = encoded_data.split(split_char);
console.log(splitted_data);
2021-08-22 15:23:36 +00:00
var fileName = document.createElement("td");
var fileNameText = document.createElement('span');
//var fileNameString = arg.data[i]['data'][0]['fn'];
var fileNameString = splitted_data[1];
fileNameText.innerText = fileNameString;
2021-08-22 15:23:36 +00:00
fileName.appendChild(fileNameText);
2021-08-07 08:54:34 +00:00
row.appendChild(timestamp);
row.appendChild(dxCall);
2021-09-04 18:23:58 +00:00
// row.appendChild(dxGrid);
2021-08-22 15:23:36 +00:00
row.appendChild(fileName);
2021-08-07 08:54:34 +00:00
tbl.appendChild(row);
2021-09-04 18:23:58 +00:00
// https://stackoverflow.com/a/26227660
var appDataFolder = process.env.HOME;
console.log("appDataFolder:" + appDataFolder);
2021-09-13 16:27:50 +00:00
var applicationFolder = path.join(appDataFolder, "FreeDATA");
console.log(applicationFolder);
2021-09-10 15:59:33 +00:00
var receivedFilesFolder = path.join(applicationFolder, "receivedFiles");
console.log("receivedFilesFolder: " + receivedFilesFolder);
2021-09-10 15:59:33 +00:00
// Creates receivedFiles folder if not exists
2021-08-23 13:36:14 +00:00
// https://stackoverflow.com/a/13544465
2021-09-10 15:59:33 +00:00
fs.mkdir(receivedFilesFolder, {
2021-09-04 18:23:58 +00:00
recursive: true
}, function(err) {
2021-08-23 13:36:14 +00:00
console.log(err);
2021-08-22 16:04:49 +00:00
});
2021-09-04 18:23:58 +00:00
2021-09-10 15:59:33 +00:00
// write file to data folder
////var base64String = arg.data[i]['data'][0]['d']
2021-08-23 13:36:14 +00:00
// remove header from base64 String
// https://www.codeblocq.com/2016/04/Convert-a-base64-string-to-a-file-in-Node/
////var base64Data = base64String.split(';base64,').pop()
//write data to file
var base64Data = splitted_data[4];
2021-09-10 15:59:33 +00:00
var receivedFile = path.join(receivedFilesFolder, fileNameString);
console.log(receivedFile);
2021-09-10 15:59:33 +00:00
require("fs").writeFile(receivedFile, base64Data, 'binary', function(err) {
//require("fs").writeFile(receivedFile, base64Data, 'base64', function(err) {
console.log(err);
2021-09-04 18:23:58 +00:00
});
2021-08-07 08:54:34 +00:00
}
});
2021-08-22 15:00:18 +00:00
2021-07-24 07:06:22 +00:00
ipcRenderer.on('run-tnc-command', (event, arg) => {
if (arg.command == 'save_my_call') {
sock.saveMyCall(arg.callsign);
}
if (arg.command == 'save_my_grid') {
sock.saveMyGrid(arg.grid);
}
2021-07-24 07:06:22 +00:00
if (arg.command == 'ping') {
sock.sendPing(arg.dxcallsign);
2021-07-24 07:06:22 +00:00
}
2021-08-07 08:54:34 +00:00
if (arg.command == 'send_file') {
sock.sendFile(arg.dxcallsign, arg.mode, arg.frames, arg.filename, arg.filetype, arg.data, arg.checksum);
2021-07-26 16:09:04 +00:00
}
if (arg.command == 'send_message') {
sock.sendMessage(arg.dxcallsign, arg.mode, arg.frames, arg.data, arg.checksum);
2021-08-07 08:54:34 +00:00
}
if (arg.command == 'stop_transmission') {
sock.stopTransmission();
}
2021-09-05 09:26:09 +00:00
});
2022-02-22 14:40:33 +00:00
2022-02-22 14:53:55 +00:00
// IPC ACTION FOR AUTO UPDATER
2022-02-22 14:40:33 +00:00
ipcRenderer.on('action-updater', (event, arg) => {
if (arg.status == "download-progress"){
bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateAvailable')).hide(); // close our update available notification
2022-02-22 14:40:33 +00:00
var progressinfo = '(' + Math.round(arg.progress.transferred/1024) + 'kB /' + Math.round(arg.progress.total/1024) + 'kB)';
document.getElementById("toastUpdateProgressInfo").innerHTML = progressinfo;
document.getElementById("toastUpdateProgressSpeed").innerHTML = Math.round(arg.progress.bytesPerSecond/1024) + "kByte/s";
document.getElementById("toastUpdateProgressBar").setAttribute("aria-valuenow", arg.progress.percent)
document.getElementById("toastUpdateProgressBar").setAttribute("style", "width:" + arg.progress.percent + "%;")
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateProgress')
); // Returns a Bootstrap toast instance
let showing = document.getElementById("toastUpdateProgress").getAttribute("class").includes("showing");
if(!showing){
toast.show();
2022-02-22 14:40:33 +00:00
}
}
if (arg.status == "checking-for-update"){
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateChecking')
2022-02-22 14:40:33 +00:00
); // Returns a Bootstrap toast instance
toast.show();
document.title = "FreeDATA by DJ2LS" + ' - v' + arg.version;
2022-02-22 14:40:33 +00:00
}
if (arg.status == "update-downloaded"){
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateDownloaded')
); // Returns a Bootstrap toast instance
toast.show();
}
if (arg.status == "update-not-available"){
bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateChecking')).hide();
2022-02-22 14:40:33 +00:00
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateNotAvailable')
); // Returns a Bootstrap toast instance
toast.show();
}
if (arg.status == "update-available"){
bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateChecking')).hide();
2022-02-22 14:40:33 +00:00
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateAvailable')
); // Returns a Bootstrap toast instance
toast.show();
}
if (arg.status == "error"){
var toast = bootstrap.Toast.getOrCreateInstance(
document.getElementById('toastUpdateNotChecking')
); // Returns a Bootstrap toast instance
toast.show();
2022-02-22 14:40:33 +00:00
}
});