From 056f5c75f1abf4ef196418834145e5f140d32796 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 15 Feb 2015 17:51:17 +0100 Subject: Modifying javascript file name --- index.html | 2 +- router.js | 39 +++++++++++++++++++++++++++++++++++++++ script.js | 39 --------------------------------------- 3 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 router.js delete mode 100644 script.js diff --git a/index.html b/index.html index 718c942..597850e 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Maquillage - + diff --git a/router.js b/router.js new file mode 100644 index 0000000..a14a308 --- /dev/null +++ b/router.js @@ -0,0 +1,39 @@ +(function () { + + function fetchFile(url, successHandler, errorHandler) { + var 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; + if (status === 200 || status === 0) { + data = xhr.responseText; + successHandler && successHandler(data); + } else { + errorHandler && errorHandler(status); + } + } + }; + xhr.send(); + }; + + function router() { + var url = location.hash.slice(2) || 'presentation'; + var contentElement = document.getElementById('content'); + fetchFile('Pages/' + url + '.md', function(contentMd) { + fetchFile('Pages/contact.html', function(contactHtml) { + var contentHtml = markdown.toHTML(contentMd); + contentElement.innerHTML = contentHtml + contactHtml; + }); + }); + } + + this.addEventListener('hashchange', router); + this.addEventListener('load', router); + +})(); diff --git a/script.js b/script.js deleted file mode 100644 index a14a308..0000000 --- a/script.js +++ /dev/null @@ -1,39 +0,0 @@ -(function () { - - function fetchFile(url, successHandler, errorHandler) { - var 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; - if (status === 200 || status === 0) { - data = xhr.responseText; - successHandler && successHandler(data); - } else { - errorHandler && errorHandler(status); - } - } - }; - xhr.send(); - }; - - function router() { - var url = location.hash.slice(2) || 'presentation'; - var contentElement = document.getElementById('content'); - fetchFile('Pages/' + url + '.md', function(contentMd) { - fetchFile('Pages/contact.html', function(contactHtml) { - var contentHtml = markdown.toHTML(contentMd); - contentElement.innerHTML = contentHtml + contactHtml; - }); - }); - } - - this.addEventListener('hashchange', router); - this.addEventListener('load', router); - -})(); -- cgit v1.2.3