X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Feuphorik.js;h=bd0cd3ad403a73b316a39a35fdd77600bf4ccbd0;hp=dfd398dda83d7778cdd616e08b50e508f9da6df4;hb=e04de9d41e7955b0092fc33b8619b4627af6b3f3;hpb=7ed3a03bffb4112ee174b05ef1d7b486d6ad6534 diff --git a/js/euphorik.js b/js/euphorik.js index dfd398d..bd0cd3a 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -154,6 +154,15 @@ Util.prototype.xmlVersAction = function(xml) //return {action: this.to_utf8(this.serializeXML(xml /*, "UTF-8"*/))} return {action: this.serializeXML(xml)} } + +/** + * Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery. + */ +Util.prototype.jsonVersAction = function(json) +{ + // FIXME : ne plus encapsuler json dans de l'xml (problème avec yaws) + return {action: "" + JSON.stringify(json) + "" } +} Util.prototype.md5 = function(chaine) { @@ -299,7 +308,24 @@ Formateur.prototype.getSmilesHTML = function() Formateur.prototype.traitementComplet = function(M, pseudo) { - return this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo)) + return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo))) +} + +/** + * Transforme les liens en entités clickables. + * Un lien vers une conversation permet d'ouvrire celle ci, elle se marque comme ceci dans un message : + * "{5F}" ou 5F est la racine de la conversation. + * Ce lien sera transformer en {5F} pouvant être clické pour créer la conv 5F. + */ +Formateur.prototype.traiterLiensConv = function(M) +{ + return M.replace( + /\{\w+\}/g, + function(lien) + { + return "" + lien + "" + } + ) } /** @@ -521,6 +547,15 @@ Client.prototype.getXMLlogin = function(login, password) return XMLDocument } +Client.prototype.getJSONLogin = function(login, password) +{ + return { + "action" : "authentification", + "login" : login, + "password" : password + } +} + Client.prototype.getXMLloginCookie = function() { var XMLDocument = this.util.creerDocumentXMLAction() @@ -664,7 +699,8 @@ Client.prototype.connexionCookie = function() Client.prototype.connexionLogin = function(login, password) { - return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password))) + // return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password))) + return this.connexion(this.util.jsonVersAction(this.getJSONLogin(login, password))) } Client.prototype.enregistrement = function(login, password) @@ -687,19 +723,19 @@ Client.prototype.enregistrement = function(login, password) Client.prototype.connexion = function(action) { - //action.action.dump() + action.action.dump("Connexion client") thisClient = this jQuery.ajax( { async: false, type: "POST", url: "request", - dataType: "xml", + dataType: "json", data: action, success: function(data) { - //thisClient.util.serializer.serializeToString(data).dump("Charger client") + thisClient.util.serializer.serializeToString(data).dump("Charger client") thisClient.chargerDonnees(data) } } @@ -762,7 +798,7 @@ Client.prototype.flush = function(async) async = true thisClient = this - //this.util.xmlVersAction(this.getXMLProfile()).action.dump("Flush client") + this.util.xmlVersAction(this.getXMLProfile()).action.dump("Flush client") jQuery.ajax( { async: async,