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