refactor(static): split schedule and weather to modules

This commit is contained in:
2026-09-07 18:09:49 +03:00
parent d44c8076b4
commit 5db61da32b
7 changed files with 124 additions and 117 deletions
+32
View File
@@ -0,0 +1,32 @@
import { DataStorage } from "../base/storage";
import { ScheduleChannelElement, ScheduleChannelGroupElement } from "./component";
import { Channel } from "./model";
export class ScheduleChannelManager {
loadChannels(selector: string) {
const channels = window.scheduleChannelStorage.getAll();
const container = document.querySelector(selector);
if (container) {
container.innerHTML = "";
for (const channel of channels) {
const element = new ScheduleChannelElement();
element.setAttribute("channel", JSON.stringify(channel));
element.setAttribute("removable", "");
container.appendChild(element);
}
const groupElement = new ScheduleChannelGroupElement();
groupElement.setAttribute("channels", JSON.stringify(channels));
container.append(groupElement);
}
}
}
declare global {
interface Window {
scheduleChannelStorage: DataStorage<Channel>;
scheduleChannelManager: ScheduleChannelManager;
}
}
window.scheduleChannelStorage = new DataStorage("schedule:channels");
window.scheduleChannelManager = new ScheduleChannelManager();