PageSourceSearch

https://kms.fr/Libs/js/Lib.js

js kms.fr collected 2026-10-04 00:01:08 UTC 76,287 bytes, 2,583 lines download raw bytes

1/*
2
3Utf8 (=utf8 sans bom)
4
5éèà
6
7Fonctions Generales JS Theo
8
9DM:04/02/2021
10DC:19/08/2015 a 08h17
11
12*/
13
14
15function EMailValide(EMail)
16{
17
18  if ( (EMail == "") || (EMail.length < 5) ) return(false);
19  
20  if (EMail.length < 5) return false
21
22  if (!CaracPermis(EMail,"@.0123456789-abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ+"))
23  {
24    return (false);
25  }
26
27  var LeAt = EMail.indexOf("@")+1;
28  //var LePt = EMail.indexOf(".")+1;//Attention, si le point est avant le "@" , on s'en rendra pas compte !
29  var LePt = EMail.lastIndexOf(".")+1;
30  
31  //alert("email="+EMail+" - At="+LeAt+" - Pt(dernier)="+LePt);
32  
33  //if ( (LeAt <= 1) || (LePt < 1) || (LeAt == EMail.length) || (LePt == EMail.length) ) return(false);//Attention, si le point est avant le "@" , on s'en rendra pas compte !
34  if ( (LeAt <= 1) || (LePt <= 1) || (LePt < LeAt) || (LeAt == EMail.length) || (LePt == EMail.length) || (EMail.charAt(LeAt-2)==".") ) return(false);
35 
36  return(true);
37}
38
39
40function UnEntier(Ent)
41{
42  var checkOK = "0123456789";
43  var checkStr = Ent;
44  var allValid = true;
45  var decPoints = 0;
46  var allNum = "";
47  for (i = 0;  i < checkStr.length;  i++)
48  {
49    C = checkStr.charAt(i);
50    for (j = 0;  j < checkOK.length;  j++)
51      if (C == checkOK.charAt(j))
52        break;
53    if (j == checkOK.length)
54    {
55      allValid = false;
56      break;
57    }
58    allNum += C;
59  }
60  if (!allValid)
61  {
62    return (false);
63  }
64  return(true);
65}
66
67function UnNomPropre(Ch)
68{
69  var checkStr = Ch;
70  var checkOK = "- '.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
71  var allValid = true;
72  for (i = 0;  i < checkStr.length;  i++)
73  {
74    C = checkStr.charAt(i);
75    for (j = 0;  j < checkOK.length;  j++)
76      if (C == checkOK.charAt(j))
77        break;
78    if (j == checkOK.length)
79    {
80      return(false);
81    }
82    return(true);
83  }
84}
85  
86function CaracPermis(Ch,Carac)
87{
88  var checkOK = Carac;
89  var checkStr = Ch;
90  var allValid = true;
91  var decPoints = 0;
92  var allNum = "";
93  for (i = 0;  i < checkStr.length;  i++)
94  {
95    C = checkStr.charAt(i);
96    for (j = 0;  j < checkOK.length;  j++)
97    if (C == checkOK.charAt(j)) break;
98    if (j == checkOK.length)
99    {
100      allValid = false;
101      break;
102    }
103    allNum += C;
104  }
105  if (!allValid)
106  {
107    return (false);
108  }
109  return(true);
110}
111
112function Format_Prix_Virgule(UnPrix)
113{
114  var Prix   = UnPrix;
115
116  if ( (Prix.indexOf(",")+1) > 0 )
117  {
118    Prix = parseFloat(Prix.replace(",","."));
119  }
120  else Prix = Prix*1;
121  Prix = Prix*1;
122  return(Prix);
123}//function Format_Prix_Virgule(UnPrix)
124
125function verif_date(input)
126{
127// Fonction de vérification de date avec les années bissextile par jerome.o
128// Accepte en entrée les dates sous la forme : 02/02/2004, 2-2-2004 avec des / ou -
129// Retourne false si la date est fausse ou érronée
130
131
132var regex = new RegExp("[/-]");
133var date = input.split(regex);
134var nbJours = new Array('',31,28,31,30,31,30,31,31,30,31,30,31);
135var result = true;
136
137if ( date['2']%4 == 0 && date['2']%100 > 0 || date['2']%400 == 0 )
138nbJours['2'] = 29;
139
140if( isNaN(date['2']) )
141result=false;
142
143if ( isNaN(date['1']) || date['1'] > 12 || date['1'] < 1 )
144result=false;
145
146if ( isNaN(date['0']) || date['0'] > nbJours[Math.round(date['1'])] || date['0'] < 1 )
147result=false;
148
149return result;
150}
151
152 
153function SHA1 (msg) 
154{//Merci http://www.webtoolkit.info/javascript-sha1.html
155/**
156*
157*  Secure Hash Algorithm (SHA1)
158*  http://www.webtoolkit.info/
159*
160**/
161 
162	function rotate_left(n,s) {
163		var t4 = ( n<<s ) | (n>>>(32-s));
164		return t4;
165	};
166 
167	function lsb_hex(val) {
168		var str="";
169		var i;
170		var vh;
171		var vl;
172 
173		for( i=0; i<=6; i+=2 ) {
174			vh = (val>>>(i*4+4))&0x0f;
175			vl = (val>>>(i*4))&0x0f;
176			str += vh.toString(16) + vl.toString(16);
177		}
178		return str;
179	};
180 
181	function cvt_hex(val) {
182		var str="";
183		var i;
184		var v;
185 
186		for( i=7; i>=0; i-- ) {
187			v = (val>>>(i*4))&0x0f;
188			str += v.toString(16);
189		}
190		return str;
191	};
192 
193 
194	function Utf8Encode(string) {
195		string = string.replace(/\r\n/g,"\n");
196		var utftext = "";
197 
198		for (var n = 0; n < string.length; n++) {
199 
200			var c = string.charCodeAt(n);
201 
202			if (c < 128) {
203				utftext += String.fromCharCode(c);
204			}
205			else if((c > 127) && (c < 2048)) {
206				utftext += String.fromCharCode((c >> 6) | 192);
207				utftext += String.fromCharCode((c & 63) | 128);
208			}
209			else {
210				utftext += String.fromCharCode((c >> 12) | 224);
211				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
212				utftext += String.fromCharCode((c & 63) | 128);
213			}
214 
215		}
216 
217		return utftext;
218	};
219 
220	var blockstart;
221	var i, j;
222	var W = new Array(80);
223	var H0 = 0x67452301;
224	var H1 = 0xEFCDAB89;
225	var H2 = 0x98BADCFE;
226	var H3 = 0x10325476;
227	var H4 = 0xC3D2E1F0;
228	var A, B, C, D, E;
229	var temp;
230 
231	msg = Utf8Encode(msg);
232 
233	var msg_len = msg.length;
234 
235	var word_array = new Array();
236	for( i=0; i<msg_len-3; i+=4 ) {
237		j = msg.charCodeAt(i)<<24 | msg.charCodeAt(i+1)<<16 |
238		msg.charCodeAt(i+2)<<8 | msg.charCodeAt(i+3);
239		word_array.push( j );
240	}
241 
242	switch( msg_len % 4 ) {
243		case 0:
244			i = 0x080000000;
245		break;
246		case 1:
247			i = msg.charCodeAt(msg_len-1)<<24 | 0x0800000;
248		break;
249 
250		case 2:
251			i = msg.charCodeAt(msg_len-2)<<24 | msg.charCodeAt(msg_len-1)<<16 | 0x08000;
252		break;
253 
254		case 3:
255			i = msg.charCodeAt(msg_len-3)<<24 | msg.charCodeAt(msg_len-2)<<16 | msg.charCodeAt(msg_len-1)<<8	| 0x80;
256		break;
257	}
258 
259	word_array.push( i );
260 
261	while( (word_array.length % 16) != 14 ) word_array.push( 0 );
262 
263	word_array.push( msg_len>>>29 );
264	word_array.push( (msg_len<<3)&0x0ffffffff );
265 
266 
267	for ( blockstart=0; blockstart<word_array.length; blockstart+=16 ) {
268 
269		for( i=0; i<16; i++ ) W[i] = word_array[blockstart+i];
270		for( i=16; i<=79; i++ ) W[i] = rotate_left(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
271 
272		A = H0;
273		B = H1;
274		C = H2;
275		D = H3;
276		E = H4;
277 
278		for( i= 0; i<=19; i++ ) {
279			temp = (rotate_left(A,5) + ((B&C) | (~B&D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
280			E = D;
281			D = C;
282			C = rotate_left(B,30);
283			B = A;
284			A = temp;
285		}
286 
287		for( i=20; i<=39; i++ ) {
288			temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
289			E = D;
290			D = C;
291			C = rotate_left(B,30);
292			B = A;
293			A = temp;
294		}
295 
296		for( i=40; i<=59; i++ ) {
297			temp = (rotate_left(A,5) + ((B&C) | (B&D) | (C&D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
298			E = D;
299			D = C;
300			C = rotate_left(B,30);
301			B = A;
302			A = temp;
303		}
304 
305		for( i=60; i<=79; i++ ) {
306			temp = (rotate_left(A,5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
307			E = D;
308			D = C;
309			C = rotate_left(B,30);
310			B = A;
311			A = temp;
312		}
313 
314		H0 = (H0 + A) & 0x0ffffffff;
315		H1 = (H1 + B) & 0x0ffffffff;
316		H2 = (H2 + C) & 0x0ffffffff;
317		H3 = (H3 + D) & 0x0ffffffff;
318		H4 = (H4 + E) & 0x0ffffffff;
319 
320	}
321 
322	var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
323 
324	return temp.toLowerCase();
325 
326 }
327 
328function Objet_Html_Via_ID_Donner_Val_Cplx(ID,Nom_Chp)
329{
330  if(!ID) return "";
331  if(!Nom_Chp) return "";
332  
333  var Obj_Html = null;
334  
335  Obj_Html = document.getElementById(ID);
336  if ( (!Obj_Html) || (Obj_Html==null) )
337	{
338	  return "";
339	}
340  
341  var Val_Html = "";
342  if ( (Nom_Chp=="value") || (Nom_Chp=="Value") ) return Obj_Html.value;
343  return Obj_Html.innerHTML;
344}
345
346function Objet_Html_Via_ID_Donner_Value(ID)
347{
348  return Objet_Html_Via_ID_Donner_Val_Cplx(ID,"value");
349}
350
351function Objet_Html_Via_ID_Donner_InnerHtml(ID)
352{
353  return Objet_Html_Via_ID_Donner_Val_Cplx(ID,"innerHTML");
354}
355
356function Objet_Html_Via_ID_Changer_Val_Cplx(ID,Nom_Chp,Val)
357{
358  if(!ID) return false;
359  if(!Nom_Chp) return false;
360  
361  var Obj_Html = null;
362  
363  Obj_Html = document.getElementById(ID);
364  if ( (!Obj_Html) || (Obj_Html==null) )
365	{
366	  return false;
367	}
368  
369  //alert("Id='"+ID+"'\nNom_Chp='"+Nom_Chp+"'\nVal='"+Val+"'");
370  if ( (Nom_Chp=="value") || (Nom_Chp=="Value") )
371  {
372    Obj_Html.value=Val;
373  }
374  else
375  {
376    Obj_Html.innerHTML = Val;
377  }
378  return true;
379}
380
381function Objet_Html_Via_ID_Changer_Value(ID,Val)
382{
383  //alert("ID="+ID+"\nVal="+Val);
384  return Objet_Html_Via_ID_Changer_Val_Cplx(ID,"value",Val);
385}
386
387function Objet_Html_Via_ID_Changer_InnerHtml(ID,Val)
388{
389  return Objet_Html_Via_ID_Changer_Val_Cplx(ID,"innerHTML",Val);
390}
391
392
393function Objet_Html_Via_ID_Style_Cplx(ID,Nom_Chp,Donner,Nvl_Val)
394{
395  if(!ID) return false;
396  if(!Nom_Chp) 
397  {
398    //On travail avec "style" tout entier
399    Nom_Chp="";
400  }
401  if(Donner) 
402  {//On doit retourner = donner la valeur de nom_chp (ou style en entier, si nom_chp est vide)
403    Donner=true;
404    Nvl_Val="";
405  }
406  else
407  {//On doit Modifier la valeur de nom_chp (ou style en entier, si nom_chp est vide)
408    Donner = false;
409  }
410  
411  var Modifier = !Donner;
412  
413  var Obj_Html = null;
414  
415  Obj_Html = document.getElementById(ID);
416  if ( (!Obj_Html) || (Obj_Html==null) )
417	{
418	  return false;
419	}
420  
421  var Styl_Glob = null;
422  var Styl_Spe = null;
423  
424  //alert("Id='"+ID+"'\nNom_Chp='"+Nom_Chp+"'\nNvl_Val='"+Nvl_Val+"'\nModifier='"+Modifier+"'");
425  
426  Styl_Glob = Obj_Html.style;
427  var Rps = Styl_Glob;
428  
429  /*
430  alert("Id='"+ID+"'\nNom_Chp='"+Nom_Chp+"'\nNvl_Val='"+Nvl_Val+"'\nModifier='"+Modifier+"'"
431    +"\nStyl_Glob='"+Styl_Glob+"'"
432    );
433  */
434  
435  if(Nom_Chp)
436  {
437    Styl_Spe = Styl_Glob.Nom_Chp;
438    Rps = Styl_Spe;
439  }
440  
441  
442  /*
443  alert("Id='"+ID+"'\nNom_Chp='"+Nom_Chp+"'\nNvl_Val='"+Nvl_Val+"'\nModifier='"+Modifier+"'"
444    +"\nStyl_Glob='"+Styl_Glob+"'"
445    +"\nStyl_Spe='"+Styl_Spe+"'"
446  );
447  */
448  
449  
450  if (Donner)
451  {
452    return Rps;
453  }
454  
455  if(Nom_Chp)
456  {
457    Styl_Glob.Nom_Chp = Nvl_Val;
458    if(Nom_Chp=="display")
459    {
460      //Obj_Html.style.display = Nvl_Val;
461    }
462    Obj_Html.style[Nom_Chp] = Nvl_Val;
463  }
464  else
465  {
466    Styl_Glob = Nvl_Val;
467    Obj_Html.style = Nvl_Val;
468  }
469  
470  if (Nom_Chp)
471  {
472    Rps = Obj_Html.style.Nom_Chp==Nvl_Val;
473    Rps = Obj_Html.style.display==Nvl_Val;
474    Rps = Obj_Html.style[Nom_Chp]==Nvl_Val;//10/07/2014
475  }
476  else
477  {
478    Rps = Obj_Html.style==Nvl_Val;
479  }
480  
481  
482  /*
483  alert("Id='"+ID+"'\nNom_Chp='"+Nom_Chp+"'\nNvl_Val='"+Nvl_Val+"'\nModifier='"+Modifier+"'"
484    +"\nStyl_Glob='"+Styl_Glob+"'"
485    +"\nStyl_Spe='"+Styl_Spe+"'"
486    +"\nRps='"+Rps+"'"
487    );
488  */
489    
490  return Rps;
491}
492
493
494function Objet_Html_Via_ID_Style_Cacher(ID)
495{
496  return Objet_Html_Via_ID_Style_Cplx(ID,"display",false,"none");//On gagne de la place avec display=none
497}
498
499function Objet_Html_Via_ID_Style_Afficher(ID)
500{
501  return Objet_Html_Via_ID_Style_Cplx(ID,"display",false,"");//On gagne de la place avec display=none
502}
503function Objet_Html_Via_ID_Style_Montrer(ID)
504{
505  return Objet_Html_Via_ID_Style_Afficher(ID);
506}
507
508function Objet_Html_Via_ID_Style_Montrer_OnOff(ID,On)
509{
510  if(On)
511  {
512    return Objet_Html_Via_ID_Style_Afficher(ID);
513  }
514  else
515  {
516    return Objet_Html_Via_ID_Style_Cacher(ID);
517  }
518}
519
520function Objet_Html_Via_ID_Style_Dire_Si_Cacher(ID)
521{
522  var Obj_Style_Display = Objet_Html_Via_ID_Style_Cplx(ID,"display",true,"");//On gagne de la place avec display=none
523  return (Obj_Style_Display=="none");
524}
525
526function Objet_Html_Via_ID_Style_Visibility_Cacher(ID)
527{
528  return Objet_Html_Via_ID_Style_Cplx(ID,"visibility",false,"hidden");//Avec visibility:hidden on cache juste le composant
529}
530
531function Objet_Html_Via_ID_Style_Visibility_Afficher(ID)
532{
533  return Objet_Html_Via_ID_Style_Cplx(ID,"visibility",false,"visible");//Avec visibility:hidden on cache juste le composant
534}
535function Objet_Html_Via_ID_Style_Visibility_Montrer(ID)
536{
537  return Objet_Html_Via_ID_Style_Visibility_Afficher(ID);
538}
539
540function Objet_Html_Via_ID_Style_Visibility_Montrer_OnOff(ID,On)
541{
542  if(On)
543  {
544    return Objet_Html_Via_ID_Style_Visibility_Afficher(ID);
545  }
546  else
547  {
548    return Objet_Html_Via_ID_Style_Visibility_Cacher(ID);
549  }
550}
551
552function Objet_Html_Via_ID_Style_Dire_Si_Visibility_Cacher(ID)
553{
554  var Obj_Style_Visibility = Objet_Html_Via_ID_Style_Cplx(ID,"visibility",true,"");
555  return (Obj_Style_Visibility=="hidden");
556}
557
558function JS_AddSlashes(Ch)
559{//Merci http://www.commentcamarche.net/faq/16308-javascript-echapper-une-apostrophe
560  var Ch0 = Ch;
561  Ch = Ch.replace(/\\/g,"\\\\");
562  Ch = Ch.replace(/\'/g,"\\'");
563  Ch = Ch.replace(/\"/g,"\\\"");
564  //alert("Ch0='"+Ch0+"'\nCh='"+Ch+"'");
565  return Ch;
566}
567
568function JS_AddSlaches(Ch)
569{
570  return JS_AddSlashes(Ch);
571}
572
573function JS_AddSlashe(Ch)
574{
575  return JS_AddSlashes(Ch);
576}
577function JS_AddSlache(Ch)
578{
579  return JS_AddSlashes(Ch);
580}
581
582function JS_AddSlash(Ch)
583{
584  return JS_AddSlashes(Ch);
585}
586function JS_AddSlach(Ch)
587{
588  return JS_AddSlashes(Ch);
589}
590
591function Formater_Ch_Changer_Coul_De_Fond(Ch,Coul_De_Fond)
592{
593  if (!Coul_De_Fond) return Ch;
594  var Rps = "<span style='background-color:"+Coul_De_Fond+"'>"+Ch+"</span>";
595  return Rps;
596}
597
598function Formater_Ch_Err_Coul(Ch,Coul_Err)
599{
600  if (!Coul_Err) return Ch;
601  return Formater_Ch_Changer_Coul_De_Fond(Ch,Coul_Err);  
602}
603
604
605function JS_UrlEnCode(str)
606{
607 // Merci http://phpjs.org/functions/urlencode/
608 
609 // http://kevin.vanzonneveld.net
610  // +   original by: Philip Peterson
611  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
612  // +      input by: AJ
613  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
614  // +   improved by: Brett Zamir (http://brett-zamir.me)
615  // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
616  // +      input by: travc
617  // +      input by: Brett Zamir (http://brett-zamir.me)
618  // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
619  // +   improved by: Lars Fischer
620  // +      input by: Ratheous
621  // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
622  // +   bugfixed by: Joris
623  // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
624  // %          note 1: This reflects PHP 5.3/6.0+ behavior
625  // %        note 2: Please be aware that this function expects to encode into UTF-8 encoded strings, as found on
626  // %        note 2: pages served as UTF-8
627  // *     example 1: urlencode('Kevin van Zonneveld!');
628  // *     returns 1: 'Kevin+van+Zonneveld%21'
629  // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
630  // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
631  // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
632  // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
633  str = (str + '').toString();
634
635  // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
636  // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
637  return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28'). replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
638}
639
640function JS_UrlDeCode(str)
641{
642  // Merci http://phpjs.org/functions/urldecode/
643  // http://kevin.vanzonneveld.net
644  // +   original by: Philip Peterson
645  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
646  // +      input by: AJ
647  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
648  // +   improved by: Brett Zamir (http://brett-zamir.me)
649  // +      input by: travc
650  // +      input by: Brett Zamir (http://brett-zamir.me)
651  // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
652  // +   improved by: Lars Fischer
653  // +      input by: Ratheous
654  // +   improved by: Orlando
655  // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
656  // +      bugfixed by: Rob
657  // +      input by: e-mike
658  // +   improved by: Brett Zamir (http://brett-zamir.me)
659  // %        note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
660  // %        note 2: Please be aware that this function expects to decode from UTF-8 encoded strings, as found on
661  // %        note 2: pages served as UTF-8
662  // *     example 1: urldecode('Kevin+van+Zonneveld%21');
663  // *     returns 1: 'Kevin van Zonneveld!'
664  // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
665  // *     returns 2: 'http://kevin.vanzonneveld.net/'
666  // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
667  // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
668  return decodeURIComponent((str + '').replace(/\+/g, '%20'));
669}
670
671function JS__Aller_Sur_Url_Avec_Param_En_Post(Url,Data)
672{//merci http://camille.descombes.free.fr/blog/index.php/envoyer-des-donnees-post-en-javascript/
673  //Créé Theo le 26/02/2013
674
675  //if (!Url) Url = "http://www.kms.fr";
676
677  //Data est forcément un tableau associatif
678  // couples chp,valeur
679  //Data = array(chp1=>Val1,Chp2=>val2,...
680
681  var form = document.createElement('form');//Creation dynamique de la fiche : Type form !!!! Ce n'est pas le name mais son type !!
682  form.setAttribute('action',Url);
683  form.setAttribute('method', 'post');
684  
685  for (var n in Data)
686  {
687    var inputvar = document.createElement('input');//Creation dynamiq d'un champ input
688    inputvar.setAttribute('type', 'hidden');//Creation dynamique d'attribut pour le champ
689    inputvar.setAttribute('name', n);
690    inputvar.setAttribute('value', Data[n]);
691    form.appendChild(inputvar);//Affectation dynamique du champ au formularie
692  }
693  document.body.appendChild(form);//Affectation dynamique du formulaire dans le body du document(page)
694  
695  //alert("Data="+Data");
696  //alert("form="+form+"\ntype='"+form.type+"'");
697  
698  form.submit();//Envoie du formulaire
699}//function JS__Aller_Sur_Url_Avec_Param_En_Post(Url,Data)
700
701function JS__Retourner_Touts_Les_Elements_De_Ce_Formulaire_Sous_Forme_De_Tableau(Nom_Form)
702{
703  //DM : 10/01/2020. déclaration 'let' au lieu de 'var'
704  //DC : 26/02/2013. Theo
705
706  //Data est forcément un tableau associatif
707  //couples chp,valeur
708  //Data = array(chp1=>Val1,Chp2=>val2,...
709
710  let Fiche = document.getElementById(Nom_Form);
711  if(!Fiche) return false;
712  
713  let Data={};
714  
715  let I=0;
716  
717  let Typ='';
718  let Nom='';
719  let Val='';
720  let Id=0;
721  
722  for (I=0;I<Fiche.elements.length;I++)
723  {
724  
725    Typ = /*window.document.*/Fiche.elements[I].type;
726    Nom = /*window.document.*/Fiche.elements[I].name;
727    Val = /*window.document.*/Fiche.elements[I].value;//Value marche pas pour les Type "select"
728    if (/*(Typ == "select") ||*/ (Typ == "select-one"))//"select" semble etre ignoré sous netscape, mais pas "select-one"...
729    {
730      Id = /*window.document.*/Fiche.elements[I].index;
731      if (Id >= 0) Val = /*window.document.*/Fiche.elements[I].options[Id].value;
732    }
733  
734    //Data[Fiche.elements[I].name]=Fiche.elements[I].value;
735    Data[Nom]=Val;
736  }
737  //alert("Data="+Data");
738
739  return Data;
740}
741
742function JS__Trouver_Cette_Ch_Dans_Cette_Page_V01(Ch)
743{
744  /* 
745  26/07/2014
746  Merci http://codes-sources.commentcamarche.net/source/15869-recherche-d-un-mot-dans-une-page
747  
748  Find In Page Script- By Mike Hall ([email protected]) 
749  Recherche de mot 
750  */
751  
752  var NS4 = (document.layers);    // Which browser?
753  var IE4 = (document.all);
754  var win = window;    // window to search.
755  var n   = 0;
756  var Msg_Ch_Non_Trouvee = "'"+Ch+"' n'a pas été trouvé. Vérifiez l'orthographe.";
757  
758  var txt, i, found;
759  
760  if (Ch == "") return false;
761  // Find next occurance of the given string on the page, wrap around to the
762  // start of the page if necessary.
763  if (NS4) 
764  {
765    // Look for match starting at the current point. If not found, rewind
766    // back to the first match.
767    if (!win.find(Ch))
768      while(win.find(Ch, false, true)) n++;
769    else
770      n++;
771    // If not found in either direction, give message.
772    if (n == 0)
773    alert(Msg_Ch_Non_Trouvee);
774  }
775  if (IE4) 
776  {
777    txt = win.document.body.createTextRange();
778    // Find the nth match from the top of the page.
779    for (i = 0; i <= n && (found = txt.findText(Ch)) != false; i++) 
780    {
781      txt.moveStart("character", 1);
782      txt.moveEnd("textedit");
783    }
784    // If found, mark it and scroll it into view.
785    if (found) 
786    {
787      txt.moveStart("character", -1);
788      txt.findText(Ch);
789      txt.select();
790      txt.scrollIntoView();
791      n++;
792    }
793    // Otherwise, start over at the top of the page and find first match.
794    else 
795    {
796      if (n > 0) 
797      {
798        n = 0;
799        findInPage(Ch);
800      }
801      // Not found anywhere, give message.
802      else
803      alert(Msg_Ch_Non_Trouvee);
804    }
805  }   
806  return false;
807}
808
809function JS__Trouver_Cette_Ch_Dans_Cette_Page_V02(Ch) 
810{
811  /*
812  26/07/2014 - Theo
813  
814  Merci 
815    http://www.toutjavascript.com/main/gorun.php3?s=searchon
816    http://www.toutjavascript.com/main/script.php3?url=searchon
817    
818  Mise à jour et amélioration par http://www.toutjavascript.com
819  D'après le script original de MHall
820  Reproduction gratuite à condition de laisser ce commentaire
821  */
822
823  var nbSearch=0;
824  
825  var txt, i, found;
826  var Msg_Ch_Non_Trouvee = "'"+Ch+"' n'a pas été trouvé. Vérifiez l'orthographe.";
827  
828  if (Ch=="") return false;
829
830  if ((document.layers)||(window.sidebar)) 
831  {
832    if (!window.find(Ch)) 
833    {
834	    alert("Fin de page atteinte.\n"+'"'+Ch+'" trouvé '+nbSearch+" fois.");
835	    while(window.find(Ch, false, true)) {nbSearch++;}
836	  } 
837    else nbSearch++;
838    if (nbSearch == 0) alert(Msg_Ch_Non_Trouvee);
839  }
840
841  if (document.all) 
842  {
843    txt = window.document.body.createTextRange();
844    for (i = 0; i <= nbSearch && (found = txt.findText(Ch)) != false; i++) 
845    {
846      txt.moveStart("character", 1);
847      txt.moveEnd("textedit");
848    }
849    if (found) 
850    {
851      txt.moveStart("character", -1);
852      txt.findText(Ch);
853      txt.select();
854      txt.scrollIntoView();
855      nbSearch++;
856    } 
857    else 
858    {
859      if (nbSearch > 0) 
860      {
861	  	  alert("Fin de page atteinte.\n"+'"'+Ch+'" trouvé '+nbSearch+" fois.");
862
863        nbSearch = 0;
864        findInPage(Ch);
865      } 
866      else 
867      { 
868	      alert(Msg_Ch_Non_Trouvee);
869	    }
870    }
871  }
872  return false;
873}
874
875function JS__Trouver_Cette_Ch_Dans_Cette_Page(Ch) 
876{
877  return JS__Trouver_Cette_Ch_Dans_Cette_Page_V02(Ch);
878}
879
880function JS__Cette_Page_Est_Dans_Frame()
881{//Merci http://forum.webrankinfo.com/comment-tester-php-son-site-est-repris-dans-une-frame-t11295.html
882  //if (top.frames.length!=0) top.location=self.document.location; 
883  var Rsl = (top.frames.length!=0);//Ca marche : 10/09/2015
884  //alert("rsl='"+Rsl+"'"); 
885  return  Rsl;
886}
887
888function JS__Sortir_De_Frame_Si_Necessaire()
889{
890  if (JS__Cette_Page_Est_Dans_Frame()) top.location=self.document.location; 
891}
892
893
894/* 
895   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb
896   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb
897   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb
898   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb
899   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb
900   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Deb 
901
902A savoir - merci http://christianelagace.com/jquery/popup-avec-jquery-dialog/
903  <!-- Bootstrap -->
904  <!-- Charger Bootstrap avant jQuery pour permettre le bon fonctionnement de .dialog() -->
905  <script src="js/bootstrap.min.js"></script>
906 
907  <!-- jQuery -->
908  <link rel="stylesheet" href="css/jquery-ui.min.css" />
909
910  <script src="js/jquery.min.js"></script>
911
912  <script src="js/jquery-ui.min.js"></script>
913
914
915  CSS adequate - elle a créé
916    .dialogstyleperso .ui-state-information
917    .dialogstyleperso .ui-state-warning
918    .dialogstyleperso .ui-state-error
919
920   Je(Theo) les ai déclaré dans Lib_CSS.css
921
922*/
923
924// Affiche un popup d'information et l'usager doit cliquer sur OK pour le refermer
925// source : http://christianelagace.com
926// Paramètre : le texte du message qui sera affiché dans le popup
927function afficherPopupInformation(message) {
928    // crée la division qui sera convertie en popup
929    $('body').append('<div id="popupinformation" title="Information"></div>');
930    $("#popupinformation").html(message);
931 
932    // transforme la division en popup
933    $("#popupinformation").dialog({
934        autoOpen: false,
935        width: 400,
936        dialogClass: 'dialogstyleperso',
937        buttons: [
938            {
939                text: "OK",
940                "class": 'ui-state-information',
941                click: function () {
942                    $(this).dialog("close");
943                }
944            }
945        ]
946    }).dialog("open");
947 
948    // ajouter le style d'erreur à la barre de titre
949    // note : on n'utilise pas .dialogClass dans la définition de la boîte de dialogue car mettrait tout le fond en rouge
950    $("#popupinformation").prev().addClass('ui-state-information');
951}
952 
953// Affiche un popup d'avertissement et l'usager doit cliquer sur OK pour le refermer
954// source : http://christianelagace.com
955// Paramètre : le texte du message qui sera affiché dans le popup
956function afficherPopupAvertissement(message) {
957    // crée la division qui sera convertie en popup 
958    $('body').append('<div id="popupavertissement" title="Avertissement"></div>');
959    $("#popupavertissement").html(message);
960 
961    // transforme la division en popup
962    $("#popupavertissement").dialog({
963        autoOpen: false,
964        width: 400,
965        dialogClass: 'dialogstyleperso',
966        buttons: [
967            {
968                text: "OK",
969                "class": 'ui-state-warning',
970                click: function () {
971                    $(this).dialog("close");
972                }
973            }
974        ]
975    }).dialog("open");
976 
977    $("#popupavertissement").prev().addClass('ui-state-warning');
978}
979 
980// Affiche un popup d'erreur et l'usager doit cliquer sur OK pour le refermer
981// source : http://christianelagace.com
982// Paramètre : le texte du message qui sera affiché dans le popup
983function afficherPopupErreur(message) {
984    // crée la division qui sera convertie en popup
985    $('body').append('<div id="popuperreur" title="Erreur"></div>');
986    $("#popuperreur").html(message);
987 
988    // transforme la division en popup
989    $("#popuperreur").dialog({
990        autoOpen: false,
991        width: 400,
992        dialogClass: 'dialogstyleperso',
993        buttons: [
994            {
995                text: "OK",
996                "class": 'ui-state-error',
997                click: function () {
998                    $(this).dialog("close");
999                }
1000            }
1001        ]
1002    }).dialog("open");
1003 
1004    $("#popuperreur").prev().addClass('ui-state-error');
1005}
1006 
1007// Affiche un popup d'information qui se refermera automatiquement après 3 secondes
1008// source : http://christianelagace.com
1009// Paramètre : le texte du message qui sera affiché dans le popup
1010function afficherPopupInformationTroisSecondes(message) {
1011    // crée la division qui sera convertie en popup
1012    $('body').append('<div id="popuptroissecondes" title="Information"></div>');
1013    $("#popuptroissecondes").html(message);
1014 
1015    // transforme la division en popup
1016    $("#popuptroissecondes").dialog({
1017        autoOpen: false,
1018        width: 400,
1019        hide: "fade",
1020        open: function (event, ui) {
1021            setTimeout(function () {
1022                $("#popuptroissecondes").dialog('close');
1023            }, 3000);
1024        }
1025    }).dialog("open");
1026}
1027 
1028// À partir d'un lien <a href>, affiche un popup de confirmation et l'usager doit cliquer sur oui ou sur non.
1029// Le oui redirige vers la page spécifiée dans l'attribut href du lien
1030// alors que le non referme la boîte de dialogue sans rien modifier.
1031// source : http://christianelagace.com
1032// Paramètres : question : le texte de la question qui sera affichée dans le popup
1033//              lien (optionnel) : référence au lien qui cause l'affichage du popup
1034//                                 On y lira l'attribut href pour savoir quelle page afficher sur un oui.
1035//                                 Si non spécifié ou si le lien n'a pas d'attribut href, réaffichera la page actuelle.
1036function afficherPopupConfirmationLien(question, lien) {
1037    // crée la division qui sera convertie en popup
1038    $('body').append('<div id="popupconfirmation" title="Confirmation"></div>');
1039    $("#popupconfirmation").html(question);
1040 
1041    // transforme la division en popup
1042    $("#popupconfirmation").dialog({
1043        autoOpen: false,
1044        width: 400,
1045        buttons: [
1046            {
1047                text: "Oui",
1048                click: function () {
1049                    $(this).dialog("close");
1050                    var hrefdefini = false;
1051                    
1052                    if (lien != null) {
1053                        if ($(lien).attr("href") != undefined) {
1054                            hrefdefini = true;
1055                            // affiche la page de l'attribut href
1056                            window.location.href = $(lien).attr("href");
1057                        }
1058                    }
1059               
1060                    if (!hrefdefini) {
1061                        // réaffiche la page actuelle
1062                        window.location.reload();
1063                    }
1064                }
1065            },
1066            {
1067                text: "Non",
1068                click: function () {
1069                    $(this).dialog("close");
1070                    return false;
1071                }
1072            }
1073        ]
1074    }).dialog("open");
1075}
1076 
1077// Pour les programmes ASP.NET, affiche un popup de confirmation et l'usager doit cliquer sur oui ou sur non. 
1078// Le oui génère un rechargement de la page alors que le non referme la boîte de dialogue sans rien modifier.
1079// source : http://christianelagace.com
1080// Paramètres : question : le texte de la question qui sera affichée dans le popup
1081//              operation : un court string qui sera retourné lors du postback
1082//              item_id (optionnel) : l'identifiant de l'item sur lequel la question porte (sera concaténé au texte de l'opération si non nul)
1083function afficherPopupConfirmationASPNET(question, operation, item_id) {
1084    var argumentPostback = operation;
1085 
1086    if (item_id != null) {
1087        argumentPostback += '***' + item_id;
1088    }
1089 
1090    // crée la division qui sera convertie en popup
1091    $('body').append('<div id="popupconfirmation" title="Confirmation"></div>');
1092    $("#popupconfirmation").html(question);
1093 
1094    // transforme la division en popup
1095    $("#popupconfirmation").dialog({
1096        autoOpen: false,
1097        width: 400,
1098        buttons: [
1099            {
1100                text: "Oui",
1101                click: function () {
1102                    $(this).dialog("close");
1103                    // la page sera rafraîchie et le code côté serveur devra tenir compte de l'information reçue
1104                    __doPostBack(this.id, argumentPostback);
1105                }
1106            },
1107            {
1108                text: "Non",
1109                click: function () {
1110                    $(this).dialog("close");
1111                    return false;
1112                }
1113            }
1114        ]
1115    });
1116    
1117    $("#popupconfirmation").dialog("open");
1118}
1119/* 
1120   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin
1121   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin
1122   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin
1123   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin
1124   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin
1125   http://christianelagace.com/jquery/popup-avec-jquery-dialog/ - Fin 
1126*/
1127
1128
1129
1130function Lib_JS_Def__Scroller_Jusqua_Ce_Id(Val_Id)
1131{//Theo : 08/07/2017. MAJ 27/04/2022.
1132  if(typeof Val_Id=='undefined') Val_Id=false;
1133  if (!Val_Id)return false;
1134  if (!document.getElementById(Val_Id)) return false;  
1135
1136  let Ch="#"+Val_Id;
1137  let Y=$(Ch).offset().top ;//Distance entre l'id et le haut de la page
1138  if(!Y) Y=0;//On force zero pour eviter undefined ou null ou autre
1139  window.scrollTo(0, Y);//On scroll en descendant, de la valeur de la distance
1140  return true;
1141}//function Lib_JS_Def__Scroller_Jusqua_Ce_Id(Val_Id)
1142
1143
1144
1145function Email__A_Une_Syntaxe_Valide(Email)
1146{
1147  //https://stackoverflow.com/questions/2507030/email-validation-using-jquery
1148
1149  if(!Email) return false;
1150  if(!Email.trim()) return false;
1151
1152  var EmailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;//V1 - //https://stackoverflow.com/questions/2507030/email-validation-using-jquery
1153      EmailReg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;//V2 : 18/01/2020 :: //https://stackoverflow.com/questions/2507030/email-validation-using-jquery
1154      
1155  var Ok = EmailReg.test(Email);
1156
1157  return Ok;
1158}
1159
1160function Email__Syntaxe_Valide(Email)
1161{
1162  return Email__A_Une_Syntaxe_Valide(Email);
1163}
1164
1165function Email__Syntaxe_InValide(Email)
1166{
1167  return !Email__Syntaxe_Valide(Email);
1168}
1169
1170function Email__Syntaxe_In_Valide(Email)
1171{
1172  return Email__Syntaxe_InValide(Email);
1173}
1174
1175
1176function Str__Accent_Off(Str)
1177{//23/01/2021 - Merci 1ere reponse :  https://stackoverflow.com/questions/5700636/using-javascript-to-perform-text-matches-with-without-accented-characters
1178  if(typeof(Str)=='undefined') return '';
1179  if(!Str.trim())
1180  {
1181    return '';
1182  }    
1183  return Str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');//Sans accent
1184}
1185
1186function Lib_JS__Ch_Date__Forcer_Format__Cplx(Ch_Dt,Forcer_En_JMA4__Bool)
1187{
1188  /*
1189  04/02/2021-Theo
1190    Accepte en entrée les dates sous la forme : 02/02/2004, 2-2-2004 avec des / ou -
1191    CF function verif_date(input)
1192  */
1193  
1194  if(!Ch_Dt)return false;
1195  Ch = Ch_Dt.trim();
1196  if(!Ch)return false;
1197  
1198  let Ch_Regex = new RegExp("[/-]");
1199  let Ch_Date = Ch.split(Ch_Regex);
1200  let Tab_Nb_Jours = new Array('',31,28,31,30,31,30,31,31,30,31,30,31);
1201  
1202  let I,J;
1203  
1204  if(Ch_Date[0].length==4)
1205  {
1206    //A4 M2 J2  doit etre transformé en J2 M2 A4
1207    I=Ch_Date[0];
1208    Ch_Date[0]=Ch_Date[2];
1209    Ch_Date[2]=I;
1210  }
1211    
1212  if ( Ch_Date['2']%4 == 0 && Ch_Date['2']%100 > 0 || Ch_Date['2']%400 == 0 )
1213  {
1214    Tab_Nb_Jours['2'] = 29;//Année bissextile
1215  }
1216
1217  if( isNaN(Ch_Date['2']) )
1218  {
1219    return false;
1220  }
1221
1222  if ( isNaN(Ch_Date['1']) || Ch_Date['1'] > 12 || Ch_Date['1'] < 1 ) return false;
1223  
1224  if ( isNaN(Ch_Date['0']) || Ch_Date['0'] > Tab_Nb_Jours[Math.round(Ch_Date['1'])] || Ch_Date['0'] < 1 ) return false;
1225  
1226  let Ch_Rps = Ch_Date['0'].padStart(2,'0')+'/'+Ch_Date['1'].padStart(2,'0')+'/'+Ch_Date['2'].padStart(4,'0');
1227  
1228  if(!Forcer_En_JMA4__Bool)
1229  {
1230    Ch_Rps = Ch_Date['2'].padStart(4,'0')+'-'+Ch_Date['1'].padStart(2,'0')+'-'+Ch_Date['0'].padStart(2,'0');
1231  }
1232  
1233  return Ch_Rps; 
1234}//function Lib_JS__Ch_Date__Forcer_Format__Cplx(Ch_Dt,Forcer_En_JMA4__Bool)
1235
1236function Lib_JS__Ch_Date__Forcer_Format__JMA4(Ch_Dt)
1237{
1238  return Lib_JS__Ch_Date__Forcer_Format__Cplx(Ch_Dt,true);
1239}//function Lib_JS__Ch_Date__Forcer_Format__JMA4(Ch_Dt)
1240
1241
1242function Lib_JS__Ch_Date__Forcer_Format__MySql(Ch_Dt)
1243{
1244  return Lib_JS__Ch_Date__Forcer_Format__Cplx(Ch_Dt,false);
1245}//function Lib_JS__Ch_Date__Forcer_Format__MySql(Ch_Dt)
1246
1247
1248function Lib_JS__Date__JMA4__Est_Valide(Ch_Dt_JMA4)
1249{
1250  /*
1251  04/02/2021-Theo
1252    Merci 
1253      https://stackoverflow.com/questions/5812220/how-to-validate-a-date
1254        1ere reponse
1255        Un moyen simple de valider une chaîne de date est de la convert
1255ir en objet date et de tester cela, par exemple
1256        Lorsque vous testez une date de cette façon, 
1257        seul le mois doit être testé car si la date est hors plage, 
1258        le mois changera. Idem si le mois est hors plage. 
1259        N'importe quelle année est valable.
1260  */
1261  
1262  if(!Ch_Dt_JMA4)return false;
1263  let Ch = Ch_Dt_JMA4.trim();  
1264  if(!Ch)return false;
1265  
1266  Ch = Lib_JS__Ch_Date__Forcer_Format__JMA4(Ch);
1267  if(!Ch) return false;
1268  
1269  let bits = Ch.split('/');
1270  let d = new Date(bits[2], bits[1] - 1, bits[0]);
1271  return d && (d.getMonth() + 1) == bits[1];  
1272}//Fin Fct ::: function Lib_JS__Date__JMA4__Est_Valide(Ch)
1273
1274
1275function Lib_JS__Date__MySql__Est_Valide(Ch_Dt_MySql)
1276{
1277  let Ch = Lib_JS__Ch_Date__Forcer_Format__JMA4(Ch_Dt_MySql);
1278  if(!Ch) return false;
1279  
1280  return Lib_JS__Date__JMA4__Est_Valide(Ch);
1281}//Fin Fct ::: function Lib_JS__Date__MySql__Est_Valide(Ch)
1282
1283
1284
1285function Lib_JS__DateTime_Local__En_Tab_MySql__Cplx(Ch_DtTm_Loc__Init)
1286{
1287  if(!Ch_DtTm_Loc__Init) return false;
1288  let Ch_DtTm_Loc=Ch_DtTm_Loc__Init.trim().toUpperCase();
1289  let L=Ch_DtTm_Loc.length;
1290  if(L==10) Ch_DtTm_Loc+='T00:00';
1291  L=Ch_DtTm_Loc.length;
1292  if(L<10 || L>19)return false;
1293  let Tab=Ch_DtTm_Loc.split('T')
1294  if(Tab.length!=2)
1295  {
1296    return false;
1297  }
1298  
1299  let Tab_Rsl={};
1300  
1301  Ch = Lib_JS__Ch_Date__Forcer_Format__MySql(Tab[0]);
1302  if(!Ch)return false;
1303  
1304  Tab_Rsl['MySql_Dt']=Ch;
1305  
1306  Ch = Tab[1];
1307  let Tab_Hr=Ch.split(':');
1308  let N=Tab_Hr.length;
1309  if(N<2 || N>3)
1310  {
1311    return false;
1312  }
1313  else
1314  if(N==2)
1315  {
1316    Tab_Rsl['Hr_HM']=Tab_Hr[0]+':'+Tab_Hr[1];
1317    Tab_Rsl['Hr_HMS']=Tab_Rsl['Hr_HM']+':00';
1318  }
1319  else
1320  {
1321    Tab_Rsl['Hr_HM']=Tab_Hr[0]+':'+Tab_Hr[1];
1322    Tab_Rsl['Hr_HMS']=Tab_Rsl['Hr_HM']+':'+Tab_Hr[2];
1323  }
1324  
1325  Tab_Rsl['MySql_DtHr']=Tab_Rsl['MySql_Dt']+' '+Tab_Rsl['Hr_HMS'];
1326  Tab_Rsl['MySql_DtHM']=Tab_Rsl['MySql_Dt']+' '+Tab_Rsl['Hr_HM'];
1327  return Tab_Rsl;
1328}//function Lib_JS__DateTime_Local__En_Tab_MySql__Cplx(Ch_DtTm_Loc__Init)
1329
1330function Lib_JS__DateTime_Local__En_MySql_DtHM(Ch_DtTm_Loc__Init)
1331{
1332  let Tab_Rsl=Lib_JS__DateTime_Local__En_Tab_MySql__Cplx(Ch_DtTm_Loc__Init);
1333  if(!Tab_Rsl)return false;
1334  return Tab_Rsl['MySql_DtHM'];
1335}//function Lib_JS__DateTime_Local__En_MySql_DtHM(Ch_DtTm_Loc__Init)
1336
1337
1338function Lib_JS__DateTime_Local__En_MySql_DtHr(Ch_DtTm_Loc__Init)
1339{
1340  let Tab_Rsl=Lib_JS__DateTime_Local__En_Tab_MySql__Cplx(Ch_DtTm_Loc__Init);
1341  if(!Tab_Rsl)return false;
1342  return Tab_Rsl['MySql_DtHr'];
1343}//function Lib_JS__DateTime_Local__En_MySql_DtHr(Ch_DtTm_Loc__Init)
1344
1345function Lib_JS__Donner__DtHr__Cplx(Tab_Param)
1346{
1347  if(typeof Tab_Param==='undefined')Tab_Param=[];
1348  let Chp='';
1349  Chp='Date_MySql';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=true;
1350  Chp='Que_Date';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=false;
1351  Chp='Que_Heure';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=false;
1352  Chp='Sec_Milli';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=false;
1353  Chp='Sec_Cent';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=false;
1354  Chp='Sec_Dix';if(typeof Tab_Param[Chp] ==='undefined')Tab_Param[Chp]=false;
1355  
1356  let Obj_Date=new Date();
1357  
1358  //https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Date  
1359  let Annee=Obj_Date.getFullYear();//Annee 4 chiffres. //Renvoie l'année (sans chiffre implicite, 1999 sera renvoyé et pas 99 par exemple) pour la date donnée, selon le temps local.
1360  let Num_Jour_De_La_Semaine=Obj_Date.getDay();//[0..6];//Renvoie le jour de la semaine (entre 0 et 6) pour la date donnée, selon le temps local.
1361  let Num_Du_Mois=Obj_Date.getMonth();//Renvoie le mois (entre 0 et 11) pour la date donnée, selon le temps local.
1362  let Num_Jr_Du_Mois=Obj_Date.getDate();//Renvoie le jour du mois (entre 1 et 31) pour la date donnée, selon le temps local.
1363  let Num_Hr=Obj_Date.getHours();//Renvoie l'heure (entre 0 et 23) pour la date donnée, selon le temps local.
1364  let Num_Mn=Obj_Date.getMinutes();//Renvoie les minutes (entre 0 et 59) pour la date donnée, selon le temps local.
1365  let Num_Sec=Obj_Date.getSeconds();//Renvoie les secondes (entre 0 et 59) pour la date donnée, selon le temps local.
1366  let Num_MilliSec=Obj_Date.getMilliseconds();//Renvoie les millisecondes (entre 0 et 999) pour la date donnée, selon le temps local.
1367  let Dt_M2=(Num_Du_Mois+1).toString().padStart(2,'0');
1368  let Dt_J2=Num_Jr_Du_Mois.toString().padStart(2,'0');
1369  
1370  let Ch_Dt='';
1371  if(Tab_Param['Date_MySql'])
1372  {
1373    Ch_Dt=Annee+'-'+Dt_M2+'-'+Dt_J2;
1374  }
1375  else
1376  {
1377    Ch_Dt=Dt_J2+'/'+Dt_M2+'/'+Annee;
1378  }
1379  if(Tab_Param['Que_Date'])
1380  {
1381    return Ch_Dt;
1382  }
1383  
1384  let Ch_Hr_HMS=Num_Hr.toString().padStart(2,'0')+':'+Num_Mn.toString().padStart(2,'0')+':'+Num_Sec.toString().padStart(2,'0');
1385  
1386  if(Tab_Param['Que_Heure'])
1387  {
1388    return Ch_Hr_HMS;
1389  }
1390  
1391  return Ch_Dt+' '+Ch_Hr_HMS;
1392}//function Lib_JS__Donner__DtHr__Cplx(Tab_Param)
1393
1394function Lib_JS__Donner__DtHr__MySql(Tab_Param)
1395{
1396  if(typeof Tab_Param==='undefined')Tab_Param=[];
1397  Tab_Param['Date_MySql']=true;
1398  Tab_Param['Que_Date']=false;
1399  Tab_Param['Que_Heure']=false;
1400  return Lib_JS__Donner__DtHr__Cplx(Tab_Param);
1401}//function Lib_JS__Donner__DtHr__MySql(Tab_Param)
1402  
1403function Lib_JS__Donner__DtHr__JMA_HMS(Tab_Param)
1404{
1405  if(typeof Tab_Param==='undefined')Tab_Param=[];
1406  Tab_Param['Date_MySql']=false;
1407  Tab_Param['Que_Date']=false;
1408  Tab_Param['Que_Heure']=false;
1409  return Lib_JS__Donner__DtHr__Cplx(Tab_Param);
1410}//function Lib_JS__Donner__DtHr__MySql(Tab_Param)
1411  
1412
1413function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Cplx(X,Entier,Nbr_Apres_Virg)
1414{
1415  if(typeof X === 'undefined')X=0;
1416  if(typeof Nbr_Apres_Virg === 'undefined')Nbr_Apres_Virg=0;
1417  if(typeof Entier === 'undefined')Entier=true;
1418  
1419  if(!Entier && Nbr_Apres_Virg>0)
1420  {
1421    //Reel
1422    X = X.toString().replace(',','.');
1423  }
1424  let Nbr = Number(X);
1425  if(isNaN(Nbr) || !isFinite(Nbr)  )
1426  {
1427    Nbr = 0;
1428  }
1429  
1430  if(Entier || Nbr_Apres_Virg<1)
1431  {
1432    Nbr = Nbr | 0;//L'opérateur pipe simple(=bit-à-bit) force la conversion en entier.
1433    //Nbr=parseInt(Nbr,10);//Marche aussi
1434  }
1435  else
1436  {
1437    Nbr=Nbr.toFixed(Nbr_Apres_Virg);
1438  }
1439  return Nbr;
1440}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Cplx(X,Entier,Nbr_Apres_Virg)
1441
1442function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Reel(X,Nbr_Apres_Virg)
1443{
1444  return Lib_JS__Nbr__Transformer_Ch_En_Nombre__Cplx(X,false,Nbr_Apres_Virg);
1445}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Reel(X,Nbr_Apres_Virg)
1446
1447function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Integer(X)
1448{
1449  return Lib_JS__Nbr__Transformer_Ch_En_Nombre__Cplx(X,true,0);
1450}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Integer(X)
1451
1452function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Int(X)
1453{
1454  return Lib_JS__Nbr__Transformer_Ch_En_Nombre__Integer(X);
1455}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Int(X)
1456
1457function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Entier(X)
1458{
1459  return Lib_JS__Nbr__Transformer_Ch_En_Nombre__Integer(X);
1460}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Entier(X)
1461
1462function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Ent(X)
1463{
1464  return Lib_JS__Nbr__Transformer_Ch_En_Nombre__Integer(X);
1465}//function Lib_JS__Nbr__Transformer_Ch_En_Nombre__Ent(X)
1466
1467function Lib_JS__Nbr__Str_Pad(Nbr,Lg,Str)
1468{
1469  if(typeof Nbr === 'undefined')return false;
1470  if(typeof Lg === 'undefined')Lg=2;
1471  if(typeof Str === 'undefined')Str='0';
1472  let N=Number(Nbr);
1473  if(isNaN(N) || !isFinite(N))
1474  {
1475    N = 0;
1476  }
1477  
1478  N = N | 0;//L'opérateur pipe simple(=bit-à-bit) force la conversion en entier.
1479  
1480  return N.toString().padStart(Lg,Str);
1481}//function Lib_JS__Nbr__Str_Pad(Nbr,Lg,Str)
1482
1483function Lib_JS__EscapeHtml_V1(Txt)
1484{
1485  //https://stackoverflow.com/questions/1787322/what-is-the-htmlspecialchars-equivalent-in-javascript
1486  return Txt
1487      .replace(/&/g, "&amp;")
1488      .replace(/</g, "&lt;")
1489      .replace(/>/g, "&gt;")
1490      .replace(/"/g, "&quot;")
1491      .replace(/'/g, "&#039;");
1492}
1493
1494
1495function Lib_JS__EscapeHtml_V2(Txt)
1496{
1497  //https://stackoverflow.com/questions/1787322/what-is-the-htmlspecialchars-equivalent-in-javascript
1498  //Plus rapide que V1 sur des gros gros texte
1499  let map = {
1500    '&': '&amp;',
1501    '<': '&lt;',
1502    '>': '&gt;',
1503    '"': '&quot;',
1504    "'": '&#039;'
1505  };
1506
1507  return Txt.replace(/[&<>"']/g, function(m) { return map[m]; });
1508}
1509
1510
1511function Lib_JS__EscapeHtml(Txt)
1512{
1513  return Lib_JS__EscapeHtml_V2(Txt);
1514}
1515
1516function Lib_JS__HtmlSpecialChars(Txt)
1517{
1518  return Lib_JS__EscapeHtml(Txt);
1519}//function Lib_JS__HtmlSpecialChars(Txt)
1520
1521function Lib_JS__Ce_Id_Existe(Id)
1522{
1523  if(typeof Id=='undefined')
1524  {
1525    return false;
1526  }//if(typeof Id=='undefined')
1527    
1528  if (!Id)return false;
1529  
1530  return document.getElementById(Id);
1531}//function Lib_JS__Ce_Id_Existe(Id)
1532
1533
1534function Lib_JS__Formulaire__Donner_Tab_Couples_Id_Val(Form_Id)
1535{
1536  /*
1537  faut recuperer les valeurs des inputs du formulaire et les retourner
1538  Nouveau nom depuis 11/02/2023
1539  Ancien nom existe toujours opour alias (retro compatibilité) : Lib_JS__Donner_Tab_Couples_Id_Val(Form_Id)
1540  */
1541  
1542  if(typeof Form_Id=='undefined')
1543  {
1544    return false;
1545  }//if(typeof Form_Id=='undefined')
1546    
1547  if(Form_Id===false)
1548  {
1549    return false;
1550  }//if(Form_Id===false)
1551  
1552  let Obj_Form = document.getElementById(Form_Id);
1553
1554  if(!Obj_Form)
1555  {
1556    return false;
1557  }
1558
1559  //https://www.developpez.net/forums/d384620/javascript/general-javascript/recuperer-id-d-page/
1560  let LesId = Obj_Form.querySelectorAll("[id]");//Retourne une nodeList : pas un array !!!        
1561
1562  let Ch,C,S;
1563  let N=0;
1564
1565  let Nom,LeId,Val,J,Lib,Rqr,Disa;
1566
1567  let Info_A_Controler_Dja_Pris_En_Compte = false;
1568
1569  let Tab_Couple_Id_Val = {};
1570
1571  let Ch_Csv_Virg_Des_Id_Lic_Acceptees='';
1572
1573  for ( let [ Index, Obj_X ] of Array.from( LesId ).entries() )//gestion des elements de la nodeListe(on les transtye en Array() )
1574  {
1575    N++;
1576    //console.log('N='+N,'Index='+Index,'Obj_X='+Obj_X,' *** [FIN] ***');
1577    Typ = Obj_X.type;
1578    Nom = Obj_X.name;
1579    LeId = Obj_X.id;
1580    Val = Obj_X.value;                
1581    Rqr = Obj_X.required;
1582    Disa = Obj_X.disabled;
1583    Ch = "Typ='"+Typ+"'. Nom='"+Nom+"'. LeId='"+LeId+"'.Val='"+Val+"'. Rqr='"+Rqr+"'. Disa='"+Disa+"'.";
1584    //console.log('N='+N,Ch,' *****');
1585
1586    if(LeId)
1587    {
1588      if(Val=='undefined')Val='';
1589      Tab_Couple_Id_Val[LeId] = Val;        
1590    }
1591  }//for ( let [ Index, Obj_X ] of Array.from( LesId ).entries() )//getsion des elements de la nodeListe
1592
1593  return Tab_Couple_Id_Val;      
1594}//function Lib_JS__Formulaire__Donner_Tab_Couples_Id_Val(Form_Id)
1595
1596function Lib_JS__Donner_Tab_Couples_Id_Val(Form_Id)
1597{//Alias pour compatibilité avec anciens appels
1598  return Lib_JS__Formulaire__Donner_Tab_Couples_Id_Val(Form_Id);//Nouveau nom depuis 11/02/2023
1599}//function Lib_JS__Donner_Tab_Couples_Id_Val(Form_Id)
1600
1601function Lib_JS_Def__Scroller_Vers_Ce_Id(Val_Id)
1602{
1603  return Lib_JS_Def__Scroller_Jusqua_Ce_Id(Val_Id);
1604}//function Lib_JS_Def__Scroller_Vers_Ce_Id(Val_Id)
1605
1606
1607function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Cplx(Msg,Typ_Box,Class,Close_Bool,Param)
1608{ 
1609  /*  
1610  ,Typ_Box//label, span, div
1611  ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1612  */
1613  if( typeof(Msg) == 'undefined' )
1614  {
1615    return '';
1616  }
1617    
1618  if( typeof(Typ_Box) == 'undefined' )
1619  {
1620    Typ_Box = '';
1621  }
1622  Typ_Box = Typ_Box.trim();
1623  
1624  if( typeof(Class) == 'undefined' )
1625  {
1626    Class = '';
1627  }
1628  Class = Class.trim();
1629  
1630  if( typeof(Close_Bool) == 'undefined' )
1631  {
1632    Close_Bool = false;
1633  }
1634  
1635  if( typeof(Param) == 'undefined' )
1636  {
1637    Param = new Array();
1638  }
1639  
1640  if(Typ_Box!='div' && Typ_Box!='label' && Typ_Box!='small' && Typ_Box!='span') Typ_Box='label';
1641  if(Msg.indexOf('<li>')!==false || Msg.indexOf('<li ')!==false)
1642  {
1643    if(Typ_Box!='div')
1644    {
1645      //span et label ne s'affichent pas bien qd il y a <li>
1646      Typ_Box = 'div';
1647    }
1648  }
1649  if(!Class) Class="info";
1650  //alert-success alert-danger alert-warning alert-infos
1651  Ch = '<'+Typ_Box
1652    +' class=" alert alert-'+Class+' alert-dismissable " ';
1653  C="id";if(typeof(Param[C])!='undefined' && Param[C]) Ch += ' '+C+'="'+Param[C]+'" ';
1654  C="style";if(typeof(Param[C])!='undefined' && Param[C]) Ch += ' '+C+'="'+Param[C]+'" ';
1655  Ch += '>';
1656  
1657  Chp='Close_Via_JS';if(typeof(Param[C])=='undefined')Param[Chp]=false;
1658  
1659  if(Close_Bool)
1660  {
1661    if(Param['Close_Via_JS'])
1662    {
1663      Ch += '<a href="#" class="Close_Via_JS" onclick="(this).parent().hide();">X</a>';//On peut fermer, reafficher et reffermer X fois : exemple Modale pour envoyer email : modules/popup/Popup_Modal_Envoy_Mail... : au 31/03/2022
1664    }
1665    else      
1666    {
1667      Ch += '<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>';
1668    }
1669  }
1670  Ch += Msg+'</'+Typ_Box+'>';
1671  return Ch;
1672}//function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Cplx(Msg,Typ_Box,Class,Close_Bool,Param)
1673
1674function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert(Msg
1675  ,Typ_Box//div ou label
1676  ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1677  ,Close_Bool
1678  ,Param)
1679{
1680  return Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Cplx(Msg,Typ_Box,Class,Close_Bool,Param);
1681}
1682
1683function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Fermable(Msg
1684  ,Typ_Box//div ou label
1685  ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1686  ,Param)
1687{
1688  return Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert(Msg
1689    ,Typ_Box//div ou label
1690    ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1691    ,true
1692    ,Param);
1693}
1694
1695function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Fermable__Via_JS(Msg
1696  ,Typ_Box//div ou label
1697  ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1698  ,Param)
1699{
1700  if( typeof(Param) == 'undefined' )
1701  {
1702    Param = new Array();
1703  }
1704  
1705  Param['Close_Via_JS']=true;
1706  return Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert(Msg
1707    ,Typ_Box//div ou label
1708    ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1709    ,true
1710    ,Param);
1711}
1712
1713function Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert_Non_Fermable(Msg
1714  ,Typ_Box//div ou label
1715  ,Class//success ou warning,..  on peut aussi faire associat° : danger Txt_15Px
1716  ,Param=false)
1717{
1718  return Lib_JS__Bootstrap__Encapsuler_Msg_Pour_Alert(Msg,Typ_Box,Class,false,Param);
1719}
1720
1721
1722function Lib_JS__Attendre__Asynchrone__Via__SetTimeOut(Duree_En_MilliSec)
1723{//https://www.delftstack.com/fr/howto/javascript/javascript-wait-for-x-seconds/ : 1/3
1724
1725  let DtHr_Deb = new Date().getTime();
1726  let DtHr_Fin = Duree = 0;
1727  
1728  if(typeof Duree_En_MilliSec == 'undefined')return false;
1729  
1730  Duree_En_MilliSec=Lib_JS__Nbr__Transformer_Ch_En_Nombre__Entier(Duree_En_MilliSec);
1731  if(Duree_En_MilliSec<1)return false;
1732  
1733  let Nom_Fct='Lib_JS__Attendre__Asynchrone__Via__SetTimeOut';
1734  
1735  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Début de l'attente");
1736  setTimeout(function(){console.log(Nom_Fct+"::L'attente de '"+Duree_En_MilliSec+"' msec est terminée");},Duree_En_MilliSec);
1737  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Fin de l'attente");
1738  
1739  DtHr_Fin = new Date().getTime();
1740  Duree = DtHr_Fin-DtHr_Deb;
1741  
1742  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Terminée en '"+Duree+"' msec.");
1743  
1744  return Duree;
1745}//function Lib_JS__Attendre__Asynchrone__Via__SetTimeOut(Duree_En_MilliSec)
1746  
1747
1748function Lib_JS__Attendre__Asynchrone__Via__Promise_Et_Async_Await(Duree_En_MilliSec)
1749{//https://www.delftstack.com/fr/howto/javascript/javascript-wait-for-x-seconds/ : 2/3
1750  /*
1751  Une méthode pour mettre en œuvre la fonction de délai dans le contexte asynchrone 
1752  consiste à combiner le concept async/await et le concept promises. 
1753  Nous pouvons créer une fonction de délai qui retourne une nouvelle promises à l’intérieur, 
1754  que nous appellerons la méthode setTimeout() avec le temps d’attente souhaité. 
1755  Ensuite, nous pouvons appeler cette fonction delay dans le contexte asynchrone de notre choix.
1756  
1757  A ce jour : 10/06/2022 je ne comprends pas comment cela fonctionne
1758  */
1759  
1760  let DtHr_Deb = new Date().getTime();
1761  let DtHr_Fin = Duree = 0;
1762  
1763  if(typeof Duree_En_MilliSec == 'undefined')return false;
1764  
1765  Duree_En_MilliSec=Lib_JS__Nbr__Transformer_Ch_En_Nombre__Entier(Duree_En_MilliSec);
1766  if(Duree_En_MilliSec<1)return false;
1767  
1768  let Nom_Fct='Lib_JS__Attendre__Asynchrone__Via__Promise_Et_Async_Await';
1769  
1770  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée.");
1771  
1772  function Sous_Fct_JS_ICI__delay(Duree_En_MilliSec)
1773  {
1774    return new Promise(function(resolve)
1775    {
1776      setTimeout(resolve,Duree_En_MilliSec);
1777    });
1778  }//function Sous_Fct_JS_ICI__delay(n)
1779  
1780  async function Sous_Fct_JS_ICI__myAsyncFunction(Duree_En_MilliSec)
1781  {
1782    //Do what you want here 
1783    let Nom_Fct_2=Nom_Fct+':-:Sous_Fct_JS_ICI__myAsyncFunction';    
1784    
1785    console.log(Nom_Fct_2+"::Avant attente de '"+Duree_En_MilliSec+"' msec demandée.");
1786
1787    await Sous_Fct_JS_ICI__delay(Duree_En_MilliSec);
1788
1789    console.log(Nom_Fct_2+"::Apres attente de '"+Duree_En_MilliSec+"' msec demandée.");
1790    //Do what you want here too
1791
1792    /*
1793    La fonction de délai peut également être optimisée en utilisant la syntaxe des flèches 
1794    dans l’ECMAScript 6, comme dans l’exemple suivant : 
1795    const delay = (n) => new Promise( r => setTimeout(r, n*1000));
1796    */
1797
1798  }//function Sous_Fct_JS_ICI__myAsyncFunction()
1799  
1800  Sous_Fct_JS_ICI__myAsyncFunction(Duree_En_MilliSec);  
1801  
1802  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Fin de l'attente");
1803  
1804  DtHr_Fin = new Date().getTime();
1805  Duree = DtHr_Fin-DtHr_Deb;
1806  
1807  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Terminée en '"+Duree+"' msec.");
1808  
1809  return Duree;
1810}//function Lib_JS__Attendre__Asynchrone__Via__Promise_Et_Async_Await(Duree_En_MilliSec)
1811
1812
1813function Lib_JS__Attendre__Synchrone__Via__Boucle_Et_Classe_Date(Duree_En_MilliSec)
1814{//https://www.delftstack.com/fr/howto/javascript/javascript-wait-for-x-seconds/ : 3/3
1815  /*
1816  Utiliser une boucle (while/for) pour implémenter la fonction delay synchrone en JavaScript
1817  Supposons que nous n’avons pas de contexte asynchrone pour utiliser la fonction delay() 
1818  ci-dessus ou que nous ne voulons pas utiliser la fonction setTimeout(). 
1819  Dans ce cas, nous pouvons implémenter une fonction de délai synchrone avec 
1820  une boucle for normale et la classe Date() pour calculer le temps.
1821
1822  L’implémentation de cette fonction est assez simple. 
1823  Il s’agit de maintenir le CPU occupé pendant la durée souhaitée. 
1824  Cela se fait en calculant le temps écoulé et en le comparant au temps d’attente 
1825  afin de pouvoir continuer l’exécution après celui-ci.
1826  */
1827  
1828  let DtHr_Deb = new Date().getTime();
1829  let DtHr_Fin = Duree = 0;
1830  
1831  if(typeof Duree_En_MilliSec == 'undefined')return false;
1832  
1833  Duree_En_MilliSec=Lib_JS__Nbr__Transformer_Ch_En_Nombre__Entier(Duree_En_MilliSec);
1834  if(Duree_En_MilliSec<1)return false;
1835  
1836  let Nom_Fct='Lib_JS__Attendre__Synchrone__Via__Boucle_Et_Classe_Date';
1837  
1838  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée.");
1839  
1840  let start = new Date().getTime();
1841  let end=0;
1842  while( (end-start) < Duree_En_MilliSec)
1843  {
1844    end = new Date().getTime();
1845  }//while( (end-start) < Duree_En_MilliSec)
1846  
1847  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Fin de l'attente");
1848  
1849  DtHr_Fin = new Date().getTime();
1850  Duree = DtHr_Fin-DtHr_Deb;
1851  
1852  console.log(Nom_Fct+"::Attente de '"+Duree_En_MilliSec+"' msec demandée. Terminée en '"+Duree+"' msec."); 
1853  
1854  return Duree;
1855}//function Lib_JS__Attendre__Synchrone__Via__Boucle_Et_Classe_Date(Duree_En_MilliSec)
1856
1857function Lib_JS__Attendre__Synchrone(Duree_En_MilliSec)
1858{
1859  return Lib_JS__Attendre__Synchrone__Via__Boucle_Et_Classe_Date(Duree_En_MilliSec);
1860}//function Lib_JS__Attendre__Synchrone(Duree_En_MilliSec)
1861
1862function Lib_JS__Attendre__ASynchrone_V01(Duree_En_MilliSec)
1863{
1864  return Lib_JS__Attendre__Asynchrone__Via__SetTimeOut(Duree_En_MilliSec);//tres simple
1865}//function Lib_JS__Attendre__ASynchrone_V01(Duree_En_MilliSec)
1866
1867function Lib_JS__Attendre__ASynchrone_V02(Duree_En_MilliSec)
1868{
1869  return Lib_JS__Attendre__Asynchrone__Via__Promise_Et_Async_Await(Duree_En_MilliSec);
1870}//function Lib_JS__Attendre__ASynchrone_V02(Duree_En_MilliSec)
1871
1872
1873function Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__Obj_JS_Script(Id_Conteneur,Str_Cod_JS)
1874{
1875  if(typeof Id_Conteneur=='undefined') return false;
1876  if(typeof Str_Cod_JS=='undefined') return false;
1877  
1878  if(!Id_Conteneur) return false;
1879  if(!Str_Cod_JS) return false;
1880  if(!document.getElementById(Id_Conteneur))return false;
1881  
1882  //Merci https://stackoverflow.com/questions/3418041/add-javascript-into-a-html-page-with-jquery
1883  let Obj_JS__Script = document.createElement("script");
1884  Obj_JS__Script.type= "text/javascript";
1885  // We have to use .text for IE, .textContent for standards compliance.
1886  
1887  if ("textContent" in Obj_JS__Script)
1888  {
1889    Obj_JS__Script.textContent = Str_Cod_JS;
1890  }
1891  else
1892  {
1893    Obj_JS__Script.text = Str_Cod_JS;
1894  }
1895
1896  // Finally, insert the script element into the div
1897  console.log("Fct='Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__Obj_JS_Script'. Id_Conteneur=",Id_Conteneur);
1898  console.log('Obj_JS__Script=',Obj_JS__Script);
1899  //console.log('Obj_JS__Script.text=',Obj_JS__Script.text);
1900  document.getElementById(Id_Conteneur).appendChild(Obj_JS__Script);
1901  //Merci https://stackoverflow.com/questions/3418041/add-javascript-into-a-html-page-with-jquery
1902  return true;
1903}//function Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__Obj_JS_Script(Id_Conteneur,Str_Cod_JS)
1904
1905
1906function Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__JQry_Html(Id_Conteneur,Str_Cod_JS)
1907{
1908  if(typeof Id_Conteneur=='undefined') return false;
1909  if(typeof Str_Cod_JS=='undefined') return false;
1910  
1911  if(!Id_Conteneur) return false;
1912  if(!Str_Cod_JS) return false;
1913  if(!document.getElementById(Id_Conteneur))return false;
1914  
1915  console.log("Fct='Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__JQry_Html'. Id_Conteneur=",Id_Conteneur);
1916  console.log('Str_Cod_JS=',Str_Cod_JS);
1917  
1918  //20/06/2022. Initialement dans le code Js pour que Org controle Doc AM.
1919  //J'ignore d'où il vient  
1920  $('#'+Id_Conteneur).html("\<script\>"+Str_Cod_JS+"\</script\>");//Faut "echapper" les chevrons.
1921  return true;
1922}//function Lib_JS__Utiliser_Le_Conteneur_De_Ce_Id_Pour_Injecter_Code_JS__Via__JQry_Html(Id_Conteneur,Str_Cod_JS)
1923
1924
1925function Lib_JS__Executer_La_Fonction_Representee_Par_Cette_Variable(Nom_Fct)
1926{
1927  if(typeof Nom_Fct=='undefined') return false;
1928  if(!Nom_Fct) return false;
1929  
1930  if(window[Nom_Fct])
1931  {//Toutes les fonctions sont des attributs de l'objet window.
1932    if(typeof(window[Nom_Fct])=='function')
1933    {
1934      //Mettre le nom de la fonction dans une variable, et utiliser la variale pour appeler la fonction
1935      //https://forum.hardware.fr/hfr/Programmation/HTML-CSS-Javascript/js-executer-fonction-sujet_102144_1.htm
1936      return window[Nom_Fct]();
1937      //https://www.pierre-giraud.com/javascript-apprendre-coder-cours/fonction-anonyme-auto-invoquee-recursive/
1938    }//if(typeof(window[Nom_Fct])=='function')
1939  }//if(window[Nom_Fct])
1940}//function Lib_JS__Executer_La_Fonction_Representee_Par_Cette_Variable(Nom_Fct)
1941
1942
1943function Lib_JS__Autocomplete_Off__Pour_Ce_Id(Id)
1944{
1945  if(typeof Id=='undefined') return false;
1946  if(!Id) return false;
1947  if(!document.getElementById(Id))return false;
1948  
1949  document.getElementById(Id).setAttribute( "autocomplete", "off" );
1950}//function Lib_JS__Autocomplete_Off__Pour_Ce_Id(Id)
1951
1952function Lib_JS__Doit_Contenir_Que_Certains_Caracteres__Cplx(Ch_A_Nettoyer,Ch_Krctr_Ok,Ch_Krctr_Ko,Param)
1953{
1954  if(typeof(Param)=='undefined') Param=[];
1955  if(typeof(Ch_A_Nettoyer)=='undefined') return '';
1956  //Ch_A_Nettoyer=Ch_A_Nettoyer.trim();//Surtout pas de trim !!!
1957  if(!Ch_A_Nettoyer) return '';
1958  let Ch_A_Nettoyer_Init = Ch_A_Nettoyer;
1959  
1960  if(typeof(Ch_Krctr_Ok)=='undefined') Ch_Krctr_Ok='';
1961  //Ch_Krctr_Ok=Ch_Krctr_Ok.trim();//Surtout pas de trim !!!
1962  
1963  if(typeof(Ch_Krctr_Ko)=='undefined') Ch_Krctr_Ko='';
1964  //Ch_Krctr_Ko=Ch_Krctr_Ko.trim();//Surtout pas de trim !!!
1965  
1966  
1967  let Ch_Propre='';
1968  let I,J,L,L_Ok,L_Ko,P_Ok,P_Ko,K,N;
1969    
1970  let Kr='';
1971  
1972  let Chp='';
1973  
1974  Chp='Accent_Ok';
1975  if(Param.indexOf(Chp)<0) Param[Chp]=false;
1976  if(!Param[Chp])
1977  {
1978    Ch_A_Nettoyer=Str__Accent_Off(Ch_A_Nettoyer);
1979    Ch_Krctr_Ok=Str__Accent_Off(Ch_Krctr_Ok);
1980    Ch_Krctr_Ko=Str__Accent_Off(Ch_Krctr_Ko);
1981  }
1982  
1983  Chp='MINUS';
1984  if(Param.indexOf(Chp)<0) Param[Chp]=false;
1985  if(Param[Chp])
1986  {
1987    Ch_A_Nettoyer=Ch_A_Nettoyer.toLowerCase();
1988    Ch_Krctr_Ok=Ch_Krctr_Ok.toLowerCase();
1989    Ch_Krctr_Ko=Ch_Krctr_Ko.toLowerCase();
1990  }
1991  Chp='MAJUS';
1992  if(Param.indexOf(Chp)<0) Param[Chp]=false;
1993  if(Param[Chp])
1994  {
1995    Ch_A_Nettoyer=Ch_A_Nettoyer.toUpperCase();
1996    Ch_Krctr_Ok=Ch_Krctr_Ok.toUpperCase();
1997    Ch_Krctr_Ko=Ch_Krctr_Ko.toUpperCase();
1998  }
1999  
2000  L=Ch_A_Nettoyer.length;
2001  L_Ok=Ch_Krctr_Ok.length;
2002  L_Ko=Ch_Krctr_Ko.length;
2003  
2004  for(I=0;I<L;I++)
2005  {
2006    Kr=Ch_A_Nettoyer[I];
2007    
2008    if(L_Ok<1)
2009    {
2010      P_Ok=1;
2011    }
2012    else
2013    {
2014      P_Ok=Ch_Krctr_Ok.indexOf(Kr);
2015    }
2016    
2017    if(L_Ko<1)
2018    {
2019      P_Ko=-1;
2020    }
2021    else
2022    {    
2023      P_Ko=Ch_Krctr_Ko.indexOf(Kr);
2024    }
2025    
2026    if( (P_Ok>=0) && (P_Ko<0) )
2027    {
2028      Ch_Propre =Ch_Propre+Kr;
2029    }
2030  }//for(I=0;I<L;I++)
2031  return Ch_Propre;
2032}//function Lib_JS__Doit_Contenir_Que_Certains_Caracteres__Cplx(Ch_A_Nettoyer,Ch_Krctr_Ok,Ch_Krctr_Ko,Param)
2033
2034function Lib_JS__Doit_Contenir_Que_Alpha_Num__Cplx(Ch_A_Nettoyer,Autres_Carac_Ok,Param)
2035{
2036  if(typeof(Ch_A_Nettoyer)=='undefined') return '';
2037  if(typeof(Param)=='undefined') Param=[];
2038  if(typeof(Autres_Carac_Ok)=='undefined') Autres_Carac_Ok='';
2039  
2040  let Chp='';
2041  
2042  let Ch_Alphab_Minus='abcdefghijklmnopqrstuvwxyz';
2043  let Ch_Alphab_Majus=Ch_Alphab_Minus.toUpperCase();
2044  let Ch_Numeric='0123456789';
2045  let Ch_Alpha_Num=Ch_Alphab_Minus+Ch_Alphab_Majus+Ch_Numeric;
2046  
2047  Chp='Accent_Ok';
2048  if(Param.indexOf(Chp)<0)
2049  {
2050    Param[Chp]=false;
2051  }
2052  
2053  Chp='MINUS';
2054  if(Param.indexOf(Chp)<0)
2055  {
2056    Param[Chp]=true;
2057  }
2058  Chp='MAJUS';
2059  if(Param.indexOf(Chp)<0)
2060  {
2061    Param[Chp]=false;
2062  }
2063  
2064  return Lib_JS__Doit_Contenir_Que_Certains_Caracteres__Cplx(Ch_A_Nettoyer,Ch_Alpha_Num+Autres_Carac_Ok,'',Param);
2065}//function Lib_JS__Doit_Contenir_Que_Alpha_Num__Cplx(Ch_A_Nettoyer,Autres_Carac_Ok,Param)
2066
2067function Lib_JS__Doit_Contenir_Que_Alpha_Num(Ch_A_Nettoyer,Param)
2068{
2069  return Lib_JS__Doit_Contenir_Que_Alpha_Num__Cplx(Ch_A_Nettoyer,Param);
2070}//function Lib_JS__Doit_Contenir_Que_Alpha_Num(Ch_A_Nettoyer,Param)
2071
2072
2073function Lib_JS__Enlever_Mots_Insignifiants_De_Cette_Chaine(Ch_A_Nettoyer,Tab_Param)
2074{
2075  if(typeof(Ch_A_Nettoyer)=='undefined') return '';
2076  if(!Ch_A_Nettoyer) return '';
2077  Ch_A_Nettoyer_Init = Ch_A_Nettoyer;
2078  
2079  if(typeof(Tab_Param)=='undefined') Tab_Param=[];
2080  
2081  Ch_A_Nettoyer = Ch_A_Nettoyer.replace(":"," ");
2082  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("`","'");
2083  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("'"," ");
2084  Ch_A_Nettoyer = Ch_A_Nettoyer.replace('"'," ");
2085  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("."," ");
2086  Ch_A_Nettoyer = Ch_A_Nettoyer.replace(","," ");
2087  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("-"," ");
2088  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("_"," ");
2089  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("/"," ");
2090  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("\\"," ");  
2091  
2092  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("   "," ");
2093  Ch_A_Nettoyer = Ch_A_Nettoyer.replace("  "," ");
2094  
2095  Ch_A_Nettoyer = Str__Accent_Off(Ch_A_Nettoyer);//Trim surtout pas !!!!
2096  if(!Ch_A_Nettoyer) return '';
2097  
2098  let Tab_Mots_Insignifiants = ["A","AU","AUX","DE","DES","DU","LE","LA","LES","UN","UNE","L'","D'","C'","S'","M'","N'","T'", "OU" ,'ET' , "EN","DANS"];
2099  let T = ['L','D','C','S','M','N','T'];//Quand le systeme aura enlevé les ' (apostrophes) C' deviendra C. c'est pour cela qu'il faut enlever les lettres seules
2100  let Tab_Ponctuation = [":",".",",","'",'"',"-","_","/","\\","`",'!','?'];
2101  //console.log('Tab_Mots_Insignifiants='+Tab_Mots_Insignifiants);
2102  
2103  Tab_Mots_Insignifiants = Tab_Mots_Insignifiants.concat(T);
2104  //console.log('Tab_Mots_Insignifiants='+Tab_Mots_Insignifiants);
2105  
2106  Tab_Mots_Insignifiants = Tab_Mots_Insignifiants.concat(Tab_Ponctuation);
2107  //console.log('Tab_Mots_Insignifiants='+Tab_Mots_Insignifiants);
2108  
2109  let Chp='Tab_Autres_Mots_A_Ignorer';if(typeof(Tab_Param[Chp])=='undefined')Tab_Param[Chp]=false;
2110  
2111  let T_Ch_A_Nettoyer = Ch_A_Nettoyer.split(' ');
2112  
2113  //console.log('Ch_A_Nettoyer='+Ch_A_Nettoyer);
2114  //console.log('T_Ch_A_Nettoyer='+T_Ch_A_Nettoyer);
2115  
2116  let Ch_Rps = "";
2117  let R,R_Up,R_Low;
2118  let Val='';
2119  
2120  for(let ChpX in T_Ch_A_Nettoyer)
2121  {
2122    Val = T_Ch_A_Nettoyer[ChpX];  
2123      
2124    R = Tab_Mots_Insignifiants.indexOf(Val);
2125    R_Up = Tab_Mots_Insignifiants.indexOf(Val.toUpperCase());
2126    R_Low = Tab_Mots_Insignifiants.indexOf(Val.toLowerCase());
2127    
2128    if(R==-1 && R_Up==-1 && R_Low==-1)
2129    {//Val est Ok, faut l'accepter et le prendre en compte
2130      if(Ch_Rps)
2131      {
2132        Ch_Rps = Ch_Rps+' '+Val;
2133      }
2134      else
2135      {
2136        Ch_Rps = Val;
2137      }
2138    }//if(R==-1 && R_Up==-1 && R_Low==-1)
2139  }//for(let ChpX in T_Ch_A_Nettoyer)
2140    
2141  Ch_Rps = Lib_JS__Doit_Contenir_Que_Alpha_Num__Cplx(Ch_Rps,' ');
2142
2143  return Ch_Rps;
2144}//function Lib_JS__Enlever_Mots_Insignifiants_De_Cette_Chaine(Ch_A_Nettoyer,Tab_Param)
2145
2146
2147function Lib_JS__JQry__Element_Avec_Ce_Id_Existe(Id)
2148{//https://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-exists/
2149  if(typeof Id=='undefined') return false;
2150  if (!Id)return false;  
2151  //if (!document.getElementById(Id)) return false;
2152  if ( $('#'+Id).length ) 
2153  {//https://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-exists/
2154    return true;
2155  }
2156  return false;
2157}//function Lib_JS__JQry__Element_Avec_Ce_Id_Existe(Id)
2158
2159
2160function Lib_JS__Donner_Tab_Gestion_UpLoad_Fic_Via_Id(Id_Elm_File)
2161{
2162  if(typeof Id_Elm_File=='undefined') return false;
2163  if (!Id_Elm_File)return false;
2164  
2165  //https://developer.mozilla.org/fr/docs/Web/API/File/Using_files_from_web_applications
2166  //https://mdn.github.io/learning-area/html/forms/file-examples/file-example.html
2167
2168  let Obj_JS__Input__Fic = document.querySelector('#'+Id_Elm_File);
2169  
2170  if(!Obj_JS__Input__Fic)
2171  {
2172    return false;
2173  }
2174    
2175  let Chp='';
2176  let V=0;
2177  
2178  let Rtrn__Tab=[];
2179  
2180  let curFiles = Obj_JS__Input__Fic.files;
2181  if(curFiles.length === 0 || curFiles.length <1)  
2182  {
2183    return false;
2184  }//if(curFiles.length === 0 || curFiles.length <1)  
2185  
2186  for(let i = 0; i < curFiles.length; i++) 
2187  {
2188    Rtrn__Tab['Fic_Nom_Rlt']=curFiles[i].name;
2189    Rtrn__Tab['Fic_Nom_Ext']=curFiles[i].name.split('.').pop().toLowerCase();
2190    return Rtrn__Tab;
2191  }//for(let i = 0; i < curFiles.length; i++) 
2192    
2193}//function Lib_JS__Donner_Tab_Gestion_UpLoad_Fic_Via_Id(Id_Elm_File)
2194
2195
2196
2197function Lib_JS__Str__Longeur(Str)
2198{
2199  if(typeof Str=='undefined') return false;
2200  if(!Str)return false;
2201  return Str.length;
2202}
2203
2204function Lib_JS__Str__Position__Ch2_Dans_Ch1(Ch1,Ch2)
2205{
2206  if(!Ch1)return false;
2207  if(!Ch2)return false;
2208  return Ch1.indexOf(Ch2);
2209}
2210
2211function Lib_JS__Str__Ch2_Existe_Dans_Ch1(Ch1,Ch2)
2212{
2213  let I=Lib_JS__Str__Position__Ch2_Dans_Ch1(Ch1,Ch2);
2214  if(I===false)
2215  {
2216    return false;
2217  }
2218  return true;
2219}
2220
2221
2222function Lib_JS__Tab_Obj__Le_Parcourir_Pour_Donner_Tab_Qui_Contient_Infos_PropieteX_ValY(Lst_JSon,Propriete_X,Val_Y)
2223{
2224  if(typeof Lst_JSon=='undefined') return false;
2225  if (!Lst_JSon)return false;
2226  //Lst_JSon doit avoir été déclaré un peut du genre = [{ a: 1}, {b: 2},{x:{1:11,2:22} }];
2227  //Ce doit etre un tabelau de Json.
2228  //Si c'est pas un tabelau, "Lst_JSon.forEach" ne fonctionnera pas !
2229  
2230  if(typeof Propriete_X=='undefined') return false;
2231  if (!Propriete_X)return false;
2232  
2233  if(typeof Val_Y=='undefined') return false;
2234  
2235  let Rtrn__Tab_JSon,Tab_X={};
2236  
2237  let Elm_Num=0;
2238  let Elm_Idx=-1;
2239  let Val='';
2240  let Nbr_Elm_Ok=0;
2241  let I=0,J=0;
2242  
2243  Lst_JSon.forEach(function(Element,Key_Idx){
2244    Elm_Num++;
2245    Elm_Idx++;
2246    Tab_X={};
2247    console.log('Element Num:'+Elm_Num,'Key_Idx='+Key_Idx,'Element=',Element);      
2248    for (let Propriete in Element) 
2249    {
2250      Val=Element[Propriete];
2251      console.log(`Key_Idx=${Key_Idx} Elm_Num=${Elm_Num}. Chp=${Propriete}. Val=${Element[Propriete]}`);
2252      if(Propriete==Propriete_X)
2253      {
2254        if(Val==Val_Y)
2255        {
2256          Nbr_Elm_Ok++;
2257          
2258          Tab_X.Tot__Elm_Idx=Elm_Idx;
2259          Tab_X.Tot__Elm_Num=Elm_Num;          
2260          Tab_X.Tot__Key_Idx=Key_Idx;
2261          
2262          Tab_X.Elm_Ok__Idx=0;
2263          Tab_X.Elm_Ok__Num=1;
2264          Tab_X.Elm_Ok__Nbr=Nbr_Elm_Ok;
2265          
2266          Tab_X.Propriete_X=Propriete;
2267          Tab_X.Val_Y=Val;
2268          
2269          Tab_X.Element=Element;
2270          
2271          Rtrn__Tab_JSon.push(Tab_X);
2272        }//if(Val==Val_Y)
2273      }//if(Propriete==Propriete_X)
2274    }//for (let Propriete in Element) 
2275  })
2276  if(Nbr_Elm_Ok<1)return false;  
2277 
2278  for (I = 0; Id< Rtrn__Tab_JSon.length; I++) 
2279  {
2280    let Tab_X = Rtrn__Tab_JSon[I];
2281    Tab_X.Elm_Ok__Idx=I;
2282    Tab_X.Elm_Ok__Num=I+1;
2283    Tab_X.Elm_Ok__Nbr=Nbr_Elm_Ok;
2284    Rtrn__Tab_JSon[I]=Tab_X;
2285  }//for (I = 0; Id< Rtrn__Tab_JSon.length; I++) 
2286
2287  return Rtrn__Tab_JSon;
2288}//function Lib_JS__Tab_Obj__Le_Parcourir_Pour_Donner_Tab_Qui_Contient_Infos_PropieteX_ValY(Lst_JSon,Propriete_X,Val_Y)
2289  
2290
2291
2292function Lib_JS__Formulaire__Donner__Lst_Infos_Champs_Via_Id_De_Ce_Form(Form_Id)
2293{
2294  //DC:11/02/2023
2295  //Je sais pas comment les fichiers sont géré. Il faudra tester pour les fichiers !!
2296  
2297  if(typeof Form_Id=='undefined') return false;
2298  if (!Form_Id)return false;
2299  
2300  let Form = document.getElementById(Form_Id);
2301  if(!Form) return false;
2302  if(typeof Form=='undefined') return false;
2303  
2304  let Rtrn__Lst_Rps=[];
2305  
2306  let Tab_Infos_Elm={};
2307  
2308  let I,J,L,P=0;
2309  let Ch,C,S;
2310  let Nom_Croch='',Nom_Sans_Croch='';
2311  
2312  let Typ='';
2313  let Nom='';
2314  let Val='',Val_Init='';
2315  let Id=0;
2316  let Rqr=false;
2317  let Chk=false;
2318  let Dsb=false;
2319  
2320  let Lst_Des_ChkBox_Name_Crochet=[];//Tableau qui contiendra des elm json/obj ?
2321  let Lst_Des_Radio_Name_Crochet=[];//Tableau qui contiendra des elm json/obj ?
2322  
2323  let Tab_Elm__Chk_Rad={};
2324  let Tab_Elm__Chk_Rad__X={};
2325  
2326  let TabX,TabY;
2327  
2328  for (I=0;I<Form.length;I++)
2329  {
2330    Id  = Form.elements[I].id;
2331    Nom = Form.elements[I].name;
2332    Typ = Form.elements[I].type;
2333    Val_Init=Val = Form.elements[I].value;
2334    Rqr = Form.elements[I].required;
2335    Chk = Form.elements[I].checked;
2336    Dsb = Form.elements[I].disabled;
2337    
2338    if(!Id) continue;
2339    
2340    TabX=TabY=false;
2341    
2342    Nom_Croch='';
2343    Nom_Sans_Croch='';
2344    L=Lib_JS__Str__Longeur(Nom);
2345    if(L>=3)
2346    {
2347      P=Lib_JS__Str__Position__Ch2_Dans_Ch1(Nom,'[]');
2348      if(P!==false && P==L-2)
2349      {
2350        Nom_Croch=Nom;
2351        Nom_Sans_Croch=Nom_Croch.substring(0,L-2);
2352      }//if(P!==false && P==L-2)      
2353    }//if(L>=3)
2354    
2355    Tab_Elm__Chk_Rad__X={};
2356    
2357    if (Typ=='checkbox')
2358    {
2359      if(!Chk)Val='';
2360    }//if (Typ=='checkbox')
2361    else
2362    if (Typ=='radio')
2363    {
2364      if(!Chk)Val='';
2365    }//if (Typ=='radio')    
2366      
2367    if(Nom_Croch && Chk)
2368    {
2369      if (Typ=='checkbox' || Typ=='radio')
2370      {
2371        Tab_Elm__Chk_Rad__X=false;
2372        if (Typ=='checkbox')
2373        {
2374          TabX=Lst_Des_ChkBox_Name_Crochet;
2375        }
2376        else
2377        {
2378          TabX=Lst_Des_Radio_Name_Crochet;
2379        }
2380
2381        Tab_Elm__Chk_Rad=Lib_JS__Tab_Obj__Le_Parcourir_Pour_Donner_Tab_Qui_Contient_Infos_PropieteX_ValY(TabX,'Nom',Nom_Croch);
2382        if(!Tab_Elm__Chk_Rad)
2383        {
2384          //C'est le premier
2385          
2386          Tab_Elm__Chk_Rad__X={};
2387            
2388          Tab_Elm__Chk_Rad__X.Nom=Nom;
2389          Tab_Elm__Chk_Rad__X.Nom_Sans_Croch=Nom_Sans_Croch;
2390          
2391          Tab_Elm__Chk_Rad__X.Id=Nom_Sans_Croch;//Il est peu problable que ce Id existe
2392          Tab_Elm__Chk_Rad__X.Typ=Typ;
2393            
2394          Tab_Elm__Chk_Rad__X.Lst_Val_Ok=[];
2395          Tab_Elm__Chk_Rad__X.Lst_Val_Ok.push(Val);          
2396          
2397          TabY={};
2398          
2399          TabY.Tot__Elm_Idx=0;
2400          TabY.Tot__Elm_Num=1;
2401          TabY.Tot__Key_Idx=0;
2402          
2403          TabY.Elm_Ok__Idx=0;
2404          TabY.Elm_Ok__Num=1;
2405          TabY.Elm_Ok__Nbr=1;
2406          
2407          TabY.Propriete_X='';
2408          TabY.Val_Y=Val;
2409          
2410          TabY.Element=Tab_Elm__Chk_Rad__X;
2411            
2412          TabX.push($TabY);
2413        }//if(!Tab_Elm__Chk_Rad)
2414        else
2415        {
2416          //c'est pas le premier faut y ajouter cette valeur
2417          TabY=Tab_Elm__Chk_Rad;
2418          /*
2419          TabY.Tot__Elm_Idx=Elm_Idx;
2420          TabY.Tot__Elm_Num=Elm_Num;          
2421          TabY.Tot__Key_Idx=Key_Idx;
2422          
2423          TabY.Elm_Ok__Idx=0;
2424          TabY.Elm_Ok__Num=1;
2425          TabY.Elm_Ok__Nbr=Nbr_Elm_Ok;
2426          
2427          TabY.Propriete_X=Propriete;
2428          TabY.Val_Y=Val;
2429          
2430          TabY.Element=Element;
2431          */
2432          TabY.Element.Lst_Val_Ok.push(Val);
2433          TabX[TabY.Tot__Key_Idx]=TabY;
2434        }//else if(!Tab_Elm__Chk_Rad)
2435          
2436        if (Typ=='checkbox')
2437        {
2438          Lst_Des_ChkBox_Name_Crochet=TabX;
2439        }
2440        else
2441        {
2442          Lst_Des_Radio_Name_Crochet=TabX;
2443        }
2444      }//if (Typ=='checkbox' || Typ=='radio')
2445    }//if(Nom_Croch && Chk)
2446    
2447    Tab_Infos_Elm={'Id':Id,'Nom':Nom,'Typ':Typ,'Val':Val,'Rqr':Rqr,'Dsb':Dsb};
2448    if(TabY)
2449    {
2450      Tab_Infos_Elm.Id=Nom_Sans_Croch;
2451      Tab_Infos_Elm.Val=TabY.Element.Lst_Val_Ok;
2452    }      
2453    Rtrn__Lst_Rps.push(Tab_Infos_Elm);
2454  }//for (I=0;I<Form.elements.length;I++)
2455
2456  return Rtrn__Lst_Rps;
2457}//function Lib_JS__Formulaire__Donner__Lst_Infos_Champs_Via_Id_De_Ce_Form(Form_Id)
2458
2459
2460
2461function Lib_JS__Formulaire__Donner__Lst_Infos_Champs_Via_Id_De_Ce_Form__Sauf_Champ_De_Cette_Liste_Optimisee(Form_Id, List_Chp_A_Ignorer)
2462{//Merci DeepSeek  jamais testé. 05/12/2025
2463  if(typeof Form_Id == 'undefined' || !Form_Id) return false;
2464  if(typeof List_Chp_A_Ignorer == 'undefined') List_Chp_A_Ignorer = [];
2465  
2466  // Appeler la fonction originale
2467  let resultatOriginal = Lib_JS__Formulaire__Donner__Lst_Infos_Champs_Via_Id_De_Ce_Form(Form_Id);
2468  
2469  if(resultatOriginal === false) return false;
2470  
2471  // Si pas de champs à ignorer, retourner le résultat original
2472  if(!List_Chp_A_Ignorer.length) return resultatOriginal;
2473  
2474  let resultatFiltre = [];
2475  
2476  // Pour chaque champ du résultat original
2477  for(let i = 0; i < resultatOriginal.length; i++) 
2478  {
2479    let champ = resultatOriginal[i];
2480    let doitEtreInclus = true;
2481    
2482    // Vérifier si ce champ doit être ignoré
2483    for(let j = 0; j < List_Chp_A_Ignorer.length; j++) {
2484      if(champ.Nom === List_Chp_A_Ignorer[j]) {
2485        doitEtreInclus = false;
2486        break;
2487      }
2488    }//for(let j = 0; j < List_Chp_A_Ignorer.length; j++)
2489    
2490    // Inclure le champ s'il n'est pas dans la liste à ignorer
2491    if(doitEtreInclus) {
2492      resultatFiltre.push(champ);
2493    }
2494  }//for(let i = 0; i < resultatOriginal.length; i++) 
2495  
2496  return resultatFiltre;
2497}
2498
2499
2500function Lib_JS__Accents_En_NonAccents(Ch)
2501{
2502  if(typeof Ch == 'undefined') return "";
2503  return Ch.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
2504}//function Lib_JS__Accents_En_NonAccents(Ch)
2505
2506
2507function Lib_JS__UcFirst(Str)
2508{
2509  if (typeof Str !== 'string' || Str.length === 0) {
2510    return Str;
2511  }
2512  let Str_Minus=Str.toLowerCase()
2513  return Str_Minus.charAt(0).toUpperCase() + Str_Minus.slice(1);
2514}//function Lib_JS__UcFirst(Str)
2515
2516function Lib_JS__UcFirst__Cplx(Ch)
2517{//'jean-luc o'reilly van der merwe.alex'; <====> Jean-Luc O'Reilly Van Der Merwe.Alex
2518  if (typeof Ch !== 'string' || Ch.length === 0) 
2519  {
2520    return Ch;
2521  }
2522
2523  // Divise le prénom en parties en fonction des séparateurs
2524  //let Tab_LesParties = Ch.split(/[\s\-\'\.]+/);
2525  let Tab_LesParties = Ch.split(/([\s\-\'\.]+)/);
2526
2527  // Met en majuscule la première lettre de chaque partie
2528  let Ch_Apres_Reconstitution = Tab_LesParties.map(function (UnePartie,Index) 
2529  {
2530    // La partie impaire contient les séparateurs
2531    
2532    if (Index % 2 === 0) 
2533    {
2534      return Lib_JS__UcFirst(UnePartie);
2535    }
2536    else 
2537    {
2538      // Les parties impaires sont les séparateurs, donc on les laisse inchangés
2539      return UnePartie;//On concatene avec le séparateur initiale !
2540    }
2541  }).join('');//Concaténation sans séparateur
2542
2543  return Ch_Apres_Reconstitution;
2544}//function Lib_JS__UcFirst__Cplx(Ch)
2545
2546function Lib_JS__UcFirst__Prn(Prn)
2547{
2548  return Lib_JS__UcFirst__Cplx(Prn)
2549}//function Lib_JS__UcFirst__Prn(Prn)
2550
2551function Lib_JS__Formater_Nom_Prn(Nom_Prn)
2552{
2553  if(typeof Nom_Prn !== 'string' || Nom_Prn.trim().length === 0)
2554  {
2555    return '';
2556  }
2557  return Lib_JS__Accents_En_NonAccents(Nom_Prn.trim()).trim().toUpperCase();//Sans Accent puis Majuscule
2558}//function Lib_JS__Formater_Nom_Prn(Nom_Prn)
2559
2560function Lib_JS__Fusionner_Nom_Prn(Nom,Prn)
2561{
2562  Nom=Lib_JS__Formater_Nom_Prn(Nom);
2563  Prn=Lib_JS__Formater_Nom_Prn(Prn);
2564  let N_Ko = (typeof Nom !== 'string' || Nom.trim().length === 0);
2565  let P_Ko = (typeof Prn !== 'string' || Prn.trim().length === 0);
2566  
2567  if (N_Ko && P_Ko)
2568  {
2569    return '';
2570  }
2571  
2572  if (N_Ko)
2573  {
2574    return Lib_JS__UcFirst__Prn(Prn);
2575  }
2576  
2577  if (P_Ko)
2578  {
2579    return Nom;
2580  }  
2581  
2582  return Nom+' '+Lib_JS__UcFirst__Prn(Prn);
2583}//function Lib_JS__Fusionner_Nom_Prn(Nom,Prn)

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.