bug fix
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 59s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 59s
This commit is contained in:
@@ -224,7 +224,13 @@ function navigateTo(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleRoute() {
|
function handleRoute() {
|
||||||
const path = window.location.pathname;
|
let path = window.location.pathname;
|
||||||
|
|
||||||
|
// Normalize path - treat /index.html, empty, or just "/" as home
|
||||||
|
if (path === "" || path === "/index.html" || path.endsWith("/index.html")) {
|
||||||
|
path = "/";
|
||||||
|
}
|
||||||
|
|
||||||
const view = routes[path] || "home";
|
const view = routes[path] || "home";
|
||||||
|
|
||||||
// Update page title for SEO
|
// Update page title for SEO
|
||||||
@@ -252,27 +258,32 @@ function handleRoute() {
|
|||||||
document.addEventListener("DOMContentLoaded", init);
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
// Load filters and metrics in parallel (single request for filters)
|
try {
|
||||||
const [filtersData, metricsData] = await Promise.all([
|
// Load filters and metrics in parallel (single request for filters)
|
||||||
fetchAPI("/api/filters", { showLoading: "filters" }),
|
const [filtersData, metricsData] = await Promise.all([
|
||||||
fetchAPI("/api/metrics"),
|
fetchAPI("/api/filters", { showLoading: "filters" }),
|
||||||
]);
|
fetchAPI("/api/metrics"),
|
||||||
|
]);
|
||||||
|
|
||||||
// Cache and apply filters
|
// Cache and apply filters
|
||||||
if (filtersData) {
|
if (filtersData) {
|
||||||
state.filters = filtersData;
|
state.filters = filtersData;
|
||||||
populateFilters(filtersData);
|
populateFilters(filtersData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache metrics
|
||||||
|
if (metricsData) {
|
||||||
|
state.metrics = metricsData.metrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load initial data
|
||||||
|
await loadSchools();
|
||||||
|
await loadRankings();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error during initialization:", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache metrics
|
// Always set up event listeners and routing, even if data loading fails
|
||||||
if (metricsData) {
|
|
||||||
state.metrics = metricsData.metrics;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load initial data
|
|
||||||
await loadSchools();
|
|
||||||
await loadRankings();
|
|
||||||
|
|
||||||
setupEventListeners();
|
setupEventListeners();
|
||||||
|
|
||||||
// Handle initial route
|
// Handle initial route
|
||||||
|
|||||||
Reference in New Issue
Block a user