X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Fclient.js;h=93e5dae4d1f2b1d8ad921f7012acac710bc3aa96;hp=9daa0f54f59b4f995b7630d6bef1004e2844ad28;hb=972919ab7f5651cd721eb6eec75f7150fdeaf347;hpb=d1e6f8e7c86f1ee75e854266463541ffedb916c9 diff --git a/js/client.js b/js/client.js index 9daa0f5..93e5dae 100644 --- a/js/client.js +++ b/js/client.js @@ -21,8 +21,9 @@ /** * Représente l'utilisateur du site. */ -euphorik.Client = function(util) { +euphorik.Client = function(util, communication) { this.util = util; + this.communication = communication this.cookie = null; this.regexCookie = /^cookie=([^;]*)/; @@ -126,7 +127,7 @@ euphorik.Client.prototype.goPremierePage = function(numConv) */ euphorik.Client.prototype.ajouterConversation = function(racine) { // vérification s'il elle n'existe pas déjà - var existe = false + var existe = false; this.conversations.each(function(i, conv) { if (conv.root === racine) { existe = true; @@ -314,25 +315,20 @@ euphorik.Client.prototype.enregistrement = function(login, password) { /** * Connexion. Réalisée de manière synchrone. */ -euphorik.Client.prototype.connexion = function(messageJson) { +euphorik.Client.prototype.connexion = function(action, messageJson) { var thisClient = this; - jQuery.ajax({ - async: false, - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(messageJson), - success: - function(data){ - if (data.reply === "error") { - thisClient.util.messageDialogue(data.error_message); - // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification - thisClient.delCookie(); - } else { - thisClient.chargerDonnees(data); - } - } - }); + + this.communication.requete( + action, + messageJson, + function(data) { + thisClient.chargerDonnees(data); + }, + function() { + thisClient.util.messageDialogue(data.error_message); + thisClient.delCookie(); // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification + } + ); return this.authentifie(); };