2021-11-19 16:30:17 +00:00
|
|
|
const path = require('path')
|
|
|
|
const {
|
|
|
|
ipcRenderer
|
|
|
|
} = require('electron')
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/26227660
|
|
|
|
var appDataFolder = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + "/.config")
|
|
|
|
var configFolder = path.join(appDataFolder, "FreeDATA");
|
|
|
|
var configPath = path.join(configFolder, 'config.json')
|
|
|
|
const config = require(configPath);
|
|
|
|
|
|
|
|
var chatDB = path.join(configFolder, 'chatDB.json')
|
|
|
|
|
|
|
|
|
|
|
|
// WINDOW LISTENER
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
|
|
// SEND MSG
|
|
|
|
document.getElementById("sendMessage").addEventListener("click", () => {
|
2021-11-19 17:49:36 +00:00
|
|
|
dxcallsign = document.getElementById('chatModuleDxCall').value
|
|
|
|
message = document.getElementById('chatModuleMessage').value
|
2022-01-28 19:07:39 +00:00
|
|
|
|
2021-11-19 16:30:17 +00:00
|
|
|
let Data = {
|
2022-01-28 19:07:39 +00:00
|
|
|
command: "send_message",
|
2021-11-19 16:30:17 +00:00
|
|
|
dxcallsign : dxcallsign.toUpperCase(),
|
2022-01-28 19:07:39 +00:00
|
|
|
mode : 12,
|
2021-11-19 16:30:17 +00:00
|
|
|
frames : 1,
|
2021-11-19 17:49:36 +00:00
|
|
|
data : message,
|
2021-11-19 16:30:17 +00:00
|
|
|
checksum : '123'
|
|
|
|
};
|
|
|
|
ipcRenderer.send('run-tnc-command', Data);
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2021-11-19 17:49:36 +00:00
|
|
|
ipcRenderer.on('action-update-rx-msg-buffer', (event, arg) => {
|
|
|
|
|
|
|
|
var data = arg.data
|
|
|
|
var tbl = document.getElementById("rx-msg-data");
|
|
|
|
document.getElementById("rx-msg-data").innerHTML = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < arg.data.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// now we update the received files list
|
|
|
|
|
|
|
|
var row = document.createElement("tr");
|
|
|
|
//https://stackoverflow.com/q/51421470
|
|
|
|
|
|
|
|
//https://stackoverflow.com/a/847196
|
2022-01-28 19:07:39 +00:00
|
|
|
timestampRaw = arg.data[i]['timestamp']
|
2021-11-19 17:49:36 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
var timestamp = document.createElement("td");
|
|
|
|
var timestampText = document.createElement('span');
|
|
|
|
timestampText.innerText = datetime
|
|
|
|
timestamp.appendChild(timestampText);
|
|
|
|
|
|
|
|
var dxCall = document.createElement("td");
|
|
|
|
var dxCallText = document.createElement('span');
|
2022-01-28 19:07:39 +00:00
|
|
|
dxCallText.innerText = arg.data[i]['dxcallsign']
|
2021-11-19 17:49:36 +00:00
|
|
|
dxCall.appendChild(dxCallText);
|
|
|
|
|
|
|
|
var message = document.createElement("td");
|
|
|
|
var messageText = document.createElement('span');
|
2022-01-28 19:07:39 +00:00
|
|
|
var messageString = arg.data[i]['rxdata'][0]['d'] //data
|
2022-01-07 17:31:13 +00:00
|
|
|
console.log(messageString)
|
2021-11-19 17:49:36 +00:00
|
|
|
messageText.innerText = messageString
|
|
|
|
message.appendChild(messageText);
|
|
|
|
|
|
|
|
row.appendChild(timestamp);
|
|
|
|
row.appendChild(dxCall);
|
|
|
|
row.appendChild(message);
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2021-11-19 17:49:36 +00:00
|
|
|
tbl.appendChild(row);
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2021-11-19 17:49:36 +00:00
|
|
|
}
|
2021-11-19 16:30:17 +00:00
|
|
|
|
|
|
|
})
|