api / public /js /app.js
Tataaicoltd's picture
deploy: taboard API (overwrite)
30a3fac verified
Raw History Blame Contribute Delete
702 Bytes
// Simple hash router + sidebar highlighting.
const App = {
routes: {
projects: ProjectsView,
tickets: TicketsView
},
start() {
window.addEventListener('hashchange', () => this.route());
this.route();
},
currentView() {
const hash = location.hash.replace(/^#\//, '') || 'projects';
return this.routes[hash] ? hash : 'projects';
},
route() {
const view = this.currentView();
document.querySelectorAll('.side-item').forEach((a) =>
a.classList.toggle('active', a.dataset.view === view)
);
const app = document.getElementById('app');
this.routes[view].render(app);
}
};
document.addEventListener('DOMContentLoaded', () => App.start());