1 /***************************************************************************
2 * Copyright (C) 2003-2007 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 ***************************************************************************/
25 prepare_client
: function()
28 if (window
.XMLHttpRequest
) {
29 Ajax
.xml_client
= new XMLHttpRequest();
30 } else if (window
.ActiveXObject
) {
32 Ajax
.xml_client
= new ActiveXObject("Msxml2.XMLHTTP");
34 Ajax
.xml_client
= new ActiveXObject("Microsoft.XMLHTTP");
37 if (Ajax
.xml_client
== null) {
38 alert("Ton client ne supporte pas Ajax, nécessaire pour certaines fonctionalités de cette page");
44 update_html
: function(obj
, src
, func
)
46 Ajax
.prepare_client();
47 if (Ajax
.xml_client
== null) {
50 Ajax
.xml_client
.abort();
51 Ajax
.xml_client
.onreadystatechange
= function()
53 if(Ajax
.xml_client
.readyState
== 4) {
54 if (Ajax
.xml_client
.status
== 200) {
56 document
.getElementById(obj
).innerHTML
= Ajax
.xml_client
.responseText
;
59 func(Ajax
.xml_client
.responseText
);
61 } else if (Ajax
.xml_client
.status
== 403) {
62 window
.location
.reload();
66 Ajax
.xml_client
.open ('GET', src
, true);
67 Ajax
.xml_client
.send (null);
72 var currentTempMessage
= 0;
73 function setOpacity(obj
, opacity
)
75 opacity
= (opacity
== 100)?99:opacity
;
77 obj
.style
.filter
= "alpha(opacity:"+opacity
+")";
78 // Safari < 1.2, Konqueror
79 obj
.style
.KHTMLOpacity
= opacity
/100;
81 obj
.style
.MozOpacity
= opacity
/100;
82 // Safari >= 1.2, Firefox and Mozilla, CSS3
83 obj
.style
.opacity
= opacity
/100
86 function _showTempMessage(id
, state
, back
)
88 var obj
= document
.getElementById(id
);
89 if (currentTempMessage
!= state
) {
92 setOpacity(obj
, back
* 5);
94 setTimeout("_showTempMessage('" + id
+ "', " + currentTempMessage
+ "," + (back
-1) + ")", 100);
100 function showTempMessage(id
, message
, success
)
102 var obj
= document
.getElementById(id
);
103 obj
.innerHTML
= (success
? "<img src='images/icons/wand.gif' alt='' /> "
104 : "<img src='images/icons/error.gif' alt='' /> ") + message
;
105 obj
.style
.fontWeight
= "bold";
106 obj
.style
.color
= (success
? "green" : "red");;
107 currentTempMessage
++;
108 setOpacity(obj
, 100);
109 setTimeout("_showTempMessage('" + id
+ "', " + currentTempMessage
+ ", 20)", 700);
112 function previewWiki(idFrom
, idTo
, withTitle
, idShow
)
114 var text
= encodeURIComponent(document
.getElementById(idFrom
).value
);
118 var url
= "wiki_preview";
122 Ajax
.update_html(idTo
, url
+ "?text=" + text
);
123 if (idShow
!= null) {
124 document
.getElementById(idShow
).style
.display
= "";
128 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: