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

View file

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

View file

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

View file

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