- Added views - Added view manager - Added router - Added home/config view - Refactored project structure
17 lines
392 B
JavaScript
17 lines
392 B
JavaScript
function navigate(view) {
|
|
history.pushState({view: view}, null, `#${view}`);
|
|
loadView(view);
|
|
}
|
|
|
|
$(window).on('popstate', function(event) {
|
|
const state = event.originalEvent.state;
|
|
if (state && state.view) {
|
|
loadView(state.view);
|
|
}
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
const initialView = location.hash.replace('#', '') || 'home';
|
|
loadView(initialView);
|
|
});
|