PageSourceSearch

https://www.gites-de-france-22-35-56.fr/lib_2/js/foncs/ajax.js

js gites-de-france-22-35-56.fr collected 2026-10-07 13:38:32 UTC 8,887 bytes, 296 lines download raw bytes

1// Adrien 10/05/23 : Attention, ce fichier n'est plus utilisé sur la majorité des sites web excepté sur le compte client et le script de résa
2
3function creeObjHttpRequest(){
4	var xhr_local=null;
5	if(window.XMLHttpRequest) // Firefox et autres
6   		xhr_local = new XMLHttpRequest();
7	else if(window.ActiveXObject){ // Internet Explorer
8	   try {
9			xhr_local = new ActiveXObject("Msxml2.XMLHTTP");
10		}catch(e){
11			xhr_local = new ActiveXObject("Microsoft.XMLHTTP");
12		}
13	}
14	return xhr_local;
15}
16
17function go(c){
18	if(!c.data.replace(/\s/g,""))
19		c.parentNode.removeChild(c);
20}
21
22function clean(d){
23	var bal=d.getElementsByTagName("*");
24	for(i=0;i<bal.length;i++){
25		a=bal[i].previousSibling;
26		if(a && a.nodeType==3)
27			go(a);
28		b=bal[i].nextSibling;
29		if(b && b.nodeType==3)
30			go(b);
31	}
32	return d;
33}
34
35
36
37function urlCentreByAjaxFromCGI(url,cgis,htmlAttente){
38    debugLogJS('urlCentreByAjaxFromCGI');
39}
40
41
42
43function listeByAjaxFromCGI(cgis,htmlAttente){
44    debugLogJS('listeByAjaxFromCGI');
45	urlCentreByAjaxFromCGI("/liste",cgis,htmlAttente);
46}
47
48function listeByAjaxFromForm(idForm,htmlAttente){
49    debugLogJS('listeByAjaxFromForm');
50	var objForm=document.getElementById(idForm);
51	if (!objForm)return;
52
53	var tabForm=getTabChmpForm(objForm);
54	var query="";
55
56	for (var i=0;i<tabForm.length;i++){
57		query+="&"+tabForm[i].id+"="+tabForm[i].value;
58	}
59	urlCentreByAjaxFromCGI("/liste",query,htmlAttente);
60}
61
62
63function urlDsPageCurrByAjaxAvecMsgAttente(url,cgi,htmlAttente){
64
65}
66
67
68
69
70function affUrlInDiv(nomDiv,url,vars,msgAttente,foncQdFini){
71	var idx=url.indexOf("?");
72	if (idx>0){
73		vars += url.substr(idx+1);
74		url = url.substr(0,idx);
75	}
76	vars+=getInfoSession("PHPSESSID");
77
78	var xhr_local=creeObjHttpRequest();
79	xhr_local.onreadystatechange = function(){
80		if(xhr_local.readyState == 4 && xhr_local.status == 200){
81
82			var reponse = xhr_local.responseText;
83			var elem=$(nomDiv);
84			if (elem) elem.innerHTML=reponse;
85			if (foncQdFini)foncQdFini(elem);
86		}
87		if(xhr_local.readyState == 4 && xhr_local.status!=200){
88			if (foncQdFini)foncQdFini(elem);
89		}
90	}
91
92	if (msgAttente!="aucun"){
93		var elem=document.getElementById(nomDiv);
94		if (elem && msgAttente)elem.innerHTML=msgAttente;
95		else affMsgAttenteInDiv(nomDiv);
96	}
97
98	xhr_local.open("POST",url,true);
99	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
100	xhr_local.send(vars);
101}
102
103function affUrlInDivFromHtml(html,foncQdFini){
104	var data=html;
105	var idx_debhtml=data.indexOf("-->");
106	if (idx_debhtml>0){
107		var js = data.substr(4,idx_debhtml-4);
108		if (js.substr(0,14)=="JS_affUrlInDiv"){
109			var tabInfos=js.split("&#164;");
110			affUrlInDiv(tabInfos[1],tabInfos[2],tabInfos[3],"",foncQdFini);
111		}else{
112			if (window.foncQdFini)window.foncQdFini(false);
113		}
114	}
115
116}
117
118
119function affUrlSsTourInDivAvecMsgAttente(nomDiv,url,query_string,html_attente){
120	var xhr_local=creeObjHttpRequest();
121	xhr_local.onreadystatechange = function(){
122		if(xhr_local.readyState == 4 && xhr_local.status == 200){
123			var contenu=xhr_local.responseText;
124			document.getElementById(nomdiv).innerHTML=contenu;
125		}
126	}
127
128	xhr_local.open("POST",url,true);
129	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
130	xhr_local.send(query_string);
131}
132
133function chargeAdresseHTMLDansDiv(nomdiv,url,query_string){
134	var xhr_local=creeObjHttpRequest();
135	xhr_local.onreadystatechange = function(){
136		if(xhr_local.readyState == 4 && xhr_local.status == 200){
137			var contenu=xhr_local.responseText;
138			document.getElementById(nomdiv).innerHTML=contenu;
139		}
140	}
141
142	xhr_local.open("POST",url,true);
143	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
144	xhr_local.send(query_string);
145}
146
147
148function appelAjaxToFunc(url,query_string,foncQdFini){
149	var xhr_local=creeObjHttpRequest();
150	xhr_local.onreadystatechange = function(){
151		if(xhr_local.readyState == 4 && xhr_local.status == 200){
152			var contenu=xhr_local.responseText;
153			if (foncQdFini)foncQdFini(contenu);
154		}
155	}
156	xhr_local.open("POST",url,true);
157	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
158	xhr_local.send(query_string);
159}
160
161function appelAjaxXMLToFunc(url,query_string,foncQdFini){
162	var xhr_local=creeObjHttpRequest();
163	xhr_local.onreadystatechange = function(){
164		if(xhr_local.readyState == 4 && xhr_local.status == 200){
165			var contenu=clean(xhr_local.responseXML.documentElement);
166			if (foncQdFini)foncQdFini(contenu);
167		}
168	}
169	xhr_local.open("POST",url,true);
170	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
171	xhr_local.send(query_string);
172}
173
174function appelAdrAjaxInDivAvecTransparence(adr,sending,msg,w,h,effacerDivChargementApresReponse,foncQdFini){
175	var html_init="<div id='divChargementAjx'><div class='divChargementAjxContent'<img src=/config_v3/imgs_defaut/loading/roue16x16.gif /><br />"+msg+"</div></div>";
176
177	if(!w) w=200;
178	if(!h) h=150;
179	afficheDivAvecTransparence(html_init,w,h);
180
181	var objStatus=document.getElementById("divChargementAjx");
182	var xhr_local=creeObjHttpRequest();
183  	xhr_local.onreadystatechange = function(){
184		if(xhr_local.readyState == 4 && xhr_local.status == 200){
185			reponse = xhr_local.responseText;
186            
187            if(effacerDivChargementApresReponse) afficheDivAvecTransparence(reponse,w,h);
188            else objStatus.innerHTML=reponse;
189			
190            if(foncQdFini) foncQdFini();
191			}
192		}
193	xhr_local.open("POST",adr,true);
194 	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
195	xhr_local.send(sending);
196}
197function appelCalendrierAnnuelGP(adr,sending,msg,w,h){    
198    appelAdrAjaxInDivAvecTransparence(adr,sending,msg,w,h,true,initCalendrierAnnuelGP);   
199}
200
201function affParamCGICurrInObjById(idDiv,param,acc,chaineAvant,chaineApres){
202    debugLogJS('affParamCGICurrInObjById');
203
204}
205
206function setCGIByAjax(querystring,rechargeListe,foncQdFini,paramFcQdFini){
207    debugLogJS('setCGIByAjax');
208
209}
210
211function chargeMotCleDsDiv(idDiv,motCle){
212	if (!window.jsonMotcle)window.jsonMotcle=[];
213	for (var i=0;i<window.jsonMotcle.length;i++){
214		if (window.jsonMotcle[i].motcle==motCle){
215			if ($(idDiv))$(idDiv).innerHTML=window.jsonMotcle[i].content;
216			return;
217		}
218	}
219	var adr="/lib_2/ajax/contenuFenetre.php";
220	var sending=getInfoSession()+"&element=motCle&typeInfo=motcle&val="+motCle;
221	appelAjaxToFunc(adr,sending,function(reponse){
222		window.jsonMotcle.push({'motcle':motCle,'content':reponse});
223		window.jsonMotcle.uniq();
224		if ($(idDiv))$(idDiv).innerHTML=reponse;
225	});
226
227	//affUrlInDiv(idDiv,adr,sending,"aucun");
228}
229function cleanAllAJAXcall(){
230	//window.stop();
231}
232
233function appelAdrAjaxToFuncXMLAvecAttente(url,query_string,foncQdFini,msg,w,h){
234    if(!msg){
235        var msg = 'Chargement en cours';
236    }
237    var html_init="<div id='divChargementAjx'><img src=/config_v3/imgs_defaut/loading/roue16x16.gif /><br />"+msg+"</div>";
238
239	if(!w) w=200;
240	if(!h) h=150;
241	afficheDivAvecTransparence(html_init,w,h);
242    (function($){
243        $.ajax({
244            type: "POST",
245            url: url,
246            data: query_string,
247            dataType:'xml',
248            success: function(reponse){
249                $('#divChargementAjx').hide('slow');
250                if (foncQdFini)foncQdFini(reponse);
251            }
252        });
253    })(jQuery);
254}
255
256/*
257 * Permet de gérer un upload en ajax, avec un form. Sans aucun plugin, vraiment très simplement
258 */
259function simpleUploaderAjax(form,fonctionSuccess){
260    (function($){
261        $(form).submit(function(event){
262            event.stopPropagation(); 
263            event.preventDefault(); 
264            var files = $('input[type=file]',form)[0].files;
265            var data = new FormData();
266            $.each(files, function(key, value){
267                data.append(key, value);
268            });
269            var queryString = '?'+$(form).serialize();
270            $.ajax({
271                url: $(form).attr('action')+queryString,
272                type: 'POST',
273                data: data,
274                cache: false,
275                dataType: 'json',
276                processData: false, // on ne veut pas transformer les files en string
277                contentType: false, // jquery par défaut met application/x-www-form-urlencoded, on n'en veut pas
278                success: function(data, textStatus, jqXHR){
279                    if(data.code == 'OK'){
280                        window[fonctionSuccess](data);
281                    }
282                    else{
283                        //console.log('ERRORS: ' + data.error);
284                    }
285                    $('.spinnerAppelAjax',form).remove();
286                },
287                error: function(jqXHR, textStatus, errorThrown){
288                    $('.spinnerAppelAjax',form).remove();
289                },
290                beforeSend:function(){
291                    $(form).append('<img class="spinnerAppelAjax" src=/config_v3/imgs_defaut/loading/roue16x16.gif />');
292                }
293            });
294        });
295    })(jQuery);
296}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.