refactor(static): add base component types

This commit is contained in:
2026-09-10 10:28:12 +03:00
parent 6683b7b5b0
commit bed8d7af7b
13 changed files with 368 additions and 236 deletions
+4 -22
View File
@@ -1,29 +1,11 @@
import { DataStorage } from "../base/storage";
import { WeatherLocationElement } from "./component";
import { DataManager } from "../base/manager";
import { WeatherLocationList } 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;
weatherLocationManager: DataManager<Location>;
}
}
window.weatherLocationStorage = new DataStorage("weather:locations");
window.weatherLocationManager = new WeatherLocationManager();
window.weatherLocationManager = new DataManager(WeatherLocationList, "weather:locations", "#storedLocations");