summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
81f8c83)
ajax.js | 74 +++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 43 insertions(+), 31 deletions(-)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1695
839d8a87-29fc-0310-9880-
83ba4fa771e5
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-Ajax = {
- xml_client: null,
- init: false,
+function AjaxEngine()
+{
+ this.xml_client = null;
+ this.init = false;
+ this.obj = null;
+ this.func = null;
- prepare_client: function()
+ this.prepare_client = function()
if (window.XMLHttpRequest) {
if (window.XMLHttpRequest) {
- Ajax.xml_client = new XMLHttpRequest();
+ this.xml_client = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
} else if (window.ActiveXObject) {
try {
- Ajax.xml_client = new ActiveXObject("Msxml2.XMLHTTP");
+ this.xml_client = new ActiveXObject("Msxml2.XMLHTTP");
- Ajax.xml_client = new ActiveXObject("Microsoft.XMLHTTP");
+ this.xml_client = new ActiveXObject("Microsoft.XMLHTTP");
- if (Ajax.xml_client == null) {
+ if (this.xml_client == null) {
alert("Ton client ne supporte pas Ajax, nécessaire pour certaines fonctionalités de cette page");
}
}
alert("Ton client ne supporte pas Ajax, nécessaire pour certaines fonctionalités de cette page");
}
}
- update_html: function(obj, src, func)
+ this.update_html = function(obj, src, func)
- Ajax.prepare_client();
- if (Ajax.xml_client == null) {
+ this.prepare_client();
+ if (this.xml_client == null) {
- Ajax.xml_client.abort();
- Ajax.xml_client.onreadystatechange = function()
- {
- if(Ajax.xml_client.readyState == 4) {
- if (Ajax.xml_client.status == 200) {
- if (obj != null) {
- document.getElementById(obj).innerHTML = Ajax.xml_client.responseText;
- }
- if (func != null) {
- func(Ajax.xml_client.responseText);
- }
- } else if (Ajax.xml_client.status == 403) {
- window.location.reload();
+ this.obj = obj;
+ this.func = func;
+ this.xml_client.abort();
+ this.xml_client.onreadystatechange = this.apply_update_html(this);
+ this.xml_client.open ('GET', src, true);
+ this.xml_client.send (null);
+ return false;
+ }
+
+ this.apply_update_html = function(ajax)
+ {
+ return function()
+ {
+ if(ajax.xml_client.readyState == 4) {
+ if (ajax.xml_client.status == 200) {
+ if (ajax.obj != null) {
+ document.getElementById(ajax.obj).innerHTML = ajax.xml_client.responseText;
+ }
+ if (ajax.func != null) {
+ ajax.func(ajax.xml_client.responseText);
+ } else if (ajax.xml_client.status == 403) {
+ window.location.reload();
- };
- Ajax.xml_client.open ('GET', src, true);
- Ajax.xml_client.send (null);
- return false;
+var Ajax = new AjaxEngine();
+
var currentTempMessage = 0;
function setOpacity(obj, opacity)
{
var currentTempMessage = 0;
function setOpacity(obj, opacity)
{