PairDrop/app/elements/routing.html
2015-12-19 01:18:02 +01:00

38 lines
910 B
HTML

<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>