FIX petites corrections concernant les messages auquels l'utilisateur veut répondre
[euphorik.git] / js / pageRegister.js
1 // coding: utf-8
2 // Copyright 2008 Grégory Burri
3 //
4 // This file is part of Euphorik.
5 //
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
18
19 function PageRegister(client, formateur, util)
20 {
21 this.nom = "register"
22
23 this.client = client
24 this.formateur = formateur
25 this.util = util
26 }
27
28 PageRegister.prototype.contenu = function()
29 {
30 return '\
31 <form action="" id="register" >\
32 <table>\
33 <tr>\
34 <td>login</td>\
35 <td><input class="login" type="text" size="20" maxlength="20"/><input class="captcha" name="captcha" type="text" size="12"></input></td>\
36 </tr>\
37 <tr>\
38 <td>password</td>\
39 <td><input class="password" type="password" size="20" maxlength="20"/></td>\
40 </tr>\
41 <tr>\
42 <td>password re</td>\
43 <td><input class="passwordRe" type="password" size="20" maxlength="20"/></td>\
44 </tr>\
45 <tr>\
46 <td></td>\
47 <td><button>valider</button>\
48 </tr>\
49 </table>\
50 </form>'
51 }
52
53 PageRegister.prototype.charger = function()
54 {
55 $("#page form#register").submit(function(){return false})
56
57 var thisPage = this
58
59 $("#page form#register button").click(
60 function()
61 {
62 if ($("#page form#register input.captcha").val() != "") return
63
64 var login = $("#page form#register input.login").val().trim()
65 var password = $("#page form#register input.password").val()
66 var passwordRe = $("#page form#register input.passwordRe").val()
67
68 if (login == "")
69 thisPage.util.messageDialogue("Le login ne doit pas être vide")
70 else if (password == "" && passwordRe == "")
71 thisPage.util.messageDialogue("Un mot de passe est obligatoire")
72 else if (password != passwordRe)
73 thisPage.util.messageDialogue("Les mots de passes ne correspondent pas")
74 else if(thisPage.client.enregistrement(login, thisPage.util.md5(password)))
75 {
76 thisPage.util.messageDialogue("Enregistrement réussi")
77 thisPage.pages.afficherPage("minichat")
78 }
79 }
80 )
81 }