MOD avancement dans le module 'communication'
[euphorik.git] / js / pageProfile.js
index 5f17b01..d772317 100755 (executable)
 // You should have received a copy of the GNU General Public License\r
 // along with Euphorik.  If not, see <http://www.gnu.org/licenses/>.\r
 \r
-function PageProfile(client, formateur, util)\r
-{\r
-   this.nom = "profile"\r
+euphorik.PageProfile = function(client, formateur, util) {\r
+   this.nom = "profile";\r
    \r
-   this.client = client\r
-   this.formateur = formateur\r
-   this.util = util\r
-}\r
+   this.client = client;\r
+   this.formateur = formateur;\r
+   this.util = util;\r
+};\r
 \r
-PageProfile.prototype.contenu = function()\r
-{\r
+euphorik.PageProfile.prototype.contenu = function() {\r
    // pourquoi ?\r
-   return ""\r
-}\r
+   return "";\r
+};\r
 \r
-PageProfile.prototype.charger = function()\r
-{\r
-   $("#page").html(this.getHTML())\r
+euphorik.PageProfile.prototype.charger = function() {\r
+   $("#page").html(this.getHTML());\r
    \r
    // en fonction du statut\r
-   if (this.client.authentifie())\r
-      this.chargerProfile()\r
-   else\r
-      this.chargerLogin()\r
+   if (this.client.authentifie()) {\r
+      this.chargerProfile();\r
+   } else {\r
+      this.chargerLogin();\r
+   }\r
       \r
-   $("#page form#profile").submit(function(){return false})\r
-}\r
+   $("#page form#profile").submit(function(){ return false; });\r
+};\r
 \r
