PairDrop/app/elements/routing.html

39 lines
910 B
HTML
Raw Normal View History

2015-12-18 16:50:36 +01:00
<script src="../bower_components/page/page.js"></script>
<script>
window.addEventListener('WebComponentsReady', function() {
// We use Page.js for routing. This is a Micro
// client-side router inspired by the Express router
// More info: https://visionmedia.github.io/page.js/
// Removes end / from app.baseUrl which page.base requires for production
if (window.location.port === '') { // if production
page.base(app.baseUrl.replace(/\/$/, ''));
}
page('/', function() {
app.route = 'home';
});
page(app.baseUrl, function() {
app.route = 'home';
});
// 404
page('*', function() {
app.$.toast.text = 'Can\'t find: ' + window.location.href + '. Redirected you to Home Page';
app.$.toast.show();
page.redirect(app.baseUrl);
});
// add #! before urls
page({
hashbang: true
});
});
</script>