1/*** functions generales ***/ 2 3/**** fonctions AJAX *****/ 4function createXmlHttpRequest() { 5 try { 6 if (typeof ActiveXObject != 'undefined') { 7 return new ActiveXObject('Microsoft.XMLHTTP'); 8 } else if (window["XMLHttpRequest"]) { 9 return new XMLHttpRequest(); 10 } 11 } catch (e) { 12 changeStatus(e); 13 } 14 return null; 15}; 16 17function downloadUrl(url, callback) { 18 var status = -1; 19 var request = createXmlHttpRequest(); 20 if (!request) { 21 return false; 22 } 23 24 request.onreadystatechange = function() { 25 if (request.readyState == 4) { 26 try { 27 status = request.status; 28 } catch (e) { 29 // Usually indicates request timed out in FF. 30 } 31 if (status == 200) { 32 callback(request.responseXML, request.status); 33 request.onreadystatechange = function() {}; 34 } 35 } 36 } 37 request.open('GET', url, true); 38 try { 39 request.send(null); 40 } catch (e) { 41 changeStatus(e); 42 } 43}; 44 45/* 46idem, retour en TXT brut 47*/ 48function downloadUrlTxt(url, callback) { 49 var status = -1; 50 var request = createXmlHttpRequest(); 51 if (!request) { 52 return false; 53 } 54 55 request.onreadystatechange = function() { 56 if (request.readyState == 4) { 57 try { 58 status = request.status; 59 } catch (e) { 60 // Usually indicates request timed out in FF. 61 } 62 if (status == 200) { 63 callback(request.responseText, request.status); 64 request.onreadystatechange = function() {}; 65 } 66 } 67 } 68 request.open('GET', url, true); 69 try { 70 request.send(null); 71 } catch (e) { 72 changeStatus(e); 73 } 74}; 75 76/* 77NB : runfile() desormais remplacé par downloadUrlTxt() 78*/ 79 80/************/ 81 82 //affiche/cache une div 83 function displayDiv(division,modeDisplay) { 84 if(document.getElementById(division)!=null) { 85 document.getElementById(division).style.display = modeDisplay; 86 } 87 } 88 89 //affiche/cache une div avec etat boolean en param 90 function displayDivByEtat(division, etat) { 91 var modeDisplay = "none"; 92 if(document.getElementById(division)!=null) { 93 if(etat) { 94 modeDisplay = "block"; 95 } 96 document.getElementById(division).style.display = modeDisplay; 97 } 98 } 99 100 //affiche/cache les div de meme nom 101 function displayDivByName(division,modeDisplay,divcachees) { 102 103 //cache ses soeurs 104 //bug à faire 105 /* 106 if(divcachees!='') { 107 displayDivByName(divcachees,'none',''); 108 }*/ 109 110 var a = document.getElementsByTagName('div'); 111 var len = a.length; 112 var out = new Array(); 113 114 for (var i = 0; i < len; i++) 115 { 116 if (a[i].getAttribute('name')==division) 117 var idDiv = a[i].getAttribute('id'); 118 if(document.getElementById(idDiv)!=null) { 119 document.getElementById(idDiv).style.display = modeDisplay; 120 } 121 } 122 123 124 125 } 126 127 //affiche/cache toutes les balises d'un type donné ayant le nom donné 128 function displayBaliseByName(nom,modeDisplay,balise) { 129 130 var a = document.getElementsByTagName(balise); 131 var len = a.length; 132 var out = new Array(); 133 134 for (var i = 0; i < len; i++) 135 { 136 if (a[i].getAttribute('name')==nom && a[i].getAttribute('id')!=null) 137 var idDiv = a[i].getAttribute('id'); 138 if(document.getElementById(idDiv)!=null) { 139 document.getElementById(idDiv).style.display = modeDisplay; 140 } 141 } 142 } 143 144 //affiche/cache les balises d'une classe donnée 145 function displayBaliseByClassName(classe, modeDisplay, balise) { 146 147 var a = document.getElementsByTagName(balise); 148 var len = a.length; 149 var out = new Array(); 150 151 for (var i = 0; i < len; i++) 152 { 153 if (a[i].className==classe) 154 var idDiv = a[i].getAttribute('id'); 155 if(document.getElementById(idDiv)!=null) { 156 document.getElementById(idDiv).style.display = modeDisplay; 157 } 158 } 159 160 161 162 } 163 164function resizeFlash(divId,h){ 165 document.getElementById(divId).style.height = h+"px"; 166} 167 168function popup(page,nom,largeur,hauteur,options) { 169 170 var top=(screen.height-hauteur)/2; 171 var left=(screen.width-largeur)/2; 172 173 if(page.indexOf("web/")<0 && page.indexOf("http://")<0) {
174 downloadUrlTxt("ajax/ajaxGetCheminsite.php", function(chemin) { 175 page = chemin + "web/" + page; 176 window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 177 }); 178 } else { 179 window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 180 } 181 182 183} 184 185function popupFenetre(idItem,largeur,hauteur) { 186 if(largeur=="") { 187 largeur = 800; 188 } 189 if(hauteur=="") { 190 hauteur = 500; 191 } 192 193 var top=(screen.height-hauteur)/2; 194 var left=(screen.width-largeur)/2; 195 196 downloadUrlTxt("ajax/ajaxGetCheminsite.php", function(chemin) { 197 popup(chemin+"web/popup.php?idItem="+idItem,'fenetre',largeur,hauteur,'resizable=1,scrollbars=1'); 198 }); 199 200} 201 202function retour_haut() { 203 $('document').ready(function() { 204 $(window).scrollTop(0); 205 }); 206} 207 208//affichage d'une galerie en colorbox via un lien dans le contenu 209function visionneuseGalerie(idGalerie) { 210 211 //menage autres galeries dejà ouvertes (classe CSS visionneuse_galerie) 212 $(".visionneuse_galerie").remove(); 213
214 //charge les images de la galerie dans une div créé à la volée 215 //via un XML 216 downloadUrlTxt("web/galerie/ajax_galerie_xml_photos.php?rand="+Math.random()+"&idGalerie="+idGalerie, function(data) { 217 if(data) { 218 //recupere le XML 219 xmlDoc = $.parseXML(data); 220 $xml = $(xmlDoc); 221 222 //creation d'une div temporaire 223 var idDivG = "div_galerie_cbox_" + idGalerie; 224 var newDivG = $("<div class='visionneuse_galerie' id='"+idDivG+"'/>"); 225 226 //ajoute les images à cette div 227 $xml.find('photo').each(function(){ 228 229 var idP = 'photoG_' + $(this).find('id').text(); 230 var repertoireP = $(this).find('repertoire').text(); 231 var fichierP = $(this).find('fichier').text(); 232 var titreP = $(this).find('titre').text(); 233 234 var newImgG = $("<a class='visionneuse_images' href='"+repertoireP+fichierP+"' id='"+idP+"' title='"+titreP+"' />"); 235 newDivG.append(newImgG); 236 237 }); 238 239 //ajoute la div au document 240 $("body").append(newDivG); 241 242 //active le colorbox 243 $('.visionneuse_images').colorbox({rel:"visionneuse_images", open:true}); 244 245 }; 246 }); 247} 248 249 250 251 252/*****utils*****/ 253function isInteger(s) 254{ var i; 255 for (i = 0; i < s.length; i++) 256 { 257 var c = s.charAt(i); 258 if (((c < "0") || (c > "9"))) return false; 259 } 260 261 return true; 262} 263 264String.prototype.trim = function() { 265 return this.replace(/(^\s*)|(\s*$)/g, ""); 266} 267 268 269/***champs requis + formats speciaux ***/ 270function validateRequiredForm(formulaire) { 271 272 if(validateEmail(formulaire)==false) { 273 return false; 274 } 275 if(validateDate(formulaire)==false) { 276 return false; 277 } 278 279 if(validateFloat(formulaire)==false) { 280 return false; 281 } 282 283 var alerte = 0; 284 for(f=0;f<formulaire.elements.length;f++) { 285 var thisAttribut = formulaire.elements[f].getAttribute("required"); 286 if((thisAttribut!='')&&(thisAttribut!=null)) { 287 //si pas disabled 288 if(formulaire.elements[f].disabled==false){ 289 //cas speciaux 290 var thisType = formulaire.elements[f].getAttribute("type"); 291 if(thisType == "radio" || thisType == "checkbox") { 292 var thisName = formulaire.elements[f].getAttribute("name"); 293 caseChecked = false; 294 for(r=0;r<formulaire.elements.length;r++) { 295 if(formulaire.elements[r].getAttribute("name")==thisName) { 296 if(formulaire.elements[r].checked==true) { 297 caseChecked = true; 298 } 299 } 300 } 301 if(!caseChecked) { 302 303 ajaxAlerteTraduction('Merci de remplir le champ ','', ' ' + thisAttribut); 304 305 formulaire.elements[f].focus(); 306 return false; 307 break; 308 } 309 } else { 310 if(formulaire.elements[f].value=='') { 311 ajaxAlerteTraduction('Merci de remplir le champ ','', ' ' + thisAttribut); 312 formulaire.elements[f].focus(); 313 return false; 314 break; 315 } 316 } 317 } 318 } 319 } 320 return true; 321} 322 323 324/*****date*****/ 325 326function validateDate(formulaire) { 327 var alerte = 0; 328 for(f=0;f<formulaire.elements.length;f++) { 329 var thisAttribut = formulaire.elements[f].getAttribute("format"); 330 if(thisAttribut=='date' && thisAttribut!=null) { 331 tabDate = formulaire.elements[f].value.split('/'); 332 if(formulaire.elements[f].value!='') { 333 if(tabDate.length!=3) { 334 alerte++; 335 break; 336 } else { 337 if(tabDate[2]!='0000' && isValidDate(tabDate[0], tabDate[1], tabDate[2])==false) { 338 alerte++; 339 break; 340 } 341 } 342 343 } 344 345 } 346 } 347 348 if(alerte>0) { 349 350 ajaxAlerteTraduction('Merci de respecter le format des dates !','', ''); 351 352 if ((formulaire.elements[f].type == "radio") || (formulaire.elements[f].type == "select") || (formulaire.elements[f].type == "text") || (formulaire.elements[f].type == "textarea")) { 353 formulaire.elements[f].focus(); 354 } 355 356 return false; 357 } 358 return true; 359 360} 361 362function isValidDate(day, month, year) { 363 if(day=='' || month=='' || year=='' || day=='undefined' || month=='undefined' || year=='undefined') { 364 return false;
365 } else { 366 if (month < 1 || month > 12) { 367 return false; 368 } 369 if (day < 1 || day > 31) { 370 return false; 371 } 372 if ((month == 4 || month == 6 || month == 9 || month == 11) && 373 (day == 31)) { 374 return false; 375 } 376 if (month == 2) { 377 var leap = (year % 4 == 0 && 378 (year % 100 != 0 || year % 400 == 0)); 379 if (day>29 || (day == 29 && !leap)) { 380 return false; 381 } 382 } 383 } 384 385 386 return true; 387} 388 389/***email***/ 390function validateEmail(formulaire) { 391 var alerte = 0; 392 for(f=0;f<formulaire.elements.length;f++) { 393 var thisAttribut = formulaire.elements[f].getAttribute("format"); 394 if(thisAttribut=='email' && thisAttribut!=null) { 395 if(formulaire.elements[f].value!='') { 396 if(checkEmail(formulaire.elements[f].value)==false) { 397 alerte++; 398 break; 399 } 400 } 401 402 } 403 } 404 405 if(alerte>0) { 406 407 ajaxAlerteTraduction('Merci de respecter le format des e-mails !','', ''); 408 if ((formulaire.elements[f].type == "text") || (formulaire.elements[f].type == "textarea")) { 409 formulaire.elements[f].focus(); 410 } 411 412 return false; 413 } 414 return true; 415 416} 417 418function checkEmail(emailStr) { 419 if (emailStr.length == 0) { 420 return true; 421 } 422 var emailPat=/^(.+)@(.+)$/; 423 var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; 424 var validChars="\[^\\s" + specialChars + "\]"; 425 var quotedUser="(\"[^\"]*\")"; 426 var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/; 427 var atom=validChars + '+'; 428 var word="(" + atom + "|" + quotedUser + ")"; 429 var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 430 var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$"); 431 var matchArray=emailStr.match(emailPat); 432 if (matchArray == null) { 433 return false; 434 } 435 var user=matchArray[1]; 436 var domain=matchArray[2]; 437 if (user.match(userPat) == null) { 438 return false; 439 } 440 var IPArray = domain.match(ipDomainPat); 441 if (IPArray != null) { 442 for (var i = 1; i <= 4; i++) { 443 if (IPArray[i] > 255) { 444 return false; 445 } 446 } 447 return true; 448 } 449 var domainArray=domain.match(domainPat); 450 if (domainArray == null) { 451 return false; 452 } 453 var atomPat=new RegExp(atom,"g"); 454 var domArr=domain.match(atomPat); 455 var len=domArr.length; 456 if ((domArr[domArr.length-1].length < 2) || 457 (domArr[domArr.length-1].length > 4)) { 458 return false; 459 } 460 if (len < 2) { 461 return false; 462 } 463 return true; 464 } 465 466/* A FAIRE 467float 468*/ 469function validateFloat(formulaire) { 470 var alerte = 0; 471 for(f=0;f<formulaire.elements.length;f++) { 472 var thisAttribut = formulaire.elements[f].getAttribute("format"); 473 if(thisAttribut=='float' && thisAttribut!=null) { 474 if(formulaire.elements[f].value!='') { 475 if(isNaN(parseFloat(formulaire.elements[f].value))) { 476 alerte++; 477 break; 478 } 479 480 } 481 482 } 483 } 484 485 if(alerte>0) { 486 ajaxAlerteTraduction('Merci de respecter le format des prix !','', ''); 487 if ((formulaire.elements[f].type == "radio") || (formulaire.elements[f].type == "select") || (formulaire.elements[f].type == "text") || (formulaire.elements[f].type == "textarea")) { 488 formulaire.elements[f].focus(); 489 } 490 491 return false; 492 } 493 return true; 494 495} 496 497/***photo detail**/ 498function viewPhotoDetail(photo,division) { 499 document.getElementById(division).innerHTML = "<p align=\"right\">
499<a href=\"javascript:void(0)\" onclick=\"displayDiv('"+division+"','none')\">[X]</a></p><p align=\"center\"><img src=\""+photo+"\"/></p>"; 500 document.getElementById(division).style.display = "block"; 501} 502 503 504function gotoAncre(ancre) { 505 var thisLocation = window.location.href; 506 tabLocation = thisLocation.split('#'); 507 window.location.href = tabLocation[0] + "#" + ancre; 508 509 $.ajax({ 510 type: "GET", 511 url: "../ajax/ajaxGetTraduction.php", 512 data: {traduction_texte: 'Lien vers'}, 513 dataType: "text" 514 }) 515 .done(function(data) { 516 window.status = data + " " + ancre; 517 }); 518 519 520} 521 522//recup en ajax un texte traduit 523function ajaxAlerteTraduction(texte,langue,complements) { 524 525 526 $.ajax({ 527 type: "GET", 528 url: "../ajax/ajaxGetTraduction.php", 529 data: {traduction_texte: texte, traduction_langue: langue}, 530 dataType: "text" 531 }) 532 .done(function(data) { 533 alert(data + complements); 534 }); 535 536 537} 538 539 540 541/* 542specials modules include 543*/ 544//recupere toutes les div de class "div_module_include" pour en afficher les contenus 545function makeDivModulesIncludes() { 546 var divs = document.getElementsByTagName("div"); 547 var len = divs.length; 548 var out = new Array(); 549 550 for (var i = 0; i < len; i++) { 551 552 var classDiv = ""; 553 classDiv = divs[i].getAttribute('class'); 554 555 if(classDiv==null) { 556 try { 557 classDiv = divs[i].className; 558 } catch(ee) { 559 } 560 } 561 562 if (classDiv=='div_module_include') { 563 var idDiv = divs[i].getAttribute('id'); 564 565 if(idDiv!=undefined && idDiv!='' && idDiv!=0) { 566 ajaxGetContenuModule(idDiv); 567 } 568 } 569 } 570} 571 572//affiche le contenu d'un module 573function ajaxGetContenuModule(idDiv) { 574 if(document.getElementById(idDiv)!=null) { 575 downloadUrlTxt("ajax/ajaxGetContenuModule.php?idDiv="+idDiv, function(data) { 576 document.getElementById(idDiv).innerHTML = data; 577 }); 578 } 579} 580
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.