// JavaScript Document function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } // Receive the rest of the URL to pass to the server // ex: /prj1/constats/valider/123 function validerConstat(theRestOfTheURL) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser is too old to use this site."); return; } ; var url=theRestOfTheURL url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange= function() { if (xmlHttp.readyState==4) document.getElementById(zoneID).innerHTML=xmlHttp.responseText; }; xmlHttp.open("GET",url,true); xmlHttp.send(null); } // Receive the rest of the URL to pass to the server // ex: /prj1/constats/valider/123 function changerSousTraitant(theRestOfTheURL) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser is too old to use this site."); return; } ; var url=theRestOfTheURL url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange= function() { if (xmlHttp.readyState==4) document.getElementById(zoneID).innerHTML=xmlHttp.responseText; }; xmlHttp.open("GET",url,true); xmlHttp.send(null); } // Il faut valider le formulaire, certains champs sont obligatoires function validaterConstat() { /* var x = document.forms["constat"]["Etage"].value; var y = document.forms["constat"]["Localisation"].value; */ if (document.forms["constat"]["Etage"].value.length==0) { alert("Vous devez choisir un étage avant de sauvegarder."); return false; } if (document.forms["constat"]["Localisation"].value.length==0) { alert("Vous devez choisir une localisation avant de sauvegarder."); return false; } } // Handle various HTML list manipulations // Copy elements from list 1 to list 2 function listbox_moveacross(sourceID, destID) { var src = document.getElementById(sourceID); var dest = document.getElementById(destID); for(var count=0; count < src.options.length; count++) { if(src.options[count].selected == true) { var option = src.options[count]; var newOption = document.createElement("option"); newOption.value = option.value; newOption.text = option.text; newOption.selected = true; try { dest.add(newOption, null); //Standard src.remove(count, null); }catch(error) { dest.add(newOption); // IE only src.remove(count); } count--; } } sortlist(destID); // listbox_selectall(dest, true); } // Select all elements in a list (so we can post a form and pass the data from the list) function listbox_selectall(listID, isSelect) { var listbox = document.getElementById(listID); for(var count=0; count < listbox.options.length; count++) { listbox.options[count].selected = isSelect; } } // Move elements of a list up or down function listbox_move(listID, direction) { var listbox = document.getElementById(listID); var selIndex = listbox.selectedIndex; if(-1 == selIndex) { alert("Please select an option to move."); return; } var increment = -1; if(direction == 'up') increment = -1; else increment = 1; if((selIndex + increment) < 0 || (selIndex + increment) > (listbox.options.length-1)) { return; } var selValue = listbox.options[selIndex].value; var selText = listbox.options[selIndex].text; listbox.options[selIndex].value = listbox.options[selIndex + increment].value listbox.options[selIndex].text = listbox.options[selIndex + increment].text listbox.options[selIndex + increment].value = selValue; listbox.options[selIndex + increment].text = selText; listbox.selectedIndex = selIndex + increment; } function sortlist(theList){ var cl = document.getElementById(theList); var clTexts = new Array(); /* alert(cl.length); alert(cl.options[1].text + "," + cl.options[1].value); alert(cl.options[2].text + "," + cl.options[2].value); */ /* for(i = 1; i < cl.length; i++){ clTexts[i-1] = cl.options[i].text.toUpperCase() + "," + cl.options[i].text + "," + cl.options[i].value + "," + cl.options[i].selected; } */ for(i = 0; i < cl.length; i++){ clTexts[i] = cl.options[i].text.toUpperCase() + "," + cl.options[i].text + "," + cl.options[i].value + "," + cl.options[i].selected; } clTexts.sort(); /* for(i = 1; i < cl.length; i++){ var parts = clTexts[i-1].split(','); cl.options[i].text = parts[1]; cl.options[i].value = parts[2]; if(parts[3] == "true"){ cl.options[i].selected = true; }else{ cl.options[i].selected = false; } } */ for(i = 0; i < cl.length; i++){ var parts = clTexts[i].split(','); cl.options[i].text = parts[1]; cl.options[i].value = parts[2]; if(parts[3] == "true"){ cl.options[i].selected = true; }else{ cl.options[i].selected = false; } } } function openLink(url, opt){ if (opt == 0) // current window window.location = url; else if (opt == 1) // new window window.open(url); else if (opt == 2) // background window {window.open(url); self.focus();} }