aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-03-07 20:28:24 +0100
committerJoris Guyonvarch2015-03-07 20:28:24 +0100
commit8066367ecdf9ddd4f00cbf6c0bfdf9eebd844f0c (patch)
treeaa6fe384a24e8d22cdbc1de0bfcaed239ed97366
parent8e086a0cf8e8c3aa31f0b700399bccc4f735cd89 (diff)
downloadmakeup-8066367ecdf9ddd4f00cbf6c0bfdf9eebd844f0c.tar.gz
makeup-8066367ecdf9ddd4f00cbf6c0bfdf9eebd844f0c.tar.bz2
makeup-8066367ecdf9ddd4f00cbf6c0bfdf9eebd844f0c.zip
Replacing var by const in javascript
-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);