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
+29
View File
@@ -0,0 +1,29 @@
import { DataStorage } from "../base/storage";
import { WeatherLocationElement } from "./component";
import { Location } from "./model";
export class WeatherLocationManager {
loadLocations(selector: string) {
const locations = window.weatherLocationStorage.getAll();
const container = document.querySelector(selector);
if (container) {
container.innerHTML = "";
for (const location of locations) {
const element = new WeatherLocationElement();
element.setAttribute("location", JSON.stringify(location));
element.setAttribute("removable", "");
container.appendChild(element);
}
}
}
}
declare global {
interface Window {
weatherLocationStorage: DataStorage<Location>;
weatherLocationManager: WeatherLocationManager;
}
}
window.weatherLocationStorage = new DataStorage("weather:locations");
window.weatherLocationManager = new WeatherLocationManager();