Add a project and module file for IntelliJ.
[euphorik.git] / js / client.js
index 0b77e65..1e87279 100644 (file)
 euphorik.Client = function(util, communication) {\r
    this.util = util;\r
    this.communication = communication;\r
-   \r
+\r
    this.cookie = null;\r
    this.regexCookie = /cookie=([^;]*)/;\r
-   \r
+\r
    this.resetPersonalData();\r
-   \r
+\r
    this.setStatus(euphorik.Client.statusType.disconnected);\r
-   \r
+\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
@@ -50,11 +50,11 @@ euphorik.Client = function(util, communication) {
 \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
+   // Authentified and registered : The user can post messages and can modify his profile.\r
    auth_registered : 0,\r
-   // authentified but not registered : The user can only post messages\r
+   // Authentified but not registered : The user can only post messages.\r
    auth_not_registered : 1,\r
-   // disconnected (the initial state) : The user cannot post message\r
+   // Disconnected (the initial state) : The user cannot post message.\r
    disconnected : 2\r
 };\r
 \r
@@ -74,11 +74,11 @@ euphorik.Client.prototype.resetPersonalData = function() {
    this.viewTimes = true;\r
    this.viewTooltips = true;\r
    this.cookie = undefined;\r
-   \r
+\r
    this.mainConversationPage = 1;\r
    this.ekMaster = false;\r
    this.ostentatiousMaster = "light";\r
-      \r
+\r
    // The user opened conversations.\r
    // Each conversation object owns theses properties :\r
    //  - root (integer)\r
@@ -99,7 +99,7 @@ euphorik.Client.prototype.setCss = function(css) {
 \r
    this.css = css;\r
    $("link#mainCss").attr("href", this.css);\r
-   \r
+\r
    if (this.autoflush) {\r
       this.flush(true);\r
    }\r
@@ -133,8 +133,7 @@ euphorik.Client.prototype.previousPage = function(numConv) {
   * Définit la première page pour la conversation donnée.\r
   * @return true si la page a changé sinon false\r
   */\r
-euphorik.Client.prototype.goFirstPage = function(numConv)\r
-{\r
+euphorik.Client.prototype.goFirstPage = function(numConv) {\r
    if (numConv < 0) {\r
       if (this.mainConversationPage === 1) {\r
          return false;\r
@@ -156,7 +155,7 @@ euphorik.Client.prototype.goFirstPage = function(numConv)
   * @return true si la conversation a été créée sinon false (par exemple si la conv existe déjà)\r
   */\r
 euphorik.Client.prototype.ajouterConversation = function(racine) {\r
-   // vérification s'il elle n'existe pas déjà   \r
+   // vérification s'il elle n'existe pas déjà\r
    var existe = false;\r
    this.conversations.each(function(i, conv) {\r
       if (conv.root === racine) {\r
@@ -166,12 +165,12 @@ euphorik.Client.prototype.ajouterConversation = function(racine) {
    if (existe) {\r
       return false;\r
    }\r
-   \r
+\r
    this.conversations.push({root : racine, page : 1, isCollapsed : false});\r
    if (this.autoflush) {\r
       this.flush(true);\r
    }\r
-   \r
+\r
    return true;\r
 };\r
 \r
@@ -179,13 +178,13 @@ euphorik.Client.prototype.supprimerConversation = function(num) {
    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
    }\r
    this.conversations.pop();\r
-   \r
+\r
    if (this.autoflush) {\r
       this.flush(true);\r
    }\r
@@ -243,11 +242,11 @@ euphorik.Client.prototype.setCookie = function() {
    if (!this.cookie) {\r
       return;\r
    }\r
-      \r
+\r
    // doesn't work under IE....\r
    /*document.cookie = "cookie=" + this.cookie + "; max-age="  + (60 * 60 * 24 * 365) */\r
-   \r
-   document.cookie = \r
+\r
+   document.cookie =\r
       "cookie="+this.cookie+"; expires=" + new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365).toUTCString();\r
 };\r
 \r
@@ -256,7 +255,7 @@ euphorik.Client.prototype.authentifie = function() {
 };\r
 \r
 euphorik.Client.prototype.setStatus = function(statut)\r
-{  \r
+{\r
    // conversation en "enum" si en "string"\r
    if (typeof(statut) === "string") {\r
       statut =\r
@@ -264,20 +263,20 @@ euphorik.Client.prototype.setStatus = function(statut)
             euphorik.Client.statusType.auth_registered :\r
          (statut === "auth_not_registered" ? euphorik.Client.statusType.auth_not_registered : euphorik.Client.statusType.disconnected);\r
    }\r
-   \r
+\r
    if (statut === this.statut) {\r
       return;\r
    }\r
-   \r
+\r
    this.statut = statut;\r
-   \r
+\r
    this.majMenu();\r
    this.majLogo();\r
 };\r
-
-/**
-  * Try to authentify the client with the cookie information.
-  * Do nothing if there is no cookie.
+\r
+/**\r
+  * Try to authentify the client with the cookie information.\r
+  * Do nothing if there is no cookie.\r
   */\r
 euphorik.Client.prototype.connectionCookie = function() {\r
    this.getCookie();\r
@@ -291,7 +290,7 @@ euphorik.Client.prototype.connexionLogin = function(login, password) {
    return this.connexion("authentification", {"login" : login, "password" : password });\r
 };\r
 \r
-euphorik.Client.prototype.enregistrement = function(login, password) { \r
+euphorik.Client.prototype.enregistrement = function(login, password) {\r
    if (this.authentifie()) {\r
       this.login = login;\r
       this.password = password;\r
@@ -311,14 +310,14 @@ euphorik.Client.prototype.enregistrement = function(login, password) {
   */\r
 euphorik.Client.prototype.getJSONEnregistrement = function(login, password) {\r
    var mess = {};\r
-   \r
+\r
    if (login && password) {\r
       mess.login = login;\r
       mess.password = password;\r
    }\r
-   \r
+\r
    mess.profile = this.getJSONProfileInfos();\r
-   \r
+\r
    return mess;\r
 };\r
 \r
@@ -327,7 +326,7 @@ euphorik.Client.prototype.getJSONEnregistrement = function(login, password) {
   */\r
 euphorik.Client.prototype.connexion = function(action, messageJson) {\r
    var thisClient = this;\r
-   \r
+\r
    this.communication.requete(\r
       action,\r
       messageJson,\r
@@ -354,13 +353,13 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
    // 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 ? data.ek_master : false;\r
-   \r
+\r
    this.setStatus(data.status);\r
-   \r
+\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.nick = data.profile.nick;\r
@@ -371,16 +370,16 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
       this.viewTimes = data.profile.view_times;\r
       this.viewTooltips = data.profile.view_tooltips;\r
       this.ostentatiousMaster = data.profile.ostentatious_master;\r
-      \r
+\r
       // la page de la conversation principale\r
       this.mainConversationPage = 1;\r
-      \r
+\r
       // les conversations\r
       this.conversations = data.profile.conversations;\r
       this.conversations.map(function(conv) {\r
          return { root : conv.root, page : 1, isCollapsed : conv.minimized };\r
       });\r
-      \r
+\r
       this.majBulle();\r
       this.majCssSelectionee();\r
    }\r
@@ -393,19 +392,19 @@ euphorik.Client.prototype.chargerDonnees = function(data) {
   */\r
 euphorik.Client.prototype.flush = function(async) {\r
    async = async || false;\r
-      \r
+\r
    if (!this.authentifie()) {\r
       return false;\r
    }\r
-   \r
+\r
    var thisClient = this;\r
    var ok = true;\r
-   \r
+\r
    this.communication.requete(\r
       "set_profile",\r
       this.getJSONProfile(),\r
       function(data) {\r
-         thisClient.majBulle();         \r
+         thisClient.majBulle();\r
       },\r
       function(data) {\r
          thisClient.util.messageDialog(data.error_message);\r
@@ -413,7 +412,7 @@ euphorik.Client.prototype.flush = function(async) {
       },\r
       async\r
    );\r
-   \r
+\r
    return ok;\r
 };\r
 \r
@@ -421,8 +420,8 @@ euphorik.Client.prototype.majMenu = function() {
    var displayType = "block";\r
 \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.statusType.auth_registered) {\r
       $("#menu .profile").css("display", displayType).text("profile");\r
       $("#menu .logout").css("display", displayType);\r