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() {
|
||||
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";
|
||||
|
||||
// Update page title for SEO
|
||||
@@ -252,27 +258,32 @@ function handleRoute() {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init() {
|
||||
// Load filters and metrics in parallel (single request for filters)
|
||||
const [filtersData, metricsData] = await Promise.all([
|
||||
fetchAPI("/api/filters", { showLoading: "filters" }),
|
||||
fetchAPI("/api/metrics"),
|
||||
]);
|
||||
try {
|
||||
// Load filters and metrics in parallel (single request for filters)
|
||||
const [filtersData, metricsData] = await Promise.all([
|
||||
fetchAPI("/api/filters", { showLoading: "filters" }),
|
||||
fetchAPI("/api/metrics"),
|
||||
]);
|
||||
|
||||
// Cache and apply filters
|
||||
if (filtersData) {
|
||||
state.filters = filtersData;
|
||||
populateFilters(filtersData);
|
||||
// Cache and apply filters
|
||||
if (filtersData) {
|
||||
state.filters = 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
|
||||
if (metricsData) {
|
||||
state.metrics = metricsData.metrics;
|
||||
}
|
||||
|
||||
// Load initial data
|
||||
await loadSchools();
|
||||
await loadRankings();
|
||||
|
||||
// Always set up event listeners and routing, even if data loading fails
|
||||
setupEventListeners();
|
||||
|
||||
// Handle initial route
|
||||
|
||||
Reference in New Issue
Block a user