diff --git a/gui/preload-chat.js b/gui/preload-chat.js index a76450f1..90312603 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -460,57 +460,51 @@ window.addEventListener("DOMContentLoaded", () => { } var timestamp = Math.floor(Date.now() / 1000); - // check if broadcast - dxcallsign.starts - if (dxcallsign.startsWith('BC-')) { - var tnc_command = "broadcast" + dxcallsign.starts; + if (dxcallsign.startsWith("BC-")) { + var tnc_command = "broadcast"; let Data = { - command: tnc_command, - broadcastChannel: dxcallsign, - data: chatmessage, - }; - ipcRenderer.send("run-tnc-command", Data); - - - + command: tnc_command, + broadcastChannel: dxcallsign, + data: chatmessage, + }; + ipcRenderer.send("run-tnc-command", Data); } else { - var file_checksum = crc32(file).toString(16).toUpperCase(); - var tnc_command = "msg" - var file_checksum = crc32(file).toString(16).toUpperCase(); - console.log(file_checksum); - var data_with_attachment = - timestamp + - split_char + - chatmessage + - split_char + - filename + - split_char + - filetype + - split_char + - file; + var file_checksum = crc32(file).toString(16).toUpperCase(); + var tnc_command = "msg"; + var file_checksum = crc32(file).toString(16).toUpperCase(); + console.log(file_checksum); + var data_with_attachment = + timestamp + + split_char + + chatmessage + + split_char + + filename + + split_char + + filetype + + split_char + + file; - document.getElementById("selectFilesButton").innerHTML = ``; - var uuid = uuidv4(); - let uuidlast = uuid.lastIndexOf("-"); - uuidlast += 1; - if (uuidlast > 0) { - uuid = uuid.substring(uuidlast); + document.getElementById("selectFilesButton").innerHTML = ``; + var uuid = uuidv4(); + let uuidlast = uuid.lastIndexOf("-"); + uuidlast += 1; + if (uuidlast > 0) { + uuid = uuid.substring(uuidlast); + } + console.log(data_with_attachment); + let Data = { + command: tnc_command, + dxcallsign: dxcallsign, + mode: 255, + frames: 5, + data: data_with_attachment, + checksum: file_checksum, + uuid: uuid, + }; + ipcRenderer.send("run-tnc-command", Data); } - console.log(data_with_attachment); - let Data = { - command: tnc_command, - dxcallsign: dxcallsign, - mode: 255, - frames: 5, - data: data_with_attachment, - checksum: file_checksum, - uuid: uuid, - }; - ipcRenderer.send("run-tnc-command", Data); - } - - db.post({ _id: uuid, diff --git a/gui/preload-main.js b/gui/preload-main.js index c62b426b..1c648964 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -2786,11 +2786,8 @@ ipcRenderer.on("run-tnc-command", (event, arg) => { arg.command ); } - if (arg.command == "broadcast") { - sock.sendBroadcastChannel( - arg.broadcastChannel, - arg.data - ); + if (arg.command == "broadcast") { + sock.sendBroadcastChannel(arg.broadcastChannel, arg.data); } if (arg.command == "stop_transmission") { sock.stopTransmission(); diff --git a/gui/sock.js b/gui/sock.js index ed84ac96..167af609 100644 --- a/gui/sock.js +++ b/gui/sock.js @@ -837,10 +837,9 @@ exports.sendFecIsWriting = function (mycallsign) { // SEND FEC TO BROADCASTCHANNEL exports.sendBroadcastChannel = function (channel, data) { - - let checksum = '' - let uuid = '' - let command = '' + let checksum = ""; + let uuid = ""; + let command = ""; data = FD.btoa_FD( "m" + split_char + @@ -853,8 +852,6 @@ exports.sendBroadcastChannel = function (channel, data) { data ); - - let payload = data; command = '{"type" : "fec", "command" : "transmit", "mode": "datac4", "wakeup": "True", "payload" : "' + @@ -863,7 +860,6 @@ exports.sendBroadcastChannel = function (channel, data) { writeTncCommand(command); }; - // RECORD AUDIO exports.record_audio = function () { command = '{"type" : "set", "command" : "record_audio"}';