Prettified Code!

This commit is contained in:
DJ2LS 2023-07-10 08:22:44 +00:00 committed by GitHub Action
parent ee396ed58e
commit 9f3a3633e4
4 changed files with 125 additions and 82 deletions

View file

@ -1,5 +1,5 @@
const { app, BrowserWindow, ipcMain, dialog, shell } = require("electron");
const https = require('https');
const https = require("https");
const { autoUpdater } = require("electron-updater");
const path = require("path");
const fs = require("fs");
@ -1050,31 +1050,30 @@ ipcMain.on("request-check-rigctld", (event, data) => {
}
});
function downloadJsonUrlToFile(url, callsignPath) {
// https://nodejs.org/api/https.html#httpsgetoptions-callback
// https://nodejs.org/api/https.html#httpsgetoptions-callback
https.get(url, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
https
.get(url, (res) => {
console.log("statusCode:", res.statusCode);
console.log("headers:", res.headers);
res.on('data', (d) => {
console.log(d);
let json = JSON.parse(d);
fs.writeFileSync(callsignPath, JSON.stringify(json, null, 2));
});
}).on('error', (e) => {
res.on("data", (d) => {
console.log(d);
let json = JSON.parse(d);
fs.writeFileSync(callsignPath, JSON.stringify(json, null, 2));
});
})
.on("error", (e) => {
console.error(e);
});
}
function downloadCallsignReverseLookupData(){
var callsignPath = path.join(configFolder, "callsigns.json");
downloadJsonUrlToFile('https://api.freedata.app/callsign_lookup.php', callsignPath)
function downloadCallsignReverseLookupData() {
var callsignPath = path.join(configFolder, "callsigns.json");
downloadJsonUrlToFile(
"https://api.freedata.app/callsign_lookup.php",
callsignPath,
);
}
downloadCallsignReverseLookupData();

View file

@ -3865,6 +3865,3 @@ function showOsPopUp(title, message) {
const NOTIFICATION_BODY = message;
new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY });
}

View file

@ -14,7 +14,6 @@ const config = require(configPath);
var callsignPath = path.join(configFolder, "callsigns.json");
const callsigns = require(callsignPath);
// WINDOW LISTENER
window.addEventListener("DOMContentLoaded", () => {
// startPing button clicked
@ -71,23 +70,23 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["dxcall"]){
dxcallText.innerText +=' (' + call + ')';
continue;
}
if (callsigns[call] == routes[i]["dxcall"]) {
dxcallText.innerText += " (" + call + ")";
continue;
}
}
dxcall.appendChild(dxcallText);
var router = document.createElement("td");
var routerText = document.createElement("span");
routerText.innerText = routes[i]["router"];
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["router"]){
routerText.innerText += ' (' + call + ')';
continue;
}
if (callsigns[call] == routes[i]["router"]) {
routerText.innerText += " (" + call + ")";
continue;
}
}
router.appendChild(routerText);
@ -152,10 +151,10 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
destinationText.innerText = routes[i]["destination"];
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["destination"]){
destinationText.innerText += ' (' + call + ')';
continue;
}
if (callsigns[call] == routes[i]["destination"]) {
destinationText.innerText += " (" + call + ")";
continue;
}
}
destination.appendChild(destinationText);

View file

@ -21,54 +21,106 @@
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-route-tab" data-bs-toggle="tab" data-bs-target="#nav-route" type="button" role="tab" aria-controls="nav-route" aria-selected="true">Routes</button>
<button class="nav-link" id="nav-signaling-tab" data-bs-toggle="tab" data-bs-target="#nav-signaling" type="button" role="tab" aria-controls="nav-signaling" aria-selected="false">Signaling</button>
<button class="nav-link" id="nav-actions-tab" data-bs-toggle="tab" data-bs-target="#nav-actions" type="button" role="tab" aria-controls="nav-actions" aria-selected="false">Actions</button>
<button
class="nav-link active"
id="nav-route-tab"
data-bs-toggle="tab"
data-bs-target="#nav-route"
type="button"
role="tab"
aria-controls="nav-route"
aria-selected="true"
>
Routes
</button>
<button
class="nav-link"
id="nav-signaling-tab"
data-bs-toggle="tab"
data-bs-target="#nav-signaling"
type="button"
role="tab"
aria-controls="nav-signaling"
aria-selected="false"
>
Signaling
</button>
<button
class="nav-link"
id="nav-actions-tab"
data-bs-toggle="tab"
data-bs-target="#nav-actions"
type="button"
role="tab"
aria-controls="nav-actions"
aria-selected="false"
>
Actions
</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active vw-100 vh-90 overflow-auto" id="nav-route" role="tabpanel" aria-labelledby="nav-route-tab">
<div
class="tab-pane fade show active vw-100 vh-90 overflow-auto"
id="nav-route"
role="tabpanel"
aria-labelledby="nav-route-tab"
>
<div class="container-fluid">
<div class="table-responsive overflow-auto" style="max-width: 99vw;max-height: 99vh;">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">DXCall</th>
<th scope="col">Router</th>
<th scope="col">Hops</th>
<th scope="col">Score</th>
<th scope="col">SNR</th>
</tr>
</thead>
<tbody id="mesh-table">
</tbody>
</table>
</div>
<div
class="table-responsive overflow-auto"
style="max-width: 99vw; max-height: 99vh"
>
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">DXCall</th>
<th scope="col">Router</th>
<th scope="col">Hops</th>
<th scope="col">Score</th>
<th scope="col">SNR</th>
</tr>
</thead>
<tbody id="mesh-table"></tbody>
</table>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-signaling" role="tabpanel" aria-labelledby="nav-signaling-tab">
<div
class="tab-pane fade"
id="nav-signaling"
role="tabpanel"
aria-labelledby="nav-signaling-tab"
>
<div class="container-fluid">
<div class="table-responsive overflow-auto" style="max-width: 99vw;max-height: 99vh;">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">Destination</th>
<th scope="col">Router</th>
<th scope="col">Frametype</th>
<th scope="col">Payload</th>
<th scope="col">Attempt</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody id="mesh-signalling-table"></tbody>
</table>
<div
class="table-responsive overflow-auto"
style="max-width: 99vw; max-height: 99vh"
>
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">Destination</th>
<th scope="col">Router</th>
<th scope="col">Frametype</th>
<th scope="col">Payload</th>
<th scope="col">Attempt</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody id="mesh-signalling-table"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-actions" role="tabpanel" aria-labelledby="nav-actions-tab">
<div
class="tab-pane fade"
id="nav-actions"
role="tabpanel"
aria-labelledby="nav-actions-tab"
>
<div class="input-group mt-1">
<input
type="text"
@ -87,9 +139,5 @@
</div>
</div>
</div>
</body>
</html>