babillard/public/js/slider.js

46 lines
806 B
JavaScript
Raw Permalink Normal View History

var images = [];
var indexImages = 0;
function afficherIndex() {
$('#debug').text(indexImages);
}
function afficherImage() {
$('#image').attr('src', "/api/contenu/"+images[indexImages]);
}
function augmenterIndex() {
if (indexImages >= images.length - 1) {
indexImages = 0;
} else {
indexImages ++;
}
}
function executionLoop(){
//afficherIndex();
afficherImage();
augmenterIndex();
}
function obtenirContenu(){
var response = '';
$.ajax({
type: "GET",
url: window.location.origin + "/api/contenu",
async: false,
success: function(text) {
response = text;
}
});
console.log(response);
images = response.split(';');
console.log(images);
}
$(function(){
obtenirContenu();
var executionInterval = setInterval(executionLoop, 10000);
});