X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fajax.js;h=9eb6a605cef74287e99f1540fde75e06f317cf33;hb=e8637579497c3bc432c0cff30241d508fa465672;hp=84a10adad321a4077cb7db19f2f8405368821f6c;hpb=311bc3ad57fea21b4463a6d8fa96737b2ec0d3c1;p=platal.git diff --git a/htdocs/javascript/ajax.js b/htdocs/javascript/ajax.js index 84a10ad..9eb6a60 100644 --- a/htdocs/javascript/ajax.js +++ b/htdocs/javascript/ajax.js @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2007 Polytechnique.org * + * Copyright (C) 2003-2008 Polytechnique.org * * http://opensource.polytechnique.org/ * * * * This program is free software; you can redistribute it and/or modify * @@ -50,6 +50,9 @@ function AjaxEngine() if (this.xml_client == null) { return true; } + if (src.match(/^http/i) == null) { + src = platal_baseurl + src; + } this.obj = obj; this.func = func; this.xml_client.abort(); @@ -63,16 +66,16 @@ function AjaxEngine() { 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.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); + if (ajax.func != null) { + ajax.func(ajax.xml_client.responseText); } - } else if (ajax.xml_client.status == 403) { - window.location.reload(); + } else if (ajax.xml_client.status == 403) { + window.location.reload(); } } }; @@ -100,7 +103,7 @@ function _showTempMessage(id, state, back) var obj = document.getElementById(id); if (currentTempMessage != state) { return; - } + } setOpacity(obj, back * 4); if (back > 0) { setTimeout("_showTempMessage('" + id + "', " + currentTempMessage + "," + (back-1) + ")", 125); @@ -126,15 +129,25 @@ function previewWiki(idFrom, idTo, withTitle, idShow) var text = encodeURIComponent(document.getElementById(idFrom).value); if (text == "") { return false; - } + } var url = "wiki_preview"; if (!withTitle) { url += "/notitle"; - } + } Ajax.update_html(idTo, url + "?text=" + text); if (idShow != null) { document.getElementById(idShow).style.display = ""; - } + } +} + +function sendTestEmail(token, forlife) +{ + Ajax.update_html(null, 'emails/test' + (forlife == null ? '' : '/' + forlife) + '?token=' + token, + function() { + showTempMessage('mail_sent', "Un mail a été envoyé avec succès" + + (forlife == null ? " sur ton adresse." : " sur l'adresse de " + forlife), + true); }); + return false; } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: