feat: update lake water data, implement service worker and manifest, and add favicon

This commit is contained in:
David Fencl
2026-06-08 20:06:23 +02:00
parent f8a7be7fa3
commit 7a7abdd3e5
61 changed files with 1455 additions and 184 deletions
+30 -10
View File
@@ -13,6 +13,7 @@ interface DataRecord {
volume?: number;
temperature?: number | null;
precipitation?: number | null;
qn?: string;
}
// Parse date from DD.MM.YYYY HH:MM to ISO
@@ -91,24 +92,42 @@ async function scrapeLake(lakeId: string, oid: string, internalId: string) {
});
if (dataTable) {
dataTable.find('tr').each((i, row) => {
let qnColIndex = -1;
let flowColIndex = 2;
let levelColIndex = 1;
// Find column indices from header dynamically
$(dataTable).find('tr').first().find('th, td').each((idx, cell) => {
const headerText = $(cell).text().trim().toLowerCase();
if (headerText.includes('qn')) {
qnColIndex = idx;
} else if (headerText.includes('hladina') || headerText.includes('stav')) {
levelColIndex = idx;
} else if (headerText.includes('odtok') || headerText.includes('průtok') || headerText.includes('prutok') || headerText.includes('flow')) {
flowColIndex = idx;
}
});
$(dataTable).find('tr').each((i, row) => {
if (i === 0) return; // skip header
const cols = $(row).find('td');
if (cols.length >= 3) {
if (cols.length > Math.max(levelColIndex, flowColIndex)) {
const rawDate = $(cols[0]).text().trim();
const levelStr = $(cols[1]).text().trim().replace(',', '.');
let flowStr = $(cols[2]).text().trim().replace(',', '.');
if (flowStr === '' && cols.length >= 4) {
flowStr = $(cols[3]).text().trim().replace(',', '.');
}
const levelStr = $(cols[levelColIndex]).text().trim().replace(',', '.');
const flowStr = $(cols[flowColIndex]).text().trim().replace(',', '.');
const qn = qnColIndex !== -1 && cols.length > qnColIndex ? $(cols[qnColIndex]).text().trim() : '';
const parsedDateStr = parseDateString(rawDate);
if (parsedDateStr) {
records.push({
const newRecord: DataRecord = {
timestamp: parsedDateStr,
level: parseFloat(levelStr) || 0,
flow: parseFloat(flowStr) || 0
});
};
if (qn) {
newRecord.qn = qn;
}
records.push(newRecord);
}
}
});
@@ -153,7 +172,8 @@ async function scrapeLake(lakeId: string, oid: string, internalId: string) {
...existing,
...item,
inflow: item.inflow !== undefined ? item.inflow : existing.inflow,
volume: item.volume !== undefined ? item.volume : existing.volume
volume: item.volume !== undefined ? item.volume : existing.volume,
qn: item.qn !== undefined ? item.qn : existing.qn
});
} else {
dataMap.set(item.timestamp, item);