// (gH) -_- tutajax.js ; TimeStamp (unix) : 27 Décembre 2009 vers 19:51
// ########################################################################
function ajaxv1(eltradio) {
// ########################################################################
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
// on transmet tout le fichier
document.getElementById("ajax1").firstChild.data = xhr.responseText ;
} else {
document.getElementById("ajax1").firstChild.data = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
var url = "tutajax4.php" ;
if (eltradio[0].checked) {
url = "tutajax_send1a.txt" ;
} else {
url = "tutajax_send1b.txt" ;
} ; // fin si
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv1
// ########################################################################
function ajaxv2(eltselect) {
// ########################################################################
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
// on commence par retirer les sauts de ligne
var texte = xhr.responseText ;
var er1 = new RegExp("\n","g") ;
texte = texte.replace(er1,"") ;
// puis on découpe en fonction des points-virgules
var er2 = new RegExp(";","g") ;
var er3 = new RegExp("=") ;
var tab = texte.split(er2) ;
for (ide=0;ide<tab.length;ide++) {
// enfin, on découpe par rapport au symbole égal
var mots = tab[ide].split(er3) ;
// si on trouve la date, on renvoie l'évènement
if (mots[0]==ladate) {
document.getElementById("ajax2").value = mots[1] ;
} ; // fin si
} ; // fin pour ide
} else {
document.getElementById("ajax2").value = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
var ladate = eltselect.options[eltselect.selectedIndex].value ;
var url = "tutajax_send2.txt" ;
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv2
// ########################################################################
function ajaxv3(eltradio) {
// ########################################################################
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById("ajax3").innerHTML = xhr.responseText ;
} else {
document.getElementById("ajax3").innerHTML = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
var url = "tutajax4.php" ;
if (eltradio[0].checked) {
url = "tutajax_send3a.html" ;
} else {
url = "tutajax_send3b.html" ;
} ; // fin si
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv3
// ########################################################################
function ajaxv4(eltselect) {
// ########################################################################
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById("ajax4").value = ""
dct = xhr.responseXML ;
tab = dct.getElementsByTagName("article") ;
for (ide=0;ide<tab.length;ide++) {
var article = tab[ide] ; // article courant
var vu = 0 // indique si on a vu l'article recherché
var nbet = 0 // nombre d'enfants textes
// on passe en revue les enfants
indc = 0 ; // indice courant d'enfant
while (indc<article.childNodes.length) {
currentElementChild=article.childNodes[indc];
if (vu<2) {
// s'il s'agit d'un noeud texte
if (currentElementChild.nodeType==1) {
nbet = nbet + 1
// et s'il correspond au texte cherché
if (currentElementChild.textContent==larticle) {
vu = 1 ;
} ; // fin si
// alors on récupère le texte suivant
if (vu==1) {
if (nbet==2) {
prix = currentElementChild.textContent
document.getElementById("ajax4").value += prix + " euros" ;
vu = 2 ;
indc = article.childNodes.length + 1
} ; // fin si
} ; // fin si
} ; // fin si
} ; // fin si
indc++
currentElementChild=article.childNodes[indc];
} // fin de tant que
} ; // fin pour ide
} else {
document.getElementById("ajax4").value = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
// ceci est le mot cherché :
var larticle = eltselect.options[eltselect.selectedIndex].value ;
var url = "tutajax_send4a.xml" ;
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv4
// ########################################################################
function ajaxv5(eltselect) {
// ########################################################################
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById("ajax5").value = ""
dct = xhr.responseXML ;
tab = dct.getElementsByTagName("article") ;
for (ide=0;ide<tab.length;ide++) {
var article = tab[ide] ;
if (article.getAttribute("nom")==larticle) {
leprix = article.getAttribute("prix") ;
document.getElementById("ajax5").value += leprix + " euros" ;
} ; // fin si
} ; // fin pour ide
} else {
document.getElementById("ajax5").value = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
// ceci est le mot cherché :
var larticle = eltselect.options[eltselect.selectedIndex].value ;
var url = "tutajax_send4b.xml" ;
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv5
// ########################################################################
function ajaxv6(eltradio) {
// ########################################################################
var xhr ;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e) {
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2) {
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
} // fin du catch
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
// on transmet tout le fichier
var tabdates = eval('(' + xhr.responseText + ')') ;
msg = " Jour du rendez-vous, le " ;
msg += tabdates[numj] ;
msg += " novembre "
document.getElementById("ajax6").firstChild.data = msg
} else {
document.getElementById("ajax6").firstChild.data = "Error code " + xhr.status ;
} ; // fin de xhr.status == 200
} ; // fin de xhr.readyState == 4
} ; // fin de fonction xhr.onreadystatechange
var url = "tutajax_send5.txt" ;
var numj = -1 ;
for (idj=0;idj<=2;idj++) {
if (eltradio[idj].checked) { numj = idj ; } ;
} ; // fin pour
xhr.open("GET", url, true);
xhr.send(null);
} ; // fin fonction ajaxv6
// ########################################################################
|