const socket = io();
socket.addEventListener("connect", () => {
socket.emit("Hello from script.js");
});
socket.addEventListener("info", indata => {
// console.log(indata);
const data = JSON.parse(indata);
$("#instruct").empty();
$("#instruct").append("
Helpful Sites");
$("#urltable").append("Sponsor | Live | Utilities |
");
$("#urltable").append("" +
data.sponsorname + " | " +
data.livename_1 + " | " + data.registersite + " |
");
$("#urltable").append("" +
data.cosponsorname + " | " +
data.livename_2 + " | |
");
});
socket.addEventListener("title", data => {
// console.log(data);
$("title").text(data);
$("#intro").text(data);
});
socket.addEventListener("links", data => {
// console.log("links " + data);
$("#links").empty();
$("#links").append("Links");
$("#linktable").append("Repeater | Reflector | Protocol | " +
"Device | Direction | Timestamp |
");
$.each(data, function(index,val){
const utcDate = new Date(val.timestamp);
var reflector = val.reflector.substring(0,7).trim();
if (reflector.substring(0,3) == "REF") reflector = "" + val.reflector + "";
$("#linktable").append("" + val.repeater + " | " + reflector +
" | " + val.protocol + " | " + val.device + " | " +
val.direction + " | " + utcDate.toLocaleString() + " |
");
// console.log(index, val);
});
});
socket.addEventListener("repeaters", data => {
$("#repeaters").empty();
$("#repeaters").append("Repeaters");
$("#rptrtable").append("Callsign | Frequency | Offset | Description | " +
"Location |
");
$.each(data, function(index,val){
$("#rptrtable").append("" +
val.callsign +
" | " +
val.frequency +
" Mhz. | " +
val.offset +
" Mhz. | " +
val.description1 +
" - " +
val.description2 +
" | aprs.fi |
");
});
});
socket.addEventListener("lastheard", data => {
// console.log("lastheard " + data);
$("#lastheard").empty();
$("#lastheard").append("Last Heard");
$("#lhtable").append("MYcall | URcall | Rpt1 | Rpt2 | Source | Date | Time | Local |
");
$.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 = "" + val.mycall + "";
if (val.msg1 != "") mcall += " / " + val.msg1;
var rpt1 = val.rpt1.substring(0,7).trim();
if (rpt1.substring(0,3) == "REF") {
rpt1 = "" + val.rpt1 + ""}
else {
rpt1 = val.rpt1
}
var rpt2 = val.rpt2.substring(0,7).trim();
if (rpt2.substring(0,3) == "REF") {
rpt2 = "" + val.rpt2 + "" }
else {
rpt2 = val.rpt2
}
$("#lhtable").append("" + mcall + " | "+ val.urcall +
" | " + rpt1 + " | " + rpt2 +
" | " + val.source + " | " + val.date + " | " + val.time + " | " +
"" + ldate +" |
");
})
});