You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
4.0 KiB

11 months ago
const socket = io();
socket.addEventListener("connect", () => {
socket.emit("Hello from script.js");
});
11 months ago
socket.addEventListener("info", indata => {
// console.log(indata);
const data = JSON.parse(indata);
$("#instruct").empty();
$("#instruct").append("<table id=\"urltable\"><caption>Helpful Sites</caption>");
11 months ago
$("#urltable").append("<tr><th>Sponsor</th><th>Live</th><th>Utilities</th></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.sponsor + "\">" +
data.sponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_1 + "\">" +
data.livename_1 + "</a></td><td><a target=\"register\" href=\"" + data.registration +
"\">" + data.registersite + "</a></td></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.cosponsor + "\">" +
data.cosponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_2 + "\">" +
data.livename_2 + "</a></td><td></td></tr>");
11 months ago
});
socket.addEventListener("title", data => {
11 months ago
// console.log(data);
11 months ago
$("title").text(data);
$("#intro").text(data);
});
socket.addEventListener("links", data => {
// console.log("links " + data);
11 months ago
$("#links").empty();
$("#links").append("<table id=\"linktable\"><caption>Links</caption>");
$("#linktable").append("<tr><th>Repeater</th><th>Reflector</th><th>Protocol</th>" +
"<th>Device</th><th>Direction</th><th>Timestamp</th></tr>");
$.each(data, function(index,val){
const utcDate = new Date(val.timestamp);
var reflector = val.reflector.substring(0,8).trim();
if (reflector.substring(0,3) == "REF") reflector = "<a href=\"http://" + reflector + ".dstargateway.org\" target=\"reflector\">" + val.reflector + "</a>";
$("#linktable").append("<tr><td>" + val.repeater + "</td><td>" + reflector +
11 months ago
"</td><td>" + val.protocol + "</td><td>" + val.device + "</td><td>" +
val.direction + "</td><td>" + utcDate.toLocaleString() + "</td></tr>");
11 months ago
// console.log(index, val);
});
});
11 months ago
socket.addEventListener("repeaters", data => {
$("#repeaters").empty();
$("#repeaters").append("<table id=\"rptrtable\"><caption>Repeaters</caption>");
11 months ago
$("#rptrtable").append("<tr><th>Callsign</th><th>Frequency</th><th>Offset</th><th>Description</th>" +
"<th>Location</th></tr>");
11 months ago
$.each(data, function(index,val){
9 months ago
$("#rptrtable").append("<tr><td>" +
val.callsign +
"</td><td>" +
val.frequency +
" Mhz.</td><td>" +
val.offset +
" Mhz.</td><td>" +
val.description1 +
" - " +
11 months ago
val.description2 +
9 months ago
"</td><td><a title=\"" +
val.latitude +
" " +
val.longitude +
"\" target=\"location\" href=\"https://aprs.fi/#!mt=roadmap&z=11&call=a%2F" +
val.callsign +
"\" >aprs.fi</a></td></tr>");
11 months ago
});
});
11 months ago
socket.addEventListener("lastheard", data => {
// console.log("lastheard " + data);
$("#lastheard").empty();
$("#lastheard").append("<table id=\"lhtable\"><caption>Last Heard</caption>");
$("#lhtable").append("<tr><th>MYcall</th><th>URcall</th><th>Rpt1</th><th>Rpt2</th><th>Source</th><th>Date GMT</th><th>Time GMT</th><th>Local</th></tr>");
11 months ago
$.each(data, function(index,val){
// console.log(index, val);
const utcDate = val.date.trim() + 'T' + val.time.trim() + 'Z';
const udate = new Date(utcDate);
const ldate = udate.toLocaleString();
var mcall = "<a href=\"https://qrz.com/db/" + val.mycall + "\" target=\"qrz\">" + val.mycall + "</a>";
11 months ago
if (val.msg1 != "") mcall += " / " + val.msg1;
var rpt1 = val.rpt1.substring(0,7).trim();
if (rpt1.substring(0,3) == "REF") {
rpt1 = "<a href=\"http://" + rpt1 + ".dstargateway.org\" target=\"reflector\">" + val.rpt1 + "</a>"}
else {
rpt1 = val.rpt1
}
var rpt2 = val.rpt2.substring(0,7).trim();
if (rpt2.substring(0,3) == "REF") {
rpt2 = "<a href=\"http://" + rpt2 + ".dstargateway.org\" target=\"reflector\">" + val.rpt2 + "</a>" }
else {
rpt2 = val.rpt2
}
11 months ago
$("#lhtable").append("<tr><td>" + mcall + "</td><td>"+ val.urcall +
"</td><td>" + rpt1 + "</td><td>" + rpt2 +
"</td><td>" + val.source + "</td><td>" + val.date + "</td><td>" + val.time + "</td>" +
"<td>" + ldate +"</td></tr>");
11 months ago
})
});