1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
entête HTML : <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Javascript :
function installation(cible,etape,nb){
// cible : fichier cible // etape : numéro de l'étape // nb : nombre total des étapes
if(etape<=nb){
rep = reqAjaxAsync(cible,montreRep); // fonction AJAX asynchrone
}
}
var txt = "";
function montreRep(){ // traitement de la réponse Asynchrone
if (flux.readyState==4){
if(flux.status==200){
//alert("statut : "+flux.status);
var val = eval("("+flux.responseText+")");
var etape = val.etape;
var nb = val.nombre;
var pour100 = Math.round(100*(etape/nb));
var cadre = document.getElementById("cadre_installation");
if(val.etat == 1) img = "<IMG SRC=\"_ok.png\" BORDER=\"0\" >";
else img = "<IMG SRC=\"_error.png\" BORDER=\"0\">";
txt += "<BR>"+img+"Etape "+val.etape+"<BR>Message d'erreur : "+val.erreur;
txt += "<BR>Information : "+val.info;
cadre.innerHTML = txt;
affiche_p100(pour100);
etapen1 = 1+val.etape;
installation(val.next,etapen1,nb);
}
}
}
function affiche_p100(p100){ // affiche la barre de progression en % et le texte revoyé par le JSON
var cadre = document.getElementById("cadre_p100");
var txt = "<DIV STYLE=\"height: 15px; width: "+p100+"px; background: gold\" align=\"CENTER\">"+p100+"%</DIV>";
cadre.innerHTML = txt;
} |
Partager