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