Prettified Code!

This commit is contained in:
DJ2LS 2023-05-14 17:45:07 +00:00 committed by GitHub Action
parent c7a9a6c1f1
commit 66ab3f4e21
3 changed files with 45 additions and 58 deletions

View file

@ -460,57 +460,51 @@ window.addEventListener("DOMContentLoaded", () => {
} }
var timestamp = Math.floor(Date.now() / 1000); var timestamp = Math.floor(Date.now() / 1000);
// check if broadcast // check if broadcast
dxcallsign.starts dxcallsign.starts;
if (dxcallsign.startsWith('BC-')) { if (dxcallsign.startsWith("BC-")) {
var tnc_command = "broadcast" var tnc_command = "broadcast";
let Data = { let Data = {
command: tnc_command, command: tnc_command,
broadcastChannel: dxcallsign, broadcastChannel: dxcallsign,
data: chatmessage, data: chatmessage,
}; };
ipcRenderer.send("run-tnc-command", Data); ipcRenderer.send("run-tnc-command", Data);
} else { } else {
var file_checksum = crc32(file).toString(16).toUpperCase(); var file_checksum = crc32(file).toString(16).toUpperCase();
var tnc_command = "msg" var tnc_command = "msg";
var file_checksum = crc32(file).toString(16).toUpperCase(); var file_checksum = crc32(file).toString(16).toUpperCase();
console.log(file_checksum); console.log(file_checksum);
var data_with_attachment = var data_with_attachment =
timestamp + timestamp +
split_char + split_char +
chatmessage + chatmessage +
split_char + split_char +
filename + filename +
split_char + split_char +
filetype + filetype +
split_char + split_char +
file; file;
document.getElementById("selectFilesButton").innerHTML = ``; document.getElementById("selectFilesButton").innerHTML = ``;
var uuid = uuidv4(); var uuid = uuidv4();
let uuidlast = uuid.lastIndexOf("-"); let uuidlast = uuid.lastIndexOf("-");
uuidlast += 1; uuidlast += 1;
if (uuidlast > 0) { if (uuidlast > 0) {
uuid = uuid.substring(uuidlast); 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({ db.post({
_id: uuid, _id: uuid,

View file

@ -2786,11 +2786,8 @@ ipcRenderer.on("run-tnc-command", (event, arg) => {
arg.command arg.command
); );
} }
if (arg.command == "broadcast") { if (arg.command == "broadcast") {
sock.sendBroadcastChannel( sock.sendBroadcastChannel(arg.broadcastChannel, arg.data);
arg.broadcastChannel,
arg.data
);
} }
if (arg.command == "stop_transmission") { if (arg.command == "stop_transmission") {
sock.stopTransmission(); sock.stopTransmission();

View file

@ -837,10 +837,9 @@ exports.sendFecIsWriting = function (mycallsign) {
// SEND FEC TO BROADCASTCHANNEL // SEND FEC TO BROADCASTCHANNEL
exports.sendBroadcastChannel = function (channel, data) { exports.sendBroadcastChannel = function (channel, data) {
let checksum = "";
let checksum = '' let uuid = "";
let uuid = '' let command = "";
let command = ''
data = FD.btoa_FD( data = FD.btoa_FD(
"m" + "m" +
split_char + split_char +
@ -853,8 +852,6 @@ exports.sendBroadcastChannel = function (channel, data) {
data data
); );
let payload = data; let payload = data;
command = command =
'{"type" : "fec", "command" : "transmit", "mode": "datac4", "wakeup": "True", "payload" : "' + '{"type" : "fec", "command" : "transmit", "mode": "datac4", "wakeup": "True", "payload" : "' +
@ -863,7 +860,6 @@ exports.sendBroadcastChannel = function (channel, data) {
writeTncCommand(command); writeTncCommand(command);
}; };
// RECORD AUDIO // RECORD AUDIO
exports.record_audio = function () { exports.record_audio = function () {
command = '{"type" : "set", "command" : "record_audio"}'; command = '{"type" : "set", "command" : "record_audio"}';