Router that selectively executes fucntions based on window.location.pathname
window.location.pathname
const router = new Router(); const settingsRoute = "/settings"; const profileRoute = "/r/[A-Z,a-z,0-9]+/"; const settings = () => { let form = document.getElementById("form"); const submit = () => { alert("Settings updated") } form.addEbentListener('submit', submit, true); } const profile = () => { let form = document.getElementById("form"); const submit = () => { alert("profile updated") } form.addEbentListener('submit', submit, true); } router.register(settingsRoute, settings); router.register(profileRoute, profile); try { router.router() } catch(e) { console.log(e); }
registers a route-function pair with Router
route to be registered
executes registered function with route matches window.pathname.location
Generated using TypeDoc
Router that selectively executes fucntions based on
window.location.pathname