diff --git a/ajax.php b/ajax.php new file mode 100644 index 0000000..ff38f36 --- /dev/null +++ b/ajax.php @@ -0,0 +1,3 @@ + $_POST['section'], 'pre' => 'Woooohou !')); diff --git a/css/styles.css b/css/styles.css index 5d46a36..292fd5c 100644 --- a/css/styles.css +++ b/css/styles.css @@ -27,3 +27,9 @@ pre { padding-top: 8px; margin-top: 10px; } + +.loading { + background-image: url(../img/ajax-loader.gif); + background-repeat: no-repeat; + padding-left: 20px; +} diff --git a/img/ajax-loader.gif b/img/ajax-loader.gif new file mode 100644 index 0000000..5b33f7e Binary files /dev/null and b/img/ajax-loader.gif differ diff --git a/index.php b/index.php index a60cf34..5448979 100644 --- a/index.php +++ b/index.php @@ -12,8 +12,6 @@ global $servers; - Git Control Center diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..63dc4c0 --- /dev/null +++ b/js/app.js @@ -0,0 +1,21 @@ +window.addEventListener('load', function() { + var sections = document.querySelectorAll('section'); + for (var i = 0; i < sections.length; i++) { + callRequest(sections[i].id); + } +}); + +function callRequest(section) { + var pre = document.querySelector('#' + section + ' pre'); + pre.innerHTML = 'Loading ...'; + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'ajax.php'); + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + xhr.send('section=' + section); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) { + var data = JSON.parse(xhr.responseText); + pre.innerHTML = data['pre']; + } + }; +}