MOD french -> english (3)
[euphorik.git] / js / client.js
index 98c0413..917ae8e 100644 (file)
 /*jslint laxbreak:true */\r
 \r
 /**\r
-  * Représente l'utilisateur du site.\r
+  * Object that represents the user.\r
+  * It carries all the user data like\r
+  *  - ID\r
+  *  - Nick\r
+  *  - E-Mail\r
+  *  - etc..\r
+  * It can access directly to the DOM if needed. Some examples :\r
+  *  - Changes the menu if the user is logged or not\r
+  *  - Changes the logo if the user is an ek master\r
+  *  - etc..\r
+  * @util See util.js.\r
+  * @communication See communication.js.\r
   */\r
 euphorik.Client = function(util, communication) {\r
    this.util = util;\r
@@ -28,28 +39,28 @@ euphorik.Client = function(util, communication) {
    this.cookie = null;\r
    this.regexCookie = /cookie=([^;]*)/;\r
    \r
-   // données personnels\r
-   this.resetDonneesPersonnelles();\r
+   this.resetPersonalData();\r
    \r
-   this.setStatut(euphorik.Client.statutType.disconnected);\r
+   this.setStatus(euphorik.Client.statusType.disconnected);\r
    \r
-   // si true alors chaque modification du client est mémorisé sur le serveur\r
+   // If true then each data change is flushed to the server.\r
+   // Active only for opera which doesn't support the unload event.\r
    this.autoflush = $.browser.opera;\r
 };\r
 \r
-// les statuts possibes du client\r
-euphorik.Client.statutType = {\r
-   // mode enregistré, peut poster des messages et modifier son profile\r
+// The three status of a client.\r
+euphorik.Client.statusType = {\r
+   // authentified and registered : The user can post messages and can modify his profile\r
    auth_registered : 0,\r
-   // mode identifié, peut poster des messages mais n'a pas accès au profile\r
+   // authentified but not registered : The user can only post messages\r
    auth_not_registered : 1,\r
-   // mode déconnecté, ne peut pas poster de message\r
+   // disconnected (the initial state) : The user cannot post message\r
    disconnected : 2\r
 };\r
 \r
-euphorik.Client.prototype.resetDonneesPersonnelles = function() {\r
+euphorik.Client.prototype.resetPersonalData = function() {\r
    this.id = 0;\r
-   this.pseudo = euphorik.conf.pseudoDefaut;\r
+   this.nick = euphorik.conf.defaultNick;\r
    this.login = "";\r
    this.password = "";\r
    this.email = "";\r
@@ -60,7 +71,7 @@ euphorik.Client.prototype.resetDonneesPersonnelles = function() {
    this.viewTooltips = true;\r
    this.cookie = undefined;\r
    \r
-   this.pagePrincipale = 1;\r
+   this.mainConversationPage = 1;\r
    this.ekMaster = false;\r
    this.ostentatiousMaster = "light";\r
    \r
@@ -84,8 +95,8 @@ euphorik.Client.prototype.setCss = function(css) {
 };\r
 \r
 euphorik.Client.prototype.pageSuivante = function(numConv) {\r
-   if (numConv < 0 && this.pagePrincipale > 1) {\r
-      this.pagePrincipale -= 1;\r
+   if (numConv < 0 && this.mainConversationPage > 1) {\r
+      this.mainConversationPage -= 1;\r
    } else if (this.conversations[numConv].page > 1) {\r
       this.conversations[numConv].page -= 1;\r
    }\r
@@ -93,7 +104,7 @@ euphorik.Client.prototype.pageSuivante = function(numConv) {
 \r
 euphorik.Client.prototype.pagePrecedente = function(numConv) {\r
    if (numConv < 0) {\r
-      this.pagePrincipale += 1;\r
+      this.mainConversationPage += 1;\r
    } else {\r
       this.conversations[numConv].page += 1;\r
    }\r
@@ -106,10 +117,10 @@ euphorik.Client.prototype.pagePrecedente = function(numConv) {
 euphorik.Client.prototype.goPremierePage = function(numConv)\r
 {\r
    if (numConv < 0) {\r
-      if (this.pagePrincipale === 1) {\r
+      if (this.mainConversationPage === 1) {\r
          return false;\r
       }\r
-      this.pagePrincipale = 1;\r
+      this.mainConversationPage = 1;\r
    } else {\r
       if (this.conversations[numConv].page === 1) {\r
          return false;\r
@@ -180,7 +191,7 @@ euphorik.Client.prototype.getJSONProfile = function() {
 \r
 euphorik.Client.prototype.getJSONProfileInfos = function() {\r
    return {\r
-      "nick" : this.pseudo,\r
+      "nick" : this.nick,\r
       "email" : this.email,\r
       "css" : this.css,\r
       "chat_order" : this.chatOrder,\r
@@ -214,7 +225,7 @@ euphorik.Client.prototype.setCookie = function() {
       return;\r
    }\r
       \r
-   // ne fonctionne pas sous IE....\r
+   // doesn't work under IE....\r
    /*document.cookie = "cookie=" + this.cookie + "; max-age="  + (60 * 60 * 24 * 365) */\r
    \r
    document.cookie = \r
@@ -222,17 +233,17 @@ euphorik.Client.prototype.setCookie = function() {
 };\r
 \r
 euphorik.Client.prototype.authentifie = function() {\r
-   return this.statut === euphorik.Client.statutType.auth_registered || this.statut === euphorik.Client.statutType.auth_not_registered;\r
+   return this.statut === euphorik.Client.statusType.auth_registered || this.statut === euphorik.Client.statusType.auth_not_registered;\r
 };\r
 \r
-euphorik.Client.prototype.setStatut = function(statut)\r
+euphorik.Client.prototype.setStatus = function(statut)\r
 {  \r
    // conversation en "enum" si en "string"\r
    if (typeof(statut) === "string") {\r
       statut =\r
          statut === "auth_registered" ?\r
-            euphorik.Client.statutType.auth_registered :\r
-         (statut === "auth_not_registered" ? euphorik.Client.statutType.auth_not_registered : euphorik.Client.statutType.disconnected);\r
+            euphorik.Client.statusType.auth_registered :\r
+         (statut === "auth_not_registered" ? euphorik.Client.statusType.auth_not_registered : euphorik.Client.statusType.disconnected);\r
    }\r
    \r
    if (statut === this.statut) {\r
@@ -266,7 +277,7 @@ euphorik.Client.prototype.enregistrement = function(login, password) {
       this.login = login;\r
       this.password = password;\r
       if(this.flush()) {\r
-         this.setStatut(euphorik.Client.statutType.auth_registered);\r
+         this.setStatus(euphorik.Client.statusType.auth_registered);\r
          return true;\r
       }\r
       return false;\r
@@ -316,8 +327,8 @@ euphorik.Client.prototype.connexion = function(action, messageJson) {
 euphorik.Client.prototype.disconnect = function() {\r
    this.flush(true);\r
    this.delCookie();\r
-   this.resetDonneesPersonnelles();\r
-   this.setStatut(euphorik.Client.statutType.disconnected);\r
+   this.resetPersonalData();\r
+   this.setStatus(euphorik.Client.statusType.disconnected);\r
 };\r
 \r
 euphorik.Client.prototype.chargerDonnees = function(data) {\r
@@ -325,7 +336,7 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
    // de l'état ekMaster\r
    this.ekMaster = data.ek_master ? data.ek_master : false;\r
    \r
-   this.setStatut(data.status);\r
+   this.setStatus(data.status);\r
    \r
    if (this.authentifie()) {\r
       this.cookie = data.cookie;\r
@@ -333,7 +344,7 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
       \r
       this.id = data.id;\r
       this.login = data.login;\r
-      this.pseudo = data.profile.nick;\r
+      this.nick = data.profile.nick;\r
       this.email = data.profile.email;\r
       this.setCss(data.profile.css);\r
       this.chatOrder = data.profile.chat_order;\r
@@ -343,7 +354,7 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
       this.ostentatiousMaster = data.profile.ostentatious_master;\r
       \r
       // la page de la conversation principale\r
-      this.pagePrincipale = 1;\r
+      this.mainConversationPage = 1;\r
       \r
       // les conversations\r
       this.conversations = data.profile.conversations;\r
@@ -393,11 +404,11 @@ euphorik.Client.prototype.majMenu = function() {
    $("#menu .admin").css("display", this.ekMaster ? displayType : "none");\r
   \r
    // met à jour le menu   \r
-   if (this.statut === euphorik.Client.statutType.auth_registered) {\r
+   if (this.statut === euphorik.Client.statusType.auth_registered) {\r
       $("#menu .profile").css("display", displayType).text("profile");\r
       $("#menu .logout").css("display", displayType);\r
       $("#menu .register").css("display", "none");\r
-   } else if (this.statut === euphorik.Client.statutType.auth_not_registered) {\r
+   } else if (this.statut === euphorik.Client.statusType.auth_not_registered) {\r
       $("#menu .profile").css("display", "none");\r
       $("#menu .logout").css("display", displayType);\r
       $("#menu .register").css("display", displayType);\r