refactor: replace feature globals with typed services
This commit is contained in:
@@ -93,7 +93,6 @@ async function vchanTakeSchedulerControl() {
|
||||
console.error("scheduler control takeover failed", e);
|
||||
}
|
||||
}
|
||||
vchanWindow.vchanTakeSchedulerControl = vchanTakeSchedulerControl;
|
||||
function vchanHandleSession(data) {
|
||||
try {
|
||||
const d = JSON.parse(data);
|
||||
@@ -123,8 +122,6 @@ function vchanHandleChannels(data) {
|
||||
console.warn("vchan: bad channels event", e);
|
||||
}
|
||||
}
|
||||
vchanWindow.vchanHandleSession = vchanHandleSession;
|
||||
vchanWindow.vchanHandleChannels = vchanHandleChannels;
|
||||
function vchanRender() {
|
||||
const picker = document.getElementById("vchan-picker");
|
||||
if (!picker) return;
|
||||
@@ -267,12 +264,10 @@ function vchanApplyCapabilities(caps) {
|
||||
picker.style.display = caps && caps.filter_controls ? "" : "none";
|
||||
vchanRenderSchedulerRelease();
|
||||
}
|
||||
vchanWindow.vchanApplyCapabilities = vchanApplyCapabilities;
|
||||
function vchanIsOnVirtual() {
|
||||
if (!vchanActiveId || vchanChannels.length === 0) return false;
|
||||
return vchanActiveId !== vchanChannels[0]?.id;
|
||||
}
|
||||
vchanWindow.vchanIsOnVirtual = vchanIsOnVirtual;
|
||||
function vchanActiveChannel() {
|
||||
return vchanChannels.find((c) => c.id === vchanActiveId) || null;
|
||||
}
|
||||
@@ -406,15 +401,34 @@ async function vchanSetChannelMode(mode) {
|
||||
console.error("vchan: set mode error", e);
|
||||
}
|
||||
}
|
||||
vchanWindow.vchanInterceptMode = async function(mode) {
|
||||
async function vchanInterceptMode(mode) {
|
||||
if (!vchanIsOnVirtual()) return false;
|
||||
await vchanSetChannelMode(mode);
|
||||
return true;
|
||||
};
|
||||
vchanWindow.vchanInterceptBandwidth = async function(bwHz) {
|
||||
}
|
||||
async function vchanInterceptBandwidth(bwHz) {
|
||||
if (!vchanIsOnVirtual()) return false;
|
||||
await vchanSetChannelBandwidth(bwHz);
|
||||
return true;
|
||||
}
|
||||
vchanWindow.trx ??= {};
|
||||
vchanWindow.trx.modules ??= {};
|
||||
vchanWindow.trx.modules.vchan = {
|
||||
get channels() {
|
||||
return vchanChannels;
|
||||
},
|
||||
get activeId() {
|
||||
return vchanActiveId;
|
||||
},
|
||||
activeChannel: vchanActiveChannel,
|
||||
applyCapabilities: vchanApplyCapabilities,
|
||||
handleSession: vchanHandleSession,
|
||||
handleChannels: vchanHandleChannels,
|
||||
isOnVirtual: vchanIsOnVirtual,
|
||||
interceptMode: vchanInterceptMode,
|
||||
interceptBandwidth: vchanInterceptBandwidth,
|
||||
takeSchedulerControl: vchanTakeSchedulerControl,
|
||||
releaseToScheduler: vchanToggleSchedulerRelease
|
||||
};
|
||||
(function() {
|
||||
const original = vchanWindow.setRigFrequency;
|
||||
|
||||
Reference in New Issue
Block a user