\r
/*jslint laxbreak:true */\r
\r
-// les statuts possibes du client\r
-euphorik.Client.statutType = {\r
- // mode enregistré, peut poster des messages et modifier son profile\r
- auth_registered : 0,\r
- // mode identifié, peut poster des messages mais n'a pas accès au profile\r
- auth_not_registered : 1,\r
- // mode déconnecté, ne peut pas poster de message\r
- deconnected : 2\r
-};\r
-\r
/**\r
* Représente l'utilisateur du site.\r
*/\r
-euphorik.Client = function(util) {\r
+euphorik.Client = function(util, communication) {\r
this.util = util;\r
+ this.communication = communication\r
\r
this.cookie = null;\r
this.regexCookie = /^cookie=([^;]*)/;\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
+ auth_registered : 0,\r
+ // mode identifié, peut poster des messages mais n'a pas accès au profile\r
+ auth_not_registered : 1,\r
+ // mode déconnecté, ne peut pas poster de message\r
+ deconnected : 2\r
+};\r
+\r
euphorik.Client.prototype.resetDonneesPersonnelles = function() {\r
this.id = 0;\r
this.pseudo = euphorik.conf.pseudoDefaut;\r
euphorik.Client.prototype.goPremierePage = function(numConv)\r
{\r
if (numConv < 0) {\r
- if (this.pagePrincipale == 1) {\r
+ if (this.pagePrincipale === 1) {\r
return false;\r
}\r
this.pagePrincipale = 1;\r
} else {\r
- if (this.conversations[numConv].page == 1) {\r
+ if (this.conversations[numConv].page === 1) {\r
return false;\r
}\r
this.conversations[numConv].page = 1;\r
*/\r
euphorik.Client.prototype.ajouterConversation = function(racine) {\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
- return false;\r
+ existe = true;\r
}\r
});\r
+ if (existe) {\r
+ return false;\r
+ }\r
\r
this.conversations.push({root : racine, page : 1, reduit : false});\r
if (this.autoflush) {\r
* de s'autentifier avec (login, password).\r
*/\r
euphorik.Client.prototype.getJSONEnregistrement = function(login, password) {\r
- var mess = { "header" : { "action" : "register", "version" : euphorik.conf.versionProtocole } };\r
+ var mess = {\r
+ "header" : { "action" : "register","version" : euphorik.conf.versionProtocole }\r
+ };\r
\r
if (login && password) {\r
mess.login = login;\r
mess.password = password;\r
}\r
\r
+ mess.profile = this.getJSONProfileInfos();\r
+ \r
return mess;\r
};\r
\r
"cookie" : this.cookie,\r
"login" : this.login,\r
"password" : this.password,\r
+ "profile" : this.getJSONProfileInfos()\r
+ };\r
+};\r
+\r
+euphorik.Client.prototype.getJSONProfileInfos = function() {\r
+ return {\r
"nick" : this.pseudo,\r
"email" : this.email,\r
"css" : this.css,\r
}\r
\r
this.statut = statut;\r
+ \r
this.majMenu();\r
this.majLogo();\r
};\r
};\r
\r
/**\r
- * Connexion. Réalisé de manière synchrone.\r
+ * Connexion. Réalisée de manière synchrone.\r
*/\r
-euphorik.Client.prototype.connexion = function(messageJson) {\r
+euphorik.Client.prototype.connexion = function(action, 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
+ this.communication.requete(\r
+ action,\r
+ messageJson,\r
+ function(data) {\r
+ thisClient.chargerDonnees(data);\r
+ },\r
+ function() {\r
+ thisClient.util.messageDialogue(data.error_message);\r
+ thisClient.delCookie(); // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification\r
+ }\r
+ );\r
return this.authentifie();\r
};\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.pseudo = data.profile.nick;\r
+ this.email = data.profile.email;\r
+ this.setCss(data.profile.css);\r
+ this.chatOrder = data.profile.chat_order;\r
+ this.nickFormat = data.profile.nick_format;\r
+ this.viewTimes = data.profile.view_times;\r
+ this.viewTooltips = data.profile.view_tooltips;\r
+ this.ostentatiousMaster = data.profile.ostentatious_master;\r
\r
// la page de la conversation principale\r
this.pagePrincipale = 1;\r
\r
// les conversations\r
- this.conversations = data.conversations;\r
+ this.conversations = data.profile.conversations;\r
this.conversations.map(function(conv) {\r
return { root : conv.root, page : 1, reduit : conv.minimized };\r
});\r
var displayType = "block";\r
\r
$("#menu .admin").css("display", this.ekMaster ? displayType : "none");\r
-\r
+ \r
// met à jour le menu \r
- if (this.statut == euphorik.Client.statutType.auth_registered) {\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
+ } 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