aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-02-18 20:40:24 +0100
committerJoris Guyonvarch2015-02-18 20:40:24 +0100
commit3acc5f10fbd8bff4914ba261861b1e39674c01f4 (patch)
tree6b2bdefd23cba4b3f320b98c1ff119bc2df72907
parentd712cc2422027a73e8904eb6cecb9078749bb8d3 (diff)
Show a notFound page if the requested page does not exists
-rw-r--r--router.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/router.js b/router.js
index c498c0c..84c8ab1 100644
--- a/router.js
+++ b/router.js
@@ -19,14 +19,21 @@
}
}
};
- xhr.send();
+ try {
+ xhr.send();
+ } catch(err) {
+ errorHandler && errorHandler(err);
+ }
};
function router() {
var url = location.hash.slice(2) || 'presentation';
+ var contentElement = document.getElementById('content');
fetchFile('Pages/' + url + '.md', function(contentMd) {
- var contentElement = document.getElementById('content');
contentElement.innerHTML = markdown.toHTML(contentMd);
+ }, function() {
+ var notFoundPage = '<h1>Page non trouvée</h1><a href="#">Retour à l\'accueil</a>';
+ contentElement.innerHTML = notFoundPage;
});
}