-PageProfile.prototype.chargerProfile = function()\r
-{ \r
-   var thisPage = this\r
+euphorik.PageProfile.prototype.chargerProfile = function() { \r
+   var thisPage = this;\r
    \r
-   $("form#profile input.login").val(this.client.login)\r
-   $("form#profile input.pseudo").val(this.client.pseudo)\r
-   $("form#profile input.email").val(this.client.email)\r
-   $("form#profile input#viewTooltips").attr("checked", this.client.viewTooltips)\r
-   $("form#profile input#viewTimes").attr("checked", this.client.viewTimes)\r
+   $("form#profile input.login").val(this.client.login);\r
+   $("form#profile input.pseudo").val(this.client.pseudo);\r
+   $("form#profile input.email").val(this.client.email);\r
+   $("form#profile input#viewTooltips").attr("checked", this.client.viewTooltips);\r
+   $("form#profile input#viewTimes").attr("checked", this.client.viewTimes);\r
    \r
-   $("form#profile select#chatOrder option").removeAttr("selected")\r
-   $("form#profile select#chatOrder option[value=" + this.client.chatOrder + "]").attr("selected", "selected")\r
+   $("form#profile select#chatOrder option").removeAttr("selected");\r
+   $("form#profile select#chatOrder option[value=" + this.client.chatOrder + "]").attr("selected", "selected");\r
    \r
-   $("form#profile select#affichagePseudo option").removeAttr("selected")\r
-   $("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected")\r
+   $("form#profile select#affichagePseudo option").removeAttr("selected");\r
+   $("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected");\r
     \r
-   if (this.client.ostentatiousMaster)\r
-   {\r
-       $("form#profile select#degreeOstentatoire option").removeAttr("selected")\r
-       $("form#profile select#degreeOstentatoire option[value=" + this.client.ostentatiousMaster + "]").attr("selected", "selected")   \r
+   if (this.client.ostentatiousMaster) {\r
+       $("form#profile select#degreeOstentatoire option").removeAttr("selected");\r
+       $("form#profile select#degreeOstentatoire option[value=" + this.client.ostentatiousMaster + "]").attr("selected", "selected");\r
    }\r
 \r
    $("form#profile button").click(\r
-      function()\r
-      {\r
-         thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo($("form#profile input.pseudo").val())\r
-         thisPage.client.email = $("form#profile input.email").val()\r
-         thisPage.client.chatOrder = $("form#profile select#chatOrder option:selected").attr("value") \r
-         thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value") \r
-         if (thisPage.client.ekMaster)\r
-            thisPage.client.ostentatiousMaster = $("form#profile select#degreeOstentatoire option:selected").attr("value") \r
-         thisPage.client.viewTooltips = $("form#profile input#viewTooltips").attr("checked")\r
-         thisPage.client.viewTimes = $("form#profile input#viewTimes").attr("checked")\r
+      function() {\r
+         thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo($("form#profile input.pseudo").val());\r
+         thisPage.client.email = $("form#profile input.email").val();\r
+         thisPage.client.chatOrder = $("form#profile select#chatOrder option:selected").attr("value");\r
+         thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value");\r
+         if (thisPage.client.ekMaster) {\r
+            thisPage.client.ostentatiousMaster = $("form#profile select#degreeOstentatoire option:selected").attr("value");\r
+         }\r
+         thisPage.client.viewTooltips = $("form#profile input#viewTooltips").attr("checked");\r
+         thisPage.client.viewTimes = $("form#profile input#viewTimes").attr("checked");\r
          \r
-         var password = $("form#profile input.password").val()\r
-         var passwordRe = $("form#profile input.passwordRe").val()  \r
-         if (password != "" || passwordRe != "")\r
-         {\r
-            if (password != passwordRe)\r
-            {            \r
-               thisPage.util.messageDialogue("Les mots de passes ne correspondent pas")\r
-               return\r
+         var password = $("form#profile input.password").val();\r
+         var passwordRe = $("form#profile input.passwordRe").val();\r
+         if (password !== "" || passwordRe !== "") {\r
+            if (password !== passwordRe) {            \r
+               thisPage.util.messageDialogue("Les mots de passes ne correspondent pas");\r
+               return;\r
             }\r
-            thisPage.client.password = thisPage.util.md5(password)\r
+            thisPage.client.password = thisPage.util.md5(password);\r
          }\r
          \r
-         if(!thisPage.client.flush())\r
-            thisPage.util.messageDialogue("Impossible de mettre à jour votre profile, causes inconnues", messageType.erreur)\r
-         else\r
-         {\r
-            thisPage.util.messageDialogue("Votre profile a été mis à jour")\r
-            thisPage.pages.afficherPage("minichat")\r
+         if(!thisPage.client.flush()) {\r
+            thisPage.util.messageDialogue("Impossible de mettre à jour votre profile, causes inconnues", euphorik.Util.messageType.erreur);\r
+         } else { \r
+            thisPage.util.messageDialogue("Votre profile a été mis à jour");\r
+            thisPage.pages.afficherPage("minichat");\r
          }\r
       }\r
-   )\r
-}\r
+   );\r
+};\r
 \r
-PageProfile.prototype.chargerLogin = function()\r
-{   \r
-   var thisPage = this\r
+euphorik.PageProfile.prototype.chargerLogin = function() {   \r
+   var thisPage = this;\r
 \r
    $("#page form#profile button").click(\r
-      function()\r
-      {\r
-         if(thisPage.client.connexionLogin($("form#profile input.login").val(), thisPage.util.md5($("form#profile input.password").val())))\r
-         {\r
+      function() {\r
+         if(thisPage.client.connexionLogin($("form#profile input.login").val(), thisPage.util.md5($("form#profile input.password").val()))) {\r
             // TODO afficher un message "ok"\r
-            thisPage.pages.afficherPage("minichat")\r
+            thisPage.pages.afficherPage("minichat");\r
          }\r
       }\r
-   )\r
-}\r
-\r
-PageProfile.prototype.getHTML = function()\r
-{\r
-return '\\r
-<form action="" id="profile" >\\r
- <table>\\r
-  <tr>\\r
-   <td>login</td>\\r
-   <td><input class="login" type="text" size="20" maxlength="20" ' + (this.client.authentifie() ? 'readonly="readonly"' : '') + ' /></td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>password</td>\\r
-   <td><input class="password" type="password" size="20" maxlength="20"/></td>\\r
-  </tr>' + \r
-  (this.client.authentifie() ? '\\r
-  <tr>\\r
-   <td>password re</td>\\r
-   <td><input class="passwordRe" type="password" size="20" maxlength="20"/></td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>pseudo</td>\\r
-   <td><input class="pseudo" type="text" size="40" maxlength="20"/></td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>e-mail</td>\\r
-   <td><input class="email" type="text" size="40" maxlength="100"/></td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>Ordre des messages</td>\\r
-   <td>\\r
-    <select id="chatOrder">\\r
-     <option value="chrono">Chronologique</option>\\r
-     <option value="reverse">Anti-chronologique</option>\\r
-    </select>\\r
-   </td>\\r
-  </tr>\\r
-  <tr>' +\r
-   (this.client.ekMaster ? '<td>Degrée d\'ostentation</td>\\r
-   <td>\\r
-    <select id="degreeOstentatoire">\\r
-     <option value="invisible">Nul</option>\\r
-     <option value="light">Faible</option>\\r
-     <option value="heavy">Élevé</option>\\r
-    </select>\\r
-   </td>' : '') +\r
-  '</tr>\\r
-  <tr>\\r
-   <td>Affichage des identifiants</td>\\r
-   <td>\\r
-    <select id="affichagePseudo">\\r
-     <option value="nick">Pseudo</option>\\r
-     <option value="login">Login</option>\\r
-     <option value="nick_login">Pseudo(Login)</option>\\r
-    </select>\\r
-   </td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>Afficher les infos bulles</td>\\r
-   <td><input type="checkbox" id="viewTooltips" /></td>\\r
-  </tr>\\r
-  <tr>\\r
-   <td>Afficher les dates</td>\\r
-   <td><input type="checkbox" id="viewTimes" /></td>\\r
-  </tr>' : '') + '\\r
-  <tr>\\r
-   <td></td>\\r
-   <td><button>Valider</button>\\r
-  </tr>\\r
- </table>\\r
-</form>' \r
-}\r
+   );\r
+};\r
 \r
+euphorik.PageProfile.prototype.getHTML = function() {\r
+   return '<form action="" id="profile" >' +\r
+      ' <table>' +\r
+      '  <tr>' +\r
+      '   <td>login</td>' +\r
+      '   <td><input class="login" type="text" size="20" maxlength="20" ' + (this.client.authentifie() ? 'readonly="readonly"' : '') + ' /></td>' +\r
+      (this.client.authentifie() ? '' : '   <td>(sensible à la <a href="http://fr.wikipedia.org/wiki/Casse_(informatique)">casse</a>)</td>') +\r
+      '  </tr>' +\r
+      '  <tr>' +\r
+      '   <td>password</td>' +\r
+      '   <td><input class="password" type="password" size="20" maxlength="20"/></td>' +\r
+      '  </tr>' + \r
+      (this.client.authentifie() ? '' +\r
+         '  <tr>' +\r
+         '   <td>password re</td>' +\r
+         '   <td><input class="passwordRe" type="password" size="20" maxlength="20"/></td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+         '   <td>pseudo</td>' +\r
+         '   <td><input class="pseudo" type="text" size="40" maxlength="20"/></td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+         '   <td>e-mail</td>' +\r
+         '   <td><input class="email" type="text" size="40" maxlength="100"/></td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+         '   <td>Ordre des messages</td>' +\r
+         '   <td>' +\r
+         '    <select id="chatOrder">' +\r
+         '     <option value="chrono">Chronologique</option>' +\r
+         '     <option value="reverse">Anti-chronologique</option>' +\r
+         '    </select>' +\r
+         '   </td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+            (this.client.ekMaster ? '' +\r
+            '   <td>Degrée d\'ostentation</td>' +\r
+            '   <td>' +\r
+            '    <select id="degreeOstentatoire">' +\r
+            '     <option value="invisible">Nul</option>' +\r
+            '     <option value="light">Faible</option>' +\r
+            '     <option value="heavy">Élevé</option>' +\r
+            '    </select>' +\r
+            '   </td>' : '') +\r
+         ' </tr>' +\r
+         '  <tr>' +\r
+         '   <td>Affichage des identifiants</td>' +\r
+         '   <td>' +\r
+         '    <select id="affichagePseudo">' +\r
+         '     <option value="nick">Pseudo</option>' +\r
+         '     <option value="login">Login</option>' +\r
+         '     <option value="nick_login">Pseudo(Login)</option>' +\r
+         '    </select>' +\r
+         '   </td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+         '   <td>Afficher les infos bulles</td>' +\r
+         '   <td><input type="checkbox" id="viewTooltips" /></td>' +\r
+         '  </tr>' +\r
+         '  <tr>' +\r
+         '   <td>Afficher les dates</td>' +\r
+         '   <td><input type="checkbox" id="viewTimes" /></td>' +\r
+         '  </tr>' : '') +\r
+      '  <tr>' +\r
+      '   <td></td>' +\r
+      '   <td><button>Valider</button></td>' +\r
+      '  </tr>' +\r
+      ' </table>' +\r
+      '</form>';\r
+};\r