X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Fclient.js;h=93e5dae4d1f2b1d8ad921f7012acac710bc3aa96;hp=11466a9b07f0215d25b5e1fd8fc4b0530ff91165;hb=972919ab7f5651cd721eb6eec75f7150fdeaf347;hpb=6c0fcdfaefd072f8b0ee1d7d8f1ba2a2c1ede8ec diff --git a/js/client.js b/js/client.js index 11466a9..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=([^;]*)/; @@ -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(); };