// // Code JavaScript pour le support de l'Ajax. Pour le projet Asloca. // // Auteur: OrdinaSoft // Patrick Lanz // Lausanne // info@ordinasoft.ch // // Premi�re version: 10 mai 2007 // // D�pend de: // - OrdinaSoft.Ajax.js // - DialogBox.js // - Master.js // // Note: quand Ajax_Initialized est d�fini, la biblioth�que OrdinaSoft.Ajax est aussi // initialis�e. //----------------------------------------------------------------------------------------------- // Initialisation du namespace. if (typeof Ajax == 'undefined') Ajax = new Object (); Ajax.Mask = null; //----------------------------------------------------------------------------------------------- // Initialisation. Ajax.Init = function () { // Attend que les d�pendances soient initialis�es if ((typeof OrdinaSoft_Ajax_Initialized == 'undefined') || (typeof DialogBox_Initialized == 'undefined') || (typeof Master_Initialized == 'undefined')) { setTimeout (Ajax.Init, 42); return false; } // non initialis� Ajax.Request.prototype = new OrdinaSoft.Ajax.Request (); // Contr�le si on a re�u une erreur en XML. Si une erreur a �t� re�ue, le message re�u sera // affich�. Doit �tre appel�e lorsque la requ�te est termin�e. // - Le r�sultat sera True si la requ�te est en ordre et False si la requ�te a une erreur. Ajax.Request.prototype.IsXmlOK = function () { var Error = this.Req.responseXML; if (Error == null) return true; Error = Error.getElementsByTagName ('Error'); if (Error.length == 0) return true; OrdinaSoft.DialogBox.MessageBox.Error (OrdinaSoft.Ajax.GetXmlText (Error [0]), Master.AppName); return false; } // Ajax.Request.prototype.IsXmlOK // Premier appel d'un groupe. OrdinaSoft.Ajax.FirstRequest = function () { if (Ajax.Mask == null) { Ajax.Mask = OrdinaSoft.Base.GetClientDiv (); var s = []; s [s.length] = ''; s [s.length] = ' '; s [s.length] = ' '; s [s.length] = ' '; s [s.length] = '
' + '
'; Ajax.Mask.innerHTML = s.join ('\r\n'); document.forms [0].appendChild (Ajax.Mask); } // Ajax.Mask == null return true; } // OrdinaSoft.Ajax.FirstRequest // Dernier appel d'un groupe. OrdinaSoft.Ajax.LastRequest = function () { if (Ajax.Mask != null) { OrdinaSoft.Base.StopClientDivTracking (Ajax.Mask); Ajax.Mask.parentNode.removeChild (Ajax.Mask); Ajax.Mask = null; } // (Ajax.Mask != null) return true; } // OrdinaSoft.Ajax.LastRequest Ajax_Initialized = true; return true; } // Ajax.Init Ajax.Init (); //---------------------------------------------------------------------------------------------- // Cr�ation d'une requ�te. // Constructeur. // - URL est l'URL de la requ�te. Ajax.Request = function (URL) { this.Init (URL); this.NoAjaxSupportFunc = function () { OrdinaSoft.DialogBox.MessageBox.Error ('Votre browser ne peut pas utiliser ce site,
' + 'car il n\'est pas compatible avec la technologie Ajax.', Master.AppName); return true; } this.ErrorFunc = function (StatusCode) { OrdinaSoft.DialogBox.MessageBox.Error ('Erreur ' + StatusCode.toString () + ' sur le serveur !
' + 'Veuillez réessayer plus tard.

' + 'Si le problème persiste, veuillez contacter le ' + Master.linkWebMaster + '.', Master.AppName); return true; } return true; } // Ajax.Request