2023-02-11 21:49:07 +00:00
const path = require ( "path" ) ;
2023-02-15 21:12:38 +00:00
const { ipcRenderer , shell , clipboard } = require ( "electron" ) ;
2023-02-11 21:49:07 +00:00
const exec = require ( "child_process" ) . spawn ;
const sock = require ( "./sock.js" ) ;
const daemon = require ( "./daemon.js" ) ;
const fs = require ( "fs" ) ;
2023-03-03 03:05:45 +00:00
const FD = require ( "./freedata" ) ;
2021-09-04 18:23:58 +00:00
const {
2023-02-11 21:49:07 +00:00
locatorToLatLng ,
distance ,
bearingDistance ,
latLngToLocator ,
} = require ( "qth-locator" ) ;
2023-02-11 09:23:04 +00:00
2023-02-11 21:49:07 +00:00
const { v4 : uuidv4 } = require ( "uuid" ) ;
2023-02-11 09:23:04 +00:00
2023-02-11 21:49:07 +00:00
const os = require ( "os" ) ;
2021-09-04 18:23:58 +00:00
2022-11-17 21:17:50 +00:00
// split character used for appending additional data to files
2023-02-11 21:49:07 +00:00
const split _char = "\0;" ;
2022-02-02 20:12:16 +00:00
2021-09-04 18:23:58 +00:00
// https://stackoverflow.com/a/26227660
2023-02-11 21:49:07 +00:00
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" ) ;
2023-02-11 21:49:07 +00:00
var configPath = path . join ( configFolder , "config.json" ) ;
2023-03-03 03:05:45 +00:00
var config = require ( configPath ) ;
2023-07-03 07:26:42 +00:00
2023-02-11 21:49:07 +00:00
const contrib = [
"DK5SM" ,
"DL4IAZ" ,
"DB1UJ" ,
"EI3HIB" ,
"VK5DGR" ,
"EI7IG" ,
"N2KIQ" ,
"KT4WO" ,
"DF7MH" ,
"G0HWW" ,
"N1QM" ,
2023-05-25 20:00:47 +00:00
"LA3QMA" ,
2023-02-11 21:49:07 +00:00
] ;
2022-11-18 14:19:41 +00:00
2023-02-12 13:44:13 +00:00
//let elements = document.querySelectorAll('[id^="hamlib_"]'); // get all elements starting with...
2023-02-12 14:44:38 +00:00
const hamlib _elements = [
"hamlib_deviceid" ,
"hamlib_deviceport" ,
"hamlib_stop_bits" ,
"hamlib_data_bits" ,
"hamlib_handshake" ,
"hamlib_serialspeed" ,
"hamlib_dtrstate" ,
"hamlib_pttprotocol" ,
"hamlib_ptt_port" ,
"hamlib_dcd" ,
"hamlib_rigctld_port" ,
"hamlib_rigctld_ip" ,
"hamlib_rigctld_path" ,
"hamlib_rigctld_server_port" ,
2023-02-12 17:40:50 +00:00
"hamlib_rigctld_custom_args" ,
2023-02-12 14:44:38 +00:00
] ;
2023-02-12 13:44:13 +00:00
2022-11-18 14:19:41 +00:00
// SET dbfs LEVEL GLOBAL
// this is an attempt of reducing CPU LOAD
// we are going to check if we have unequal values before we start calculating again
2023-02-11 21:49:07 +00:00
var dbfs _level _raw = 0 ;
2023-02-14 14:18:08 +00:00
var noise _level _raw = 0 ;
2023-01-22 19:36:05 +00:00
//Global version variable
var appVer = null ;
2022-11-18 14:19:41 +00:00
2023-07-02 13:43:54 +00:00
//Track the number of times TNC has been started
//So that warning is shown when using auto start and 2nd start
//if hamlib is not running
var tncStartCount = 0 ;
2023-05-20 18:43:27 +00:00
2021-07-23 15:40:44 +00:00
// START INTERVALL COMMAND EXECUTION FOR STATES
2022-03-12 14:06:49 +00:00
//setInterval(sock.getRxBuffer, 1000);
2021-07-24 07:06:22 +00:00
// WINDOW LISTENER
2023-02-11 21:49:07 +00:00
window . addEventListener ( "DOMContentLoaded" , ( ) => {
// save frequency event listener
document . getElementById ( "saveFrequency" ) . addEventListener ( "click" , ( ) => {
var freq = document . getElementById ( "newFrequency" ) . value ;
console . log ( freq ) ;
let Data = {
type : "set" ,
command : "frequency" ,
frequency : freq ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2023-01-04 20:07:46 +00:00
2023-02-11 21:49:07 +00:00
// enter button for input field
document
. getElementById ( "newFrequency" )
. addEventListener ( "keypress" , function ( event ) {
2023-01-04 20:07:46 +00:00
if ( event . key === "Enter" ) {
event . preventDefault ( ) ;
document . getElementById ( "saveFrequency" ) . click ( ) ;
}
} ) ;
2023-02-11 21:49:07 +00:00
// save mode event listener
document . getElementById ( "saveModePKTUSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "PKTUSB" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2023-05-25 20:00:47 +00:00
// save mode event listener
document . getElementById ( "saveModeDIGU" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "DIGU" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
// save mode event listener
document . getElementById ( "saveModeDIGL" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "DIGL" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2022-12-26 11:11:59 +00:00
2023-02-11 21:49:07 +00:00
// save mode event listener
document . getElementById ( "saveModeUSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "USB" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2022-12-26 11:11:59 +00:00
2023-02-11 21:49:07 +00:00
// save mode event listener
document . getElementById ( "saveModeLSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "LSB" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2022-12-26 11:11:59 +00:00
2023-02-11 21:49:07 +00:00
// save mode event listener
document . getElementById ( "saveModeAM" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "AM" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
2022-03-10 18:45:37 +00:00
2023-02-11 21:49:07 +00:00
// save mode event listener
document . getElementById ( "saveModeFM" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "FM" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
// start stop audio recording event listener
document
. getElementById ( "startStopRecording" )
. addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "record_audio" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
document
. getElementById ( "received_files_folder" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "get-folder-path" , {
title : "Title" ,
2023-02-28 12:55:11 +00:00
action : "return-folder-paths-received_files_folder" ,
2023-02-11 21:49:07 +00:00
} ) ;
2023-02-28 12:55:54 +00:00
ipcRenderer . on (
"return-folder-paths-received_files_folder" ,
( event , data ) => {
document . getElementById ( "received_files_folder" ) . value =
data . path . filePaths [ 0 ] ;
config . received _files _folder = data . path . filePaths [ 0 ] ;
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-07-05 16:43:56 +00:00
} ,
2023-02-28 12:55:54 +00:00
) ;
2022-03-10 18:45:37 +00:00
} ) ;
2023-02-28 12:55:11 +00:00
document
. getElementById ( "shared_folder_path" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "get-folder-path" , {
title : "Title" ,
action : "return-folder-paths-shared_folder_path" ,
} ) ;
2023-02-28 12:55:54 +00:00
ipcRenderer . on (
"return-folder-paths-shared_folder_path" ,
( event , data ) => {
document . getElementById ( "shared_folder_path" ) . value =
data . path . filePaths [ 0 ] ;
config . shared _folder _path = data . path . filePaths [ 0 ] ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-28 12:55:54 +00:00
) ;
2023-02-28 12:55:11 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
document
. getElementById ( "openReceivedFilesFolder" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "open-folder" , {
2022-03-10 18:45:37 +00:00
path : config . received _files _folder ,
2023-02-11 21:49:07 +00:00
} ) ;
2022-03-10 18:45:37 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
/ *
2021-11-07 11:17:23 +00:00
// 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 )
} )
* /
2023-02-11 21:49:07 +00:00
// ENABLE TOOLTIPS EVERYWHERE
// https://getbootstrap.com/docs/5.1/components/tooltips/
var tooltipTriggerList = [ ] . slice . call (
2023-07-05 16:43:56 +00:00
document . querySelectorAll ( '[data-bs-toggle="tooltip"]' ) ,
2023-02-11 21:49:07 +00:00
) ;
var tooltipList = tooltipTriggerList . map ( function ( tooltipTriggerEl ) {
return new bootstrap . Tooltip ( tooltipTriggerEl ) ;
} ) ;
// LOAD SETTINGS
2023-02-12 13:44:13 +00:00
// load settings by function
loadSettings ( hamlib _elements ) ;
2023-02-11 21:49:07 +00:00
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.title = document.title + ' - Call: ' + config.mycall;
updateTitle ( ) ;
document . getElementById ( "myCallSSID" ) . value = ssid ;
document . getElementById ( "myGrid" ) . value = config . mygrid ;
// hamlib settings
document . getElementById ( "hamlib_deviceid" ) . value = config . hamlib _deviceid ;
document . getElementById ( "hamlib_rigctld_ip" ) . value = config . hamlib _rigctld _ip ;
document . getElementById ( "hamlib_rigctld_port" ) . value =
config . hamlib _rigctld _port ;
2023-05-20 07:54:56 +00:00
document . getElementById ( "tci_ip" ) . value = config . tci _ip ;
document . getElementById ( "tci_port" ) . value = config . tci _port ;
2023-05-17 13:38:52 +00:00
2023-02-11 21:49:07 +00:00
document . getElementById ( "hamlib_rigctld_path" ) . value =
config . hamlib _rigctld _path ;
document . getElementById ( "hamlib_rigctld_server_port" ) . value =
config . hamlib _rigctld _server _port ;
2023-05-12 07:40:44 +00:00
// running this in try catch for setting default value in case of wrong beacon intervals
2023-05-12 08:15:13 +00:00
// https://stackoverflow.com/a/69293164
2023-05-12 08:15:46 +00:00
console . log ( config . beacon _interval ) ;
let selectElement = document . getElementById ( "beaconInterval" ) ;
let optionValues = [ ... selectElement . options ] . map ( ( o ) => o . value ) ;
2023-05-12 08:15:13 +00:00
console . log ( optionValues ) ;
2023-05-12 08:15:46 +00:00
if ( optionValues . includes ( config . beacon _interval ) ) {
document . getElementById ( "beaconInterval" ) . value = config . beacon _interval ;
2023-05-12 08:15:13 +00:00
} else {
2023-05-12 08:15:46 +00:00
document . getElementById ( "beaconInterval" ) . value = "300" ;
2023-05-12 07:40:44 +00:00
}
2023-05-12 08:15:13 +00:00
2023-02-11 21:49:07 +00:00
document . getElementById ( "scatterSwitch" ) . value = config . enable _scatter ;
document . getElementById ( "fftSwitch" ) . value = config . enable _fft ;
document . getElementById ( "received_files_folder" ) . value =
config . received _files _folder ;
if ( config . enable _scatter == "True" ) {
document . getElementById ( "scatterSwitch" ) . checked = true ;
} else {
document . getElementById ( "scatterSwitch" ) . checked = false ;
}
2023-02-28 12:55:11 +00:00
document . getElementById ( "shared_folder_path" ) . value =
config . shared _folder _path ;
2023-05-09 11:08:47 +00:00
if ( config . enable _auto _retry == "True" ) {
document . getElementById ( "enable_auto_retry" ) . checked = true ;
} else {
document . getElementById ( "enable_auto_retry" ) . checked = false ;
}
2023-05-09 11:09:24 +00:00
document . getElementById ( "max_retry_attempts" ) . value =
config . max _retry _attempts ;
2023-05-09 11:08:47 +00:00
2023-02-28 12:55:54 +00:00
if ( config . enable _request _profile == "True" ) {
2023-02-28 12:55:11 +00:00
document . getElementById ( "enable_request_profile" ) . checked = true ;
} else {
document . getElementById ( "enable_request_profile" ) . checked = false ;
}
2023-02-28 12:55:54 +00:00
if ( config . enable _request _shared _folder == "True" ) {
2023-02-28 12:55:11 +00:00
document . getElementById ( "enable_request_shared_folder" ) . checked = true ;
} else {
document . getElementById ( "enable_request_shared_folder" ) . checked = false ;
}
2023-02-14 15:00:10 +00:00
if ( config . enable _is _writing == "True" ) {
document . getElementById ( "enable_is_writing" ) . checked = true ;
} else {
document . getElementById ( "enable_is_writing" ) . checked = false ;
}
2023-02-11 21:49:07 +00:00
if ( config . enable _fft == "True" ) {
document . getElementById ( "fftSwitch" ) . checked = true ;
} else {
document . getElementById ( "fftSwitch" ) . checked = false ;
}
if ( config . low _bandwidth _mode == "True" ) {
2023-07-04 15:36:52 +00:00
document . getElementById ( "250HzModeSwitch" ) . checked = true ;
2023-02-11 21:49:07 +00:00
} else {
2023-07-04 15:36:52 +00:00
document . getElementById ( "250HzModeSwitch" ) . checked = false ;
2023-02-11 21:49:07 +00:00
}
if ( config . high _graphics == "True" ) {
document . getElementById ( "GraphicsSwitch" ) . checked = true ;
} else {
document . getElementById ( "GraphicsSwitch" ) . checked = false ;
}
if ( config . enable _fsk == "True" ) {
document . getElementById ( "fskModeSwitch" ) . checked = true ;
} else {
document . getElementById ( "fskModeSwitch" ) . checked = false ;
}
if ( config . respond _to _cq == "True" ) {
document . getElementById ( "respondCQSwitch" ) . checked = true ;
} else {
document . getElementById ( "respondCQSwitch" ) . checked = false ;
}
if ( config . enable _explorer == "True" ) {
document . getElementById ( "ExplorerSwitch" ) . checked = true ;
} else {
document . getElementById ( "ExplorerSwitch" ) . checked = false ;
}
if ( config . explorer _stats . toLowerCase ( ) == "true" ) {
document . getElementById ( "ExplorerStatsSwitch" ) . checked = true ;
} else {
document . getElementById ( "ExplorerStatsSwitch" ) . checked = false ;
}
if ( config . auto _tune == "True" ) {
document . getElementById ( "autoTuneSwitch" ) . checked = true ;
} else {
document . getElementById ( "autoTuneSwitch" ) . checked = false ;
}
2023-03-27 21:06:11 +00:00
if ( config . auto _start == 1 ) {
document . getElementById ( "AutoStartSwitch" ) . checked = true ;
} else {
document . getElementById ( "AutoStartSwitch" ) . checked = false ;
}
2023-06-11 14:40:01 +00:00
if ( config . enable _sys _notification == 1 ) {
2023-06-11 03:14:25 +00:00
document . getElementById ( "NotificationSwitch" ) . checked = true ;
} else {
document . getElementById ( "NotificationSwitch" ) . checked = false ;
}
2023-07-05 16:43:56 +00:00
if ( config . enable _mesh _features . toLowerCase ( ) == "true" ) {
document . getElementById ( "liMeshTable" ) . style . visibility = "visible" ;
2023-07-03 07:26:42 +00:00
document . getElementById ( "liMeshTable" ) . style . display = "block" ;
document . getElementById ( "enableMeshSwitch" ) . checked = true ;
} else {
2023-07-05 16:43:56 +00:00
document . getElementById ( "liMeshTable" ) . style . visibility = "hidden" ;
2023-07-03 07:26:42 +00:00
document . getElementById ( "liMeshTable" ) . style . display = "none" ;
2023-07-05 16:43:56 +00:00
document . getElementById ( "enableMeshSwitch" ) . checked = false ;
2023-07-03 07:26:42 +00:00
}
2023-02-11 21:49:07 +00:00
// theme selector
2023-03-16 07:59:54 +00:00
changeGuiDesign ( config . theme ) ;
2023-02-11 21:49:07 +00:00
// Update channel selector
document . getElementById ( "update_channel_selector" ) . value =
config . update _channel ;
document . getElementById ( "updater_channel" ) . innerHTML = escape (
2023-07-05 16:43:56 +00:00
config . update _channel ,
2023-02-11 21:49:07 +00:00
) ;
// Update tuning range fmin fmax
document . getElementById ( "tuning_range_fmin" ) . value = config . tuning _range _fmin ;
document . getElementById ( "tuning_range_fmax" ) . value = config . tuning _range _fmax ;
2023-03-06 11:48:27 +00:00
//Update TX delay
document . getElementById ( "tx_delay" ) . value = config . tx _delay ;
2023-02-11 21:49:07 +00:00
// Update TX Audio Level
document . getElementById ( "audioLevelTXvalue" ) . innerHTML = parseInt (
2023-07-05 16:43:56 +00:00
config . tx _audio _level ,
2023-02-11 21:49:07 +00:00
) ;
document . getElementById ( "audioLevelTX" ) . value = parseInt (
2023-07-05 16:43:56 +00:00
config . tx _audio _level ,
2023-02-11 21:49:07 +00:00
) ;
// Update RX Buffer Size
document . getElementById ( "rx_buffer_size" ) . value = config . rx _buffer _size ;
if ( config . spectrum == "waterfall" ) {
document . getElementById ( "waterfall-scatter-switch1" ) . checked = true ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch3" ) . checked = false ;
document . getElementById ( "waterfall" ) . style . visibility = "visible" ;
document . getElementById ( "waterfall" ) . style . height = "100%" ;
document . getElementById ( "waterfall" ) . style . display = "block" ;
document . getElementById ( "scatter" ) . style . height = "0px" ;
document . getElementById ( "scatter" ) . style . visibility = "hidden" ;
document . getElementById ( "scatter" ) . style . display = "none" ;
document . getElementById ( "chart" ) . style . height = "0px" ;
document . getElementById ( "chart" ) . style . visibility = "hidden" ;
document . getElementById ( "chart" ) . style . display = "none" ;
} else if ( config . spectrum == "scatter" ) {
document . getElementById ( "waterfall-scatter-switch1" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = true ;
document . getElementById ( "waterfall-scatter-switch3" ) . checked = false ;
document . getElementById ( "waterfall" ) . style . visibility = "hidden" ;
document . getElementById ( "waterfall" ) . style . height = "0px" ;
document . getElementById ( "waterfall" ) . style . display = "none" ;
document . getElementById ( "scatter" ) . style . height = "100%" ;
document . getElementById ( "scatter" ) . style . visibility = "visible" ;
document . getElementById ( "scatter" ) . style . display = "block" ;
document . getElementById ( "chart" ) . style . visibility = "hidden" ;
document . getElementById ( "chart" ) . style . height = "0px" ;
document . getElementById ( "chart" ) . style . display = "none" ;
} else {
document . getElementById ( "waterfall-scatter-switch1" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch3" ) . checked = true ;
document . getElementById ( "waterfall" ) . style . visibility = "hidden" ;
document . getElementById ( "waterfall" ) . style . height = "0px" ;
document . getElementById ( "waterfall" ) . style . display = "none" ;
document . getElementById ( "scatter" ) . style . height = "0px" ;
document . getElementById ( "scatter" ) . style . visibility = "hidden" ;
document . getElementById ( "scatter" ) . style . display = "none" ;
document . getElementById ( "chart" ) . style . visibility = "visible" ;
document . getElementById ( "chart" ) . style . height = "100%" ;
document . getElementById ( "chart" ) . style . display = "block" ;
}
// radio control element
if ( config . radiocontrol == "rigctld" ) {
document . getElementById ( "radio-control-switch-disabled" ) . checked = false ;
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-switch-rigctld" ) . checked = true ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-switch-tci" ) . checked = false ;
2023-02-11 21:49:07 +00:00
document . getElementById ( "radio-control-disabled" ) . style . visibility =
"hidden" ;
document . getElementById ( "radio-control-disabled" ) . style . display = "none" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "none" ;
document . getElementById ( "radio-control-tci" ) . style . visibility = "hidden" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
2023-02-11 21:49:07 +00:00
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
"visible" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . display = "block" ;
2023-05-20 07:54:56 +00:00
} else if ( config . radiocontrol == "tci" ) {
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-switch-disabled" ) . checked = false ;
document . getElementById ( "radio-control-switch-rigctld" ) . checked = false ;
document . getElementById ( "radio-control-switch-tci" ) . checked = true ;
document . getElementById ( "radio-control-disabled" ) . style . visibility =
"hidden" ;
document . getElementById ( "radio-control-disabled" ) . style . display = "none" ;
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
2023-05-20 07:54:56 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
"hidden" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . display = "none" ;
2023-05-20 07:54:56 +00:00
document . getElementById ( "radio-control-tci" ) . style . visibility = "visible" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "block" ;
2023-02-11 21:49:07 +00:00
} else {
document . getElementById ( "radio-control-switch-disabled" ) . checked = true ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-switch-rigctld" ) . checked = false ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-switch-tci" ) . checked = false ;
2023-02-11 21:49:07 +00:00
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
2023-02-11 21:49:07 +00:00
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "none" ;
document . getElementById ( "radio-control-tci" ) . style . visibility = "hidden" ;
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
2023-02-11 21:49:07 +00:00
"hidden" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . display = "none" ;
2023-02-11 21:49:07 +00:00
}
// remote tnc
if ( config . tnclocation == "remote" ) {
document . getElementById ( "local-remote-switch1" ) . checked = false ;
document . getElementById ( "local-remote-switch2" ) . checked = true ;
document . getElementById ( "remote-tnc-field" ) . style . visibility = "visible" ;
toggleClass ( "remote-tnc-field" , "d-none" , false ) ;
} else {
document . getElementById ( "local-remote-switch1" ) . checked = true ;
document . getElementById ( "local-remote-switch2" ) . checked = false ;
document . getElementById ( "remote-tnc-field" ) . style . visibility = "hidden" ;
toggleClass ( "remote-tnc-field" , "d-none" , true ) ;
}
// Create spectrum object on canvas with ID "waterfall"
global . spectrum = new Spectrum ( "waterfall" , {
spectrumPercent : 0 ,
wf _rows : 192 , //Assuming 1 row = 1 pixe1, 192 is the height of the spectrum container
} ) ;
//Set waterfalltheme
document . getElementById ( "wftheme_selector" ) . value = config . wftheme ;
spectrum . setColorMap ( config . wftheme ) ;
document . getElementById ( "btnAbout" ) . addEventListener ( "click" , ( ) => {
document . getElementById ( "aboutVersion" ) . innerText = appVer ;
let maxcol = 3 ;
let col = 2 ;
let shuffled = contrib
. map ( ( value ) => ( { value , sort : Math . random ( ) } ) )
. sort ( ( a , b ) => a . sort - b . sort )
. map ( ( { value } ) => value ) ;
let list = "<li>DJ2LS</li>" ;
let list2 = "" ;
let list3 = "" ;
shuffled . forEach ( ( element ) => {
switch ( col ) {
case 1 :
list += "<li>" + element + "</li>" ;
break ;
case 2 :
list2 += "<li>" + element + "</li>" ;
break ;
case 3 :
list3 += "<li>" + element + "</li>" ;
break ;
}
col = col + 1 ;
if ( col > maxcol ) {
col = 1 ;
}
2022-02-02 20:12:16 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
//list+="</ul>";
divContrib . innerHTML = "<ul>" + list + "</ul>" ;
divContrib2 . innerHTML = "<ul>" + list2 + "</ul>" ;
divContrib3 . innerHTML = "<ul>" + list3 + "</ul>" ;
//console.log(shuffled)
} ) ;
// on click radio control toggle view
// disabled
document
. getElementById ( "radio-control-switch-disabled" )
. addEventListener ( "click" , ( ) => {
2023-02-12 20:05:48 +00:00
//document.getElementById("hamlib_info_field").innerHTML =
// "Disables TNC rig control";
2023-02-11 21:49:07 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = "block" ;
document . getElementById ( "radio-control-disabled" ) . style . visibility =
"visible" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "none" ;
document . getElementById ( "radio-control-tci" ) . style . visibility = "hidden" ;
2023-02-11 21:49:07 +00:00
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
2023-02-11 21:49:07 +00:00
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
2023-02-11 21:49:07 +00:00
"hidden" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . display = "none" ;
2023-02-11 21:49:07 +00:00
config . radiocontrol = "disabled" ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// // radio settings 'rigctld' event listener
document
2023-02-12 14:08:13 +00:00
. getElementById ( "radio-control-switch-rigctld" )
2023-02-11 21:49:07 +00:00
. addEventListener ( "click" , ( ) => {
2023-02-12 20:05:48 +00:00
//document.getElementById("hamlib_info_field").innerHTML =
// "Edit your rigctld settings and start and stop rigctld .";
2022-10-03 12:02:58 +00:00
2023-02-11 21:49:07 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = "none" ;
document . getElementById ( "radio-control-disabled" ) . style . visibility =
"hidden" ;
2022-09-20 05:59:47 +00:00
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
2022-09-20 05:59:47 +00:00
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "none" ;
document . getElementById ( "radio-control-tci" ) . style . visibility = "hidden" ;
2023-02-12 14:08:13 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
2023-02-11 21:49:07 +00:00
"visible" ;
2023-02-12 14:44:38 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . display = "block" ;
2022-09-20 05:59:47 +00:00
2023-02-11 21:49:07 +00:00
config . radiocontrol = "rigctld" ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2022-09-20 05:59:47 +00:00
} ) ;
2023-02-15 21:15:36 +00:00
2023-05-17 13:23:49 +00:00
// // radio settings 'rigctld' event listener
document
. getElementById ( "radio-control-switch-tci" )
. addEventListener ( "click" , ( ) => {
//document.getElementById("hamlib_info_field").innerHTML =
// "Edit your rigctld settings and start and stop rigctld .";
document . getElementById ( "radio-control-disabled" ) . style . display = "none" ;
document . getElementById ( "radio-control-disabled" ) . style . visibility =
"hidden" ;
document . getElementById ( "radio-control-rigctld" ) . style . display = "none" ;
2023-05-20 07:54:56 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility =
"hidden" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-help" ) . style . display = "none" ;
document . getElementById ( "radio-control-help" ) . style . visibility = "hidden" ;
2023-05-20 07:54:56 +00:00
document . getElementById ( "radio-control-tci" ) . style . visibility = "visible" ;
2023-05-17 13:23:49 +00:00
document . getElementById ( "radio-control-tci" ) . style . display = "block" ;
config . radiocontrol = "tci" ;
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-02-15 21:15:36 +00:00
document
2023-02-15 21:12:38 +00:00
. getElementById ( "btnHamlibCopyCommand" )
. addEventListener ( "click" , ( ) => {
hamlib _params ( ) ;
let rigctld = document . getElementById ( "hamlib_rigctld_path" ) . value ;
2023-03-28 23:27:48 +00:00
//Escape spaces in executable file
switch ( os . platform ( ) . toLowerCase ( ) ) {
case "darwin" :
case "linux" :
2023-03-28 23:29:51 +00:00
rigctld = rigctld . replace ( " " , "\\ " ) ;
2023-03-28 23:27:48 +00:00
break ;
case "win32" :
case "win64" :
2023-03-28 23:29:51 +00:00
if ( rigctld . indexOf ( " " ) > - 1 ) rigctld = '"' + rigctld + '"' ;
2023-03-28 23:27:48 +00:00
break ;
default :
console . log ( "Unhandled OS Platform: " , os . platform ( ) ) ;
break ;
}
2023-03-28 23:29:51 +00:00
rigctld +=
" " + document . getElementById ( "hamlib_rigctld_command" ) . value + " -vv" ;
2023-02-15 21:15:36 +00:00
document . getElementById ( "btnHamlibCopyCommandBi" ) . classList =
"bi bi-clipboard2-check-fill" ;
2023-02-15 21:12:38 +00:00
clipboard . writeText ( rigctld ) ;
setTimeout ( function ( ) {
2023-02-15 21:15:36 +00:00
document . getElementById ( "btnHamlibCopyCommandBi" ) . classList =
"bi bi-clipboard" ;
2023-02-15 21:12:38 +00:00
} , 2000 ) ;
} ) ;
2022-09-23 09:17:59 +00:00
2023-02-11 21:49:07 +00:00
document
. getElementById ( "hamlib_rigctld_path" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "get-file-path" , {
title : "Title" ,
2023-02-28 12:55:54 +00:00
action : "return-file-path-hamlib_rigctld_path" ,
2023-02-11 21:49:07 +00:00
} ) ;
2023-02-28 12:55:11 +00:00
ipcRenderer . on ( "return-file-path-hamlib_rigctld_path" , ( event , data ) => {
2023-02-11 21:49:07 +00:00
rigctldPath = data . path . filePaths [ 0 ] ;
document . getElementById ( "hamlib_rigctld_path" ) . value = rigctldPath ;
config . hamlib _rigctld _path = rigctldPath ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-15 21:12:38 +00:00
hamlib _params ( ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2022-09-20 17:24:07 +00:00
} ) ;
2022-10-03 12:17:03 +00:00
2023-02-11 21:49:07 +00:00
// radio settings 'hamlib_rigctld_server_port' event listener
document
. getElementById ( "hamlib_rigctld_server_port" )
. addEventListener ( "change" , ( ) => {
config . hamlib _rigctld _server _port = document . getElementById (
2023-07-05 16:43:56 +00:00
"hamlib_rigctld_server_port" ,
2023-02-11 21:49:07 +00:00
) . value ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-15 21:12:38 +00:00
hamlib _params ( ) ;
2022-10-03 12:17:03 +00:00
} ) ;
2023-02-12 14:59:46 +00:00
// hamlib bulk event listener for saving settings
2023-02-12 14:44:38 +00:00
hamlib _elements . forEach ( function ( elem ) {
try {
document . getElementById ( elem ) . addEventListener ( "change" , function ( ) {
2023-02-12 14:59:46 +00:00
config [ elem ] = document . getElementById ( elem ) . value ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-12 15:00:08 +00:00
console . log ( config ) ;
2023-02-15 21:12:38 +00:00
hamlib _params ( ) ;
2023-02-12 14:44:38 +00:00
} ) ;
} catch ( e ) {
console . log ( e ) ;
console . log ( elem ) ;
}
} ) ;
2023-02-12 13:44:13 +00:00
2023-02-11 21:49:07 +00:00
document
. getElementById ( "hamlib_rigctld_start" )
. addEventListener ( "click" , ( ) => {
var rigctldPath = document . getElementById ( "hamlib_rigctld_path" ) . value ;
2023-02-15 21:12:38 +00:00
var paramList = hamlib _params ( ) ;
2023-02-15 21:15:36 +00:00
2023-02-15 21:12:38 +00:00
let Data = {
path : rigctldPath ,
parameters : paramList ,
} ;
ipcRenderer . send ( "request-start-rigctld" , Data ) ;
} ) ;
2022-10-03 12:17:03 +00:00
2023-02-15 21:15:36 +00:00
hamlib _params = function ( ) {
var paramList = [ ] ;
2022-10-03 12:17:03 +00:00
2023-03-04 09:19:29 +00:00
// hamlib stopbits setting
if ( document . getElementById ( "hamlib_deviceid" ) . value !== "-- ignore --" ) {
2023-03-04 10:16:46 +00:00
var hamlib _deviceid = document . getElementById ( "hamlib_deviceid" ) . value ;
paramList = paramList . concat ( "--model=" + hamlib _deviceid ) ;
2023-03-04 09:19:29 +00:00
}
2023-02-15 21:15:36 +00:00
// hamlib deviceport setting
if ( document . getElementById ( "hamlib_deviceport" ) . value !== "ignore" ) {
var hamlib _deviceport =
document . getElementById ( "hamlib_deviceport" ) . value ;
2023-02-16 23:14:07 +00:00
paramList = paramList . concat ( "--rig-file=" + hamlib _deviceport ) ;
2023-02-15 21:15:36 +00:00
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib serialspeed setting
if ( document . getElementById ( "hamlib_serialspeed" ) . value !== "ignore" ) {
var hamlib _serialspeed =
document . getElementById ( "hamlib_serialspeed" ) . value ;
2023-02-16 23:14:07 +00:00
paramList = paramList . concat ( "--serial-speed=" + hamlib _serialspeed ) ;
2023-02-15 21:15:36 +00:00
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib databits setting
if ( document . getElementById ( "hamlib_data_bits" ) . value !== "ignore" ) {
var hamlib _data _bits = document . getElementById ( "hamlib_data_bits" ) . value ;
paramList = paramList . concat ( "--set-conf=data_bits=" + hamlib _data _bits ) ;
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib stopbits setting
if ( document . getElementById ( "hamlib_stop_bits" ) . value !== "ignore" ) {
var hamlib _stop _bits = document . getElementById ( "hamlib_stop_bits" ) . value ;
paramList = paramList . concat ( "--set-conf=stop_bits=" + hamlib _stop _bits ) ;
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib handshake setting
if ( document . getElementById ( "hamlib_handshake" ) . value !== "ignore" ) {
var hamlib _handshake = document . getElementById ( "hamlib_handshake" ) . value ;
paramList = paramList . concat (
2023-07-05 16:43:56 +00:00
"--set-conf=serial_handshake=" + hamlib _handshake ,
2023-02-15 21:15:36 +00:00
) ;
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib dcd setting
if ( document . getElementById ( "hamlib_dcd" ) . value !== "ignore" ) {
var hamlib _dcd = document . getElementById ( "hamlib_dcd" ) . value ;
paramList = paramList . concat ( "--dcd-type=" + hamlib _dcd ) ;
}
2022-09-23 17:18:20 +00:00
2023-02-15 21:15:36 +00:00
// hamlib ptt port
if ( document . getElementById ( "hamlib_ptt_port" ) . value !== "ignore" ) {
var hamlib _ptt _port = document . getElementById ( "hamlib_ptt_port" ) . value ;
2023-02-16 23:14:07 +00:00
paramList = paramList . concat ( "--ptt-file=" + hamlib _ptt _port ) ;
2023-02-15 21:15:36 +00:00
}
2022-10-03 11:10:19 +00:00
2023-02-15 21:15:36 +00:00
// hamlib ptt type
if ( document . getElementById ( "hamlib_pttprotocol" ) . value !== "ignore" ) {
var hamlib _ptt _type = document . getElementById ( "hamlib_pttprotocol" ) . value ;
paramList = paramList . concat ( "--ptt-type=" + hamlib _ptt _type ) ;
}
2022-10-03 12:17:03 +00:00
2023-02-15 21:15:36 +00:00
// hamlib dtr state
if ( document . getElementById ( "hamlib_dtrstate" ) . value !== "ignore" ) {
var hamlib _dtrstate = document . getElementById ( "hamlib_dtrstate" ) . value ;
paramList = paramList . concat ( "--set-conf=dtr_state=" + hamlib _dtrstate ) ;
}
2023-02-12 17:43:22 +00:00
2023-02-15 21:15:36 +00:00
var hamlib _rigctld _server _port = document . getElementById (
2023-07-05 16:43:56 +00:00
"hamlib_rigctld_server_port" ,
2023-02-15 21:15:36 +00:00
) . value ;
2023-02-16 23:13:26 +00:00
paramList = paramList . concat ( "--port=" + hamlib _rigctld _server _port ) ;
2022-10-03 12:17:03 +00:00
2023-02-15 21:15:36 +00:00
//Custom rigctld arguments to pass to rigctld
var hamlib _rigctld _custom _args = document . getElementById (
2023-07-05 16:43:56 +00:00
"hamlib_rigctld_custom_args" ,
2023-02-15 21:15:36 +00:00
) . value ;
paramList = paramList . concat ( hamlib _rigctld _custom _args ) ;
2022-09-20 17:37:54 +00:00
2023-02-15 21:15:36 +00:00
document . getElementById ( "hamlib_rigctld_command" ) . value =
paramList . join ( " " ) ; // join removes the commas
2023-02-15 21:12:38 +00:00
2023-02-15 21:15:36 +00:00
console . log ( paramList ) ;
//console.log(rigctldPath);
return paramList ;
} ;
2022-09-20 17:37:54 +00:00
2023-02-11 21:49:07 +00:00
document
. getElementById ( "hamlib_rigctld_stop" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "request-stop-rigctld" , {
path : "123" ,
parameters : "--version" ,
} ) ;
} ) ;
// on click waterfall scatter toggle view
// waterfall
document
. getElementById ( "waterfall-scatter-switch1" )
. addEventListener ( "click" , ( ) => {
document . getElementById ( "chart" ) . style . visibility = "hidden" ;
document . getElementById ( "chart" ) . style . display = "none" ;
document . getElementById ( "chart" ) . style . height = "0px" ;
document . getElementById ( "scatter" ) . style . height = "0px" ;
document . getElementById ( "scatter" ) . style . display = "none" ;
document . getElementById ( "scatter" ) . style . visibility = "hidden" ;
document . getElementById ( "waterfall" ) . style . display = "block" ;
document . getElementById ( "waterfall" ) . style . visibility = "visible" ;
document . getElementById ( "waterfall" ) . style . height = "100%" ;
config . spectrum = "waterfall" ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// scatter
document
. getElementById ( "waterfall-scatter-switch2" )
. addEventListener ( "click" , ( ) => {
document . getElementById ( "scatter" ) . style . display = "block" ;
document . getElementById ( "scatter" ) . style . visibility = "visible" ;
document . getElementById ( "scatter" ) . style . height = "100%" ;
document . getElementById ( "waterfall" ) . style . visibility = "hidden" ;
document . getElementById ( "waterfall" ) . style . height = "0px" ;
document . getElementById ( "waterfall" ) . style . display = "none" ;
document . getElementById ( "chart" ) . style . visibility = "hidden" ;
document . getElementById ( "chart" ) . style . height = "0px" ;
document . getElementById ( "chart" ) . style . display = "none" ;
config . spectrum = "scatter" ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// chart
document
. getElementById ( "waterfall-scatter-switch3" )
. addEventListener ( "click" , ( ) => {
document . getElementById ( "waterfall" ) . style . visibility = "hidden" ;
document . getElementById ( "waterfall" ) . style . height = "0px" ;
document . getElementById ( "waterfall" ) . style . display = "none" ;
document . getElementById ( "scatter" ) . style . height = "0px" ;
document . getElementById ( "scatter" ) . style . visibility = "hidden" ;
document . getElementById ( "scatter" ) . style . display = "none" ;
document . getElementById ( "chart" ) . style . height = "100%" ;
document . getElementById ( "chart" ) . style . display = "block" ;
document . getElementById ( "chart" ) . style . visibility = "visible" ;
config . spectrum = "chart" ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +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 ;
document . getElementById ( "remote-tnc-field" ) . style . visibility = "hidden" ;
config . tnclocation = "localhost" ;
toggleClass ( "remote-tnc-field" , "d-none" , true ) ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
document
. getElementById ( "local-remote-switch2" )
. addEventListener ( "click" , ( ) => {
document . getElementById ( "local-remote-switch1" ) . checked = false ;
document . getElementById ( "local-remote-switch2" ) . checked = true ;
document . getElementById ( "remote-tnc-field" ) . style . visibility = "visible" ;
config . tnclocation = "remote" ;
toggleClass ( "remote-tnc-field" , "d-none" , false ) ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// on change ping callsign
document . getElementById ( "dxCall" ) . addEventListener ( "change" , ( ) => {
document . getElementById ( "dataModalDxCall" ) . value =
document . getElementById ( "dxCall" ) . value ;
} ) ;
// on change ping callsign
document . getElementById ( "dataModalDxCall" ) . addEventListener ( "change" , ( ) => {
document . getElementById ( "dxCall" ) . value =
document . getElementById ( "dataModalDxCall" ) . value ;
} ) ;
// 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 ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2022-10-03 07:36:43 +00:00
let Data = {
2023-02-11 21:49:07 +00:00
port : document . getElementById ( "tnc_port" ) . value ,
adress : document . getElementById ( "tnc_adress" ) . value ,
2022-10-03 07:36:43 +00:00
} ;
2023-02-11 21:49:07 +00:00
ipcRenderer . send ( "request-update-tnc-ip" , Data ) ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
Data = {
port : parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( "request-update-daemon-ip" , Data ) ;
} ) ;
// on change tnc port
document . getElementById ( "tnc_port" ) . addEventListener ( "change" , ( ) => {
config . tnc _port = document . getElementById ( "tnc_port" ) . value ;
config . daemon _port =
parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2022-01-18 18:38:05 +00:00
2023-02-11 21:49:07 +00:00
let Data = {
port : document . getElementById ( "tnc_port" ) . value ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( "request-update-tnc-ip" , Data ) ;
2021-08-07 17:46:02 +00:00
2023-02-11 21:49:07 +00:00
Data = {
port : parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( "request-update-daemon-ip" , Data ) ;
} ) ;
// on change audio TX Level
document . getElementById ( "audioLevelTX" ) . addEventListener ( "change" , ( ) => {
var tx _audio _level = parseInt (
2023-07-05 16:43:56 +00:00
document . getElementById ( "audioLevelTX" ) . value ,
2023-02-11 21:49:07 +00:00
) ;
document . getElementById ( "audioLevelTXvalue" ) . innerHTML = tx _audio _level ;
config . tx _audio _level = tx _audio _level ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-05 19:06:27 +00:00
2023-02-11 21:49:07 +00:00
let Data = {
command : "set_tx_audio_level" ,
tx _audio _level : tx _audio _level ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
document . getElementById ( "sendTestFrame" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "send_test_frame" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
// saveMyCall button clicked
document . getElementById ( "myCall" ) . addEventListener ( "input" , ( ) => {
callsign = document . getElementById ( "myCall" ) . value ;
ssid = document . getElementById ( "myCallSSID" ) . value ;
callsign _ssid = callsign . toUpperCase ( ) + "-" + ssid ;
config . mycall = callsign _ssid ;
// split document title by looking for Call then split and update it
//var documentTitle = document.title.split('Call:')
//document.title = documentTitle[0] + 'Call: ' + callsign_ssid;
updateTitle ( callsign _ssid ) ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
daemon . saveMyCall ( callsign _ssid ) ;
} ) ;
2023-02-05 08:06:58 +00:00
2023-02-11 21:49:07 +00:00
// saveMyGrid button clicked
document . getElementById ( "myGrid" ) . addEventListener ( "input" , ( ) => {
grid = document . getElementById ( "myGrid" ) . value ;
config . mygrid = grid ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
daemon . saveMyGrid ( grid ) ;
} ) ;
// startPing button clicked
document . getElementById ( "sendPing" ) . addEventListener ( "click" , ( ) => {
var dxcallsign = document . getElementById ( "dxCall" ) . value . toUpperCase ( ) ;
if ( dxcallsign == "" || dxcallsign == null || dxcallsign == undefined )
return ;
pauseButton ( document . getElementById ( "sendPing" ) , 2000 ) ;
sock . sendPing ( dxcallsign ) ;
} ) ;
// dataModalstartPing button clicked
document . getElementById ( "dataModalSendPing" ) . addEventListener ( "click" , ( ) => {
var dxcallsign = document . getElementById ( "dataModalDxCall" ) . value ;
dxcallsign = dxcallsign . toUpperCase ( ) ;
sock . sendPing ( dxcallsign ) ;
} ) ;
// close app, update and restart
document
. getElementById ( "update_and_install" )
. addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "request-restart-and-install" ) ;
} ) ;
2023-02-23 15:38:27 +00:00
/ * d i s a b l e d b e c a u s e i t ' s c a u s i n g c o n f u s i o n T O D O : r e m o v e e n t i r e c o d e s o m e d a y
2023-02-11 21:49:07 +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 ( ) ;
} ) ;
2023-02-23 14:48:55 +00:00
* /
2023-02-11 21:49:07 +00:00
// sendCQ button clicked
document . getElementById ( "sendCQ" ) . addEventListener ( "click" , ( ) => {
pauseButton ( document . getElementById ( "sendCQ" ) , 2000 ) ;
sock . sendCQ ( ) ;
} ) ;
// Start beacon button clicked
document . getElementById ( "startBeacon" ) . addEventListener ( "click" , ( ) => {
2023-02-12 04:04:57 +00:00
let bcn = document . getElementById ( "startBeacon" ) ;
2023-02-12 04:05:48 +00:00
bcn . disabled = true ;
2023-02-11 21:49:07 +00:00
interval = document . getElementById ( "beaconInterval" ) . value ;
2023-02-12 04:04:57 +00:00
//Use class list to determine state of beacon, secondary == off
2023-02-12 04:05:48 +00:00
if ( bcn . className . toLowerCase ( ) . indexOf ( "secondary" ) > 0 ) {
2023-02-12 04:04:57 +00:00
//Stopped; let us start it
sock . startBeacon ( interval ) ;
} else {
sock . stopBeacon ( ) ;
}
2023-02-11 21:49:07 +00:00
config . beacon _interval = interval ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-12 04:05:48 +00:00
bcn . disabled = false ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-05-09 11:08:47 +00:00
// enable_auto_retry Switch clicked
document . getElementById ( "enable_auto_retry" ) . addEventListener ( "click" , ( ) => {
console . log ( document . getElementById ( "enable_auto_retry" ) . checked ) ;
if ( document . getElementById ( "enable_auto_retry" ) . checked == true ) {
config . enable _auto _retry = "True" ;
} else {
config . enable _auto _retry = "False" ;
}
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
// max_retry_attempts Switch clicked
2023-05-09 11:09:24 +00:00
document
. getElementById ( "max_retry_attempts" )
. addEventListener ( "change" , ( ) => {
console . log ( document . getElementById ( "max_retry_attempts" ) . value ) ;
config . max _retry _attempts =
document . getElementById ( "max_retry_attempts" ) . value ;
2023-05-09 11:08:47 +00:00
2023-05-09 11:09:24 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-05-09 11:08:47 +00:00
2023-02-11 21:49:07 +00:00
// sendscatter Switch clicked
document . getElementById ( "scatterSwitch" ) . addEventListener ( "click" , ( ) => {
console . log ( document . getElementById ( "scatterSwitch" ) . checked ) ;
if ( document . getElementById ( "scatterSwitch" ) . checked == true ) {
config . enable _scatter = "True" ;
2023-02-04 11:00:53 +00:00
} else {
2023-02-11 21:49:07 +00:00
config . enable _scatter = "False" ;
2023-02-04 11:00:53 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-02-04 11:00:53 +00:00
2023-02-11 21:49:07 +00:00
// sendfft Switch clicked
document . getElementById ( "fftSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "fftSwitch" ) . checked == true ) {
config . enable _fft = "True" ;
2023-01-21 23:26:43 +00:00
} else {
2023-02-11 21:49:07 +00:00
config . enable _fft = "False" ;
2023-01-21 23:26:43 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-01-21 23:26:43 +00:00
2023-02-11 21:49:07 +00:00
// enable 500z Switch clicked
2023-07-04 15:36:52 +00:00
document . getElementById ( "250HzModeSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "250HzModeSwitch" ) . checked == true ) {
2023-02-11 21:49:07 +00:00
config . low _bandwidth _mode = "True" ;
2023-01-23 03:31:13 +00:00
} else {
2023-02-11 21:49:07 +00:00
config . low _bandwidth _mode = "False" ;
2023-01-23 03:31:13 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2021-10-02 09:29:08 +00:00
2023-02-11 21:49:07 +00:00
// enable response to cq clicked
document . getElementById ( "respondCQSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "respondCQSwitch" ) . checked == true ) {
config . respond _to _cq = "True" ;
} else {
config . respond _to _cq = "False" ;
2021-09-13 16:27:50 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2021-09-05 09:26:09 +00:00
2023-02-11 21:49:07 +00:00
// enable explorer Switch clicked
document . getElementById ( "ExplorerSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "ExplorerSwitch" ) . checked == true ) {
config . enable _explorer = "True" ;
} else {
config . enable _explorer = "False" ;
2022-12-24 14:51:26 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// enable explorer stats Switch clicked
document
. getElementById ( "ExplorerStatsSwitch" )
. addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "ExplorerStatsSwitch" ) . checked == true ) {
config . explorer _stats = "True" ;
} else {
config . explorer _stats = "False" ;
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// enable autotune Switch clicked
document . getElementById ( "autoTuneSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "autoTuneSwitch" ) . checked == true ) {
config . auto _tune = "True" ;
} else {
config . auto _tune = "False" ;
2023-01-06 16:33:20 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-03-27 21:06:11 +00:00
//Handle change of fancy graphics
2023-02-11 21:49:07 +00:00
document . getElementById ( "GraphicsSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "GraphicsSwitch" ) . checked == true ) {
config . high _graphics = "True" ;
2021-08-07 17:46:02 +00:00
} else {
2023-02-11 21:49:07 +00:00
config . high _graphics = "False" ;
2021-08-07 17:46:02 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
set _CPU _mode ( ) ;
} ) ;
2021-09-04 18:23:58 +00:00
2023-03-27 21:07:54 +00:00
//Handle change of Auto-start settings
document . getElementById ( "AutoStartSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "AutoStartSwitch" ) . checked == true ) {
2023-04-26 01:11:06 +00:00
config . auto _start = 1 ;
2023-03-27 21:07:54 +00:00
} else {
2023-04-26 01:11:06 +00:00
config . auto _start = 0 ;
2023-03-27 21:07:54 +00:00
}
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-03-27 21:06:11 +00:00
2023-07-02 13:43:54 +00:00
//Handle change of Notification settings
document
. getElementById ( "NotificationSwitch" )
. addEventListener ( "click" , ( ) => {
2023-06-11 03:14:25 +00:00
if ( document . getElementById ( "NotificationSwitch" ) . checked == true ) {
2023-06-11 14:40:01 +00:00
config . enable _sys _notification = 1 ;
2023-06-11 03:14:25 +00:00
} else {
2023-06-11 14:40:01 +00:00
config . enable _sys _notification = 0 ;
2023-06-11 03:14:25 +00:00
}
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-02-11 21:49:07 +00:00
// enable fsk Switch clicked
document . getElementById ( "fskModeSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "fskModeSwitch" ) . checked == true ) {
config . enable _fsk = "True" ;
2023-01-12 23:14:42 +00:00
} else {
2023-02-11 21:49:07 +00:00
config . enable _fsk = "False" ;
2023-01-12 23:14:42 +00:00
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-01-12 23:14:42 +00:00
2023-07-03 07:26:42 +00:00
// enable MESH Switch clicked
document . getElementById ( "enableMeshSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "enableMeshSwitch" ) . checked == true ) {
config . enable _mesh _features = "True" ;
2023-07-05 16:43:56 +00:00
document . getElementById ( "liMeshTable" ) . style . visibility = "visible" ;
document . getElementById ( "liMeshTable" ) . style . display = "block" ;
2023-07-03 07:26:42 +00:00
} else {
config . enable _mesh _features = "False" ;
2023-07-05 16:43:56 +00:00
document . getElementById ( "liMeshTable" ) . style . visibility = "hidden" ;
document . getElementById ( "liMeshTable" ) . style . display = "none" ;
2023-07-03 07:26:42 +00:00
}
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-02-14 15:00:10 +00:00
// enable is writing switch clicked
document . getElementById ( "enable_is_writing" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "enable_is_writing" ) . checked == true ) {
config . enable _is _writing = "True" ;
} else {
config . enable _is _writing = "False" ;
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-14 15:00:10 +00:00
} ) ;
2023-02-28 12:55:11 +00:00
// enable enable_request_shared_folder switch clicked
2023-02-28 12:55:54 +00:00
document
. getElementById ( "enable_request_shared_folder" )
. addEventListener ( "click" , ( ) => {
if (
document . getElementById ( "enable_request_shared_folder" ) . checked == true
) {
config . enable _request _shared _folder = "True" ;
} else {
config . enable _request _shared _folder = "False" ;
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:23:14 +00:00
FD . saveConfig ( config , configPath ) ;
2023-03-03 03:22:00 +00:00
//Update file list after setting change
2023-03-03 03:23:14 +00:00
ipcRenderer . send ( "read-files-in-folder" , {
folder : config . shared _folder _path . toString ( ) ,
} ) ;
2023-02-28 12:55:54 +00:00
} ) ;
2023-02-28 12:55:11 +00:00
// enable enable_request_profile switch clicked
2023-02-28 12:55:54 +00:00
document
. getElementById ( "enable_request_profile" )
. addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "enable_request_profile" ) . checked == true ) {
config . enable _request _profile = "True" ;
} else {
config . enable _request _profile = "False" ;
}
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-28 12:55:54 +00:00
} ) ;
2023-02-28 12:55:11 +00:00
2023-02-11 21:49:07 +00:00
// Tuning range clicked
document . getElementById ( "tuning_range_fmin" ) . addEventListener ( "click" , ( ) => {
var tuning _range _fmin = document . getElementById ( "tuning_range_fmin" ) . value ;
config . tuning _range _fmin = tuning _range _fmin ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
document . getElementById ( "tuning_range_fmax" ) . addEventListener ( "click" , ( ) => {
var tuning _range _fmax = document . getElementById ( "tuning_range_fmax" ) . value ;
config . tuning _range _fmax = tuning _range _fmax ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-03-06 11:48:27 +00:00
document . getElementById ( "tx_delay" ) . addEventListener ( "click" , ( ) => {
var tx _delay = document . getElementById ( "tx_delay" ) . value ;
config . tx _delay = tx _delay ;
FD . saveConfig ( config , configPath ) ;
} ) ;
2023-02-11 21:49:07 +00:00
// Theme selector clicked
2023-03-16 07:28:29 +00:00
2023-02-23 17:16:07 +00:00
document . getElementById ( "theme_selector" ) . addEventListener ( "change" , ( ) => {
2023-03-16 07:28:47 +00:00
/ *
2023-02-11 21:49:07 +00:00
var theme = document . getElementById ( "theme_selector" ) . value ;
if ( theme != "default" ) {
var theme _path =
"../node_modules/bootswatch/dist/" + theme + "/bootstrap.min.css" ;
2023-01-12 23:14:42 +00:00
} else {
2023-02-11 21:49:07 +00:00
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
2023-01-12 23:14:42 +00:00
}
2023-03-16 07:28:29 +00:00
* /
2023-03-16 07:28:47 +00:00
var theme = document . getElementById ( "theme_selector" ) . value ;
2023-03-16 07:59:32 +00:00
changeGuiDesign ( theme ) ;
2023-02-11 21:49:07 +00:00
config . theme = theme ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
// Waterfall theme selector changed
document . getElementById ( "wftheme_selector" ) . addEventListener ( "change" , ( ) => {
var wftheme = document . getElementById ( "wftheme_selector" ) . value ;
spectrum . setColorMap ( wftheme ) ;
config . wftheme = wftheme ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// Update channel selector changed
document
. getElementById ( "update_channel_selector" )
. addEventListener ( "change" , ( ) => {
config . update _channel = document . getElementById (
2023-07-05 16:43:56 +00:00
"update_channel_selector" ,
2023-02-11 21:49:07 +00:00
) . value ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
console . log ( "Autoupdate channel changed to " , config . update _channel ) ;
} ) ;
// rx buffer size selector clicked
document . getElementById ( "rx_buffer_size" ) . addEventListener ( "click" , ( ) => {
var rx _buffer _size = document . getElementById ( "rx_buffer_size" ) . value ;
config . rx _buffer _size = rx _buffer _size ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
//screen size
window . addEventListener ( "resize" , ( ) => {
config . screen _height = window . innerHeight ;
config . screen _width = window . innerWidth ;
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-02-11 21:49:07 +00:00
} ) ;
// Explorer button clicked
document . getElementById ( "openExplorer" ) . addEventListener ( "click" , ( ) => {
shell . openExternal (
"https://explorer.freedata.app/?myCall=" +
2023-07-05 16:43:56 +00:00
document . getElementById ( "myCall" ) . value ,
2023-02-11 21:49:07 +00:00
) ;
} ) ;
// Stats button clicked
document . getElementById ( "btnStats" ) . addEventListener ( "click" , ( ) => {
shell . openExternal ( "https://statistics.freedata.app" ) ;
} ) ;
2023-02-12 02:18:09 +00:00
// GH Link clicked
document . getElementById ( "fdWww" ) . addEventListener ( "click" , ( ) => {
shell . openExternal ( "https://freedata.app" ) ;
} ) ;
2023-02-11 21:49:07 +00:00
// GH Link clicked
document . getElementById ( "ghUrl" ) . addEventListener ( "click" , ( ) => {
shell . openExternal ( "https://github.com/DJ2LS/FreeDATA" ) ;
} ) ;
// Wiki Link clicked
document . getElementById ( "wikiUrl" ) . addEventListener ( "click" , ( ) => {
shell . openExternal ( "https://wiki.freedata.app" ) ;
} ) ;
2023-05-20 18:43:27 +00:00
2023-02-11 21:49:07 +00:00
// Discord Link clicked
document . getElementById ( "discordUrl" ) . addEventListener ( "click" , ( ) => {
2023-06-10 13:06:33 +00:00
shell . openExternal ( "https://discord.freedata.app/" ) ;
2023-02-11 21:49:07 +00:00
} ) ;
2023-04-26 01:19:02 +00:00
2023-02-11 21:49:07 +00:00
// startTNC button clicked
document . getElementById ( "startTNC" ) . addEventListener ( "click" , ( ) => {
2023-04-26 01:11:06 +00:00
tncStartCount ++ ;
2023-02-11 21:49:07 +00:00
var tuning _range _fmin = document . getElementById ( "tuning_range_fmin" ) . value ;
var tuning _range _fmax = document . getElementById ( "tuning_range_fmax" ) . value ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
var rigctld _ip = document . getElementById ( "hamlib_rigctld_ip" ) . value ;
var rigctld _port = document . getElementById ( "hamlib_rigctld_port" ) . value ;
2023-05-17 13:38:52 +00:00
2023-05-20 07:54:56 +00:00
var tci _ip = document . getElementById ( "tci_ip" ) . value ;
2023-05-17 13:38:52 +00:00
var tci _port = document . getElementById ( "tci_port" ) . value ;
2023-02-11 21:49:07 +00:00
var hamlib _rigctld _server _port = document . getElementById (
2023-07-05 16:43:56 +00:00
"hamlib_rigctld_server_port" ,
2023-02-11 21:49:07 +00:00
) . value ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
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_pttprotocol" ) . value ;
var hamlib _dcd = document . getElementById ( "hamlib_dcd" ) . value ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
var mycall = document . getElementById ( "myCall" ) . value ;
var ssid = document . getElementById ( "myCallSSID" ) . value ;
callsign _ssid = mycall . toUpperCase ( ) + "-" + ssid ;
var mygrid = document . getElementById ( "myGrid" ) . value ;
2023-01-12 23:14:42 +00:00
2023-02-11 21:49:07 +00:00
var rx _audio = document . getElementById ( "audio_input_selectbox" ) . value ;
var tx _audio = document . getElementById ( "audio_output_selectbox" ) . value ;
2023-02-11 11:21:27 +00:00
2023-02-11 21:49:07 +00:00
var pttport = document . getElementById ( "hamlib_ptt_port" ) . value ;
2023-02-12 13:44:13 +00:00
var data _bits = document . getElementById ( "hamlib_data_bits" ) . value ;
var stop _bits = document . getElementById ( "hamlib_stop_bits" ) . value ;
2023-02-11 21:49:07 +00:00
var handshake = document . getElementById ( "hamlib_handshake" ) . value ;
2023-03-06 11:48:27 +00:00
var tx _delay = document . getElementById ( "tx_delay" ) . value ;
2023-07-03 07:26:42 +00:00
2023-07-05 16:43:56 +00:00
if ( document . getElementById ( "enableMeshSwitch" ) . checked == true ) {
var enable _mesh _features = "True" ;
document . getElementById ( "liMeshTable" ) . style . visibility = "visible" ;
document . getElementById ( "liMeshTable" ) . style . display = "block" ;
} else {
var enable _mesh _features = "False" ;
document . getElementById ( "liMeshTable" ) . style . visibility = "hidden" ;
document . getElementById ( "liMeshTable" ) . style . display = "none" ;
}
2023-07-03 07:26:42 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "scatterSwitch" ) . checked == true ) {
var enable _scatter = "True" ;
2023-01-12 23:14:42 +00:00
} else {
2023-02-11 21:49:07 +00:00
var enable _scatter = "False" ;
2023-01-27 07:47:55 +00:00
}
2023-02-04 05:28:28 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "fftSwitch" ) . checked == true ) {
var enable _fft = "True" ;
2022-12-26 11:11:59 +00:00
} else {
2023-02-11 21:49:07 +00:00
var enable _fft = "False" ;
2022-12-26 11:11:59 +00:00
}
2023-07-04 15:36:52 +00:00
if ( document . getElementById ( "250HzModeSwitch" ) . checked == true ) {
2023-02-11 21:49:07 +00:00
var low _bandwidth _mode = "True" ;
} else {
var low _bandwidth _mode = "False" ;
2023-01-27 07:47:55 +00:00
}
2022-02-15 17:10:14 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "fskModeSwitch" ) . checked == true ) {
var enable _fsk = "True" ;
} else {
var enable _fsk = "False" ;
2023-01-27 07:47:55 +00:00
}
2021-07-17 07:03:40 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "respondCQSwitch" ) . checked == true ) {
var respond _to _cq = "True" ;
} else {
var respond _to _cq = "False" ;
2023-01-27 07:47:55 +00:00
}
2022-03-04 15:50:32 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "ExplorerSwitch" ) . checked == true ) {
var enable _explorer = "True" ;
2022-11-18 12:08:37 +00:00
} else {
2023-02-11 21:49:07 +00:00
var enable _explorer = "False" ;
2022-11-18 12:08:37 +00:00
}
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "ExplorerStatsSwitch" ) . checked == true ) {
var explorer _stats = "True" ;
} else {
var explorer _stats = "False" ;
2022-11-18 14:19:41 +00:00
}
2021-07-24 07:06:22 +00:00
2023-02-11 21:49:07 +00:00
if ( document . getElementById ( "autoTuneSwitch" ) . checked == true ) {
var auto _tune = "True" ;
2021-08-15 14:48:48 +00:00
} else {
2023-02-11 21:49:07 +00:00
var auto _tune = "False" ;
}
// 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-09-04 18:23:58 +00:00
}
2023-02-11 21:49:07 +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 ;
}
2023-01-27 19:44:36 +00:00
}
2023-02-11 05:53:14 +00:00
2023-05-17 13:38:52 +00:00
if ( document . getElementById ( "radio-control-switch-rigctld" ) . checked ) {
2023-05-20 07:54:56 +00:00
var radiocontrol = "rigctld" ;
2023-05-17 13:38:52 +00:00
} else if ( document . getElementById ( "radio-control-switch-tci" ) . checked ) {
2023-05-20 07:54:56 +00:00
var radiocontrol = "tci" ;
2023-02-11 21:49:07 +00:00
} else {
2023-05-20 07:54:56 +00:00
var radiocontrol = "disabled" ;
2023-02-11 21:49:07 +00:00
}
var tx _audio _level = document . getElementById ( "audioLevelTX" ) . value ;
var rx _buffer _size = document . getElementById ( "rx_buffer_size" ) . value ;
config . radiocontrol = radiocontrol ;
config . mycall = callsign _ssid ;
config . mygrid = mygrid ;
config . hamlib _deviceid = deviceid ;
config . hamlib _deviceport = deviceport ;
config . hamlib _serialspeed = serialspeed ;
config . hamlib _pttprotocol = pttprotocol ;
2023-02-12 13:44:13 +00:00
config . hamlib _ptt _port = pttport ;
2023-02-11 21:49:07 +00:00
config . hamlib _data _bits = data _bits ;
config . hamlib _stop _bits = stop _bits ;
config . hamlib _handshake = handshake ;
config . hamlib _dcd = hamlib _dcd ;
config . hamlib _rigctld _port = rigctld _port ;
config . hamlib _rigctld _ip = rigctld _ip ;
config . hamlib _rigctld _server _port = hamlib _rigctld _server _port ;
config . enable _scatter = enable _scatter ;
config . enable _fft = enable _fft ;
config . enable _fsk = enable _fsk ;
config . low _bandwidth _mode = low _bandwidth _mode ;
config . tx _audio _level = tx _audio _level ;
config . respond _to _cq = respond _to _cq ;
config . rx _buffer _size = rx _buffer _size ;
config . enable _explorer = enable _explorer ;
config . explorer _stats = explorer _stats ;
config . auto _tune = auto _tune ;
2023-03-06 11:48:27 +00:00
config . tx _delay = tx _delay ;
2023-05-17 13:38:52 +00:00
config . tci _ip = tci _ip ;
config . tci _port = tci _port ;
2023-07-03 07:26:42 +00:00
config . enable _mesh _features = enable _mesh _features ;
2023-02-11 21:49:07 +00:00
2023-03-03 03:05:45 +00:00
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
2023-03-03 03:06:25 +00:00
FD . saveConfig ( config , configPath ) ;
2023-04-26 01:11:06 +00:00
//Display a message if hamlib control is enabled and not running
2023-04-26 01:19:02 +00:00
if (
config . radiocontrol == "rigctld" &&
rigctldActive == false &&
( config . auto _start == 0 || tncStartCount > 1 )
) {
2023-04-26 01:11:06 +00:00
if (
2023-04-26 01:19:02 +00:00
! window . confirm (
2023-07-05 16:43:56 +00:00
"Rig control is set to hamlib/rigctl, but it doesn't appear to be running.\n\nPlease start rigctld (start button in Rig Control area), or use rigctl mode 'none'. If you're having issues starting rigctld please review the Hamlib tab in settings.\n\nClick OK to continue or cancel to abort." ,
2023-04-26 01:11:06 +00:00
)
2023-04-26 01:19:02 +00:00
) {
return ;
}
2023-04-26 01:11:06 +00:00
}
2023-02-11 21:49:07 +00:00
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 _bandwidth _mode ,
tuning _range _fmin ,
tuning _range _fmax ,
enable _fsk ,
tx _audio _level ,
respond _to _cq ,
rx _buffer _size ,
enable _explorer ,
explorer _stats ,
2023-03-06 11:48:27 +00:00
auto _tune ,
2023-05-17 13:38:52 +00:00
tx _delay ,
tci _ip ,
2023-07-03 04:31:48 +00:00
tci _port ,
2023-07-05 16:43:56 +00:00
enable _mesh _features ,
2023-02-11 21:49:07 +00:00
) ;
} ) ;
document . getElementById ( "tncLog" ) . addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "request-open-tnc-log" ) ;
} ) ;
2023-05-28 15:19:21 +00:00
document . getElementById ( "meshtable" ) . addEventListener ( "click" , ( ) => {
ipcRenderer . send ( "request-open-mesh-module" ) ;
} ) ;
2023-02-11 21:49:07 +00:00
// stopTNC button clicked
document . getElementById ( "stopTNC" ) . addEventListener ( "click" , ( ) => {
if ( ! confirm ( "Stop the TNC?" ) ) return ;
daemon . stopTNC ( ) ;
} ) ;
2023-07-02 13:43:54 +00:00
// btnCleanDB button clicked
document . getElementById ( "btnCleanDB" ) . addEventListener ( "click" , ( ) => {
2023-07-04 17:49:23 +00:00
document . getElementById ( "divCleanDBSpinner" ) . classList . remove ( "invisible" ) ;
2023-07-02 13:43:54 +00:00
ipcRenderer . send ( "request-clean-db" ) ;
} ) ;
2023-07-01 21:03:22 +00:00
2023-02-11 21:49:07 +00:00
// TEST HAMLIB
document . getElementById ( "testHamlib" ) . addEventListener ( "click" , ( ) => {
2023-02-12 13:44:13 +00:00
var data _bits = document . getElementById ( "hamlib_data_bits" ) . value ;
var stop _bits = document . getElementById ( "hamlib_stop_bits" ) . value ;
2023-02-11 21:49:07 +00:00
var handshake = document . getElementById ( "hamlib_handshake" ) . value ;
var pttport = document . getElementById ( "hamlib_ptt_port" ) . 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_pttprotocol" ) . value ;
if ( document . getElementById ( "radio-control-switch-disabled" ) . checked ) {
var radiocontrol = "disabled" ;
} else {
var radiocontrol = "rigctld" ;
}
daemon . testHamlib (
radiocontrol ,
deviceid ,
deviceport ,
serialspeed ,
pttprotocol ,
pttport ,
data _bits ,
stop _bits ,
handshake ,
rigctld _ip ,
2023-07-05 16:43:56 +00:00
rigctld _port ,
2023-02-11 21:49:07 +00:00
) ;
} ) ;
// START TRANSMISSION
document . getElementById ( "startTransmission" ) . addEventListener ( "click" , ( ) => {
var fileList = document . getElementById ( "dataModalFile" ) . files ;
console . log ( fileList ) ;
var reader = new FileReader ( ) ;
reader . readAsBinaryString ( fileList [ 0 ] ) ;
//reader.readAsDataURL(fileList[0]);
reader . onload = function ( e ) {
// binary data
var data = e . target . result ;
console . log ( data ) ;
let Data = {
command : "send_file" ,
dxcallsign : document
. getElementById ( "dataModalDxCall" )
. value . toUpperCase ( ) ,
mode : document . getElementById ( "datamode" ) . value ,
frames : document . getElementById ( "framesperburst" ) . value ,
filetype : fileList [ 0 ] . type ,
filename : fileList [ 0 ] . name ,
data : data ,
checksum : "123123123" ,
} ;
// only send command if dxcallsign entered and we have a file selected
if ( document . getElementById ( "dataModalDxCall" ) . value . length > 0 ) {
ipcRenderer . send ( "run-tnc-command" , Data ) ;
}
} ;
reader . onerror = function ( e ) {
// error occurred
console . log ( "Error : " + e . type ) ;
} ;
} ) ;
// STOP TRANSMISSION
document . getElementById ( "stopTransmission" ) . addEventListener ( "click" , ( ) => {
let Data = {
command : "stop_transmission" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
} ) ;
// STOP TRANSMISSION AND CONNECRTION
document
. getElementById ( "stop_transmission_connection" )
. addEventListener ( "click" , ( ) => {
let Data = {
command : "stop_transmission" ,
} ;
ipcRenderer . send ( "run-tnc-command" , Data ) ;
sock . disconnectARQ ( ) ;
} ) ;
// OPEN CHAT MODULE
document . getElementById ( "openRFChat" ) . addEventListener ( "click" , ( ) => {
let Data = {
command : "openRFChat" ,
} ;
ipcRenderer . send ( "request-show-chat-window" , Data ) ;
} ) ;
2023-05-14 13:10:01 +00:00
document . getElementById ( "thTime" ) . addEventListener ( "click" , ( ) => {
2023-05-14 13:11:10 +00:00
if ( hslLastSort == 0 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 0 ) ;
2023-05-15 21:03:51 +00:00
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
document . getElementById ( "thFreq" ) . addEventListener ( "click" , ( ) => {
2023-05-14 13:11:10 +00:00
if ( hslLastSort == 1 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 1 ) ;
2023-05-15 21:03:51 +00:00
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
document . getElementById ( "thDxcall" ) . addEventListener ( "click" , ( ) => {
2023-05-14 13:11:10 +00:00
if ( hslLastSort == 3 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 3 ) ;
2023-05-15 21:03:51 +00:00
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
document . getElementById ( "thDxgrid" ) . addEventListener ( "click" , ( ) => {
2023-05-14 13:11:10 +00:00
if ( hslLastSort == 4 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 4 ) ;
2023-05-15 21:03:51 +00:00
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
document . getElementById ( "thDist" ) . addEventListener ( "click" , ( ) => {
2023-05-14 13:11:10 +00:00
if ( hslLastSort == 5 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 5 ) ;
2023-05-15 21:03:51 +00:00
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
2023-05-15 21:12:52 +00:00
document . getElementById ( "thType" ) . addEventListener ( "click" , ( ) => {
if ( hslLastSort == 6 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 6 ) ;
resetSortIcon ( ) ;
} ) ;
document . getElementById ( "thSnr" ) . addEventListener ( "click" , ( ) => {
if ( hslLastSort == 7 && hslLastSortDir == "asc" ) hslLastSortDir = "desc" ;
else hslLastSortDir = "asc" ;
sorthslTable ( 7 ) ;
resetSortIcon ( ) ;
2023-05-14 13:10:01 +00:00
} ) ;
2023-05-20 18:43:27 +00:00
2023-07-05 16:43:56 +00:00
autostart _rigctld ( ) ;
2023-02-11 05:53:14 +00:00
} ) ;
2023-07-02 15:33:53 +00:00
//End of domcontentloaded
2023-02-11 05:53:14 +00:00
2023-05-15 21:13:50 +00:00
function resetSortIcon ( ) {
2023-05-15 21:03:51 +00:00
document . getElementById ( "hslSort" ) . remove ( ) ;
2023-05-15 21:13:50 +00:00
let headers = document . querySelectorAll (
2023-07-05 16:43:56 +00:00
"#tblHeardStationList > thead > tr > th" ,
2023-05-15 21:13:50 +00:00
) ;
2023-05-18 19:53:33 +00:00
if ( hslLastSortDir == "desc" ) text = "bi-sort-up" ;
2023-05-18 19:52:18 +00:00
else text = "bi-sort-down" ;
2023-05-18 19:53:33 +00:00
const sicon = document . createElement ( "i" ) ;
sicon . id = "hslSort" ;
sicon . classList . add ( "bi" , text ) ;
2023-05-18 19:52:18 +00:00
headers [ hslLastSort ] . prepend ( sicon ) ;
2023-05-15 21:03:51 +00:00
}
2023-02-11 21:49:07 +00:00
function connectedStation ( data ) {
if ( typeof data . dxcallsign == "undefined" ) {
return ;
}
if (
! ( typeof data . arq == "undefined" ) &&
data . arq . toLowerCase ( ) == "session"
) {
var prefix = "w/ " ;
} else {
switch ( data . irs ) {
case "True" :
//We are receiving station
var prefix = "de " ;
break ;
case "False" :
//We are sending station
var prefix = "to " ;
break ;
default :
//Shouldn't happen
console . trace ( "No data.irs data in tnc-message" ) ;
var prefix = "" ;
break ;
}
}
document . getElementById ( "txtConnectedWith" ) . textContent =
prefix + data . dxcallsign ;
}
2021-08-07 18:57:36 +00:00
2023-07-04 17:49:23 +00:00
//Called by chat to turn off db clean spinner
2023-07-05 16:43:56 +00:00
ipcRenderer . on ( "action-update-dbclean-spinner" , ( ) => {
document . getElementById ( "divCleanDBSpinner" ) . classList . add ( "invisible" ) ;
2023-07-04 17:49:23 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
//Listen for events caused by tnc 'tnc-message' rx
ipcRenderer . on ( "action-update-reception-status" , ( event , arg ) => {
var data = arg [ "data" ] [ 0 ] ;
var txprog = document . getElementById ( "transmission_progress" ) ;
ipcRenderer . send ( "request-show-electron-progressbar" , data . percent ) ;
txprog . setAttribute ( "aria-valuenow" , data . percent ) ;
txprog . setAttribute ( "style" , "width:" + data . percent + "%;" ) ;
// SET TIME LEFT UNTIL FINIHED
if ( typeof data . finished == "undefined" ) {
var time _left = "time left: estimating" ;
} else {
var arq _seconds _until _finish = data . finished ;
var hours = Math . floor ( arq _seconds _until _finish / 3600 ) ;
var minutes = Math . floor ( ( arq _seconds _until _finish % 3600 ) / 60 ) ;
var seconds = arq _seconds _until _finish % 60 ;
if ( hours < 0 ) {
hours = 0 ;
}
if ( minutes < 0 ) {
minutes = 0 ;
}
if ( seconds < 0 ) {
seconds = 0 ;
}
if ( hours > 0 ) {
time _left =
"time left: ~" +
hours . toString ( ) . padStart ( 2 , "0" ) +
":" +
minutes . toString ( ) . padStart ( 2 , "0" ) +
"." +
seconds . toString ( ) . padStart ( 2 , "0" ) ;
2021-08-08 09:09:18 +00:00
} else {
2023-02-11 21:49:07 +00:00
time _left =
"time left: ~" +
minutes . toString ( ) . padStart ( 2 , "0" ) +
"." +
seconds . toString ( ) . padStart ( 2 , "0" ) ;
}
}
var time _left = "<strong>" + time _left + " || Speed/min: " ;
// SET BYTES PER MINUTE
2023-04-22 10:38:56 +00:00
2023-02-11 21:49:07 +00:00
if ( typeof data . bytesperminute == "undefined" ) {
var arq _bytes _per _minute = 0 ;
} else {
var arq _bytes _per _minute = data . bytesperminute ;
}
// SET BYTES PER MINUTE COMPRESSED
var compress = data . compression ;
if ( isNaN ( compress ) ) {
compress = 1 ;
}
var arq _bytes _per _minute _compressed = Math . round (
2023-07-05 16:43:56 +00:00
arq _bytes _per _minute * compress ,
2023-02-11 21:49:07 +00:00
) ;
2023-04-22 10:39:19 +00:00
console . log ( arq _bytes _per _minute ) ;
2023-02-11 21:49:07 +00:00
time _left +=
formatBytes ( arq _bytes _per _minute , 1 ) +
" (comp: " +
formatBytes ( arq _bytes _per _minute _compressed , 1 ) +
")</strong>" ;
document . getElementById ( "transmission_timeleft" ) . innerHTML = time _left ;
connectedStation ( data ) ;
} ) ;
2021-08-07 18:57:36 +00:00
2023-02-11 21:49:07 +00:00
//Listen for events caused by tnc 'tnc-message's tx
ipcRenderer . on ( "action-update-transmission-status" , ( event , arg ) => {
var data = arg [ "data" ] [ 0 ] ;
var txprog = document . getElementById ( "transmission_progress" ) ;
ipcRenderer . send ( "request-show-electron-progressbar" , data . percent ) ;
txprog . setAttribute ( "aria-valuenow" , data . percent ) ;
txprog . setAttribute ( "style" , "width:" + data . percent + "%;" ) ;
// SET TIME LEFT UNTIL FINIHED
if ( typeof data . finished == "undefined" ) {
var time _left = "time left: estimating" ;
} else {
var arq _seconds _until _finish = data . finished ;
var hours = Math . floor ( arq _seconds _until _finish / 3600 ) ;
var minutes = Math . floor ( ( arq _seconds _until _finish % 3600 ) / 60 ) ;
var seconds = arq _seconds _until _finish % 60 ;
if ( hours < 0 ) {
hours = 0 ;
}
if ( minutes < 0 ) {
minutes = 0 ;
}
if ( seconds < 0 ) {
seconds = 0 ;
}
if ( hours > 0 ) {
time _left =
"time left: ~" +
hours . toString ( ) . padStart ( 2 , "0" ) +
":" +
minutes . toString ( ) . padStart ( 2 , "0" ) +
"." +
seconds . toString ( ) . padStart ( 2 , "0" ) ;
} else {
time _left =
"time left: ~" +
minutes . toString ( ) . padStart ( 2 , "0" ) +
"." +
seconds . toString ( ) . padStart ( 2 , "0" ) ;
}
}
var time _left = "<strong>" + time _left + " || Speed/min: " ;
// SET BYTES PER MINUTE
if ( typeof data . bytesperminute == "undefined" ) {
var arq _bytes _per _minute = 0 ;
} else {
var arq _bytes _per _minute = data . bytesperminute ;
}
// SET BYTES PER MINUTE COMPRESSED
var compress = data . compression ;
if ( isNaN ( compress ) ) {
compress = 1 ;
}
var arq _bytes _per _minute _compressed = Math . round (
2023-07-05 16:43:56 +00:00
arq _bytes _per _minute * compress ,
2023-02-11 21:49:07 +00:00
) ;
time _left +=
formatBytes ( arq _bytes _per _minute , 1 ) +
" (comp: " +
formatBytes ( arq _bytes _per _minute _compressed , 1 ) +
")</strong>" ;
2023-02-20 17:55:21 +00:00
document . getElementById ( "transmission_timeleft" ) . innerHTML = time _left ;
2023-02-11 21:49:07 +00:00
connectedStation ( data ) ;
} ) ;
2021-08-07 18:57:36 +00:00
2023-02-15 21:12:38 +00:00
//Just some stuff I want to experiment with - n1qm
//https://gist.github.com/senseisimple/002cdba344de92748695a371cef0176a
2023-02-15 21:15:36 +00:00
function signal _quality _perc _quad ( rssi , perfect _rssi = 10 , worst _rssi = - 150 ) {
nominal _rssi = perfect _rssi - worst _rssi ;
signal _quality =
( 100 * ( perfect _rssi - worst _rssi ) * ( perfect _rssi - worst _rssi ) -
( perfect _rssi - rssi ) *
( 15 * ( perfect _rssi - worst _rssi ) + 62 * ( perfect _rssi - rssi ) ) ) /
( ( perfect _rssi - worst _rssi ) * ( perfect _rssi - worst _rssi ) ) ;
2023-02-15 21:12:38 +00:00
if ( signal _quality > 100 ) {
signal _quality = 100 ;
} else if ( signal _quality < 1 ) {
signal _quality = 0 ;
}
return Math . ceil ( signal _quality ) ;
2023-02-15 21:15:36 +00:00
}
2023-02-11 21:49:07 +00:00
var lastHeard = "" ;
2023-07-02 13:43:54 +00:00
var checkForNewMessageWait = 85 ;
2023-06-11 06:07:40 +00:00
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-update-tnc-state" , ( event , arg ) => {
2023-06-11 06:07:40 +00:00
//check for new messages
2023-07-02 13:43:54 +00:00
if ( checkForNewMessageWait >= 100 ) {
2023-06-11 06:07:40 +00:00
//This is very expensive
ipcRenderer . send ( "request-update-unread-messages" ) ;
2023-07-02 13:43:54 +00:00
checkForNewMessageWait = - 1 ;
2023-06-11 06:07:40 +00:00
}
checkForNewMessageWait ++ ;
2023-02-11 21:49:07 +00:00
// update FFT
if ( typeof arg . fft !== "undefined" ) {
2023-05-12 20:14:38 +00:00
// FIXME: WE need to fix this when disabled waterfall chart
try {
var array = JSON . parse ( "[" + arg . fft + "]" ) ;
spectrum . addData ( array [ 0 ] ) ;
} catch ( e ) {
console . log ( e ) ;
2023-05-12 20:14:07 +00:00
}
2023-02-11 21:49:07 +00:00
}
if ( typeof arg . mycallsign !== "undefined" ) {
updateTitle ( arg . mycallsign ) ;
}
// update mygrid information with data from tnc
if ( typeof arg . mygrid !== "undefined" ) {
document . getElementById ( "myGrid" ) . value = arg . mygrid ;
}
// DATA STATE
global . rxBufferLengthTnc = arg . rx _buffer _length ;
// START OF SCATTER CHART
2023-02-26 06:03:32 +00:00
if ( typeof arg . scatter == "undefined" ) {
2023-02-26 02:29:12 +00:00
var scatterSize = 0 ;
} else {
var scatterSize = arg . scatter . length ;
}
if ( scatterSize > 0 && global . scatterData != newScatterData ) {
const scatterConfig = {
plugins : {
legend : {
display : false ,
} ,
tooltip : {
enabled : false ,
} ,
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 ,
} ,
2023-02-11 21:49:07 +00:00
} ,
} ,
} ,
2023-02-26 02:29:12 +00:00
animations : false ,
scales : {
x : {
type : "linear" ,
position : "bottom" ,
display : true ,
min : - 80 ,
max : 80 ,
ticks : {
display : false ,
} ,
2023-02-11 21:49:07 +00:00
} ,
2023-02-26 02:29:12 +00:00
y : {
display : true ,
min : - 80 ,
max : 80 ,
ticks : {
display : false ,
} ,
2023-02-11 21:49:07 +00:00
} ,
} ,
2023-02-26 02:29:12 +00:00
} ;
var scatterData = arg . scatter ;
var newScatterData = {
datasets : [
{
//label: 'constellation diagram',
data : scatterData ,
options : scatterConfig ,
backgroundColor : "rgb(255, 99, 132)" ,
} ,
] ,
} ;
2023-02-11 21:49:07 +00:00
global . scatterData = newScatterData ;
if ( typeof global . scatterChart == "undefined" ) {
var scatterCtx = document . getElementById ( "scatter" ) . getContext ( "2d" ) ;
global . scatterChart = new Chart ( scatterCtx , {
type : "scatter" ,
data : global . scatterData ,
options : scatterConfig ,
} ) ;
} else {
global . scatterChart . data = global . scatterData ;
global . scatterChart . update ( ) ;
}
}
// END OF SCATTER CHART
// START OF SPEED CHART
var speedDataTime = [ ] ;
if ( typeof arg . speed _list == "undefined" ) {
var speed _listSize = 0 ;
} else {
var speed _listSize = arg . speed _list . length ;
}
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
var timestamp = arg . speed _list [ i ] . timestamp * 1000 ;
var h = new Date ( timestamp ) . getHours ( ) ;
var m = new Date ( timestamp ) . getMinutes ( ) ;
var s = new Date ( timestamp ) . getSeconds ( ) ;
var time = h + ":" + m + ":" + s ;
speedDataTime . push ( time ) ;
}
var speedDataBpm = [ ] ;
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
speedDataBpm . push ( arg . speed _list [ i ] . bpm ) ;
}
var speedDataSnr = [ ] ;
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
2023-02-15 13:09:51 +00:00
let snr = NaN ;
2023-02-15 13:20:56 +00:00
if ( arg . speed _list [ i ] . snr !== 0 ) {
snr = arg . speed _list [ i ] . snr ;
2023-02-15 13:26:14 +00:00
} else {
2023-02-15 13:26:32 +00:00
snr = NaN ;
2023-02-15 13:20:56 +00:00
}
2023-02-15 13:26:14 +00:00
speedDataSnr . push ( snr ) ;
2023-02-11 21:49:07 +00:00
}
var speedChartConfig = {
type : "line" ,
} ;
// https://www.chartjs.org/docs/latest/samples/line/segments.html
const skipped = ( speedCtx , value ) =>
speedCtx . p0 . skip || speedCtx . p1 . skip ? value : undefined ;
const down = ( speedCtx , value ) =>
speedCtx . p0 . parsed . y > speedCtx . p1 . parsed . y ? value : undefined ;
var newSpeedData = {
labels : speedDataTime ,
datasets : [
{
type : "line" ,
label : "SNR[dB]" ,
data : speedDataSnr ,
borderColor : "rgb(75, 192, 192, 1.0)" ,
2023-02-15 13:19:35 +00:00
pointRadius : 1 ,
2023-02-11 21:49:07 +00:00
segment : {
2023-02-15 13:36:36 +00:00
borderColor : ( speedCtx ) =>
2023-02-15 13:41:51 +00:00
skipped ( speedCtx , "rgb(0,0,0,0.4)" ) ||
down ( speedCtx , "rgb(192,75,75)" ) ,
2023-02-15 13:36:36 +00:00
borderDash : ( speedCtx ) => skipped ( speedCtx , [ 3 , 3 ] ) ,
2023-02-11 21:49:07 +00:00
} ,
spanGaps : true ,
backgroundColor : "rgba(75, 192, 192, 0.2)" ,
order : 1 ,
yAxisID : "SNR" ,
} ,
{
type : "bar" ,
label : "Speed[bpm]" ,
data : speedDataBpm ,
borderColor : "rgb(120, 100, 120, 1.0)" ,
backgroundColor : "rgba(120, 100, 120, 0.2)" ,
order : 0 ,
yAxisID : "SPEED" ,
} ,
] ,
} ;
var speedChartOptions = {
responsive : true ,
animations : true ,
cubicInterpolationMode : "monotone" ,
tension : 0.4 ,
scales : {
SNR : {
type : "linear" ,
2023-02-15 13:19:35 +00:00
ticks : { beginAtZero : false , color : "rgb(255, 99, 132)" } ,
2023-02-11 21:49:07 +00:00
position : "right" ,
} ,
SPEED : {
type : "linear" ,
2023-02-15 13:19:35 +00:00
ticks : { beginAtZero : false , color : "rgb(120, 100, 120)" } ,
2023-02-11 21:49:07 +00:00
position : "left" ,
grid : {
drawOnChartArea : false , // only want the grid lines for one axis to show up
} ,
} ,
x : { ticks : { beginAtZero : true } } ,
} ,
} ;
if ( typeof global . speedChart == "undefined" ) {
var speedCtx = document . getElementById ( "chart" ) . getContext ( "2d" ) ;
global . speedChart = new Chart ( speedCtx , {
data : newSpeedData ,
options : speedChartOptions ,
} ) ;
} else {
if ( speedDataSnr . length > 0 ) {
global . speedChart . data = newSpeedData ;
global . speedChart . update ( ) ;
}
}
// END OF SPEED CHART
// PTT STATE
switch ( arg . ptt _state ) {
case "True" :
2023-04-20 09:55:17 +00:00
document . getElementById ( "ptt_state" ) . className =
"btn btn-sm btn-danger me-1" ;
2023-02-11 21:49:07 +00:00
break ;
case "False" :
2023-04-20 09:55:17 +00:00
document . getElementById ( "ptt_state" ) . className =
"btn btn-sm btn-success me-1" ;
2023-02-11 21:49:07 +00:00
break ;
default :
document . getElementById ( "ptt_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-secondary me-1" ;
2023-02-11 21:49:07 +00:00
break ;
}
// AUDIO RECORDING
if ( arg . audio _recording == "True" ) {
2023-04-20 09:55:17 +00:00
document . getElementById ( "startStopRecording" ) . textContent = "Stop Rec" ;
2023-02-11 21:49:07 +00:00
} else {
2023-04-20 09:55:17 +00:00
document . getElementById ( "startStopRecording" ) . textContent = "Record" ;
2023-02-11 21:49:07 +00:00
}
2023-02-15 22:19:07 +00:00
//CHANNEL CODEC2 BUSY STATE
if ( arg . is _codec2 _traffic == "True" ) {
2023-02-26 06:03:32 +00:00
document . getElementById ( "c2_busy" ) . className = "btn btn-sm btn-success" ;
2023-02-15 22:19:07 +00:00
} else {
2023-02-26 06:03:32 +00:00
document . getElementById ( "c2_busy" ) . className =
"btn btn-sm btn-outline-secondary" ;
2023-02-15 22:19:07 +00:00
}
2023-02-11 21:49:07 +00:00
// CHANNEL BUSY STATE
switch ( arg . channel _busy ) {
case "True" :
2023-02-26 06:03:32 +00:00
document . getElementById ( "channel_busy" ) . className =
"btn btn-sm btn-danger" ;
2023-02-11 21:49:07 +00:00
break ;
case "False" :
2023-02-26 06:03:32 +00:00
document . getElementById ( "channel_busy" ) . className =
"btn btn-sm btn-success" ;
2023-02-11 21:49:07 +00:00
break ;
default :
2023-02-26 06:03:32 +00:00
document . getElementById ( "channel_busy" ) . className =
"btn btn-sm btn-secondary" ;
2023-02-11 21:49:07 +00:00
break ;
}
// BUSY STATE
switch ( arg . busy _state ) {
case "BUSY" :
2023-04-20 09:55:17 +00:00
document . getElementById ( "busy_state" ) . className =
"btn btn-sm btn-danger me-1" ;
2023-02-26 02:29:12 +00:00
//Seems to be no longer user accessible
//document.getElementById("startTransmission").disabled = true;
2023-02-11 21:49:07 +00:00
break ;
case "IDLE" :
document . getElementById ( "busy_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-success me-1" ;
2023-02-11 21:49:07 +00:00
break ;
default :
document . getElementById ( "busy_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-secondary me-1" ;
2023-02-26 02:29:12 +00:00
//Seems to be no longer user accessible
//document.getElementById("startTransmission").disabled = true;
2023-02-11 21:49:07 +00:00
break ;
}
// ARQ STATE
switch ( arg . arq _state ) {
case "True" :
2023-04-20 09:55:17 +00:00
document . getElementById ( "arq_state" ) . className =
"btn btn-sm btn-warning me-1" ;
2023-02-26 02:29:12 +00:00
//Seems to be no longer user accessible
//document.getElementById("startTransmission").disabled = false;
2023-02-11 21:49:07 +00:00
break ;
default :
document . getElementById ( "arq_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-secondary me-1" ;
2023-02-26 02:29:12 +00:00
//Seems to be no longer user accessible
//document.getElementById("startTransmission").disabled = false;
2023-02-11 21:49:07 +00:00
break ;
}
// ARQ SESSION
switch ( arg . arq _session ) {
case "True" :
document . getElementById ( "arq_session" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-warning me-1" ;
2023-02-11 21:49:07 +00:00
break ;
default :
document . getElementById ( "arq_session" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-secondary me-1" ;
2023-02-11 21:49:07 +00:00
break ;
}
if ( arg . arq _state == "True" || arg . arq _session == "True" ) {
2023-02-26 06:03:32 +00:00
document . getElementById ( "spnConnectedWith" ) . className =
2023-04-20 09:54:47 +00:00
"bi bi-chat-fill text-success me-1" ;
2023-02-11 21:49:07 +00:00
} else {
2023-02-26 02:29:12 +00:00
document . getElementById ( "spnConnectedWith" ) . className = "bi bi-chat-fill" ;
2023-06-09 22:10:11 +00:00
ipcRenderer . send ( "request-clear-chat-connected" ) ;
2023-02-11 21:49:07 +00:00
}
// HAMLIB STATUS
if ( arg . hamlib _status == "connected" ) {
document . getElementById ( "rigctld_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-success btn-sm me-1" ;
2023-02-11 21:49:07 +00:00
} else {
document . getElementById ( "rigctld_state" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-secondary btn-sm me-1" ;
2023-02-11 21:49:07 +00:00
}
// BEACON
switch ( arg . beacon _state ) {
case "True" :
2023-02-26 06:03:32 +00:00
document . getElementById ( "startBeacon" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-success ms-1" ;
2023-02-12 04:05:48 +00:00
if ( document . getElementById ( "beaconInterval" ) . disabled == false ) {
2023-02-12 04:04:57 +00:00
document . getElementById ( "beaconInterval" ) . disabled = true ;
2023-02-11 21:49:07 +00:00
}
break ;
default :
2023-02-26 06:03:32 +00:00
document . getElementById ( "startBeacon" ) . className =
2023-04-20 09:54:47 +00:00
"btn btn-sm btn-outline-secondary ms-1" ;
2023-02-12 04:04:57 +00:00
if ( document . getElementById ( "beaconInterval" ) . disabled == true ) {
document . getElementById ( "beaconInterval" ) . disabled = false ;
}
2023-02-11 21:49:07 +00:00
break ;
}
// dbfs
// https://www.moellerstudios.org/converting-amplitude-representations/
2023-02-26 23:41:51 +00:00
if (
arg . dbfs _level . length != 0 &&
! isNaN ( arg . dbfs _level ) &&
dbfs _level _raw != arg . dbfs _level
) {
2023-02-11 21:49:07 +00:00
dbfs _level _raw = arg . dbfs _level ;
dbfs _level = Math . pow ( 10 , arg . dbfs _level / 20 ) * 100 ;
document . getElementById ( "dbfs_level_value" ) . textContent =
2023-02-14 14:50:44 +00:00
Math . round ( arg . dbfs _level ) + " dBFS (Audio Level)" ;
2023-02-11 21:49:07 +00:00
var dbfscntrl = document . getElementById ( "dbfs_level" ) ;
dbfscntrl . setAttribute ( "aria-valuenow" , dbfs _level ) ;
2023-02-26 06:03:32 +00:00
dbfscntrl . style = "width:" + dbfs _level + "%;" ;
2023-02-26 02:29:12 +00:00
//dbfscntrl.setAttribute("style", "width:" + dbfs_level + "%;");
2023-02-11 21:49:07 +00:00
}
2023-02-14 14:18:08 +00:00
// noise / strength
// https://www.moellerstudios.org/converting-amplitude-representations/
2023-02-26 23:41:51 +00:00
if (
2023-02-27 10:22:09 +00:00
arg . strength != 0 &&
2023-02-26 23:41:51 +00:00
! isNaN ( arg . strength ) &&
noise _level _raw != arg . strength
) {
2023-02-14 21:13:48 +00:00
//console.log(arg.strength);
2023-02-14 14:18:08 +00:00
noise _level _raw = arg . strength ;
noise _level = Math . pow ( 10 , arg . strength / 20 ) * 100 ;
document . getElementById ( "noise_level_value" ) . textContent =
2023-02-14 14:25:00 +00:00
Math . round ( arg . strength ) + " dB (S-Meter)" ;
2023-02-14 14:18:08 +00:00
var noisecntrl = document . getElementById ( "noise_level" ) ;
noisecntrl . setAttribute ( "aria-valuenow" , noise _level ) ;
2023-02-26 02:29:12 +00:00
noisecntrl . style = "width:" + noise _level + "%;" ;
//noisecntrl.setAttribute("style", "width:" + noise_level + "%;");
2023-02-14 14:18:08 +00:00
}
2023-02-11 21:49:07 +00:00
// SET FREQUENCY
// https://stackoverflow.com/a/2901298
var freq = arg . frequency . toString ( ) . replace ( /\B(?=(\d{3})+(?!\d))/g , "." ) ;
document . getElementById ( "frequency" ) . textContent = freq ;
//document.getElementById("newFrequency").value = arg.frequency;
// SET MODE
document . getElementById ( "mode" ) . textContent = arg . mode ;
// SET bandwidth
document . getElementById ( "bandwidth" ) . textContent = arg . bandwidth ;
// SET SPEED LEVEL
switch ( arg . speed _level ) {
case "0" :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-1" ;
break ;
case "1" :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-2" ;
break ;
case "2" :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-3" ;
break ;
default :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-4" ;
break ;
}
// SET TOTAL BYTES
if ( typeof arg . total _bytes == "undefined" ) {
var total _bytes = 0 ;
} else {
var total _bytes = arg . total _bytes ;
}
document . getElementById ( "total_bytes" ) . textContent = total _bytes ;
//Check if heard station list has changed
if (
typeof arg . stations != "undefined" &&
arg . stations . length > 0 &&
JSON . stringify ( arg . stations ) != lastHeard
) {
//console.log("Updating last heard stations");
lastHeard = JSON . stringify ( arg . stations ) ;
updateHeardStations ( arg ) ;
}
} ) ;
2021-08-07 18:57:36 +00:00
2023-02-11 21:49:07 +00:00
function updateHeardStations ( arg ) {
// UPDATE HEARD STATIONS
var tbl = document . getElementById ( "heardstations" ) ;
tbl . innerHTML = "" ;
if ( typeof arg . stations == "undefined" ) {
var heardStationsLength = 0 ;
} else {
var heardStationsLength = arg . stations . length ;
}
for ( i = 0 ; i < heardStationsLength ; i ++ ) {
// first we update the PING window
if (
arg . stations [ i ] [ "dxcallsign" ] ==
document . getElementById ( "dxCall" ) . value . toUpperCase ( )
) {
var dxGrid = arg . stations [ i ] [ "dxgrid" ] ;
var myGrid = document . getElementById ( "myGrid" ) . value ;
try {
var dist = parseInt ( distance ( myGrid , dxGrid ) ) + " km" ;
document . getElementById ( "dataModalPingDistance" ) . textContent = dist ;
} catch {
document . getElementById ( "dataModalPingDistance" ) . textContent = "---" ;
}
document . getElementById ( "dataModalPingDB" ) . textContent =
arg . stations [ i ] [ "snr" ] ;
}
// now we update the heard stations list
var row = document . createElement ( "tr" ) ;
//https://stackoverflow.com/q/51421470
//https://stackoverflow.com/a/847196
timestampRaw = arg . stations [ i ] [ "timestamp" ] ;
2023-04-22 10:38:56 +00:00
2023-04-22 10:39:19 +00:00
var datetime = new Date ( timestampRaw * 1000 ) . toLocaleString (
2023-07-02 13:43:54 +00:00
navigator . language ,
{
hourCycle : "h23" ,
2023-05-25 03:20:28 +00:00
year : "numeric" ,
month : "2-digit" ,
day : "2-digit" ,
hour : "2-digit" ,
minute : "2-digit" ,
2023-07-02 13:43:54 +00:00
second : "2-digit" ,
2023-07-05 16:43:56 +00:00
} ,
2023-04-22 10:39:19 +00:00
) ;
2023-04-22 10:38:56 +00:00
//var hours = date.getHours();
//var minutes = "0" + date.getMinutes();
//var seconds = "0" + date.getSeconds();
//var datetime = hours + ":" + minutes.substr(-2) + ":" + seconds.substr(-2);
2023-02-11 21:49:07 +00:00
var timestamp = document . createElement ( "td" ) ;
var timestampText = document . createElement ( "span" ) ;
timestampText . innerText = datetime ;
timestamp . appendChild ( timestampText ) ;
var frequency = document . createElement ( "td" ) ;
var frequencyText = document . createElement ( "span" ) ;
frequencyText . innerText = arg . stations [ i ] [ "frequency" ] ;
frequency . appendChild ( frequencyText ) ;
var dxCall = document . createElement ( "td" ) ;
var dxCallText = document . createElement ( "span" ) ;
dxCallText . innerText = arg . stations [ i ] [ "dxcallsign" ] ;
let dxCallTextCall = dxCallText . innerText ;
let dxCallTextShort = dxCallTextCall . split ( "-" , 1 ) [ 0 ] ;
row . addEventListener ( "click" , function ( ) {
document . getElementById ( "dxCall" ) . value = dxCallTextCall ;
} ) ;
dxCall . appendChild ( dxCallText ) ;
var dxGrid = document . createElement ( "td" ) ;
var dxGridText = document . createElement ( "span" ) ;
dxGridText . innerText = arg . stations [ i ] [ "dxgrid" ] ;
dxGrid . appendChild ( dxGridText ) ;
var gridDistance = document . createElement ( "td" ) ;
var gridDistanceText = document . createElement ( "span" ) ;
try {
if ( arg . stations [ i ] [ "dxgrid" ] . toString ( ) != "------" ) {
gridDistanceText . innerText =
parseInt (
distance (
document . getElementById ( "myGrid" ) . value ,
2023-07-05 16:43:56 +00:00
arg . stations [ i ] [ "dxgrid" ] ,
) ,
2023-02-11 21:49:07 +00:00
) + " km" ;
} else {
gridDistanceText . innerText = "---" ;
}
} catch {
gridDistanceText . innerText = "---" ;
}
gridDistance . appendChild ( gridDistanceText ) ;
var dataType = document . createElement ( "td" ) ;
var dataTypeText = document . createElement ( "span" ) ;
dataTypeText . innerText = arg . stations [ i ] [ "datatype" ] ;
dataType . appendChild ( dataTypeText ) ;
switch ( dataTypeText . innerText ) {
case "CQ CQ CQ" :
dataTypeText . textContent = "CQ CQ" ;
row . classList . add ( "table-success" ) ;
break ;
case "DATA-CHANNEL" :
dataTypeText . innerHTML =
'<i title="Data Channel" class="bi bi-file-earmark-binary-fill"></i>' ;
row . classList . add ( "table-warning" ) ;
break ;
case "BEACON" :
dataTypeText . textContent = "BCN" ;
row . classList . add ( "table-light" ) ;
break ;
case "PING" :
row . classList . add ( "table-info" ) ;
break ;
case "PING-ACK" :
row . classList . add ( "table-primary" ) ;
break ;
case "SESSION-HB" :
dataTypeText . innerHTML =
'<i title="Heartbeat" class="bi bi-heart-pulse-fill"></i>' ;
//dataType.appendChild(dataTypeText);
break ;
}
var snr = document . createElement ( "td" ) ;
var snrText = document . createElement ( "span" ) ;
snrText . innerText = arg . stations [ i ] [ "snr" ] ;
snr . appendChild ( snrText ) ;
var offset = document . createElement ( "td" ) ;
var offsetText = " " ;
if ( contrib . indexOf ( dxCallTextShort ) >= 0 ) {
var offsetText =
'<i title="Yeah baby, yeah!!!!" class="bi bi-award-fill text-primary"></i>' ;
} else {
if ( dxCallTextShort == "DJ2LS" ) {
var offsetText =
'<i title="Yeah FreeDATA, yeah!!!!" class="bi bi-emoji-wink-fill text-warning"></i>' ;
}
2021-08-07 18:57:36 +00:00
}
2023-02-11 21:49:07 +00:00
offset . innerHTML = offsetText ;
row . appendChild ( timestamp ) ;
row . appendChild ( frequency ) ;
row . appendChild ( offset ) ;
row . appendChild ( dxCall ) ;
row . appendChild ( dxGrid ) ;
row . appendChild ( gridDistance ) ;
row . appendChild ( dataType ) ;
row . appendChild ( snr ) ;
tbl . appendChild ( row ) ;
}
2023-05-14 13:10:01 +00:00
sorthslTable ( hslLastSort ) ;
2023-02-11 05:53:14 +00:00
}
2021-07-17 07:03:40 +00:00
2023-03-28 23:27:48 +00:00
var populateSerial = false ;
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-update-daemon-state" , ( event , arg ) => {
/ *
2021-11-07 11:17:23 +00:00
// 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 + "%"
2021-11-07 11:17:23 +00:00
* /
2023-02-11 21:49:07 +00:00
/ *
2022-01-05 13:15:59 +00:00
document . getElementById ( "ram_load" ) . innerHTML = arg . ram _usage + "%"
document . getElementById ( "cpu_load" ) . innerHTML = arg . cpu _usage + "%"
2022-02-08 14:27:34 +00:00
* /
2023-02-11 21:49:07 +00:00
// OPERATING SYSTEM
//document.getElementById("operating_system").innerHTML = "OS " + os.type()
2021-12-20 17:05:00 +00:00
2023-02-11 21:49:07 +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" ;
2022-02-02 20:12:16 +00:00
* /
2023-02-11 21:49:07 +00:00
/ *
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" ;
2022-02-02 20:12:16 +00:00
* /
2023-02-11 21:49:07 +00:00
/ *
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" ;
2022-02-02 20:12:16 +00:00
* /
2023-03-28 23:29:51 +00:00
if ( arg . tnc _running _state != "stopped" && populateSerial == true ) return ;
// UPDATE SERIAL DEVICES
2023-03-28 23:27:48 +00:00
if (
document . getElementById ( "hamlib_deviceport" ) . length !=
arg . serial _devices . length
) {
document . getElementById ( "hamlib_deviceport" ) . innerHTML = "" ;
var ignore = document . createElement ( "option" ) ;
ignore . text = "-- ignore --" ;
ignore . value = "ignore" ;
document . getElementById ( "hamlib_deviceport" ) . add ( ignore ) ;
for ( i = 0 ; i < arg . serial _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
option . text =
arg . serial _devices [ i ] [ "port" ] +
" -- " +
arg . serial _devices [ i ] [ "description" ] ;
option . value = arg . serial _devices [ i ] [ "port" ] ;
document . getElementById ( "hamlib_deviceport" ) . add ( option ) ;
}
// set device from config if available
document . getElementById ( "hamlib_deviceport" ) . value =
config . hamlib _deviceport ;
}
2023-02-11 21:49:07 +00:00
2023-03-28 23:27:48 +00:00
if (
document . getElementById ( "hamlib_ptt_port" ) . length !=
arg . serial _devices . length
) {
document . getElementById ( "hamlib_ptt_port" ) . innerHTML = "" ;
var ignore = document . createElement ( "option" ) ;
ignore . text = "-- ignore --" ;
ignore . value = "ignore" ;
document . getElementById ( "hamlib_ptt_port" ) . add ( ignore ) ;
for ( i = 0 ; i < arg . serial _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
option . text =
arg . serial _devices [ i ] [ "port" ] +
" -- " +
arg . serial _devices [ i ] [ "description" ] ;
option . value = arg . serial _devices [ i ] [ "port" ] ;
document . getElementById ( "hamlib_ptt_port" ) . add ( option ) ;
}
// set device from config if available
document . getElementById ( "hamlib_ptt_port" ) . value = config . hamlib _ptt _port ;
}
//Serial devices are updated on first pass
populateSerial = true ;
if ( arg . tnc _running _state != "stopped" ) return ;
2023-03-28 23:29:51 +00:00
2023-02-11 21:49:07 +00:00
// UPDATE AUDIO INPUT
2023-03-28 23:29:51 +00:00
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
if ( config . rx _audio == option . text ) {
option . setAttribute ( "selected" , true ) ;
2023-02-11 21:49:07 +00:00
}
2023-03-28 23:29:51 +00:00
document . getElementById ( "audio_input_selectbox" ) . add ( option ) ;
2021-07-17 07:03:40 +00:00
}
2023-03-28 23:29:51 +00:00
}
2023-02-11 21:49:07 +00:00
// UPDATE AUDIO OUTPUT
2023-03-28 23:29:51 +00:00
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 ) ;
2023-02-11 21:49:07 +00:00
}
2023-03-28 23:29:51 +00:00
document . getElementById ( "audio_output_selectbox" ) . add ( option ) ;
2021-07-17 07:03:40 +00:00
}
2023-03-28 23:29:51 +00:00
}
2023-05-20 18:43:27 +00:00
//Once audio devices are populated, try starting TNC if it hasn't been started yet in this session
//and if autostart is enabled
if ( tncStartCount <= 0 ) autostart _tnc ( ) ;
2022-02-12 15:34:47 +00:00
} ) ;
// ACTION UPDATE HAMLIB TEST
2023-02-11 21:49:07 +00:00
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";
}
2022-02-12 15:34:47 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
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)";
}
2022-02-12 15:34:47 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-update-tnc-connection" , ( event , arg ) => {
if ( arg . tnc _connection == "open" ) {
/ *
2022-02-08 14:27:34 +00:00
document . getElementById ( 'hamlib_deviceid' ) . disabled = true ;
document . getElementById ( 'hamlib_deviceport' ) . 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;
2022-02-08 14:27:34 +00:00
document . getElementById ( 'startTNC' ) . disabled = true ;
document . getElementById ( 'dxCall' ) . disabled = false ;
document . getElementById ( "hamlib_serialspeed" ) . disabled = true ;
document . getElementById ( "openDataModule" ) . disabled = false ;
2022-09-23 09:17:59 +00:00
* /
2021-08-28 16:46:49 +00:00
2023-02-11 21:49:07 +00:00
// collapse settings screen
var collapseFirstRow = new bootstrap . Collapse (
document . getElementById ( "collapseFirstRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseFirstRow . hide ( ) ;
var collapseSecondRow = new bootstrap . Collapse (
document . getElementById ( "collapseSecondRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseSecondRow . hide ( ) ;
var collapseThirdRow = new bootstrap . Collapse (
document . getElementById ( "collapseThirdRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseThirdRow . show ( ) ;
var collapseFourthRow = new bootstrap . Collapse (
document . getElementById ( "collapseFourthRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseFourthRow . show ( ) ;
//Set tuning for fancy graphics mode (high/low CPU)
set _CPU _mode ( ) ;
2023-05-20 18:43:27 +00:00
//GUI will auto connect to TNC if already running, if that is the case increment start count if 0
2023-07-02 13:43:54 +00:00
if ( tncStartCount == 0 ) tncStartCount ++ ;
2023-02-11 21:49:07 +00:00
} else {
/ *
2022-02-08 14:27:34 +00:00
document . getElementById ( 'hamlib_deviceid' ) . disabled = false ;
document . getElementById ( 'hamlib_deviceport' ) . 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;
2022-02-08 14:27:34 +00:00
document . getElementById ( 'startTNC' ) . disabled = false ;
document . getElementById ( 'dxCall' ) . disabled = true ;
document . getElementById ( "hamlib_serialspeed" ) . disabled = false ;
document . getElementById ( "openDataModule" ) . disabled = true ;
2022-09-23 09:17:59 +00:00
* /
2023-02-11 21:49:07 +00:00
// collapse settings screen
var collapseFirstRow = new bootstrap . Collapse (
document . getElementById ( "collapseFirstRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseFirstRow . show ( ) ;
var collapseSecondRow = new bootstrap . Collapse (
document . getElementById ( "collapseSecondRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseSecondRow . show ( ) ;
var collapseThirdRow = new bootstrap . Collapse (
document . getElementById ( "collapseThirdRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseThirdRow . hide ( ) ;
var collapseFourthRow = new bootstrap . Collapse (
document . getElementById ( "collapseFourthRow" ) ,
2023-07-05 16:43:56 +00:00
{ toggle : false } ,
2023-02-11 21:49:07 +00:00
) ;
collapseFourthRow . hide ( ) ;
}
2021-07-24 07:06:22 +00:00
} ) ;
2021-07-17 07:03:40 +00:00
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-update-rx-buffer" , ( event , arg ) => {
var data = arg . data [ "data" ] ;
2021-10-17 13:57:41 +00:00
2023-02-11 21:49:07 +00:00
var tbl = document . getElementById ( "rx-data" ) ;
document . getElementById ( "rx-data" ) . innerHTML = "" ;
2021-08-22 15:00:18 +00:00
2023-02-11 21:49:07 +00:00
for ( i = 0 ; i < arg . data . length ; i ++ ) {
// first we update the PING window
if (
arg . data [ i ] [ "dxcallsign" ] ==
document . getElementById ( "dxCall" ) . value . toUpperCase ( )
) {
/ *
2023-02-12 10:37:02 +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' ]
}
* /
2023-02-11 21:49:07 +00:00
//document.getElementById("pingDB").innerHTML = arg.stations[i]['snr'];
document . getElementById ( "dataModalPingDB" ) . innerHTML =
arg . stations [ i ] [ "snr" ] ;
}
2022-01-30 13:16:08 +00:00
2023-02-11 21:49:07 +00:00
// now we update the received files list
2021-07-19 19:01:38 +00:00
2023-02-11 21:49:07 +00:00
var row = document . createElement ( "tr" ) ;
//https://stackoverflow.com/q/51421470
2021-07-25 16:19:51 +00:00
2023-02-11 21:49:07 +00:00
//https://stackoverflow.com/a/847196
timestampRaw = arg . data [ i ] [ "timestamp" ] ;
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
2023-02-11 21:49:07 +00:00
var timestamp = document . createElement ( "td" ) ;
var timestampText = document . createElement ( "span" ) ;
timestampText . innerText = datetime ;
timestamp . appendChild ( timestampText ) ;
2021-07-25 16:19:51 +00:00
2023-02-11 21:49:07 +00:00
var dxCall = document . createElement ( "td" ) ;
var dxCallText = document . createElement ( "span" ) ;
dxCallText . innerText = arg . data [ i ] [ "dxcallsign" ] ;
dxCall . appendChild ( dxCallText ) ;
2021-07-25 16:19:51 +00:00
2023-02-11 21:49:07 +00:00
/ *
2023-02-12 10:37:02 +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
2023-02-11 21:49:07 +00:00
console . log ( arg . data ) ;
2023-03-03 03:05:45 +00:00
var encoded _data = FD . atob _FD ( arg . data [ i ] [ "data" ] ) ;
2023-02-11 21:49:07 +00:00
var splitted _data = encoded _data . split ( split _char ) ;
console . log ( splitted _data ) ;
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 ;
fileName . appendChild ( fileNameText ) ;
row . appendChild ( timestamp ) ;
row . appendChild ( dxCall ) ;
// row.appendChild(dxGrid);
row . appendChild ( fileName ) ;
tbl . appendChild ( row ) ;
// https://stackoverflow.com/a/26227660
//var appDataFolder = process.env.HOME;
//console.log("appDataFolder:" + appDataFolder);
//var applicationFolder = path.join(appDataFolder, "FreeDATA");
//console.log(applicationFolder);
//var receivedFilesFolder = path.join(applicationFolder, "receivedFiles");
var receivedFilesFolder = path . join ( config . received _files _folder ) ;
console . log ( "receivedFilesFolder: " + receivedFilesFolder ) ;
// Creates receivedFiles folder if not exists
// https://stackoverflow.com/a/13544465
fs . mkdir (
receivedFilesFolder ,
{
recursive : true ,
} ,
function ( err ) {
console . log ( err ) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
// write file to data folder
////var base64String = arg.data[i]['data'][0]['d']
// 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 ] ;
var receivedFile = path . join ( receivedFilesFolder , fileNameString ) ;
console . log ( receivedFile ) ;
require ( "fs" ) . writeFile ( receivedFile , base64Data , "binary" , function ( err ) {
//require("fs").writeFile(receivedFile, base64Data, 'base64', function(err) {
console . log ( err ) ;
} ) ;
}
2021-08-07 08:54:34 +00:00
} ) ;
2023-02-12 23:16:02 +00:00
ipcRenderer . on ( "run-tnc-command-fec-iswriting" , ( event ) => {
2023-02-12 23:15:12 +00:00
//console.log("Sending sendFecIsWriting");
sock . sendFecIsWriting ( config . mycall ) ;
} ) ;
2021-08-22 15:00:18 +00:00
2023-06-11 06:07:40 +00:00
//Change background color of RF Chat button if new messages are available
2023-07-02 13:43:54 +00:00
ipcRenderer . on ( "action-update-unread-messages-main" , ( event , data ) => {
2023-06-11 06:07:40 +00:00
//Do something
2023-07-02 13:43:54 +00:00
if ( data == true ) {
document . getElementById ( "openRFChat" ) . classList . add ( "btn-warning" ) ;
document . getElementById ( "openRFChat" ) . classList . remove ( "btn-secondary" ) ;
} else {
document . getElementById ( "openRFChat" ) . classList . remove ( "btn-warning" ) ;
document . getElementById ( "openRFChat" ) . classList . add ( "btn-secondary" ) ;
2023-06-11 06:07:40 +00:00
}
} ) ;
2023-02-11 21:49:07 +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 ) ;
}
if ( arg . command == "ping" ) {
sock . sendPing ( arg . dxcallsign ) ;
}
if ( arg . command == "send_file" ) {
sock . sendFile (
arg . dxcallsign ,
arg . mode ,
arg . frames ,
arg . filename ,
arg . filetype ,
arg . data ,
2023-07-05 16:43:56 +00:00
arg . checksum ,
2023-02-11 21:49:07 +00:00
) ;
}
2023-02-27 10:22:09 +00:00
if ( arg . command == "msg" ) {
2023-02-11 21:49:07 +00:00
sock . sendMessage (
arg . dxcallsign ,
arg . mode ,
arg . frames ,
arg . data ,
arg . checksum ,
arg . uuid ,
2023-07-05 16:43:56 +00:00
arg . command ,
2023-02-11 21:49:07 +00:00
) ;
}
2023-05-14 17:45:07 +00:00
if ( arg . command == "broadcast" ) {
2023-05-15 16:56:21 +00:00
sock . sendBroadcastChannel ( arg . broadcastChannel , arg . data , arg . uuid ) ;
2023-02-11 21:49:07 +00:00
}
if ( arg . command == "stop_transmission" ) {
sock . stopTransmission ( ) ;
}
if ( arg . command == "set_tx_audio_level" ) {
sock . setTxAudioLevel ( arg . tx _audio _level ) ;
}
if ( arg . command == "record_audio" ) {
sock . record _audio ( ) ;
}
if ( arg . command == "send_test_frame" ) {
sock . sendTestFrame ( ) ;
}
if ( arg . command == "frequency" ) {
sock . set _frequency ( arg . frequency ) ;
}
if ( arg . command == "mode" ) {
sock . set _mode ( arg . mode ) ;
}
2023-02-26 13:08:26 +00:00
2023-02-26 15:27:55 +00:00
if ( arg . command == "requestUserInfo" ) {
2023-02-26 13:08:26 +00:00
sock . sendRequestInfo ( arg . dxcallsign ) ;
}
2023-02-26 17:11:20 +00:00
2023-02-28 14:19:41 +00:00
if ( arg . command == "requestSharedFolderList" ) {
sock . sendRequestSharedFolderList ( arg . dxcallsign ) ;
}
2023-03-05 06:32:22 +00:00
if ( arg . command == "requestSharedFile" ) {
2023-03-05 06:38:36 +00:00
sock . sendRequestSharedFile ( arg . dxcallsign , arg . file ) ;
2023-03-05 06:32:22 +00:00
}
2023-02-28 14:19:41 +00:00
// responses
2023-02-26 17:11:38 +00:00
if ( arg . command == "responseUserInfo" ) {
2023-02-26 17:11:20 +00:00
sock . sendResponseInfo ( arg . dxcallsign , arg . userinfo ) ;
}
2023-02-28 14:19:41 +00:00
if ( arg . command == "responseSharedFolderList" ) {
sock . sendResponseSharedFolderList ( arg . dxcallsign , arg . folderFileList ) ;
}
2023-03-05 21:16:03 +00:00
if ( arg . command == "responseSharedFile" ) {
sock . sendResponseSharedFile ( arg . dxcallsign , arg . file , arg . filedata ) ;
}
2023-06-11 07:12:40 +00:00
2023-07-05 16:43:56 +00:00
if ( arg . command == "mesh_ping" ) {
2023-06-11 07:12:40 +00:00
sock . sendMeshPing ( arg . dxcallsign ) ;
}
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
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-updater" , ( event , arg ) => {
if ( arg . status == "download-progress" ) {
var progressinfo =
"(" +
Math . round ( arg . progress . transferred / 1024 ) +
"kB /" +
Math . round ( arg . progress . total / 1024 ) +
"kB)" +
" @ " +
Math . round ( arg . progress . bytesPerSecond / 1024 ) +
"kByte/s" ;
document . getElementById ( "UpdateProgressInfo" ) . innerHTML = progressinfo ;
document
. getElementById ( "UpdateProgressBar" )
. setAttribute ( "aria-valuenow" , arg . progress . percent ) ;
document
. getElementById ( "UpdateProgressBar" )
. setAttribute ( "style" , "width:" + arg . progress . percent + "%;" ) ;
}
if ( arg . status == "checking-for-update" ) {
//document.title = document.title + ' - v' + arg.version;
updateTitle (
config . myCall ,
config . tnc _host ,
config . tnc _port ,
2023-07-05 16:43:56 +00:00
" -v " + arg . version ,
2023-02-11 21:49:07 +00:00
) ;
document . getElementById ( "updater_status" ) . innerHTML =
'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>' ;
document . getElementById ( "updater_status" ) . className =
"btn btn-secondary btn-sm" ;
document . getElementById ( "update_and_install" ) . style . display = "none" ;
}
if ( arg . status == "update-downloaded" ) {
document . getElementById ( "update_and_install" ) . removeAttribute ( "style" ) ;
document . getElementById ( "updater_status" ) . innerHTML =
'<i class="bi bi-cloud-download ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className =
"btn btn-success btn-sm" ;
// HERE WE NEED TO RUN THIS SOMEHOW...
//mainLog.info('quit application and install update');
//autoUpdater.quitAndInstall();
}
if ( arg . status == "update-not-available" ) {
document . getElementById ( "updater_status" ) . innerHTML =
'<i class="bi bi-check2-square ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className =
"btn btn-success btn-sm" ;
document . getElementById ( "update_and_install" ) . style . display = "none" ;
}
if ( arg . status == "update-available" ) {
document . getElementById ( "updater_status" ) . innerHTML =
'<i class="bi bi-hourglass-split ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className =
"btn btn-warning btn-sm" ;
document . getElementById ( "update_and_install" ) . style . display = "none" ;
}
if ( arg . status == "error" ) {
document . getElementById ( "updater_status" ) . innerHTML =
'<i class="bi bi-exclamation-square ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className =
"btn btn-danger btn-sm" ;
document . getElementById ( "update_and_install" ) . style . display = "none" ;
}
2022-02-22 14:40:33 +00:00
} ) ;
2022-06-07 08:08:15 +00:00
// ----------- INFO MODAL ACTIONS -------------------------------
// CQ TRANSMITTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-cq-toast-transmitting" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = "transmitting cq" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
2023-02-13 00:13:14 +00:00
// fec iswriting received
ipcRenderer . on ( "action-show-fec-toast-iswriting" , ( event , data ) => {
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let content = ` ${ dxcallsign } </strong> is typing ` ;
displayToast (
( type = "success" ) ,
( icon = "bi-pencil-fill" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-13 00:13:14 +00:00
) ;
} ) ;
2022-06-07 08:08:15 +00:00
// CQ RECEIVED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-cq-toast-received" , ( event , data ) => {
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let dxgrid = data [ "data" ] [ 0 ] [ "dxgrid" ] ;
let content = ` cq from <strong> ${ dxcallsign } </strong> ( ${ dxgrid } ) ` ;
2023-07-02 13:43:54 +00:00
showOsPopUp ( "CQ from " + dxcallsign , "Say hello!" ) ;
2023-02-11 21:49:07 +00:00
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// QRV TRANSMITTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-qrv-toast-transmitting" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = "transmitting qrv" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// QRV RECEIVED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-qrv-toast-received" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let dxgrid = data [ "data" ] [ 0 ] [ "dxgrid" ] ;
let content = ` received qrv from <strong> ${ dxcallsign } </strong> ( ${ dxgrid } ) ` ;
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// BEACON TRANSMITTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-beacon-toast-transmitting" , ( event , data ) => {
displayToast (
( type = "info" ) ,
( icon = "bi-broadcast" ) ,
( content = "transmitting beacon" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// BEACON RECEIVED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-beacon-toast-received" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let dxgrid = data [ "data" ] [ 0 ] [ "dxgrid" ] ;
let content = ` beacon from <strong> ${ dxcallsign } </strong> ( ${ dxgrid } ) ` ;
displayToast (
( type = "info" ) ,
( icon = "bi-broadcast" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// PING TRANSMITTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-ping-toast-transmitting" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = "transmitting ping" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// PING RECEIVED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-ping-toast-received" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let content = ` ping from <strong> ${ dxcallsign } </strong> ` ;
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// PING RECEIVED ACK
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-ping-toast-received-ack" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let dxgrid = data [ "data" ] [ 0 ] [ "dxgrid" ] ;
let content = ` ping ACK from <strong> ${ dxcallsign } </strong> ( ${ dxgrid } ) ` ;
displayToast (
( type = "success" ) ,
( icon = "bi-check" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// DATA CHANNEL OPENING TOAST
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-datachannel-opening" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let content = ` opening datachannel with <strong> ${ dxcallsign } </strong> ` ;
displayToast (
( type = "secondary" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
2022-11-17 21:17:50 +00:00
// DATA CHANNEL WAITING TOAST
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-datachannel-waiting" , ( event , data ) => {
displayToast (
( type = "warning" ) ,
( icon = "bi-smartwatch" ) ,
( content = "channel busy - waiting..." ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-11-17 21:17:50 +00:00
} ) ;
2022-06-07 08:08:15 +00:00
// DATA CHANNEL OPEN TOAST
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-datachannel-open" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "datachannel open" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// DATA CHANNEL RECEIVED OPENER TOAST
2023-02-11 21:49:07 +00:00
ipcRenderer . on (
"action-show-arq-toast-datachannel-received-opener" ,
( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
let dxcallsign = data [ "data" ] [ 0 ] [ "dxcallsign" ] ;
let content = ` datachannel requested by <strong> ${ dxcallsign } </strong> ` ;
displayToast (
( type = "success" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = content ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
// ARQ TRANSMISSION FAILED
// TODO: use for both - transmitting and receiving --> we need to change the IDs
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-transmission-failed" , ( event , data ) => {
displayToast (
( type = "danger" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "transmission failed" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
2023-01-22 04:13:23 +00:00
// ARQ TRANSMISSION FAILED (Version mismatch)
2023-02-11 21:49:07 +00:00
ipcRenderer . on (
"action-show-arq-toast-transmission-failed-ver" ,
( event , data ) => {
displayToast (
( type = "danger" ) ,
( icon = "bi-broadcast" ) ,
2023-02-12 10:37:02 +00:00
( content = "protocol version missmatch" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
2023-01-22 04:13:23 +00:00
2022-06-07 08:08:15 +00:00
// ARQ TRANSMISSION STOPPED
// TODO: RENAME ID -- WRONG
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-transmission-stopped" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "transmission stopped" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// ARQ TRANSMISSION FAILED
// TODO: USE FOR TX AND RX
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-transmission-failed" , ( event , data ) => {
displayToast (
( type = "danger" ) ,
( icon = "bi-broadcast" ) ,
( content = "arq transmission failed" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// ARQ TRANSMISSION TRANSMITTED
2023-02-11 21:49:07 +00:00
ipcRenderer . on (
"action-show-arq-toast-transmission-transmitted" ,
( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
2023-02-12 23:36:27 +00:00
//let content = `received cq from <strong>${dxcallsign}</strong> (${dxgrid})`;
2023-02-11 21:49:07 +00:00
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = "data transmitted" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
// ARQ TRANSMISSION TRANSMITTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on (
"action-show-arq-toast-transmission-transmitting" ,
( event , data ) => {
2022-11-11 12:24:12 +00:00
var irs _snr = data [ "data" ] [ 0 ] . irs _snr ;
2022-11-11 12:32:37 +00:00
2023-02-11 21:49:07 +00:00
if ( irs _snr <= 0 ) {
displayToast (
( type = "warning" ) ,
( icon = "bi-broadcast" ) ,
( content = "low link margin: <strong>" + irs _snr + " dB</strong>" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
} else if ( irs _snr > 0 && irs _snr <= 5 ) {
displayToast (
( type = "warning" ) ,
( icon = "bi-broadcast" ) ,
( content = "medium link margin: <strong>" + irs _snr + " dB</strong>" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
} else if ( irs _snr > 5 && irs _snr < 12.7 ) {
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content = "high link margin: <strong>" + irs _snr + " dB</strong>" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
} else if ( irs _snr >= 12.7 ) {
displayToast (
( type = "success" ) ,
( icon = "bi-broadcast" ) ,
( content =
"very high link margin: <strong>" + irs _snr + " dB</strong>" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-11-11 11:57:14 +00:00
} else {
2023-02-11 21:49:07 +00:00
//displayToast(type='info', icon='bi-broadcast', content='no snr information', duration=5000);
2022-11-11 11:57:14 +00:00
}
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
// ARQ TRANSMISSION RECEIVED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-transmission-received" , ( event , data ) => {
console . log ( data [ "data" ] [ 0 ] ) ;
displayToast (
( type = "success" ) ,
( icon = "bi-check-circle" ) ,
( content = "all data received" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 08:08:15 +00:00
} ) ;
// ARQ TRANSMISSION RECEIVING
2023-02-11 21:49:07 +00:00
ipcRenderer . on (
"action-show-arq-toast-transmission-receiving" ,
( event , data ) => {
displayToast (
( type = "primary" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "session receiving" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2023-07-05 16:43:56 +00:00
} ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-07 09:31:59 +00:00
2022-06-15 08:51:19 +00:00
// ARQ SESSION CONNECTING
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-session-connecting" , ( event , data ) => {
displayToast (
( type = "primary" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "connecting..." ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-15 08:51:19 +00:00
} ) ;
// ARQ SESSION CONNECTED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-session-connected" , ( event , data ) => {
displayToast (
( type = "success" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "session connected" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-15 08:51:19 +00:00
} ) ;
2022-11-17 23:03:18 +00:00
// ARQ SESSION CONNECTED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-session-waiting" , ( event , data ) => {
displayToast (
( type = "warning" ) ,
( icon = "bi-smartwatch" ) ,
( content = "session waiting..." ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-11-17 23:03:18 +00:00
} ) ;
2022-06-15 08:51:19 +00:00
// ARQ SESSION CLOSE
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-session-close" , ( event , data ) => {
displayToast (
( type = "warning" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "session close" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-15 08:51:19 +00:00
} ) ;
// ARQ SESSION FAILED
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-show-arq-toast-session-failed" , ( event , data ) => {
displayToast (
( type = "danger" ) ,
( icon = "bi-arrow-left-right" ) ,
( content = "session failed" ) ,
2023-07-05 16:43:56 +00:00
( duration = 5000 ) ,
2023-02-11 21:49:07 +00:00
) ;
2022-06-15 08:51:19 +00:00
} ) ;
2022-06-07 09:31:59 +00:00
2022-09-23 09:17:59 +00:00
// enable or disable a setting by given switch and element
2023-02-12 10:37:02 +00:00
// not used at this time
2023-02-11 21:49:07 +00:00
function enable _setting ( enable _switch , enable _object ) {
if ( document . getElementById ( enable _switch ) . checked ) {
config [ enable _switch ] = true ;
document
. getElementById ( enable _object )
. removeAttribute ( "disabled" , "disabled" ) ;
} else {
config [ enable _switch ] = false ;
document . getElementById ( enable _object ) . setAttribute ( "disabled" , "disabled" ) ;
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2022-09-23 09:17:59 +00:00
}
// enable or disable a setting switch
2023-02-12 10:37:02 +00:00
// not used at this time
2023-02-11 21:49:07 +00:00
function set _setting _switch ( setting _switch , enable _object , state ) {
document . getElementById ( setting _switch ) . checked = state ;
enable _setting ( setting _switch , enable _object ) ;
}
2022-11-08 13:54:27 +00:00
2023-03-28 23:27:48 +00:00
var rigctldActive = false ;
2023-02-11 21:49:07 +00:00
setInterval ( checkRigctld , 500 ) ;
function checkRigctld ( ) {
var rigctld _ip = document . getElementById ( "hamlib_rigctld_ip" ) . value ;
var rigctld _port = document . getElementById ( "hamlib_rigctld_port" ) . value ;
2022-11-08 13:54:27 +00:00
2023-02-11 21:49:07 +00:00
let Data = {
ip : rigctld _ip ,
port : rigctld _port ,
} ;
2023-01-27 06:55:16 +00:00
2023-02-11 21:49:07 +00:00
//Prevents an error on startup if hamlib settings aren't populated yet
if ( rigctld _port . length > 0 && rigctld _ip . length > 0 ) {
ipcRenderer . send ( "request-check-rigctld" , Data ) ;
}
2022-09-23 12:06:13 +00:00
}
2022-11-08 13:54:27 +00:00
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-check-rigctld" , ( event , data ) => {
document . getElementById ( "hamlib_rigctld_status" ) . value = data [ "state" ] ;
2023-03-28 23:27:48 +00:00
rigctldActive = data [ "active" ] ;
2023-04-26 01:19:02 +00:00
if ( data [ "active" ] == true ) {
document . getElementById ( "hamlib_rigctld_stop" ) . disabled = false ;
document . getElementById ( "hamlib_rigctld_start" ) . disabled = true ;
document . getElementById ( "testHamlib" ) . disabled = false ;
} else {
document . getElementById ( "hamlib_rigctld_stop" ) . disabled = true ;
document . getElementById ( "hamlib_rigctld_start" ) . disabled = false ;
document . getElementById ( "testHamlib" ) . disabled = true ;
2023-04-26 01:11:06 +00:00
}
2022-11-08 13:54:27 +00:00
} ) ;
2023-01-22 19:36:05 +00:00
2023-02-11 21:49:07 +00:00
ipcRenderer . on ( "action-set-app-version" , ( event , data ) => {
appVer = data ;
2023-01-22 19:36:05 +00:00
} ) ;
2023-02-11 21:49:07 +00:00
function updateTitle (
mycall = config . mycall ,
tnc = config . tnc _host ,
tncport = config . tnc _port ,
2023-07-05 16:43:56 +00:00
appender = "" ,
2023-02-11 21:49:07 +00:00
) {
//Multiple consecutive spaces get converted to a single space
var title =
"FreeDATA " +
appVer +
" - Call: " +
mycall +
" - TNC: " +
tnc +
":" +
tncport +
appender ;
if ( title != document . title ) {
document . title = title ;
}
2023-01-21 05:40:01 +00:00
}
2023-02-26 02:29:12 +00:00
//Set force to true to ensure a class is present on a control, otherwise set to false to ensure it isn't present
2023-02-11 21:49:07 +00:00
function toggleClass ( control , classToToggle , force ) {
var cntrl = document . getElementById ( control ) ;
if ( cntrl == undefined ) {
2023-02-26 02:29:12 +00:00
console . log ( "toggle class: unknown control: " , control ) ;
2023-02-11 21:49:07 +00:00
return ;
}
2023-02-26 02:29:12 +00:00
var activeClasses = cntrl . className ;
2023-02-11 21:49:07 +00:00
//var oldactive = activeClasses;
if ( force == true && activeClasses . indexOf ( classToToggle ) >= 0 ) {
return ;
}
if ( force == false && activeClasses . indexOf ( classToToggle ) == - 1 ) {
return ;
}
if ( force == true ) {
activeClasses += " " + classToToggle ;
} else {
activeClasses = activeClasses . replace ( classToToggle , "" ) ;
}
activeClasses = activeClasses . replace ( " " , " " ) . trim ( ) ;
2023-02-26 02:29:12 +00:00
cntrl . className = activeClasses ;
2023-02-11 21:49:07 +00:00
//console.log(control," toggleClass; force: ", force, "class: " ,classToToggle, " in: '" ,oldactive, "' out: '",activeClasses,"'");
2023-01-27 03:55:55 +00:00
}
function set _CPU _mode ( ) {
2023-02-11 21:49:07 +00:00
if ( config . high _graphics . toUpperCase ( ) == "FALSE" ) {
toggleClass ( "dbfs_level" , "disable-effects" , true ) ;
toggleClass ( "dbfs_level" , "progress-bar-striped" , false ) ;
2023-02-14 14:18:08 +00:00
toggleClass ( "noise_level" , "disable-effects" , true ) ;
toggleClass ( "noise_level" , "progress-bar-striped" , false ) ;
2023-02-11 21:49:07 +00:00
toggleClass ( "waterfall" , "disable-effects" , true ) ;
toggleClass ( "transmission_progress" , "disable-effects" , true ) ;
toggleClass ( "transmission_progress" , "progress-bar-striped" , false ) ;
} else {
toggleClass ( "dbfs_level" , "disable-effects" , false ) ;
toggleClass ( "dbfs_level" , "progress-bar-striped" , true ) ;
2023-02-14 14:18:08 +00:00
toggleClass ( "noise_level" , "disable-effects" , false ) ;
toggleClass ( "noise_level" , "progress-bar-striped" , true ) ;
2023-02-11 21:49:07 +00:00
toggleClass ( "waterfall" , "disable-effects" , false ) ;
toggleClass ( "transmission_progress" , "disable-effects" , false ) ;
toggleClass ( "transmission_progress" , "progress-bar-striped" , true ) ;
}
2023-01-27 03:55:55 +00:00
}
2023-02-03 22:14:02 +00:00
//Temporarily disable a button with timeout
2023-01-21 05:40:01 +00:00
function pauseButton ( btn , timems ) {
2023-02-11 21:49:07 +00:00
btn . disabled = true ;
var curText = btn . innerHTML ;
if ( config . high _graphics . toUpperCase ( ) == "TRUE" ) {
btn . innerHTML =
'<span class="spinner-grow spinner-grow-sm force-gpu" role="status" aria-hidden="true">' ;
}
setTimeout ( ( ) => {
btn . innerHTML = curText ;
btn . disabled = false ;
} , timems ) ;
2023-02-05 17:54:23 +00:00
}
//https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
function formatBytes ( bytes , decimals = 1 ) {
2023-02-11 21:49:07 +00:00
if ( ! + bytes ) return "0 Bytes" ;
2023-02-05 17:54:23 +00:00
2023-02-11 21:49:07 +00:00
const k = 1024 ;
const dm = decimals < 0 ? 0 : decimals ;
const sizes = [ "B" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" , "ZB" , "YB" ] ;
2023-02-05 17:54:23 +00:00
2023-02-11 21:49:07 +00:00
const i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ;
2023-02-05 17:54:23 +00:00
2023-02-11 21:49:07 +00:00
return ` ${ parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) } ${ sizes [ i ] } ` ;
2023-02-11 09:23:04 +00:00
}
// display toast
2023-02-11 21:49:07 +00:00
function displayToast (
type = "primary" ,
icon = "bi-info" ,
content = "default" ,
2023-07-05 16:43:56 +00:00
duration = 5000 ,
2023-02-11 21:49:07 +00:00
) {
mainToastContainer = document . getElementById ( "mainToastContainer" ) ;
let randomID = uuidv4 ( ) ;
let toastCode = `
2023-02-11 09:23:04 +00:00
< div class = "toast align-items-center bg-outline-${type} border-1" id = "${randomID}" role = "alert" aria - live = "assertive" aria - atomic = "true" >
< div class = "d-flex" >
< div class = "toast-body p-0 m-0 bg-white rounded-2 w-100" >
< div class = "row p-1 m-0" >
< div class = "col-auto bg-${type} rounded-start rounded-2 d-flex align-items-center" >
< i class = "bi ${icon}" style = "font-size: 1rem; color: white" > < / i >
< / d i v >
< div class = "col p-2" >
$ { content }
< / d i v >
< / d i v >
< / d i v >
< button type = "button" class = "btn-close me-2 m-auto" data - bs - dismiss = "toast" aria - label = "Close" > < / b u t t o n >
< / d i v >
< / d i v >
` ;
2023-02-11 21:49:07 +00:00
// insert toast to toast container
mainToastContainer . insertAdjacentHTML ( "beforeend" , toastCode ) ;
2023-02-11 09:23:04 +00:00
2023-02-11 21:49:07 +00:00
// register toast
let toastHTMLElement = document . getElementById ( randomID ) ;
let toast = bootstrap . Toast . getOrCreateInstance ( toastHTMLElement ) ; // Returns a Bootstrap toast instance
toast . _config . delay = duration ;
2023-02-11 09:23:04 +00:00
2023-02-11 21:49:07 +00:00
// show toast
toast . show ( ) ;
2023-02-11 09:23:04 +00:00
2023-02-11 21:49:07 +00:00
//register event listener if toast is hidden
toastHTMLElement . addEventListener ( "hidden.bs.toast" , ( ) => {
// remove eventListener
toastHTMLElement . removeEventListener ( "hidden.bs.toast" , this ) ;
// remove toast
toastHTMLElement . remove ( ) ;
} ) ;
}
2023-02-12 13:44:13 +00:00
2023-02-12 14:44:38 +00:00
function loadSettings ( elements ) {
elements . forEach ( function ( id ) {
let element = document . getElementById ( id ) ;
2023-02-12 13:44:13 +00:00
2023-02-12 14:44:38 +00:00
if ( element . tagName === "SELECT" ) {
2023-02-12 14:59:46 +00:00
element . value = config [ id ] ;
2023-02-12 13:44:13 +00:00
2023-02-12 14:44:38 +00:00
// add selected value
for ( var i = 0 , j = element . options . length ; i < j ; ++ i ) {
2023-02-12 14:59:46 +00:00
if ( element . options [ i ] . innerHTML === config [ id ] ) {
2023-02-12 14:44:38 +00:00
element . selectedIndex = i ;
break ;
2023-02-12 13:44:13 +00:00
}
2023-02-12 14:44:38 +00:00
}
} else if ( element . tagName === "INPUT" && element . type === "text" ) {
2023-02-12 14:59:46 +00:00
element . value = config [ id ] ;
2023-02-12 14:44:38 +00:00
} else if ( element . tagName === "INPUT" && element . type === "radio" ) {
2023-02-12 14:59:46 +00:00
element . value = config [ id ] ;
2023-02-12 13:44:13 +00:00
2023-02-12 14:59:46 +00:00
if ( config [ id ] === "True" ) {
2023-02-12 14:44:38 +00:00
element . checked = true ;
} else {
element . checked = false ;
}
2023-02-12 14:59:46 +00:00
} else {
2023-02-12 15:00:08 +00:00
console . log ( "nothing matched...." ) ;
2023-02-12 14:44:38 +00:00
}
} ) ;
2023-03-03 03:06:25 +00:00
ipcRenderer . on ( "update-config" , ( event , data ) => {
config = data ;
2023-03-03 03:05:45 +00:00
} ) ;
2023-02-12 14:44:38 +00:00
}
2023-03-16 07:59:32 +00:00
2023-03-16 07:59:54 +00:00
function changeGuiDesign ( design ) {
2023-03-16 07:59:32 +00:00
if (
design != "default" &&
design != "default_light" &&
design != "default_dark" &&
design != "default_auto"
) {
var theme _path =
"../node_modules/bootswatch/dist/" + design + "/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = design ;
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
} else if ( design == "default" || design == "default_light" ) {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = "default_light" ;
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
document . documentElement . setAttribute ( "data-bs-theme" , "light" ) ;
} else if ( design == "default_dark" ) {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = "default_dark" ;
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
document . querySelector ( "html" ) . setAttribute ( "data-bs-theme" , "dark" ) ;
} else if ( design == "default_auto" ) {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = "default_auto" ;
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
// https://stackoverflow.com/a/57795495
// check if dark mode or light mode used in OS
if (
window . matchMedia &&
window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches
) {
// dark mode
document . documentElement . setAttribute ( "data-bs-theme" , "dark" ) ;
} else {
document . documentElement . setAttribute ( "data-bs-theme" , "light" ) ;
}
// also register event listener for automatic change
window
. matchMedia ( "(prefers-color-scheme: dark)" )
. addEventListener ( "change" , ( event ) => {
let newColorScheme = event . matches ? "dark" : "light" ;
if ( newColorScheme == "dark" ) {
document . documentElement . setAttribute ( "data-bs-theme" , "dark" ) ;
} else {
document . documentElement . setAttribute ( "data-bs-theme" , "light" ) ;
}
} ) ;
} else {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = "default_light" ;
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
document . documentElement . setAttribute ( "data-bs-theme" , "light" ) ;
}
//update path to css file
2023-03-16 07:59:54 +00:00
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
2023-05-14 13:10:01 +00:00
}
2023-03-27 21:07:54 +00:00
2023-05-14 13:11:10 +00:00
var hslLastSort = 0 ;
2023-05-15 21:03:51 +00:00
var hslLastSortDir = "desc" ;
2023-05-14 13:11:10 +00:00
//https://www.w3schools.com/howto/howto_js_sort_table.asp
function sorthslTable ( n ) {
hslLastSort = n ;
var table ,
rows ,
switching ,
i ,
x ,
y ,
shouldSwitch ,
dir ,
switchcount = 0 ;
table = document . getElementById ( "tblHeardStationList" ) ;
switching = true ;
// Set the sorting direction to ascending:
//hslLastSortDir = "asc";
/ * M a k e a l o o p t h a t w i l l c o n t i n u e u n t i l
2023-05-14 13:10:01 +00:00
no switching has been done : * /
2023-05-14 13:11:10 +00:00
while ( switching ) {
// Start by saying: no switching is done:
switching = false ;
rows = table . rows ;
/ * L o o p t h r o u g h a l l t a b l e r o w s ( e x c e p t t h e
2023-05-14 13:10:01 +00:00
first , which contains table headers ) : * /
2023-05-14 13:11:10 +00:00
for ( i = 1 ; i < rows . length - 1 ; i ++ ) {
// Start by saying there should be no switching:
shouldSwitch = false ;
/ * G e t t h e t w o e l e m e n t s y o u w a n t t o c o m p a r e ,
2023-05-14 13:10:01 +00:00
one from current row and one from the next : * /
2023-05-14 13:11:10 +00:00
x = rows [ i ] . getElementsByTagName ( "TD" ) [ n ] ;
y = rows [ i + 1 ] . getElementsByTagName ( "TD" ) [ n ] ;
/ * C h e c k i f t h e t w o r o w s s h o u l d s w i t c h p l a c e ,
2023-05-14 13:10:01 +00:00
based on the direction , asc or desc : * /
2023-05-14 13:11:10 +00:00
if ( hslLastSortDir == "asc" ) {
if ( x . innerHTML . toLowerCase ( ) > y . innerHTML . toLowerCase ( ) ) {
// If so, mark as a switch and break the loop:
shouldSwitch = true ;
break ;
}
} else if ( hslLastSortDir == "desc" ) {
if ( x . innerHTML . toLowerCase ( ) < y . innerHTML . toLowerCase ( ) ) {
// If so, mark as a switch and break the loop:
shouldSwitch = true ;
break ;
2023-05-14 13:10:01 +00:00
}
2023-03-27 21:06:11 +00:00
}
2023-05-14 13:11:10 +00:00
}
if ( shouldSwitch ) {
/ * I f a s w i t c h h a s b e e n m a r k e d , m a k e t h e s w i t c h
2023-05-14 13:10:01 +00:00
and mark that a switch has been done : * /
2023-05-14 13:11:10 +00:00
rows [ i ] . parentNode . insertBefore ( rows [ i + 1 ] , rows [ i ] ) ;
switching = true ;
// Each time a switch is done, increase this count by 1:
switchcount ++ ;
2023-03-27 21:06:11 +00:00
}
}
2023-03-16 07:59:54 +00:00
}
2023-03-27 21:07:54 +00:00
2023-05-20 18:43:27 +00:00
function autostart _rigctld ( ) {
2023-05-14 13:11:10 +00:00
if ( config . auto _start == 1 ) {
//Start rigctld if radiocontrol is in correct mode and is not active
if ( config . radiocontrol == "rigctld" && rigctldActive == false ) {
//console.log("Autostarting rigctld");
document . getElementById ( "hamlib_rigctld_start" ) . click ( ) ;
2023-03-27 21:06:11 +00:00
}
2023-05-20 18:43:27 +00:00
}
}
function autostart _tnc ( ) {
if ( config . auto _start == 1 ) {
2023-05-14 13:11:10 +00:00
//Now start TNC
document . getElementById ( "startTNC" ) . click ( ) ;
2023-07-02 13:43:54 +00:00
}
2023-06-11 03:14:25 +00:00
}
//Have the operating system show a notification popup
2023-07-02 13:43:54 +00:00
function showOsPopUp ( title , message ) {
2023-06-11 14:40:01 +00:00
if ( config . enable _sys _notification == 0 ) return ;
2023-06-11 03:14:25 +00:00
const NOTIFICATION _TITLE = title ;
const NOTIFICATION _BODY = message ;
new Notification ( NOTIFICATION _TITLE , { body : NOTIFICATION _BODY } ) ;
2023-07-02 13:43:54 +00:00
}
2023-07-07 09:56:27 +00:00