diff options
Diffstat (limited to 'beta_old1/app/script.js')
-rw-r--r-- | beta_old1/app/script.js | 341 |
1 files changed, 341 insertions, 0 deletions
diff --git a/beta_old1/app/script.js b/beta_old1/app/script.js new file mode 100644 index 0000000..2c14563 --- /dev/null +++ b/beta_old1/app/script.js @@ -0,0 +1,341 @@ +function isNotEmpty (idInput) +{ + if (document.getElementById(idInput).value.length > 0) { return (true);} else {return (false);} +} + +function addPers(form) +{ + if(form.contactDispo) + { + if(form.contactDispo.options.selectedIndex>=0) + { + var oValue = form.contactDispo.options[form.contactDispo.options.selectedIndex].value; + + var exist = false; + var i = 0; + while (i<form.participants.options.length && !exist) { if (form.participants.options[i].value == oValue) exist = true; i=i+1;} + + if (!exist) + { + var oText = form.contactDispo.options[form.contactDispo.options.selectedIndex].text; + var o = new Option(oText,oValue); + form.participants.options[form.participants.options.length]=o; + } + } + } +} + +function switchCSS() +{ + + alert ( "On change de CSS !"); + var listCSS = document.getElementById('switcherCSS'); + if (listCSS) + { + if (listCSS.options.selectedIndex>=0) + { + alert ( "On passe au css :" + listCSS.options[listCSS.options.selectedIndex].value); + setActiveStyleSheet(listCSS.options[listCSS.options.selectedIndex].value); + } + } + +} + +function addAllPers(form) +{ + if(form.contactDispo) + { + for (var j=0;j<form.contactDispo.options.length;j++) + { + var oValue = form.contactDispo.options[j].value; + var exist = false; + var i = 0; + + while (i<form.participants.options.length && !exist) { if (form.participants.options[i].value == oValue) exist = true; i=i+1;} + + if (!exist) + { + var oText = form.contactDispo.options[j].text; + var o = new Option(oText,oValue); + form.participants.options[form.participants.options.length]=o; + } + } + } +} + +function newPers(form) +{ + if (verifMail(form.courriel.value)) + { + var oValue = form.courriel.value; + + var exist = false; + var i = 0; + while (i<form.participants.options.length && !exist) { if (form.participants.options[i].value == oValue) exist = true; i=i+1;} + + if (!exist) + { + var oText = form.courriel.value; + var o = new Option(oText,oValue); + form.participants.options[form.participants.options.length]=o; + } + } + else + { + alert ("Mail invalide"); + } +} + +function verifMail(mail) +{ + if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) return true; else return false; +} + + +function removePers(form) +{ + if (form.participants.options.selectedIndex>=0) + { + var i = form.participants.options.selectedIndex; + form.participants.options[form.participants.options.selectedIndex]=null; + if (parseInt(i) > 0) {form.participants.options.selectedIndex=parseInt(i)-1;} else {form.participants.options.selectedIndex=0;} + } + else + { + alert("Suppression impossible : aucune ligne sélectionnée"); + } +} + +function loadid(url,id,isPop) { + if (isPop) + document.getElementById('msg').innerHTML = "<em>Chargement en cours ...<a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>"; + else + document.getElementById('msg').innerHTML = "<em>Chargement en cours ...</em>"; + + document.getElementById(id).innerHTML = ""; + document.getElementById('msg').style.display='block'; + + var http_request = false; + + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + if (http_request.overrideMimeType) { + http_request.overrideMimeType('text/xml'); + } + } else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) {} + } + } + + if (!http_request) { + alert('Abandon : Impossible de créer une instance XMLHTTP'); + return false; + } + + http_request.onreadystatechange = function(){ + + if (http_request.readyState == 4) { + if (http_request.status == 200) { + document.getElementById(id).innerHTML = http_request.responseText; + document.getElementById('msg').style.display='none'; + document.getElementById('msg').innerHTML = ""; + + } else { + if (isPop) + document.getElementById('msg').innerHTML = "<em>Un problème est survenu ...<a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',true)\" >Réessayer</a> - <a href=\"#\" onclick=\"popoff('"+id+"')\" >Fermer</a></em>"; + else + document.getElementById('msg').innerHTML = "<em>Un problème est survenu ...<a href=\"#\" onclick=\"loadid('"+url+"','"+id+"',false)\" >Réessayer</a></em>"; + } + } + }; + + http_request.open('GET', url, true); + http_request.send(null); +} + +function popon (id) +{ + var thisPopup = document.getElementById(id); + thisPopup.style.display='block'; + //var thisMasque = document.getElementById('masque'); + //thisMasque.style.display='block'; +} + +function popoff (id) +{ + var thisPopup = document.getElementById(id); + thisPopup.style.display='none'; + //var thisMasque = document.getElementById('masque'); + //thisMasque.style.display='none'; +} + +function addcreneau(form) +{ + if(form.day.options.selectedIndex>=0 && form.month.options.selectedIndex>=0 && form.year.options.selectedIndex>=0 && form.hourStart.options.selectedIndex>=0 && form.minuteStart.options.selectedIndex>=0 && form.hourEnd.options.selectedIndex>=0 && form.minuteEnd.options.selectedIndex>=0) + { + if (verifDate(form.day.options[form.day.options.selectedIndex].value,form.month.options[form.month.options.selectedIndex].value,form.year.options[form.year.options.selectedIndex].value)) + { + //Création de la valeur + var oValue = form.hourStart.options[form.hourStart.options.selectedIndex].value + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + "." + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value; + oValue = oValue + "." + form.day.options[form.day.options.selectedIndex].value + "." + form.month.options[form.month.options.selectedIndex].value + "." + form.year.options[form.year.options.selectedIndex].value; + + //Test si la valeur est déja dans la liste + var exist = false; + var i = 0; + while (i<form.creneaux.options.length && !exist) { if (form.creneaux.options[i].value == oValue) exist = true; i=i+1;} + + //Création du texte et de l'option et insertion de l'option si la valeur n'a pas été trouvée + if (!exist) + { + var oText = form.hourStart.options[form.hourStart.options.selectedIndex].value + ":" + form.minuteStart.options[form.minuteStart.options.selectedIndex].value + " -> " + form.hourEnd.options[form.hourEnd.options.selectedIndex].value + ":" + form.minuteEnd.options[form.minuteEnd.options.selectedIndex].value; + oText = oText + " " + form.day.options[form.day.options.selectedIndex].value + "/" + form.month.options[form.month.options.selectedIndex].value + "/" + form.year.options[form.year.options.selectedIndex].value; + var o = new Option(oText,oValue); + form.creneaux.options[form.creneaux.options.length]=o; + } + } + } +} + +function removecreneau(form) +{ + if (form.creneaux.options.selectedIndex>=0) + { + var i = form.creneaux.options.selectedIndex; + form.creneaux.options[form.creneaux.options.selectedIndex]=null; + if (parseInt(i) > 0) {form.creneaux.options.selectedIndex=parseInt(i)-1;} else {form.creneaux.options.selectedIndex=0;} + } + else + { + alert("Suppression impossible : aucune ligne sélectionnée"); + } +} + +function dataListe(idSelect,idInput) +{ + var liste = document.getElementById(idSelect); + if (liste) + { + for (var i=0;i<liste.options.length;i++) + { + var newInput = document.createElement("input"); +/* newInput.setAttribute("type", "hidden"); + newInput.setAttribute("name", (idInput+"["+i+"]")); + newInput.setAttribute("value", liste.options[i].value);*/ + newInput.type = "hidden"; + newInput.name = idInput+"["+i+"]"; + newInput.value = liste.options[i].value; + liste.form.appendChild(newInput); + } + return (true); + } + else + { + return (false); + } + +} +function verifDate(day,month,year) +{ + var a= year; + var m= month; + var d= day; + var ok=true; + + var date2=new Date(a,m-1,d); + d2=date2.getDate(); + m2=date2.getMonth()+1; + a2=date2.getFullYear(); + if (a2<=100) {a2=1900+a2} //Pour depasser 2000 + if ( (d!=d2)||(m!=m2)||(a!=a2) ) + { + alert("Cette date n'existe pas !"); + ok=false; + } + return (ok); +} +function loadlist(url,id,idListe) +{ + + if (document.getElementById(id)) + { + loadid((url+document.getElementById(id).options[document.getElementById(id).options.selectedIndex].value),idListe,false); + } +} +//*************************************************************************// +// Formulaire profil +//*************************************************************************// +function verifProfil() +{ + //return(true==(isNotEmpty('nomP')) && true==(isNotEmpty('prenomP')) && true==(isNotEmpty('loginP')) && true==(isNotEmpty('courrielP'))); + if(false==isNotEmpty('nomP')) { alert("Saisissez votre nom avant de valider."); return false;} + if(false==isNotEmpty('prenomP')) { alert("Saisissez votre prenom avant de valider."); return false;} + if(false==isNotEmpty('courrielP')) { alert("Saisissez votre courriel avant de valider."); return false;} + if(false==isNotEmpty('loginP')) { alert("Saisissez votre login avant de valider."); return false;} + return true; +} + +//*************************************************************************// +// Switcher CSS +//*************************************************************************// +function setActiveStyleSheet(title) { + var i, a, main; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { + a.disabled = true; + if(a.getAttribute("title") == title) a.disabled = false; + } + } +} +function getActiveStyleSheet() { + var i, a; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); + } + return null; +} +function getPreferredStyleSheet() { + var i, a; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 + && a.getAttribute("rel").indexOf("alt") == -1 + && a.getAttribute("title") + ) return a.getAttribute("title"); + } + return null; +} +function createCookie(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; +} +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} +window.onload = function(e) { + var cookie = readCookie("aworcustom_css"); + var title = cookie ? cookie : getPreferredStyleSheet(); + setActiveStyleSheet(title); +} +window.onunload = function(e) { + var title = getActiveStyleSheet(); + createCookie("aworcustom_css", title, 365); +} +var cookie = readCookie("aworcustom_css"); +var title = cookie ? cookie : getPreferredStyleSheet(); +setActiveStyleSheet(title);
\ No newline at end of file |