mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Prettified Code!
This commit is contained in:
parent
8c99edf2a7
commit
ff8c41fa91
|
@ -213,9 +213,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
chatFilter.push({ type: "ping-ack" });
|
chatFilter.push({ type: "ping-ack" });
|
||||||
if (document.getElementById("chkBeacon").checked == true)
|
if (document.getElementById("chkBeacon").checked == true)
|
||||||
chatFilter.push({ type: "beacon" });
|
chatFilter.push({ type: "beacon" });
|
||||||
if (document.getElementById("chkRequest").checked == true)
|
if (document.getElementById("chkRequest").checked == true)
|
||||||
chatFilter.push({ type: "request" });
|
chatFilter.push({ type: "request" });
|
||||||
if (document.getElementById("chkResponse").checked == true)
|
if (document.getElementById("chkResponse").checked == true)
|
||||||
chatFilter.push({ type: "response" });
|
chatFilter.push({ type: "response" });
|
||||||
updateAllChat(true);
|
updateAllChat(true);
|
||||||
});
|
});
|
||||||
|
@ -694,55 +694,51 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => {
|
||||||
|
|
||||||
console.log(splitted_data);
|
console.log(splitted_data);
|
||||||
|
|
||||||
if(splitted_data[1] == 'msg'){
|
if (splitted_data[1] == "msg") {
|
||||||
|
obj.timestamp = parseInt(splitted_data[4]);
|
||||||
|
obj.dxcallsign = item.dxcallsign;
|
||||||
|
obj.dxgrid = item.dxgrid;
|
||||||
|
obj.command = splitted_data[1];
|
||||||
|
obj.checksum = splitted_data[2];
|
||||||
|
// convert message to unicode from utf8 because of emojis
|
||||||
|
//No, don't convert; we're already UTF-8!!!!!
|
||||||
|
obj.uuid = splitted_data[3];
|
||||||
|
obj.msg = splitted_data[5];
|
||||||
|
obj.status = "null";
|
||||||
|
obj.snr = "null";
|
||||||
|
obj.type = "received";
|
||||||
|
obj.filename = splitted_data[6];
|
||||||
|
obj.filetype = splitted_data[7];
|
||||||
|
//obj.file = btoa(splitted_data[8]);
|
||||||
|
obj.file = btoa_FD(splitted_data[8]);
|
||||||
|
} else if (splitted_data[1] == "req") {
|
||||||
|
obj.uuid = uuidv4().toString();
|
||||||
|
obj.timestamp = Math.floor(Date.now() / 1000);
|
||||||
|
obj.dxcallsign = item.dxcallsign;
|
||||||
|
obj.command = splitted_data[1];
|
||||||
|
obj.type = "request";
|
||||||
|
obj.status = "received";
|
||||||
|
obj.snr = "null";
|
||||||
|
obj.msg = splitted_data[2];
|
||||||
|
obj.filename = "null";
|
||||||
|
obj.filetype = "null";
|
||||||
|
obj.file = "null";
|
||||||
|
|
||||||
obj.timestamp = parseInt(splitted_data[4]);
|
sendUserData(item.dxcallsign);
|
||||||
obj.dxcallsign = item.dxcallsign;
|
} else if (splitted_data[1] == "res") {
|
||||||
obj.dxgrid = item.dxgrid;
|
obj.uuid = uuidv4().toString();
|
||||||
obj.command = splitted_data[1];
|
obj.timestamp = Math.floor(Date.now() / 1000);
|
||||||
obj.checksum = splitted_data[2];
|
obj.dxcallsign = item.dxcallsign;
|
||||||
// convert message to unicode from utf8 because of emojis
|
obj.command = splitted_data[1];
|
||||||
//No, don't convert; we're already UTF-8!!!!!
|
obj.type = "response";
|
||||||
obj.uuid = splitted_data[3];
|
obj.status = "received";
|
||||||
obj.msg = splitted_data[5];
|
obj.snr = "null";
|
||||||
obj.status = "null";
|
obj.msg = splitted_data[2];
|
||||||
obj.snr = "null";
|
obj.filename = "null";
|
||||||
obj.type = "received";
|
obj.filetype = "null";
|
||||||
obj.filename = splitted_data[6];
|
obj.file = "null";
|
||||||
obj.filetype = splitted_data[7];
|
|
||||||
//obj.file = btoa(splitted_data[8]);
|
|
||||||
obj.file = btoa_FD(splitted_data[8]);
|
|
||||||
|
|
||||||
} else if (splitted_data[1] == 'req') {
|
console.log(splitted_data);
|
||||||
obj.uuid = uuidv4().toString();
|
|
||||||
obj.timestamp = Math.floor(Date.now() / 1000);
|
|
||||||
obj.dxcallsign = item.dxcallsign;
|
|
||||||
obj.command = splitted_data[1];
|
|
||||||
obj.type = "request";
|
|
||||||
obj.status = "received";
|
|
||||||
obj.snr = "null";
|
|
||||||
obj.msg = splitted_data[2];
|
|
||||||
obj.filename = "null";
|
|
||||||
obj.filetype = "null";
|
|
||||||
obj.file = "null";
|
|
||||||
|
|
||||||
sendUserData(item.dxcallsign)
|
|
||||||
|
|
||||||
} else if (splitted_data[1] == 'res') {
|
|
||||||
obj.uuid = uuidv4().toString();
|
|
||||||
obj.timestamp = Math.floor(Date.now() / 1000);
|
|
||||||
obj.dxcallsign = item.dxcallsign;
|
|
||||||
obj.command = splitted_data[1];
|
|
||||||
obj.type = "response";
|
|
||||||
obj.status = "received";
|
|
||||||
obj.snr = "null";
|
|
||||||
obj.msg = splitted_data[2];
|
|
||||||
obj.filename = "null";
|
|
||||||
obj.filetype = "null";
|
|
||||||
obj.file = "null";
|
|
||||||
|
|
||||||
|
|
||||||
console.log(splitted_data)
|
|
||||||
let userData = new Object();
|
let userData = new Object();
|
||||||
userData.user_info_image = splitted_data[2];
|
userData.user_info_image = splitted_data[2];
|
||||||
userData.user_info_callsign = config.mycall;
|
userData.user_info_callsign = config.mycall;
|
||||||
|
@ -758,7 +754,6 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => {
|
||||||
|
|
||||||
addUserToDatabaseIfNotExists(userData);
|
addUserToDatabaseIfNotExists(userData);
|
||||||
getSetUserInformation(config.mycall);
|
getSetUserInformation(config.mycall);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_obj_to_database(obj);
|
add_obj_to_database(obj);
|
||||||
|
@ -982,7 +977,6 @@ update_chat = function (obj) {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (obj.type == "newchat") {
|
if (obj.type == "newchat") {
|
||||||
var new_message = `
|
var new_message = `
|
||||||
<div class="p-0 rounded m-auto mt-1 w-50 bg-light bg-gradient" id="msg-${obj._id}">
|
<div class="p-0 rounded m-auto mt-1 w-50 bg-light bg-gradient" id="msg-${obj._id}">
|
||||||
|
@ -1382,7 +1376,7 @@ update_chat_obj_by_uuid = function (uuid) {
|
||||||
};
|
};
|
||||||
|
|
||||||
add_obj_to_database = function (obj) {
|
add_obj_to_database = function (obj) {
|
||||||
console.log(obj)
|
console.log(obj);
|
||||||
db.put({
|
db.put({
|
||||||
_id: obj.uuid,
|
_id: obj.uuid,
|
||||||
timestamp: parseInt(obj.timestamp),
|
timestamp: parseInt(obj.timestamp),
|
||||||
|
@ -1775,9 +1769,7 @@ function getSetUserInformation(selected_callsign) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendUserData(dxcallsign) {
|
||||||
|
|
||||||
function sendUserData(dxcallsign){
|
|
||||||
const userInfoFields = [
|
const userInfoFields = [
|
||||||
"user_info_image",
|
"user_info_image",
|
||||||
"user_info_callsign",
|
"user_info_callsign",
|
||||||
|
@ -1792,26 +1784,22 @@ function sendUserData(dxcallsign){
|
||||||
"user_info_comments",
|
"user_info_comments",
|
||||||
];
|
];
|
||||||
|
|
||||||
let info = '';
|
let info = "";
|
||||||
userInfoFields.forEach(function (subelem) {
|
userInfoFields.forEach(function (subelem) {
|
||||||
if (subelem !== "user_info_image") {
|
if (subelem !== "user_info_image") {
|
||||||
info += document.getElementById(subelem).value;
|
info += document.getElementById(subelem).value;
|
||||||
info += split_char;
|
info += split_char;
|
||||||
} else {
|
} else {
|
||||||
info += document.getElementById(subelem).src;
|
info += document.getElementById(subelem).src;
|
||||||
info += split_char;
|
info += split_char;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(info)
|
console.log(info);
|
||||||
|
|
||||||
ipcRenderer.send("run-tnc-command", {
|
ipcRenderer.send("run-tnc-command", {
|
||||||
command: "responseUserInfo",
|
command: "responseUserInfo",
|
||||||
dxcallsign: selected_callsign,
|
dxcallsign: selected_callsign,
|
||||||
userinfo: info
|
userinfo: info,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -2577,10 +2577,9 @@ ipcRenderer.on("run-tnc-command", (event, arg) => {
|
||||||
sock.set_mode(arg.mode);
|
sock.set_mode(arg.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.command == "requestUserInfo") {
|
if (arg.command == "requestUserInfo") {
|
||||||
sock.sendRequestInfo(arg.dxcallsign);
|
sock.sendRequestInfo(arg.dxcallsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// IPC ACTION FOR AUTO UPDATER
|
// IPC ACTION FOR AUTO UPDATER
|
||||||
|
|
|
@ -716,7 +716,6 @@ exports.sendResponseInfo = function (dxcallsign, userinfo) {
|
||||||
sendRequest(dxcallsign, 255, 1, userinfo, "res");
|
sendRequest(dxcallsign, 255, 1, userinfo, "res");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//STOP TRANSMISSION
|
//STOP TRANSMISSION
|
||||||
exports.stopTransmission = function () {
|
exports.stopTransmission = function () {
|
||||||
command = '{"type" : "arq", "command": "stop_transmission"}';
|
command = '{"type" : "arq", "command": "stop_transmission"}';
|
||||||
|
|
Loading…
Reference in a new issue