/********************************************************************************************/
// Variables globales
/********************************************************************************************/
var sitear='http://paris.cour-administrative-appel.fr/ta-caa';
/********************************************************************************************/
// Aficher / cacher le loading
/********************************************************************************************/
function loading(targetid) {
/* var chaine=document.getElementById(targetid).className;
// Si en train de loader, cacher le loader
if (chaine.indexOf('loading')!=-1) {
var reg=new RegExp("(loading)", "gi");
document.getElementById(targetid).className = chaine.replace(reg,'');
}
// Sinon, afficher le loader
else {
document.getElementById(targetid).className=chaine+' loading';
}
*/
}
/********************************************************************************************/
// AJAX permet de charcher le contenu d un fichier dans un
/********************************************************************************************/
function load(url, targetid) {
// Sans autre instruction, utiliser le jardin
if (!targetid) {var targetid='backyard'};
// var myAjax = new Ajax.Updater(targetid, url, {method:'get', evalScripts:true, onCreate:function () {loading(targetid)}, onComplete:function () {loading(targetid)}});
var myAjax = new Ajax.Updater(targetid, url, {method:'get', evalScripts:true});
}
/********************************************************************************************/
// Post comment
/********************************************************************************************/
function poston(objet, onobjet) {
// A la fin, on load quoi ?
loadthis=sitear+'/node.php?ajx=refresh&what=make_'+objet+onobjet;
// Notre formulaire et notre liste
form='form'+objet+'on'+onobjet;
list='listof'+objet+'on'+onobjet;
// Ce que je fais
// alert('je post '+form+' et rafraichis '+list);
// aller, on poste en ajax
post(form, sitear+'/node.php?pageclef=form', null, true, null, loadthis, list);
}
/********************************************************************************************/
// AJAX permet de envoyer un formulaire sans reloader une page
/********************************************************************************************/
// Poster un formulaire
function post(form, url, etat, asynchronous, gohere, loadthat, loadithere) {
// Quel formulaire ?
if (!form){form='main';}
// Si le formulaire existe
if (document.getElementById(form)) {
// Loading ?
if (loading) {
var complete = function(objet) {loading(loading);}
}
// Si AJAX trouve la page
var success = function(objet) {
// Voilà le retour
// alert(objet.responseText);
// Se rendre à l'objet ?
if (gohere=='reach') {location.href=objet.responseText;}
// Si gohere de n'importe quelle url, y aller
else if (gohere || loadthat) {
// Voilà ce que je fais
// alert(loadthat+' here '+loadithere);
if (loadthat) {load(loadthat+'&alerteclef='+objet.responseText, loadithere);}
if (gohere) {location.href=gohere;}
}
// Ou montrer le contenu retourné ?
else if (objet.responseText) {alert(objet.responseText);}
}
// Si AJAX retourne un echec
var failure = function(objet) {
alert('Error ' + objet.status + ' : ' + objet.statusText);
}
// Special TinyMCE : sauvegarder le contenu
if (typeof(tinyMCE)!='undefined') {tinyMCE.triggerSave();};
// On récupère les valeurs des champs
var content = Form.serialize(form);
// On ajoute l'etat demandé
if (etat) {
var table=document.getElementById('table').value;
content=content+'&'+table+'_setetat='+etat;
}
// Doit-on atteindre l'objet à la fin ?
if (gohere=='reach') {
content=content+'&return=reach';
}
// On envoie là où le form le demande
if (!url) {var url=document.getElementById(form).action;}
// Asynchrone par defaut
if (!asynchronous) {var asynchronous=true;}
// Et voilà
var query = new Ajax.Request(
url, {
asynchronous:asynchronous,
method:'post',
parameters:content,
onComplete:complete,
onSuccess:success,
onFailure:failure /*pas de virgule ici pour ie6*/
}
);
}
// Si le formulaire n'existe pas mais qu'on a un goto
else if (gohere) {location.href=gohere;}
}
/********************************************************************************************/
// Vérifier les formulaires
/********************************************************************************************/
// Quelques fonctions de vérification
function is_ko(type, fieldid) {
// Ssi le champ existe
if (field=document.getElementById(fieldid)) {
//alert(type);
switch (type) {
// Checkboxes ?
case 'checkbox' :
// Boucler pour voir si au moins une est cochée
var ok=null;
i=0;
while (document.getElementById(fieldid+i)) {
if (document.getElementById(fieldid+i).checked === true ) {ok=true;}
i=i+1;
}
if (!ok) {return true;}
break;
// Email ?
case 'email' :
if (field.value.indexOf('@')<0 || field.value.indexOf('.')<0 || field.value==0) {return true;}
break;
// Date ?
case 'date' :
// Boucler pour voir si les trois (jour, mois, année) sont remplis
var mydate = field.getElementsByTagName('select');
var ko=false;
var year = mydate[2].options[mydate[2].selectedIndex].value;
var month = mydate[1].options[mydate[1].selectedIndex].value;
var day = mydate[0].options[mydate[0].selectedIndex].value;
if (day == '00') {ko=true;}
if (month == '00') {ko=true;}
if (year == '0000') {ko=true;}
source_date = new Date(year,month-1,day);
//alert(source_date);
if(year != source_date.getFullYear()) { ko=true; }
if(month-1 != source_date.getMonth()) { ko=true; }
if(day != source_date.getDate()) { ko=true; }
//alert(ko);
if (ko) {return true;}
break;
// Password ?
case 'password' :
// Si le champs n'est pas caché, et si les deux sont identiques
if (!document.getElementById(fieldid+'_change') && (field.value==0 || field.value!=document.getElementById(fieldid+'_check').value)) {return true;}
if (document.getElementById(fieldid+'_change') && document.getElementById(fieldid+'_change').style.display!='none' && (field.value==0 || field.value!=document.getElementById(fieldid+'_check').value)) {return true;}
break;
// Pour les chaines et tout le reste
default:
// Pour les chaines avec taille limite
if (!isNaN(type)) {
//alert(field.value.length)
if (field.value.length textarea.clientHeight && !window.opera) {textarea.rows += 1};
}
/********************************************************************************************/
// Changer une class
/********************************************************************************************/
function switchclass(id, newclass) {
var chaine=document.getElementById(id).className;
// Si la classe est déjà montée, l'enlever
if (chaine.indexOf(newclass)!=-1) {
chaine=document.getElementById(id).className=chaine.replace(newclass, '');
chaine=document.getElementById(id).className=chaine.replace(' '+newclass, '');
}
// Sinon, l'ajouter
else {document.getElementById(id).className = chaine+' '+newclass;}
}
/********************************************************************************************/
// Changer les états des champs
/********************************************************************************************/
function switchfield(id, event) {
var chaine=document.getElementById(id).className;
switch(event) {
// ONBLUR : S'il est onfocus, le remettre sans onfocus, ni ko
case 'onblur':
chaine=document.getElementById(id).className=chaine.replace(' onfocus', '');
chaine=document.getElementById(id).className=chaine.replace(' ko', '');
THISform_modified=true;
break;
// ONMOUSEEVENT : S'il est onfocus, ne rien faire
case 'onmouseout':
case 'onmouseover':
if (chaine.indexOf('onfocus')!=-1) {break;}
// Dans tous les autres cas : ajouter la class à la chaine
default:
if (chaine.indexOf('onmouseout')!=-1 || chaine.indexOf('onmouseover')!=-1 || chaine.indexOf('onfocus')!=-1 || chaine.indexOf('onblur')!=-1) {
chaine=chaine.substring(0, chaine.lastIndexOf(" "));
}
document.getElementById(id).className = chaine+' '+event;
break;
}
}
/********************************************************************************************/
// Ne pas quitter la page avec un formulaire commencé...
/********************************************************************************************/
var THISform_modified=null;
var THISform_saved=null;
function confirmexit() {
if (THISform_modified && !THISform_saved) {return 'Si vous quittez ce formulaire, tous vos changements seront perdus.';}
}
/********************************************************************************************/
// Input Placeholder Text
/********************************************************************************************/
/* Project: Input Placeholder Text
Title: Automatic population of form fields with contents of title attributes
Created: 13 August 2005 by Jon Gibbins (aka dotjay)
Modified: 13 November 2006 by Jon Gibbins (aka dotjay)
Add the following classes to text inputs or textareas to get the desired behaviour:
auto-select : Will pre-populate the input with the title attribute and select the text when it receives focus.
auto-clear : Will pre-populate the input with the title attribute and clear the text when it receives focus.
populate : Will just populate the input with the title attribute.
Note: if auto-select and auto-clear are set, auto-select takes precedence.
*/
function populateforms() {
if (!document.getElementsByTagName) return true;
ourForms = document.getElementsByTagName('form');
// go through each form
var numForms = ourForms.length;
for (var i=0;i