1 /***************************************************************************
2 * Copyright (C) 2003-2008 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
23 this.xml_client
= null;
28 this.prepare_client
= function()
31 if (window
.XMLHttpRequest
) {
32 this.xml_client
= new XMLHttpRequest();
33 } else if (window
.ActiveXObject
) {
35 this.xml_client
= new ActiveXObject("Msxml2.XMLHTTP");
37 this.xml_client
= new ActiveXObject("Microsoft.XMLHTTP");
40 if (this.xml_client
== null) {
41 alert("Ton client ne supporte pas Ajax, nécessaire pour certaines fonctionalités de cette page");
47 this.update_html
= function(obj
, src
, func
)
49 this.prepare_client();
50 if (this.xml_client
== null) {
53 if (src
.match(/^http/i) == null) {
54 src
= platal_baseurl
+ src
;
58 this.xml_client
.abort();
59 this.xml_client
.onreadystatechange
= this.apply_update_html(this);
60 this.xml_client
.open ('GET', src
, true);
61 this.xml_client
.send (null);
65 this.apply_update_html
= function(ajax
)
69 if(ajax
.xml_client
.readyState
== 4) {
70 if (ajax
.xml_client
.status
== 200) {
71 if (ajax
.obj
!= null) {
72 document
.getElementById(ajax
.obj
).innerHTML
= ajax
.xml_client
.responseText
;
74 if (ajax
.func
!= null) {
75 ajax
.func(ajax
.xml_client
.responseText
);
77 } else if (ajax
.xml_client
.status
== 403) {
78 window
.location
.reload();
85 var Ajax
= new AjaxEngine();
87 var currentTempMessage
= 0;
88 function setOpacity(obj
, opacity
)
90 opacity
= (opacity
== 100)?99:opacity
;
92 obj
.style
.filter
= "alpha(opacity:"+opacity
+")";
93 // Safari < 1.2, Konqueror
94 obj
.style
.KHTMLOpacity
= opacity
/100;
96 obj
.style
.MozOpacity
= opacity
/100;
97 // Safari >= 1.2, Firefox and Mozilla, CSS3
98 obj
.style
.opacity
= opacity
/100
101 function _showTempMessage(id
, state
, back
)
103 var obj
= document
.getElementById(id
);
104 if (currentTempMessage
!= state
) {
107 setOpacity(obj
, back
* 4);
109 setTimeout("_showTempMessage('" + id
+ "', " + currentTempMessage
+ "," + (back
-1) + ")", 125);
115 function showTempMessage(id
, message
, success
)
117 var obj
= document
.getElementById(id
);
118 obj
.innerHTML
= (success
? "<img src='images/icons/wand.gif' alt='' /> "
119 : "<img src='images/icons/error.gif' alt='' /> ") + message
;
120 obj
.style
.fontWeight
= "bold";
121 obj
.style
.color
= (success
? "green" : "red");;
122 currentTempMessage
++;
123 setOpacity(obj
, 100);
124 setTimeout("_showTempMessage('" + id
+ "', " + currentTempMessage
+ ", 25)", 1000);
127 function previewWiki(idFrom
, idTo
, withTitle
, idShow
)
129 var text
= encodeURIComponent(document
.getElementById(idFrom
).value
);
133 var url
= "wiki_preview";
137 Ajax
.update_html(idTo
, url
+ "?text=" + text
);
138 if (idShow
!= null) {
139 document
.getElementById(idShow
).style
.display
= "";
143 function sendTestEmail(forlife
)
145 Ajax
.update_html(null, 'emails/test' + (forlife == null ? '' : '/' + forlife
),
147 showTempMessage('mail_sent', "Un mail a été envoyé avec succès"
148 + (forlife
== null ? " sur ton adresse." : " sur l'adresse de " + forlife
),
153 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: