aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--router.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/router.js b/router.js
index 8af98ab..c6c2c03 100644
--- a/router.js
+++ b/router.js
@@ -4,15 +4,15 @@
this.addEventListener('load', router);
function router() {
- var url = location.hash.slice(2) || 'presentation';
- var contentElement = document.getElementById('content');
- var htmlElement = document.querySelector('html');
+ const url = location.hash.slice(2) || 'presentation';
+ const contentElement = document.getElementById('content');
+ const htmlElement = document.querySelector('html');
addClass(htmlElement, 'waitCursor');
fetchFile('Pages/' + url + '.md', function(contentMd) {
removeClass(htmlElement, 'waitCursor');
contentElement.innerHTML = markdown.toHTML(contentMd);
}, function() {
- var notFoundPage = '<h1>Page non trouvée</h1><a href="#">Retour à l\'accueil</a>';
+ const notFoundPage = '<h1>Page non trouvée</h1><a href="#">Retour à l\'accueil</a>';
contentElement.innerHTML = notFoundPage;
});
}
@@ -26,18 +26,16 @@
}
function fetchFile(url, successHandler, errorHandler) {
- var xhr = typeof XMLHttpRequest != 'undefined'
+ const xhr = typeof XMLHttpRequest != 'undefined'
? new XMLHttpRequest()
: new ActiveXObject('Microsoft.XMLHTTP');
xhr.open('get', url, true);
xhr.responseType = 'text';
xhr.onreadystatechange = function() {
- var status;
- var data;
if (xhr.readyState == 4) {
- status = xhr.status;
+ const status = xhr.status;
if (status === 200 || status === 0) {
- data = xhr.responseText;
+ const data = xhr.responseText;
successHandler && successHandler(data);
} else {
errorHandler && errorHandler(status);