Files
RotRouter/public/index.html
T
erikbrockoandClaude Opus 5.5 fb1c733699 show the world map behind each rotator scale
Fall back to the IP-rotator firmware's default xplanet grayline map
(remoteqth.com/xplanet/OK.png) when the rotator has no map URL, draw it
beneath the scale instead of over the spokes, refresh it every 30 min
with a cache-buster, and skip it for elevation rotators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:46:56 +00:00

816 lines
29 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RotRouter</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,700,300&subset=latin-ext" rel="stylesheet" type="text/css">
<style>
:root {
--box-size: 400px;
}
html, body {
font-family: 'Roboto Condensed', sans-serif, Arial, Tahoma, Verdana;
background-color: #000;
color: #ccc;
margin: 0;
padding: 0;
}
.tab-bar {
display: flex;
align-items: center;
background: #111;
border-bottom: 1px solid #333;
padding: 0 8px;
gap: 0;
user-select: none;
}
.tab {
padding: 10px 18px;
font-size: 15px;
color: #888;
cursor: pointer;
border-bottom: 2px solid transparent;
white-space: nowrap;
}
.tab:hover { color: #ccc; }
.tab.active {
color: #fff;
border-bottom-color: #4a9eff;
}
.rotators {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
padding: 20px;
}
.rotator-card {
display: none;
flex-direction: column;
align-items: center;
}
.rotator-card.visible {
display: flex;
}
canvas {
display: block;
cursor: crosshair;
}
.info-panel {
width: var(--box-size);
margin-top: 8px;
text-align: center;
}
.rotator-label {
font-size: 22px;
font-weight: bold;
color: #fff;
margin: 0 0 2px;
}
.rotator-bands {
font-size: 15px;
color: #aaa;
margin: 0 0 6px;
}
.status-bar {
font-size: 20px;
margin: 0;
}
.status-wrapper {
color: #000;
background: #666;
padding: 4px 6px;
border-radius: 5px;
display: inline-block;
}
.text-white { color: #fff; }
.text-bold { font-weight: bold; }
.text-red { color: red; }
.text-muted { color: #666; font-size: 73%; }
.turned-by {
font-size: 14px;
color: #888;
margin: 4px 0 0;
}
.turned-by .source {
color: #e0e040;
}
.station-bar {
display: none;
gap: 8px;
padding: 8px 12px;
background: #0a0a0a;
border-bottom: 1px solid #222;
flex-wrap: wrap;
user-select: none;
}
.station-bar.visible {
display: flex;
}
.station-pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 12px;
border: 2px solid #333;
border-radius: 16px;
cursor: pointer;
font-size: 14px;
color: #888;
transition: border-color 0.15s;
}
.station-pill:hover { border-color: #666; }
.station-pill.selected { color: #fff; }
.station-pill .dot {
width: 10px;
height: 10px;
border-radius: 50%;
}
.station-pill .freq {
color: #666;
font-size: 12px;
}
.station-pill.selected .freq { color: #aaa; }
</style>
</head>
<body>
<div class="tab-bar" id="tab-bar"></div>
<div class="station-bar" id="station-bar"></div>
<div class="rotators" id="rotators"></div>
<script>
// Same default as the IP-rotator firmware: a live xplanet grayline map centred on OK.
const DEFAULT_MAP_URL = 'https://remoteqth.com/xplanet/OK.png';
const MAP_REFRESH_MS = 30 * 60 * 1000;
const MAP_RETRY_MS = 10 * 1000;
class RotatorState {
constructor() {
this.boxSize = 400;
this.center = this.boxSize / 2;
this.azShift = 0;
this.azRange = 360;
this.azimuth = 0;
this.antRadiationAngle = 0;
this.status = 4;
this.mapUrl = "";
this.elevation = 0;
this.mac = "";
this.antName = "";
this.adc = 0;
this.online = false;
this.bands = [];
this.targetAngle = null;
}
}
class RotatorRenderer {
constructor(canvas, state) {
this.canvas = canvas;
this.ctx = canvas.getContext('2d');
this.state = state;
this.bgCanvas = document.createElement('canvas');
this.bgCanvas.width = state.boxSize;
this.bgCanvas.height = state.boxSize;
this.bgCtx = this.bgCanvas.getContext('2d');
this.mapImage = null;
this.mapUrl = null;
this.mapLoadGeneration = 0;
this.mapRetryTimer = null;
setInterval(() => this.loadMap(), MAP_REFRESH_MS);
}
getPoint(angle, radius) {
const rad = angle * Math.PI / 180;
return {
x: this.state.center + Math.sin(rad) * radius,
y: this.state.center - Math.cos(rad) * radius
};
}
/** Sets the background map; elevation rotators get none, like in the firmware UI. */
updateMap(url) {
const nextUrl = this.state.elevation !== 0 ? null
: (url && url !== '0') ? url : DEFAULT_MAP_URL;
if (nextUrl !== this.mapUrl) {
this.mapUrl = nextUrl;
this.mapImage = null;
this.loadMap();
}
this.drawBackgroundCache();
}
/** (Re)loads the map with a cache-buster so the grayline stays current. */
loadMap() {
clearTimeout(this.mapRetryTimer);
if (!this.mapUrl) return;
const generation = ++this.mapLoadGeneration;
const img = new Image();
img.onload = () => {
if (generation !== this.mapLoadGeneration) return;
this.mapImage = img;
this.drawBackgroundCache();
};
img.onerror = () => {
if (generation !== this.mapLoadGeneration) return;
this.mapRetryTimer = setTimeout(() => this.loadMap(), MAP_RETRY_MS);
};
img.src = this.mapUrl + (this.mapUrl.includes('?') ? '&' : '?') + 't=' + Date.now();
}
drawBackgroundCache() {
const ctx = this.bgCtx;
const sz = this.state.boxSize;
const cx = this.state.center;
const cy = this.state.center;
ctx.clearRect(0, 0, sz, sz);
// The map's globe has the same 0.9 radius as the scale, so it is drawn at full size.
if (this.mapImage) {
ctx.drawImage(this.mapImage, 0, 0, sz, sz);
}
ctx.beginPath();
ctx.lineWidth = 1;
ctx.strokeStyle = '#606060';
for (let i = 0; i < 24; i++) {
const startRadius = (i % 2 === 0) ? sz / 2 * 0.1 : sz / 2 * 0.3;
const pStart = this.getPoint(i * 15, startRadius);
const pEnd = this.getPoint(i * 15, sz / 2 * 0.9);
ctx.moveTo(pStart.x, pStart.y);
ctx.lineTo(pEnd.x, pEnd.y);
}
ctx.stroke();
ctx.lineWidth = 8;
ctx.strokeStyle = 'orange';
if (this.state.azRange > 360) {
const startRad = (270 + this.state.azShift) * Math.PI / 180;
const stopRad = (270 + this.state.azShift + this.state.azRange - 360) * Math.PI / 180;
ctx.beginPath();
ctx.arc(cx, cy, sz / 2 * 0.9 - 8, startRad, stopRad);
ctx.stroke();
}
ctx.beginPath();
const startArc = this.state.elevation === 0 ? 0 : Math.PI;
ctx.arc(cx, cy, sz / 2 * 0.9, startArc, 2 * Math.PI);
ctx.lineWidth = 2;
ctx.strokeStyle = '#c0c0c0';
ctx.font = "16px Arial";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = "#808080";
const maxTick = this.state.elevation === 0 ? 35 : 18;
const offset = this.state.elevation === 0 ? 0 : 270;
for (let i = 0; i <= maxTick; i++) {
const angle = i * 10 + offset;
if (i % 9 !== 0) {
const p1 = this.getPoint(angle, sz / 2 * 0.95);
const p2 = this.getPoint(angle, sz / 2 * 0.9);
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
}
if (i % 3 === 0 && i % 9 !== 0) {
const pt = this.getPoint(angle, sz / 2);
ctx.fillText(i * 10, pt.x, pt.y);
}
}
if (this.state.elevation === 0) {
ctx.fillStyle = "white";
ctx.fillText("N", cx, sz * 0.025);
ctx.fillText("E", sz * 0.975, cy);
ctx.fillText("S", cx, sz * 0.975);
ctx.fillText("W", sz * 0.025, cy);
}
ctx.stroke();
if (this.state.azRange < 360) {
ctx.beginPath();
ctx.lineWidth = 1;
ctx.strokeStyle = 'white';
const p1 = this.getPoint(this.state.azShift, sz / 2 * 0.9);
const p2 = this.getPoint(this.state.azShift + this.state.azRange, sz / 2 * 0.9);
ctx.moveTo(cx, cy); ctx.lineTo(p1.x, p1.y);
ctx.moveTo(cx, cy); ctx.lineTo(p2.x, p2.y);
ctx.stroke();
if (this.state.azRange + this.state.antRadiationAngle < 360) {
ctx.beginPath();
ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
const darkRange = 360 - this.state.azRange - this.state.antRadiationAngle;
const steps = (darkRange - 20) / 10;
const startAngle = this.state.azShift + this.state.azRange + this.state.antRadiationAngle / 2;
const startPt = this.getPoint(startAngle, sz / 2 * 0.9);
ctx.moveTo(cx, cy);
ctx.lineTo(startPt.x, startPt.y);
for (let i = 0; i < steps; i++) {
const pt = this.getPoint(startAngle + 10 * (i + 1), sz / 2 * 0.9);
ctx.lineTo(pt.x, pt.y);
}
const endPt = this.getPoint(this.state.azShift - this.state.antRadiationAngle / 2, sz / 2 * 0.9);
ctx.lineTo(endPt.x, endPt.y);
ctx.fill();
}
}
this.render();
}
render() {
const ctx = this.ctx;
const sz = this.state.boxSize;
const cx = this.state.center;
const cy = this.state.center;
const { azShift, azRange, azimuth, status, antRadiationAngle, targetAngle } = this.state;
ctx.clearRect(0, 0, sz, sz);
ctx.drawImage(this.bgCanvas, 0, 0);
const isOffline = !this.state.online;
if (isOffline) {
// Grey overlay
ctx.beginPath();
ctx.arc(cx, cy, sz / 2 * 0.9, 0, 2 * Math.PI);
ctx.fillStyle = 'rgba(0, 0, 0, 0.6)';
ctx.fill();
// OFFLINE label
ctx.font = 'bold 50px Arial';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = '#666';
ctx.fillText('OFFLINE', cx, cy);
return;
}
// Setpoint line (only while turning)
if (targetAngle != null && status !== 4) {
ctx.beginPath();
ctx.lineWidth = 2;
ctx.strokeStyle = 'red';
const pt = this.getPoint(targetAngle, sz / 2 * 0.9);
ctx.moveTo(cx, cy);
ctx.lineTo(pt.x, pt.y);
ctx.stroke();
}
// Pointer
ctx.beginPath();
ctx.lineWidth = 5;
const isOutOfRange = azimuth < 0 || azimuth > azRange;
if (isOutOfRange) ctx.strokeStyle = '#c0c0c0';
else if (status !== 4) ctx.strokeStyle = "red";
else if (azimuth > 359) ctx.strokeStyle = "orange";
else ctx.strokeStyle = '#00aa00';
const displayAngle = azimuth + azShift;
const pStart = this.getPoint(displayAngle, sz / 2 * 0.9);
const pEnd = this.getPoint(displayAngle, sz / 2 * 0.7);
ctx.moveTo(pStart.x, pStart.y);
ctx.lineTo(pEnd.x, pEnd.y);
ctx.stroke();
if (status !== 4) {
ctx.beginPath();
ctx.fillStyle = "red";
const offset = status < 4 ? -6 : 6;
const a1 = this.getPoint(displayAngle + offset / 2, sz / 2 * 0.85);
const a2 = this.getPoint(displayAngle + offset / 2, sz / 2 * 0.75);
const a3 = this.getPoint(displayAngle + offset * 1.3, sz / 2 * 0.8);
ctx.moveTo(a1.x, a1.y); ctx.lineTo(a2.x, a2.y); ctx.lineTo(a3.x, a3.y);
const b1 = this.getPoint(displayAngle + offset * 1.5, sz / 2 * 0.83);
const b2 = this.getPoint(displayAngle + offset * 1.5, sz / 2 * 0.77);
const b3 = this.getPoint(displayAngle + offset * 2, sz / 2 * 0.8);
ctx.moveTo(b1.x, b1.y); ctx.lineTo(b2.x, b2.y); ctx.lineTo(b3.x, b3.y);
ctx.fill();
}
ctx.font = "bold 70px Arial";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
let textAngle = this.state.elevation === 0 ? azimuth + azShift : azimuth;
if (textAngle > 359) textAngle -= 360;
const textLoc = this.getPoint(displayAngle + 180, sz * 0.2);
if (isOutOfRange) {
ctx.font = "bold 22px Arial";
ctx.fillStyle = '#c0c0c0';
ctx.fillText(azimuth < 0 ? "CCW endstop zone" : "CW endstop zone", textLoc.x, textLoc.y);
} else {
ctx.fillStyle = "black";
ctx.fillText(`${textAngle}\u00B0`, textLoc.x + 3, textLoc.y + 3);
if (status !== 4) ctx.fillStyle = "red";
else if (azimuth > 359) ctx.fillStyle = "orange";
else ctx.fillStyle = "green";
ctx.fillText(`${textAngle}\u00B0`, textLoc.x, textLoc.y);
}
ctx.beginPath();
ctx.moveTo(cx, cy);
const ccwAngle = antRadiationAngle / 2;
for (let i = 0; i <= 16; i++) {
const pt = this.getPoint(displayAngle - ccwAngle + (antRadiationAngle / 16) * i, sz / 2 * 0.9);
ctx.lineTo(pt.x, pt.y);
}
if (isOutOfRange) ctx.fillStyle = "rgba(255, 255, 255, 0.10)";
else if (status !== 4) ctx.fillStyle = "rgba(255, 0, 0, 0.25)";
else if (azimuth > 359) ctx.fillStyle = "rgba(255, 165, 0, 0.25)";
else ctx.fillStyle = "rgba(255, 255, 255, 0.25)";
ctx.fill();
}
}
class RotatorUI {
constructor(label, container, state) {
this.state = state;
this.label = label;
this.card = document.createElement('div');
this.card.className = 'rotator-card';
const card = this.card;
this.nameEl = document.createElement('p');
this.nameEl.className = 'rotator-label';
this.nameEl.textContent = label;
card.appendChild(this.nameEl);
this.bandsEl = document.createElement('p');
this.bandsEl.className = 'rotator-bands';
card.appendChild(this.bandsEl);
const canvas = document.createElement('canvas');
canvas.width = state.boxSize;
canvas.height = state.boxSize;
card.appendChild(canvas);
const infoPanel = document.createElement('div');
infoPanel.className = 'info-panel';
infoPanel.innerHTML = `
<p class="status-bar">
<span class="status-wrapper">
POE <span class="adc text-white text-bold">0</span> V |
raw <span class="az text-bold">0</span>&deg;
<span class="online text-muted"></span>
</span>
</p>
<p class="turned-by">Last turned by: <span class="source">-</span></p>
`;
card.appendChild(infoPanel);
container.appendChild(card);
this.els = {
adc: infoPanel.querySelector('.adc'),
az: infoPanel.querySelector('.az'),
online: infoPanel.querySelector('.online'),
turnedBy: infoPanel.querySelector('.turned-by .source'),
};
this.renderer = new RotatorRenderer(canvas, state);
canvas.addEventListener("click", (evt) => {
const rect = canvas.getBoundingClientRect();
const x = evt.clientX - rect.left;
const y = evt.clientY - rect.top;
let angle = Math.atan2(state.center - y, x - state.center) * 180 / Math.PI;
angle = Math.round((90 - angle + 360) % 360);
state.targetAngle = angle;
this.renderer.render();
fetch(`/turn/${encodeURIComponent(label)}`, {
method: 'POST',
headers: { 'Content-type': 'application/x-www-form-urlencoded' },
body: `ROT=${angle}`
}).catch(() => {});
});
this.updateStatic();
}
updateStatic() {
this.nameEl.textContent = this.state.antName || this.label;
this.bandsEl.textContent = this.state.bands.length
? this.state.bands.map(b => b + " MHz").join(", ")
: "";
this.renderer.updateMap(this.state.mapUrl);
}
updateDynamic() {
const adcFormatted = Math.round(this.state.adc * 10) / 10;
if (this.state.adc < 11.5) {
this.els.adc.innerHTML = `<span class="text-red">${adcFormatted}</span>`;
} else {
this.els.adc.innerText = adcFormatted;
}
this.els.az.innerText = this.state.azimuth;
this.els.online.innerHTML = this.state.online
? " | <span class=\"text-white\">&bull;</span> Connected"
: " | <span class=\"text-red\">&bull;</span> Offline";
}
updateTurnedBy(setpoint, station) {
const el = this.els.turnedBy;
el.textContent = `${setpoint.station ?? setpoint.sourceIp} \u2192 ${setpoint.targetAz}\u00B0`;
el.style.color = station ? station.color : '';
}
}
class RotatorApp {
constructor() {
this.rotators = {};
this.labels = [];
this.stations = {};
this.stationPills = {};
this.stationRadio = {};
this.selectedStation = null;
this.autoMode = false;
this.container = document.getElementById('rotators');
this.tabBar = document.getElementById('tab-bar');
this.stationBar = document.getElementById('station-bar');
this.websocket = null;
}
async initialize() {
const init = await this.startWs();
this.stations = init.stations;
this.stationRadio = init.stationRadio;
const stored = loadSelectedStation();
this.selectedStation = (stored && this.stations[stored]) ? stored : init.clientStation;
for (const [label, rotState] of Object.entries(init.rotators)) {
const state = new RotatorState();
state.bands = rotState.bands;
const ui = new RotatorUI(label, this.container, state);
this.rotators[label] = { state, ui };
this.labels.push(label);
if (rotState.initData) this.applyInitData(label, rotState.initData);
if (rotState.dynamic) this.applyDynamic(label, rotState.dynamic);
if (rotState.setpoint) this.applySetpoint(label, rotState.setpoint);
}
this.buildTabBar();
this.buildStationBar();
this.updateTitle();
this.applyHash();
window.addEventListener('hashchange', () => this.applyHash());
}
updateTitle() {
document.title = Object.values(this.rotators)
.map(r => r.state.antName || "Rotator")
.join(" / ");
}
buildTabBar() {
this.autoTab = this.createTab('Auto', 'auto');
for (const label of this.labels) {
this.rotators[label].tab = this.createTab(this.rotators[label].state.antName || label, label);
}
this.allTab = this.createTab('All', 'all');
}
createTab(text, hash) {
const tab = document.createElement('div');
tab.className = 'tab';
tab.textContent = text;
tab.addEventListener('click', () => { location.hash = encodeURIComponent(hash); });
this.tabBar.appendChild(tab);
return tab;
}
buildStationBar() {
for (const [name, cfg] of Object.entries(this.stations)) {
const pill = document.createElement('div');
pill.className = 'station-pill';
const dot = document.createElement('span');
dot.className = 'dot';
dot.style.background = cfg.color;
pill.appendChild(dot);
const nameSpan = document.createElement('span');
nameSpan.textContent = name;
pill.appendChild(nameSpan);
const freq = document.createElement('span');
freq.className = 'freq';
const radio = this.stationRadio[name];
freq.textContent = radio ? formatFreq(radio.freq) : '';
pill.appendChild(freq);
pill.addEventListener('click', () => {
this.selectedStation = name;
saveSelectedStation(name);
this.updateStationSelection();
this.applyAutoTab();
});
this.stationBar.appendChild(pill);
this.stationPills[name] = { el: pill, freqEl: freq };
}
this.updateStationSelection();
}
updateStationSelection() {
for (const [name, pill] of Object.entries(this.stationPills)) {
const selected = name === this.selectedStation;
pill.el.classList.toggle('selected', selected);
pill.el.style.borderColor = selected ? this.stations[name].color : '';
}
}
applyHash() {
const hash = decodeURIComponent(location.hash.slice(1));
this.autoMode = hash !== 'all' && !this.rotators[hash];
if (this.autoMode) this.applyAutoTab();
else if (hash === 'all') this.showAll();
else this.showTab(hash);
const hasStations = Object.keys(this.stations).length > 0;
this.stationBar.classList.toggle('visible', this.autoMode && hasStations);
this.autoTab.classList.toggle('active', this.autoMode);
this.allTab.classList.toggle('active', hash === 'all');
}
applyAutoTab() {
const radio = this.selectedStation ? this.stationRadio[this.selectedStation] : null;
const match = radio ? this.findRotatorForBand(radio.band) : null;
if (match) this.showTab(match, true);
else this.showAll();
}
findRotatorForBand(band) {
return this.labels.find(l => this.rotators[l].state.bands.includes(band)) ?? null;
}
showTab(label, isAuto = false) {
for (const l of this.labels) {
const rot = this.rotators[l];
const visible = l === label;
rot.ui.card.classList.toggle('visible', visible);
rot.tab.classList.toggle('active', !isAuto && visible);
}
// re-render: the canvas may have been hidden
this.rotators[label].ui.renderer.render();
}
showAll() {
for (const l of this.labels) {
const rot = this.rotators[l];
rot.ui.card.classList.add('visible');
rot.tab.classList.remove('active');
rot.ui.renderer.render();
}
}
applyInitData(label, initData) {
const rot = this.rotators[label];
for (const [key, value] of Object.entries(initData)) {
if (value !== null) rot.state[key] = value;
}
rot.ui.updateStatic();
if (rot.tab) rot.tab.textContent = rot.state.antName || label;
this.updateTitle();
}
applyDynamic(label, { azimuth, status, adc, online }) {
const rot = this.rotators[label];
const needsRender = rot.state.azimuth !== azimuth
|| rot.state.status !== status
|| rot.state.online !== online;
rot.state.adc = adc;
rot.state.azimuth = azimuth;
rot.state.status = status;
rot.state.online = online;
if (needsRender) rot.ui.renderer.render();
rot.ui.updateDynamic();
}
applySetpoint(label, setpoint) {
const rot = this.rotators[label];
rot.state.targetAngle = setpoint.targetAz;
rot.ui.renderer.render();
rot.ui.updateTurnedBy(setpoint, this.stations[setpoint.station]);
}
handleRadioInfo({ station, band, freq }) {
this.stationRadio[station] = { band, freq };
const pill = this.stationPills[station];
if (pill) pill.freqEl.textContent = formatFreq(freq);
if (this.autoMode && station === this.selectedStation) this.applyAutoTab();
}
handleMessage(msg) {
if (msg.type === 'radioInfo') {
this.handleRadioInfo(msg);
return;
}
if (!this.rotators[msg.label]) return;
switch (msg.type) {
case 'initData': this.applyInitData(msg.label, msg.initData); break;
case 'dynamic': this.applyDynamic(msg.label, msg.dynamic); break;
case 'setpoint': this.applySetpoint(msg.label, msg.setpoint); break;
}
}
startWs() {
return new Promise((resolve) => {
const ws = new WebSocket(wsUrl());
this.websocket = ws;
ws.addEventListener("message", (e) => {
let msg;
try {
msg = JSON.parse(e.data);
} catch {
return;
}
if (msg.type === 'init') resolve(msg);
else this.handleMessage(msg);
});
const pingTimer = setInterval(() => {
if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ ping: 1 }));
}, 2000);
ws.addEventListener("close", () => {
clearInterval(pingTimer);
reloadWhenServerIsBack();
});
});
}
}
function wsUrl() {
return location.origin.replace(/^http/, 'ws') + location.pathname.replace(/\/?$/, '/') + 'ws';
}
/** Polls until the server accepts a WebSocket again, then reloads to get a fresh state. */
function reloadWhenServerIsBack() {
setTimeout(() => {
const probe = new WebSocket(wsUrl());
probe.addEventListener("open", () => location.reload());
probe.addEventListener("error", () => reloadWhenServerIsBack());
}, 2000);
}
/** N1MM frequencies are in tens of Hz. */
function formatFreq(freq) {
return (freq / 100000).toFixed(3) + ' MHz';
}
const STATION_STORAGE_KEY = 'rotrouter.selectedStation';
function loadSelectedStation() {
try {
return localStorage.getItem(STATION_STORAGE_KEY);
} catch {
return null;
}
}
function saveSelectedStation(name) {
try {
localStorage.setItem(STATION_STORAGE_KEY, name);
} catch {
// storage unavailable (private mode etc.) — selection just won't persist
}
}
document.addEventListener("DOMContentLoaded", () => {
new RotatorApp().initialize();
});
</script>
</body>
</html>