Premier affichages OK

This commit is contained in:
Michel Roux 2013-10-02 12:21:30 +02:00
parent 0a6ac31204
commit d001b21ef7
5 changed files with 30 additions and 2 deletions

3
ajax.php Normal file
View File

@ -0,0 +1,3 @@
<?php
echo json_encode(array('section' => $_POST['section'], 'pre' => 'Woooohou !'));

View File

@ -27,3 +27,9 @@ pre {
padding-top: 8px; padding-top: 8px;
margin-top: 10px; margin-top: 10px;
} }
.loading {
background-image: url(../img/ajax-loader.gif);
background-repeat: no-repeat;
padding-left: 20px;
}

BIN
img/ajax-loader.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -12,8 +12,6 @@ global $servers;
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script> <script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript">
</script>
<title>Git Control Center</title> <title>Git Control Center</title>
</head> </head>
<body data-spy="scroll"> <body data-spy="scroll">

21
js/app.js Normal file
View File

@ -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 = '<span class="loading">Loading ...</span>';
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'];
}
};
}