Moved the webapp to a webpack with some typescript, updated server wtih new endpoints
This commit is contained in:
27
webapp/src/main.ts
Normal file
27
webapp/src/main.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import ClimateChart from "./ClimateChart";
|
||||
|
||||
const ROOT_URL: string = "climate/";
|
||||
const CHART_DOM_ID: string = "myChart";
|
||||
|
||||
function createClimateChart() {
|
||||
const pathname = window.location.pathname;
|
||||
let minutesDisplayed = 60;
|
||||
const argsStart = pathname.search(/\?minute-span=/);
|
||||
if (argsStart !== -1) {
|
||||
const parsedMins = Number(pathname[12]);
|
||||
if (!isNaN(parsedMins) && parsedMins > 0) {
|
||||
minutesDisplayed = parsedMins;
|
||||
}
|
||||
}
|
||||
return new ClimateChart(ROOT_URL, CHART_DOM_ID, minutesDisplayed);
|
||||
}
|
||||
|
||||
const overlay = document.createElement('div');
|
||||
overlay.innerText = 'Loading data...';
|
||||
overlay.className = 'overlay';
|
||||
document.getRootNode().appendChild(overlay);
|
||||
|
||||
const climateChart = createClimateChart();
|
||||
climateChart.onLoaded(() => {
|
||||
overlay.classList.add('hidden');
|
||||
})
|
||||
Reference in New Issue
Block a user