X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fajax.js;h=30a2f6ee476b2b3e21979c8b407ce5c808de61be;hb=12d4424c4b4af630844f18ccebe2c6eb1a4c2a91;hp=2d67102f6510165de88b64e9198a56e5a87289e9;hpb=be6ab042d1dc34d9e42557281b48dd8da400231b;p=platal.git diff --git a/htdocs/javascript/ajax.js b/htdocs/javascript/ajax.js index 2d67102..30a2f6e 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 * @@ -66,16 +66,18 @@ 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(); + } else if (ajax.xml_client.status >= 500) { + alert("Une erreur s'est produite lors du traitement de la requête"); } } }; @@ -129,15 +131,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, hruid) +{ + Ajax.update_html(null, 'emails/test' + (hruid == null ? '' : '/' + hruid) + '?token=' + token, + function() { + showTempMessage('mail_sent', "Un email a été envoyé avec succès" + + (hruid == null ? " sur ton adresse." : " sur l'adresse de " + hruid), + true); }); + return false; } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: