Listing du fichier tutajax.js
00001// (gH) -_- tutajax.js ; TimeStamp (unix) : 27 Décembre 2009 vers 19:51
00002
00003 // ########################################################################
00004
00005 function ajaxv1(eltradio) {
00006
00007 // ########################################################################
00008
00009 var xhr;
00010 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00011 catch (e) {
00012 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00013 catch (e2) {
00014 try { xhr = new XMLHttpRequest(); }
00015 catch (e3) { xhr = false; }
00016 }
00017 } // fin du catch
00018
00019 xhr.onreadystatechange = function() {
00020 if (xhr.readyState == 4) {
00021 if (xhr.status == 200) {
00022 // on transmet tout le fichier
00023 document.getElementById("ajax1").firstChild.data = xhr.responseText ;
00024 } else {
00025 document.getElementById("ajax1").firstChild.data = "Error code " + xhr.status ;
00026 } ; // fin de xhr.status == 200
00027 } ; // fin de xhr.readyState == 4
00028 } ; // fin de fonction xhr.onreadystatechange
00029
00030 var url = "tutajax4.php" ;
00031 if (eltradio[0].checked) {
00032 url = "tutajax_send1a.txt" ;
00033 } else {
00034 url = "tutajax_send1b.txt" ;
00035 } ; // fin si
00036 xhr.open("GET", url, true);
00037 xhr.send(null);
00038
00039 } ; // fin fonction ajaxv1
00040
00041 // ########################################################################
00042
00043 function ajaxv2(eltselect) {
00044
00045 // ########################################################################
00046
00047 var xhr;
00048 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00049 catch (e) {
00050 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00051 catch (e2) {
00052 try { xhr = new XMLHttpRequest(); }
00053 catch (e3) { xhr = false; }
00054 }
00055 } // fin du catch
00056
00057 xhr.onreadystatechange = function() {
00058 if (xhr.readyState == 4) {
00059 if (xhr.status == 200) {
00060 // on commence par retirer les sauts de ligne
00061 var texte = xhr.responseText ;
00062 var er1 = new RegExp("\n","g") ;
00063 texte = texte.replace(er1,"") ;
00064 // puis on découpe en fonction des points-virgules
00065 var er2 = new RegExp(";","g") ;
00066 var er3 = new RegExp("=") ;
00067 var tab = texte.split(er2) ;
00068 for (ide=0;ide<tab.length;ide++) {
00069 // enfin, on découpe par rapport au symbole égal
00070 var mots = tab[ide].split(er3) ;
00071 // si on trouve la date, on renvoie l'évènement
00072 if (mots[0]==ladate) {
00073 document.getElementById("ajax2").value = mots[1] ;
00074 } ; // fin si
00075 } ; // fin pour ide
00076 } else {
00077 document.getElementById("ajax2").value = "Error code " + xhr.status ;
00078 } ; // fin de xhr.status == 200
00079 } ; // fin de xhr.readyState == 4
00080 } ; // fin de fonction xhr.onreadystatechange
00081
00082 var ladate = eltselect.options[eltselect.selectedIndex].value ;
00083 var url = "tutajax_send2.txt" ;
00084 xhr.open("GET", url, true);
00085 xhr.send(null);
00086
00087 } ; // fin fonction ajaxv2
00088
00089 // ########################################################################
00090
00091 function ajaxv3(eltradio) {
00092
00093 // ########################################################################
00094
00095 var xhr;
00096 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00097 catch (e) {
00098 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00099 catch (e2) {
00100 try { xhr = new XMLHttpRequest(); }
00101 catch (e3) { xhr = false; }
00102 }
00103 } // fin du catch
00104
00105 xhr.onreadystatechange = function() {
00106 if (xhr.readyState == 4) {
00107 if (xhr.status == 200) {
00108 document.getElementById("ajax3").innerHTML = xhr.responseText ;
00109 } else {
00110 document.getElementById("ajax3").innerHTML = "Error code " + xhr.status ;
00111 } ; // fin de xhr.status == 200
00112 } ; // fin de xhr.readyState == 4
00113 } ; // fin de fonction xhr.onreadystatechange
00114
00115 var url = "tutajax4.php" ;
00116 if (eltradio[0].checked) {
00117 url = "tutajax_send3a.html" ;
00118 } else {
00119 url = "tutajax_send3b.html" ;
00120 } ; // fin si
00121 xhr.open("GET", url, true);
00122 xhr.send(null);
00123
00124 } ; // fin fonction ajaxv3
00125
00126 // ########################################################################
00127
00128 function ajaxv4(eltselect) {
00129
00130 // ########################################################################
00131
00132 var xhr;
00133 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00134 catch (e) {
00135 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00136 catch (e2) {
00137 try { xhr = new XMLHttpRequest(); }
00138 catch (e3) { xhr = false; }
00139 }
00140 } // fin du catch
00141
00142 xhr.onreadystatechange = function() {
00143 if (xhr.readyState == 4) {
00144 if (xhr.status == 200) {
00145 document.getElementById("ajax4").value = ""
00146 dct = xhr.responseXML ;
00147 tab = dct.getElementsByTagName("article") ;
00148 for (ide=0;ide<tab.length;ide++) {
00149 var article = tab[ide] ; // article courant
00150 var vu = 0 // indique si on a vu l'article recherché
00151 var nbet = 0 // nombre d'enfants textes
00152 // on passe en revue les enfants
00153 indc = 0 ; // indice courant d'enfant
00154 while (indc<article.childNodes.length) {
00155 currentElementChild=article.childNodes[indc];
00156 if (vu<2) {
00157 // s'il s'agit d'un noeud texte
00158 if (currentElementChild.nodeType==1) {
00159 nbet = nbet + 1
00160 // et s'il correspond au texte cherché
00161 if (currentElementChild.textContent==larticle) {
00162 vu = 1 ;
00163 } ; // fin si
00164 // alors on récupère le texte suivant
00165 if (vu==1) {
00166 if (nbet==2) {
00167 prix = currentElementChild.textContent
00168 document.getElementById("ajax4").value += prix + " euros" ;
00169 vu = 2 ;
00170 indc = article.childNodes.length + 1
00171 } ; // fin si
00172 } ; // fin si
00173 } ; // fin si
00174 } ; // fin si
00175 indc++
00176 currentElementChild=article.childNodes[indc];
00177 } // fin de tant que
00178 } ; // fin pour ide
00179
00180 } else {
00181 document.getElementById("ajax4").value = "Error code " + xhr.status ;
00182 } ; // fin de xhr.status == 200
00183 } ; // fin de xhr.readyState == 4
00184 } ; // fin de fonction xhr.onreadystatechange
00185
00186 // ceci est le mot cherché :
00187
00188 var larticle = eltselect.options[eltselect.selectedIndex].value ;
00189
00190 var url = "tutajax_send4a.xml" ;
00191 xhr.open("GET", url, true);
00192 xhr.send(null);
00193
00194 } ; // fin fonction ajaxv4
00195
00196 // ########################################################################
00197
00198 function ajaxv5(eltselect) {
00199
00200 // ########################################################################
00201
00202 var xhr;
00203 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00204 catch (e) {
00205 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00206 catch (e2) {
00207 try { xhr = new XMLHttpRequest(); }
00208 catch (e3) { xhr = false; }
00209 }
00210 } // fin du catch
00211
00212 xhr.onreadystatechange = function() {
00213 if (xhr.readyState == 4) {
00214 if (xhr.status == 200) {
00215 document.getElementById("ajax5").value = ""
00216 dct = xhr.responseXML ;
00217 tab = dct.getElementsByTagName("article") ;
00218 for (ide=0;ide<tab.length;ide++) {
00219 var article = tab[ide] ;
00220 if (article.getAttribute("nom")==larticle) {
00221 leprix = article.getAttribute("prix") ;
00222 document.getElementById("ajax5").value += leprix + " euros" ;
00223 } ; // fin si
00224 } ; // fin pour ide
00225
00226 } else {
00227 document.getElementById("ajax5").value = "Error code " + xhr.status ;
00228 } ; // fin de xhr.status == 200
00229 } ; // fin de xhr.readyState == 4
00230 } ; // fin de fonction xhr.onreadystatechange
00231
00232 // ceci est le mot cherché :
00233
00234 var larticle = eltselect.options[eltselect.selectedIndex].value ;
00235
00236 var url = "tutajax_send4b.xml" ;
00237 xhr.open("GET", url, true);
00238 xhr.send(null);
00239
00240 } ; // fin fonction ajaxv5
00241
00242 // ########################################################################
00243
00244 function ajaxv6(eltradio) {
00245
00246 // ########################################################################
00247
00248 var xhr ;
00249 try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00250 catch (e) {
00251 try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00252 catch (e2) {
00253 try { xhr = new XMLHttpRequest(); }
00254 catch (e3) { xhr = false; }
00255 }
00256 } // fin du catch
00257
00258 xhr.onreadystatechange = function() {
00259 if (xhr.readyState == 4) {
00260 if (xhr.status == 200) {
00261 // on transmet tout le fichier
00262 var tabdates = eval('(' + xhr.responseText + ')') ;
00263 msg = " Jour du rendez-vous, le " ;
00264 msg += tabdates[numj] ;
00265 msg += " novembre "
00266 document.getElementById("ajax6").firstChild.data = msg
00267 } else {
00268 document.getElementById("ajax6").firstChild.data = "Error code " + xhr.status ;
00269 } ; // fin de xhr.status == 200
00270 } ; // fin de xhr.readyState == 4
00271 } ; // fin de fonction xhr.onreadystatechange
00272
00273
00274 var url = "tutajax_send5.txt" ;
00275 var numj = -1 ;
00276 for (idj=0;idj<=2;idj++) {
00277 if (eltradio[idj].checked) { numj = idj ; } ;
00278 } ; // fin pour
00279
00280 xhr.open("GET", url, true);
00281 xhr.send(null);
00282
00283 } ; // fin fonction ajaxv6
00284
00285 // ########################################################################
00286
00287
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)