Files
aitbc/apps/explorer-web/src/main.ts
oib 9b9c5beb23 ```
chore: enhance .gitignore and remove obsolete documentation files

- Reorganize .gitignore with categorized sections for better maintainability
- Add comprehensive ignore patterns for Python, Node.js, databases, logs, and build artifacts
- Add project-specific ignore rules for coordinator, explorer, and deployment files
- Remove outdated documentation: BITCOIN-WALLET-SETUP.md, LOCAL_ASSETS_SUMMARY.md, README-CONTAINER-DEPLOYMENT.md, README-DOMAIN-DEPLOYMENT.md
```
2026-01-24 14:44:51 +01:00

83 lines
2.3 KiB
TypeScript

import "../public/css/theme.css";
import "../public/css/base.css";
import "../public/css/layout.css";
import { siteHeader } from "./components/siteHeader";
import { siteFooter } from "./components/siteFooter";
import { overviewTitle, renderOverviewPage, initOverviewPage } from "./pages/overview";
import { blocksTitle, renderBlocksPage, initBlocksPage } from "./pages/blocks";
import { transactionsTitle, renderTransactionsPage, initTransactionsPage } from "./pages/transactions";
import { addressesTitle, renderAddressesPage, initAddressesPage } from "./pages/addresses";
import { receiptsTitle, renderReceiptsPage, initReceiptsPage } from "./pages/receipts";
import { initNotifications } from "./components/notifications";
type PageConfig = {
title: string;
render: () => string;
init?: () => void | Promise<void>;
};
const overviewConfig: PageConfig = {
title: overviewTitle,
render: renderOverviewPage,
init: initOverviewPage,
};
const routes: Record<string, PageConfig> = {
"/": overviewConfig,
"/index.html": overviewConfig,
"/blocks": {
title: blocksTitle,
render: renderBlocksPage,
init: initBlocksPage,
},
"/transactions": {
title: transactionsTitle,
render: renderTransactionsPage,
init: initTransactionsPage,
},
"/addresses": {
title: addressesTitle,
render: renderAddressesPage,
init: initAddressesPage,
},
"/receipts": {
title: receiptsTitle,
render: renderReceiptsPage,
init: initReceiptsPage,
},
};
function render(): void {
initNotifications();
const root = document.querySelector<HTMLDivElement>("#app");
if (!root) {
console.warn("[Explorer] Missing #app root element");
return;
}
const currentPath = window.location.pathname.replace(/\/$/, "");
// Remove /explorer prefix for routing
const normalizedPath = currentPath.replace(/^\/explorer/, "") || "/";
const page = routes[normalizedPath] ?? null;
root.innerHTML = `
${siteHeader(page?.title ?? "Explorer")}
<main class="page">${(page ?? notFoundPageConfig).render()}</main>
${siteFooter()}
`;
void page?.init?.();
}
const notFoundPageConfig: PageConfig = {
title: "Not Found",
render: () => `
<section class="not-found">
<h2>Page Not Found</h2>
<p>The requested view is not available yet.</p>
</section>
`,
};
document.addEventListener("DOMContentLoaded", render);