From e62cac90de539ba08409a309a4c5402762fa2f5d Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 14 May 2023 12:36:49 +0000 Subject: [PATCH] Prettified Code! --- gui/preload-chat.js | 83 +++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index ca40b8c2..9f90fcf1 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -460,57 +460,50 @@ window.addEventListener("DOMContentLoaded", () => { } var timestamp = Math.floor(Date.now() / 1000); - // check if broadcast - if (dxcallsign == 'broadcast') { - - var tnc_command = "broadcast" + if (dxcallsign == "broadcast") { + var tnc_command = "broadcast"; let Data = { - command: tnc_command, - data: chatmessage, - }; - ipcRenderer.send("run-tnc-command", Data); - - - + command: tnc_command, + 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,