MOD avancement dans la Grande Restructuration
authorGreg Burri <greg.burri@gmail.com>
Fri, 18 Jul 2008 07:06:09 +0000 (07:06 +0000)
committerGreg Burri <greg.burri@gmail.com>
Fri, 18 Jul 2008 07:06:09 +0000 (07:06 +0000)
js/client.js
js/euphorik.js

index a09819b..ea96902 100644 (file)
@@ -26,12 +26,12 @@ euphorik.Client.statutType = {
    auth_not_registered : 1,\r
    // mode déconnecté, ne peut pas poster de message\r
    deconnected : 2\r
    auth_not_registered : 1,\r
    // mode déconnecté, ne peut pas poster de message\r
    deconnected : 2\r
-}\r
+};\r
 \r
 /**\r
   * Représente l'utilisateur du site.\r
   */\r
 \r
 /**\r
   * Représente l'utilisateur du site.\r
   */\r
-function Client(util) {\r
+euphorik.Client = function(util) {\r
    this.util = util;\r
    \r
    this.cookie = null;\r
    this.util = util;\r
    \r
    this.cookie = null;\r
@@ -43,10 +43,10 @@ function Client(util) {
    this.setStatut(euphorik.Client.statutType.deconnected);\r
    \r
    // si true alors chaque modification du client est mémorisé sur le serveur\r
    this.setStatut(euphorik.Client.statutType.deconnected);\r
    \r
    // si true alors chaque modification du client est mémorisé sur le serveur\r
-   this.autoflush = $.browser["opera"];\r
-}\r
+   this.autoflush = $.browser.opera;\r
+};\r
 \r
 \r
-Client.prototype.resetDonneesPersonnelles = function() {\r
+euphorik.Client.prototype.resetDonneesPersonnelles = function() {\r
    this.id = 0;\r
    this.pseudo = euphorik.conf.pseudoDefaut;\r
    this.login = "";\r
    this.id = 0;\r
    this.pseudo = euphorik.conf.pseudoDefaut;\r
    this.login = "";\r
@@ -68,10 +68,10 @@ Client.prototype.resetDonneesPersonnelles = function() {
    // - page (entier)\r
    // - reduit (bool)\r
    this.conversations = [];\r
    // - page (entier)\r
    // - reduit (bool)\r
    this.conversations = [];\r
-}\r
+};\r
 \r
 \r
-Client.prototype.setCss = function(css) {\r
-   if (this.css == css || css == "") {\r
+euphorik.Client.prototype.setCss = function(css) {\r
+   if (this.css === css || !css) {\r
       return;\r
    }\r
 \r
       return;\r
    }\r
 \r
@@ -80,30 +80,29 @@ Client.prototype.setCss = function(css) {
    if (this.autoflush) {\r
       this.flush(true);\r
    }\r
    if (this.autoflush) {\r
       this.flush(true);\r
    }\r
-}\r
+};\r
 \r
 \r
-Client.prototype.pageSuivante = function(numConv) {\r
+euphorik.Client.prototype.pageSuivante = function(numConv) {\r
    if (numConv < 0 && this.pagePrincipale > 1) {\r
       this.pagePrincipale -= 1;\r
    } else if (this.conversations[numConv].page > 1) {\r
       this.conversations[numConv].page -= 1;\r
    }\r
    if (numConv < 0 && this.pagePrincipale > 1) {\r
       this.pagePrincipale -= 1;\r
    } else if (this.conversations[numConv].page > 1) {\r
       this.conversations[numConv].page -= 1;\r
    }\r
-}\r
+};\r
 \r
 \r
-Client.prototype.pagePrecedente = function(numConv) {\r
+euphorik.Client.prototype.pagePrecedente = function(numConv) {\r
    if (numConv < 0) {\r
       this.pagePrincipale += 1;\r
    if (numConv < 0) {\r
       this.pagePrincipale += 1;\r
-   }\r
-   else {\r
+   } else {\r
       this.conversations[numConv].page += 1;\r
    }\r
       this.conversations[numConv].page += 1;\r
    }\r
-}\r
+};\r
 \r
 /**\r
   * Définit la première page pour la conversation donnée.\r
   * @return true si la page a changé sinon false\r
   */\r
 \r
 /**\r
   * Définit la première page pour la conversation donnée.\r
   * @return true si la page a changé sinon false\r
   */\r
-Client.prototype.goPremierePage = function(numConv)\r
+euphorik.Client.prototype.goPremierePage = function(numConv)\r
 {\r
    if (numConv < 0) {\r
       if (this.pagePrincipale == 1) {\r
 {\r
    if (numConv < 0) {\r
       if (this.pagePrincipale == 1) {\r
@@ -117,7 +116,7 @@ Client.prototype.goPremierePage = function(numConv)
       this.conversations[numConv].page = 1;\r
    }\r
    return true;\r
       this.conversations[numConv].page = 1;\r
    }\r
    return true;\r
-}\r
+};\r
 \r
 /**\r
   * Ajoute une conversation à la vue de l'utilisateur.\r
 \r
 /**\r
   * Ajoute une conversation à la vue de l'utilisateur.\r
@@ -125,74 +124,77 @@ Client.prototype.goPremierePage = function(numConv)
   * @param racines la racine de la conversation (integer)\r
   * @return true si la conversation a été créée sinon false (par exemple si la conv existe déjà)\r
   */\r
   * @param racines la racine de la conversation (integer)\r
   * @return true si la conversation a été créée sinon false (par exemple si la conv existe déjà)\r
   */\r
-Client.prototype.ajouterConversation = function(racine) {\r
-   // vérification s'il elle n'existe pas déjà\r
-   for (var i = 0; i < this.conversations.length; i++)\r
-      if (this.conversations[i].root == racine)\r
-         return false\r
+euphorik.Client.prototype.ajouterConversation = function(racine) {\r
+   // vérification s'il elle n'existe pas déjà   \r
+   this.conversations.each(function(i, conv) {\r
+      if (conv.root === racine) {\r
+         return false;\r
+      }\r
+   });\r
    \r
    \r
-   this.conversations.push({root : racine, page : 1, reduit : false})\r
-   if (this.autoflush) this.flush(true)\r
+   this.conversations.push({root : racine, page : 1, reduit : false});\r
+   if (this.autoflush) {\r
+      this.flush(true);\r
+   }\r
    \r
    \r
-   return true\r
-}\r
+   return true;\r
+};\r
 \r
 \r
-Client.prototype.supprimerConversation = function(num)\r
-{\r
-   if (num < 0 || num >= this.conversations.length) return\r
+euphorik.Client.prototype.supprimerConversation = function(num) {\r
+   if (num < 0 || num >= this.conversations.length) {\r
+      return;\r
+   }\r
    \r
    // décalage TODO : supprimer le dernier élément \r
    \r
    // décalage TODO : supprimer le dernier élément \r
-   for (var i = num; i < this.conversations.length - 1; i++)\r
-      this.conversations[i] = this.conversations[i+1]\r
-   this.conversations.pop()\r
+   for (var i = num; i < this.conversations.length - 1; i++) {\r
+      this.conversations[i] = this.conversations[i+1];\r
+   }\r
+   this.conversations.pop();\r
    \r
    \r
-   if (this.autoflush) this.flush(true)\r
-}\r
+   if (this.autoflush) {\r
+      this.flush(true);\r
+   }\r
+};\r
 \r
 \r
-Client.prototype.getJSONLogin = function(login, password)\r
-{\r
+euphorik.Client.prototype.getJSONLogin = function(login, password) {\r
    return {\r
       "header" : { "action" : "authentification", "version" : euphorik.conf.versionProtocole },\r
       "login" : login,\r
       "password" : password\r
    return {\r
       "header" : { "action" : "authentification", "version" : euphorik.conf.versionProtocole },\r
       "login" : login,\r
       "password" : password\r
-   }\r
-}\r
+   };\r
+};\r
 \r
 \r
-Client.prototype.getJSONLoginCookie = function()\r
-{\r
+euphorik.Client.prototype.getJSONLoginCookie = function() {\r
    return {\r
       "header" : { "action" : "authentification", "version" : euphorik.conf.versionProtocole },\r
       "cookie" : this.cookie\r
    return {\r
       "header" : { "action" : "authentification", "version" : euphorik.conf.versionProtocole },\r
       "cookie" : this.cookie\r
-   }\r
-}  \r
+   };\r
+}; \r
 \r
 /**\r
   * le couple (login, password) est facultatif. S'il n'est pas fournit alors il ne sera pas possible\r
   * de s'autentifier avec (login, password).\r
   */\r
 \r
 /**\r
   * le couple (login, password) est facultatif. S'il n'est pas fournit alors il ne sera pas possible\r
   * de s'autentifier avec (login, password).\r
   */\r
-Client.prototype.getJSONEnregistrement = function(login, password)\r
-{\r
-   var mess = { "header" : { "action" : "register", "version" : euphorik.conf.versionProtocole }}\r
+euphorik.Client.prototype.getJSONEnregistrement = function(login, password) {\r
+   var mess = { "header" : { "action" : "register", "version" : euphorik.conf.versionProtocole } };\r
    \r
    \r
-   if (login != undefined && password != undefined)\r
-   {\r
-      mess["login"] = login\r
-      mess["password"] = password\r
+   if (login && password) {\r
+      mess.login = login;\r
+      mess.password = password;\r
    }\r
    \r
    return mess;\r
    }\r
    \r
    return mess;\r
-}\r
+};\r
 \r
 \r
-Client.prototype.getJSONConversations = function()\r
-{\r
-   var conversations = new Array()\r
-   for (var i = 0; i < this.conversations.length; i++)\r
-      conversations.push({root : this.conversations[i].root, minimized : this.conversations[i].reduit})\r
-   return conversations\r
-}\r
+euphorik.Client.prototype.getJSONConversations = function() {\r
+   var conversations = [];\r
+   this.conversations.each(function(i, conv) {\r
+      conversations.push({ "root" : conv.root, "minimized" : conv.reduit });\r
+   });\r
+   return conversations;\r
+};\r
 \r
 \r
-Client.prototype.getJSONProfile = function()\r
-{\r
+euphorik.Client.prototype.getJSONProfile = function() {\r
    return {\r
       "header" : { "action" : "set_profile", "version" : euphorik.conf.versionProtocole },\r
       "cookie" : this.cookie,\r
    return {\r
       "header" : { "action" : "set_profile", "version" : euphorik.conf.versionProtocole },\r
       "cookie" : this.cookie,\r
@@ -207,58 +209,60 @@ Client.prototype.getJSONProfile = function()
       "view_tooltips" : this.viewTooltips,\r
       "conversations" : this.getJSONConversations(),\r
       "ostentatious_master" : this.ostentatiousMaster\r
       "view_tooltips" : this.viewTooltips,\r
       "conversations" : this.getJSONConversations(),\r
       "ostentatious_master" : this.ostentatiousMaster\r
-   }\r
-}\r
+   };\r
+};\r
 \r
 /**\r
 \r
 /**\r
-  * Renvoie null si pas définit.\r
+  * .\r
   */\r
   */\r
-Client.prototype.getCookie = function()\r
-{\r
-   var cookie = this.regexCookie.exec(document.cookie)\r
-   if (cookie == null) this.cookie = null\r
-   else this.cookie = cookie[1]\r
-}\r
+euphorik.Client.prototype.getCookie = function() {\r
+   var cookie = this.regexCookie.exec(document.cookie);\r
+   if (cookie) {\r
+      this.cookie = cookie[1];\r
+   } else {\r
+      this.cookie = undefined;\r
+   }\r
+};\r
 \r
 \r
-Client.prototype.delCookie = function()\r
-{\r
-   document.cookie = "cookie=; max-age=0"\r
-}\r
+euphorik.Client.prototype.delCookie = function() {\r
+   document.cookie = "cookie=; max-age=0";\r
+   this.cookie = undefined;\r
+};\r
 \r
 \r
-Client.prototype.setCookie = function()\r
-{\r
-   if (this.cookie == null || this.cookie == undefined)\r
-      return\r
+euphorik.Client.prototype.setCookie = function() {\r
+   if (!this.cookie) {\r
+      return;\r
+   }\r
       \r
    // ne fonctionne pas sous IE....\r
    /*document.cookie = "cookie=" + this.cookie + "; max-age="  + (60 * 60 * 24 * 365) */\r
    \r
    document.cookie = \r
       \r
    // ne fonctionne pas sous IE....\r
    /*document.cookie = "cookie=" + this.cookie + "; max-age="  + (60 * 60 * 24 * 365) */\r
    \r
    document.cookie = \r
-      "cookie="+this.cookie+"; expires=" + new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365).toUTCString()\r
-}\r
+      "cookie="+this.cookie+"; expires=" + new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365).toUTCString();\r
+};\r
 \r
 \r
-Client.prototype.authentifie = function()\r
-{\r
-   return this.statut == euphorik.Client.statutType.auth_registered || this.statut == euphorik.Client.statutType.auth_not_registered\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
+};\r
 \r
 \r
-Client.prototype.setStatut = function(statut)\r
+euphorik.Client.prototype.setStatut = function(statut)\r
 {  \r
    // conversation en "enum" si en "string"\r
 {  \r
    // conversation en "enum" si en "string"\r
-   if (typeof(statut) == "string")\r
-   {\r
+   if (typeof(statut) === "string") {\r
       statut =\r
       statut =\r
-         statut == "auth_registered" ?\r
+         statut === "auth_registered" ?\r
             euphorik.Client.statutType.auth_registered :\r
             euphorik.Client.statutType.auth_registered :\r
-         (statut == "auth_not_registered" ? euphorik.Client.statutType.auth_not_registered : euphorik.Client.statutType.deconnected)\r
-   }   \r
+         (statut === "auth_not_registered" ? euphorik.Client.statutType.auth_not_registered : euphorik.Client.statutType.deconnected);\r
+   }\r
    \r
    \r
-   if (statut == this.statut) return\r
+   if (statut === this.statut) {\r
+      return;\r
+   }\r
    \r
    \r
-   this.statut = statut   \r
-   this.majMenu()\r
-   this.majLogo()\r
-}\r
+   this.statut = statut;\r
+   this.majMenu();\r
+   this.majLogo();\r
+};\r
 \r
 /**\r
   * Effectue la connexion vers le serveur.\r
 \r
 /**\r
   * Effectue la connexion vers le serveur.\r
@@ -266,269 +270,234 @@ Client.prototype.setStatut = function(statut)
   * S'il existe un cookie en local on s'authentifie directement avec lui.\r
   * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.\r
   */\r
   * S'il existe un cookie en local on s'authentifie directement avec lui.\r
   * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.\r
   */\r
-Client.prototype.connexionCookie = function()\r
-{\r
-   this.getCookie()\r
-   if (this.cookie == null) return false;\r
-   return this.connexion(this.getJSONLoginCookie())\r
-}\r
-\r
-Client.prototype.connexionLogin = function(login, password)\r
-{\r
-   return this.connexion(this.getJSONLogin(login, password))\r
-}\r
-\r
-Client.prototype.enregistrement = function(login, password)\r
-{ \r
-   if (this.authentifie())\r
-   {\r
-      this.login = login\r
-      this.password = password\r
-      if(this.flush())\r
-      {\r
-         this.setStatut(euphorik.Client.statutType.auth_registered)\r
-         return true\r
-      }\r
-      return false\r
+euphorik.Client.prototype.connexionCookie = function() {\r
+   this.getCookie();\r
+   if (!this.cookie) {\r
+      return false;\r
    }\r
    }\r
-   else\r
-   {\r
-      return this.connexion(this.getJSONEnregistrement(login, password))\r
+   return this.connexion(this.getJSONLoginCookie());\r
+};\r
+\r
+euphorik.Client.prototype.connexionLogin = function(login, password) {\r
+   return this.connexion(this.getJSONLogin(login, password));\r
+};\r
+\r
+euphorik.Client.prototype.enregistrement = function(login, password) { \r
+   if (this.authentifie()) {\r
+      this.login = login;\r
+      this.password = password;\r
+      if(this.flush()) {\r
+         this.setStatut(euphorik.Client.statutType.auth_registered);\r
+         return true;\r
+      }\r
+      return false;\r
+   } else {\r
+      return this.connexion(this.getJSONEnregistrement(login, password));\r
    }\r
    }\r
-}\r
+};\r
 \r
 /**\r
   * Connexion. Réalisé de manière synchrone.\r
   */\r
 \r
 /**\r
   * Connexion. Réalisé de manière synchrone.\r
   */\r
-Client.prototype.connexion = function(messageJson)\r
-{\r
-   var thisClient = this\r
-   jQuery.ajax(\r
-      {\r
-         async: false,\r
-         type: "POST",\r
-         url: "request",\r
-         dataType: "json",\r
-         data: this.util.jsonVersAction(messageJson),\r
-         success:\r
-            function(data)\r
-            {\r
-               if (data["reply"] == "error")\r
-               {\r
-                  thisClient.util.messageDialogue(data["error_message"])\r
-                  // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification\r
-                  thisClient.delCookie()\r
-               }\r
-               else\r
-                  thisClient.chargerDonnees(data)\r
+euphorik.Client.prototype.connexion = function(messageJson) {\r
+   var thisClient = this;\r
+   jQuery.ajax({\r
+      async: false,\r
+      type: "POST",\r
+      url: "request",\r
+      dataType: "json",\r
+      data: this.util.jsonVersAction(messageJson),\r
+      success:\r
+         function(data){\r
+            if (data.reply === "error") {\r
+               thisClient.util.messageDialogue(data.error_message);\r
+               // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification\r
+               thisClient.delCookie();\r
+            } else {\r
+               thisClient.chargerDonnees(data);\r
             }\r
             }\r
-      }\r
-   )\r
-   return this.authentifie()\r
-}\r
+         }\r
+   });\r
+   return this.authentifie();\r
+};\r
 \r
 \r
-Client.prototype.deconnexion = function()\r
-{\r
-   this.flush(true)\r
-   this.delCookie()\r
-   this.resetDonneesPersonnelles()\r
-   this.setStatut(euphorik.Client.statutType.deconnected) // deconnexion\r
-}\r
+euphorik.Client.prototype.deconnexion = function() {\r
+   this.flush(true);\r
+   this.delCookie();\r
+   this.resetDonneesPersonnelles();\r
+   this.setStatut(euphorik.Client.statutType.deconnected); // deconnexion\r
+};\r
 \r
 \r
-Client.prototype.chargerDonnees = function(data)\r
-{\r
+euphorik.Client.prototype.chargerDonnees = function(data) {\r
    // la modification du statut qui suit met à jour le menu, le menu dépend (page admin)\r
    // de l'état ekMaster\r
    // la modification du statut qui suit met à jour le menu, le menu dépend (page admin)\r
    // de l'état ekMaster\r
-   this.ekMaster = data["ek_master"] != undefined ? data["ek_master"] : false\r
+   this.ekMaster = data.ek_master ? data.ek_master : false;\r
    \r
    \r
-   this.setStatut(data["status"]) \r
+   this.setStatut(data.status);\r
    \r
    \r
-   if (this.authentifie())\r
-   {\r
-      this.cookie = data["cookie"]\r
-      this.setCookie()\r
+   if (this.authentifie()) {\r
+      this.cookie = data.cookie;\r
+      this.setCookie();\r
       \r
       \r
-      this.id = data["id"]\r
-      this.login = data["login"]\r
-      this.pseudo = data["nick"]\r
-      this.email = data["email"]\r
-      this.setCss(data["css"])\r
-      this.chatOrder = data["chat_order"]\r
-      this.nickFormat = data["nick_format"]\r
-      this.viewTimes = data["view_times"]\r
-      this.viewTooltips = data["view_tooltips"]\r
-      this.ostentatiousMaster = data["ostentatious_master"]\r
+      this.id = data.id;\r
+      this.login = data.login;\r
+      this.pseudo = data.nick;\r
+      this.email = data.email;\r
+      this.setCss(data.css);\r
+      this.chatOrder = data.chat_order;\r
+      this.nickFormat = data.nick_format;\r
+      this.viewTimes = data.view_times;\r
+      this.viewTooltips = data.view_tooltips;\r
+      this.ostentatiousMaster = data.ostentatious_master;\r
       \r
       // la page de la conversation principale\r
       \r
       // la page de la conversation principale\r
-      this.pagePrincipale = 1\r
+      this.pagePrincipale = 1;\r
       \r
       // les conversations\r
       \r
       // les conversations\r
-      this.conversations = data["conversations"]\r
-      for (var i = 0; i < this.conversations.length; i++)\r
-         this.conversations[i] = {root : this.conversations[i].root, page : 1, reduit : this.conversations[i].minimized}\r
+      this.conversations = data.conversations;\r
+      this.conversations.map(function(conv) {\r
+         return { root : conv.root, page : 1, reduit : conv.minimized };\r
+      });\r
       \r
       \r
-      this.majBulle()\r
-      this.majCssSelectionee()\r
-      //this.majLogo()\r
+      this.majBulle();\r
+      this.majCssSelectionee();\r
    }\r
    }\r
-}\r
+};\r
 \r
 /**\r
   * Met à jour les données personne sur serveur.\r
   * @param async de manière asynchrone ? défaut = true\r
   * @return false si le flush n'a pas pû se faire sinon true\r
   */\r
 \r
 /**\r
   * Met à jour les données personne sur serveur.\r
   * @param async de manière asynchrone ? défaut = true\r
   * @return false si le flush n'a pas pû se faire sinon true\r
   */\r
-Client.prototype.flush = function(async)\r
-{\r
-   if (async == undefined)\r
-      async = false\r
+euphorik.Client.prototype.flush = function(async) {\r
+   async = async || false;\r
       \r
       \r
-   if (!this.authentifie())\r
-      return false\r
-\r
-   var thisClient = this\r
-   var ok = true\r
-   jQuery.ajax(\r
-      {\r
-         async: async,\r
-         type: "POST",\r
-         url: "request",\r
-         dataType: "json",\r
-         data: this.util.jsonVersAction(this.getJSONProfile()),\r
-         success:\r
-            function(data)\r
-            {\r
-               if (data["reply"] == "error")\r
-               {\r
-                  thisClient.util.messageDialogue(data["error_message"])\r
-                  ok = false\r
-               }\r
-               else\r
-               {\r
-                  thisClient.majBulle()\r
-               }\r
+   if (!this.authentifie()) {\r
+      return false;\r
+   }\r
+\r
+   var thisClient = this;\r
+   var ok = true;\r
+   jQuery.ajax({\r
+      async: async,\r
+      type: "POST",\r
+      url: "request",\r
+      dataType: "json",\r
+      data: this.util.jsonVersAction(this.getJSONProfile()),\r
+      success:\r
+         function(data) {\r
+            if (data.reply === "error") {\r
+               thisClient.util.messageDialogue(data.error_message);\r
+               ok = false;\r
+            } else {\r
+               thisClient.majBulle();\r
             }\r
             }\r
-      }\r
-   )\r
+         }\r
+   });\r
    \r
    \r
-   return ok\r
-}\r
+   return ok;\r
+};\r
 \r
 \r
-Client.prototype.majMenu = function()\r
-{\r
-   var displayType = "block"\r
+euphorik.Client.prototype.majMenu = function() {\r
+   var displayType = "block";\r
 \r
 \r
-   $("#menu .admin").css("display", this.ekMaster ? displayType : "none")\r
+   $("#menu .admin").css("display", this.ekMaster ? displayType : "none");\r
 \r
    // met à jour le menu   \r
 \r
    // met à jour le menu   \r
-   if (this.statut == euphorik.Client.statutType.auth_registered)\r
-   {\r
-      $("#menu .profile").css("display", displayType).text("profile")\r
-      $("#menu .logout").css("display", displayType)\r
-      $("#menu .register").css("display", "none")\r
-   }\r
-   else if (this.statut == euphorik.Client.statutType.auth_not_registered)\r
-   {\r
-      $("#menu .profile").css("display", "none")\r
-      $("#menu .logout").css("display", displayType)\r
-      $("#menu .register").css("display", displayType)\r
-   }\r
-   else\r
-   {\r
-      $("#menu .profile").css("display", displayType).text("login")\r
-      $("#menu .logout").css("display", "none")\r
-      $("#menu .register").css("display", displayType)\r
+   if (this.statut == euphorik.Client.statutType.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
+      $("#menu .profile").css("display", "none");\r
+      $("#menu .logout").css("display", displayType);\r
+      $("#menu .register").css("display", displayType);\r
+   } else {\r
+      $("#menu .profile").css("display", displayType).text("login");\r
+      $("#menu .logout").css("display", "none");\r
+      $("#menu .register").css("display", displayType);\r
    }\r
    }\r
-}\r
+};\r
 \r
 /**\r
 \r
 /**\r
-  * Met à jour l'affichage des infos bulles en fonction du profile.\r
+  * Met à jour l'affichage ou non des infos bulles en fonction du profile.\r
   */\r
   */\r
-Client.prototype.majBulle = function()\r
-{\r
-   this.util.bulleActive = this.viewTooltips\r
-}\r
+euphorik.Client.prototype.majBulle = function() {\r
+   this.util.bulleActive = this.viewTooltips;\r
+};\r
 \r
 /**\r
   * Met à jour la css sélectionnée, lors du chargement des données.\r
   */\r
 \r
 /**\r
   * Met à jour la css sélectionnée, lors du chargement des données.\r
   */\r
-Client.prototype.majCssSelectionee = function()\r
-{\r
+euphorik.Client.prototype.majCssSelectionee = function() {\r
    // extraction du numéro de la css courante\r
    // extraction du numéro de la css courante\r
-   var numCssCourante = this.css.match(/^.*?\/(\d)\/.*$/)\r
-   if (numCssCourante != null && numCssCourante[1] != undefined)\r
-   {\r
-      $("#menuCss option").removeAttr("selected")\r
-      $("#menuCss option[value=" + numCssCourante[1]+ "]").attr("selected", "selected")\r
+   var numCssCourante = this.css.match(/^.*?\/(\d)\/.*$/);\r
+   if (numCssCourante && numCssCourante[1]) {\r
+      $("#menuCss option").removeAttr("selected");\r
+      $("#menuCss option[value=" + numCssCourante[1]+ "]").attr("selected", "selected");\r
    }\r
    }\r
-}\r
+};\r
 \r
 /**\r
   * Change la "class" du logo en fonction du statut de ekMaster.\r
   */\r
 \r
 /**\r
   * Change la "class" du logo en fonction du statut de ekMaster.\r
   */\r
-Client.prototype.majLogo = function()\r
-{\r
-   if (this.ekMaster)\r
-      $("#logo").addClass("ekMaster")\r
-   else\r
-      $("#logo").removeClass("ekMaster")   \r
-}\r
-\r
+euphorik.Client.prototype.majLogo = function() {\r
+   if (this.ekMaster) {\r
+      $("#logo").addClass("ekMaster");\r
+   } else {\r
+      $("#logo").removeClass("ekMaster");\r
+   }\r
+};\r
 \r
 \r
-Client.prototype.slap = function(userId, raison)\r
-{\r
-   var thisClient = this\r
+euphorik.Client.prototype.slap = function(userId, raison) {\r
+   var thisClient = this;\r
    \r
    jQuery.ajax({\r
       type: "POST",\r
       url: "request",\r
       dataType: "json",\r
    \r
    jQuery.ajax({\r
       type: "POST",\r
       url: "request",\r
       dataType: "json",\r
-      data: this.util.jsonVersAction(\r
-         {\r
-            "header" : { "action" : "slap", "version" : euphorik.conf.versionProtocole },\r
-            "cookie" : thisClient.cookie,\r
-            "user_id" : userId,\r
-            "reason" : raison\r
-         }),\r
+      data: this.util.jsonVersAction({\r
+         "header" : { "action" : "slap", "version" : euphorik.conf.versionProtocole },\r
+         "cookie" : thisClient.cookie,\r
+         "user_id" : userId,\r
+         "reason" : raison\r
+      }),\r
       success: \r
       success: \r
-         function(data)\r
-         {\r
-            if (data["reply"] == "error")\r
-               thisClient.util.messageDialogue(data["error_message"])\r
+         function(data) {\r
+            if (data.reply === "error") {\r
+               thisClient.util.messageDialogue(data.error_message);\r
+            }\r
          }\r
          }\r
-   })\r
-}\r
+   });\r
+};\r
 \r
 \r
-Client.prototype.ban = function(userId, raison, minutes)\r
+euphorik.Client.prototype.ban = function(userId, raison, minutes)\r
 {\r
 {\r
-   var thisClient = this\r
+   var thisClient = this;\r
 \r
    // par défaut un ban correspond à 3 jours\r
 \r
    // par défaut un ban correspond à 3 jours\r
-   if (typeof(minutes) == "undefined")\r
-      minutes = euphorik.conf.tempsBan;\r
+   minutes = minutes || euphorik.conf.tempsBan;\r
       \r
    jQuery.ajax({\r
       type: "POST",\r
       url: "request",\r
       dataType: "json",\r
       \r
    jQuery.ajax({\r
       type: "POST",\r
       url: "request",\r
       dataType: "json",\r
-      data: this.util.jsonVersAction(\r
-         {\r
-            "header" : { "action" : "ban", "version" : euphorik.conf.versionProtocole },\r
-            "cookie" : thisClient.cookie,\r
-            "duration" : minutes,\r
-            "user_id" : userId,\r
-            "reason" : raison\r
-         }),\r
+      data: this.util.jsonVersAction({\r
+         "header" : { "action" : "ban", "version" : euphorik.conf.versionProtocole },\r
+         "cookie" : thisClient.cookie,\r
+         "duration" : minutes,\r
+         "user_id" : userId,\r
+         "reason" : raison\r
+      }),\r
       success: \r
       success: \r
-         function(data)\r
-         {\r
-            if (data["reply"] == "error")\r
-               thisClient.util.messageDialogue(data["error_message"])\r
+         function(data) {\r
+            if (data.reply === "error") {\r
+               thisClient.util.messageDialogue(data.error_message);\r
+            }\r
          }\r
          }\r
-   })\r
-}\r
+   });\r
+};\r
 \r
 \r
-Client.prototype.kick = function(userId, raison)\r
-{\r
-   this.ban(userId, raison, euphorik.conf.tempsKick)\r
-}\r
+euphorik.Client.prototype.kick = function(userId, raison) {\r
+   this.ban(userId, raison, euphorik.conf.tempsKick);\r
+};\r
index 28cba42..8c13841 100755 (executable)
@@ -67,16 +67,22 @@ var euphorik = {}
 Object.prototype.each = function(f) {\r
    for (var k in this) {\r
       if (this.hasOwnProperty(k)) {\r
 Object.prototype.each = function(f) {\r
    for (var k in this) {\r
       if (this.hasOwnProperty(k)) {\r
-         f(k, this[k])\r
+         f(k, this[k]);\r
       }\r
    }\r
       }\r
    }\r
-}\r
+};\r
 \r
 Array.prototype.each = function(f) {\r
    for (var i = 0; i < this.length; i++) {\r
 \r
 Array.prototype.each = function(f) {\r
    for (var i = 0; i < this.length; i++) {\r
-      f(i, this[i])\r
+      f(i, this[i]);\r
    }\r
    }\r
-}\r
+};\r
+\r
+Array.prototype.map = function(f) {\r
+   for (var i = 0; i < this.length; i++) {\r
+      this[i] = f(this[i])\r
+   }\r
+};\r
 
 String.prototype.trim = function() {
        return jQuery.trim(this) // anciennement : this.replace(/^\s+|\s+$/g, "");
 
 String.prototype.trim = function() {
        return jQuery.trim(this) // anciennement : this.replace(/^\s+|\s+$/g, "");