bae705aa97
- Add NFC ePassport roadmap (ICAO 9303, eIDAS) - Add TensorFlow.js edge face detection (BlazeFace) - Add structured audit logger (GDPR-compliant) - Risk scoring support Part of KYC Apple Native UX v1.1.0
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
// ═══════════════════════════════════════════════════════════════════════════
|
|
// LandveX Finance — Simple Router
|
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
export class Router {
|
|
constructor(opts = {}) {
|
|
this.routes = opts.routes || {};
|
|
this.default = opts.default || 'dashboard';
|
|
this.current = null;
|
|
}
|
|
|
|
start() {
|
|
// Handle browser back/forward
|
|
window.addEventListener('popstate', () => this.handle());
|
|
|
|
// Initial route
|
|
this.handle();
|
|
}
|
|
|
|
handle() {
|
|
const hash = window.location.hash.replace('#/', '') || this.default;
|
|
this.navigate(hash, false);
|
|
}
|
|
|
|
navigate(route, pushState = true) {
|
|
if (this.current === route) return;
|
|
this.current = route;
|
|
|
|
if (pushState) {
|
|
window.history.pushState(null, '', `#/${route}`);
|
|
}
|
|
|
|
const handler = this.routes[route] || this.routes[this.default];
|
|
if (handler) handler();
|
|
}
|
|
}
|