X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=js%2FpageMinichat%2FpageMinichat.js;h=64914b1c3ef65914bec11030b583e8840be49ac1;hb=de42c1d3c8cd320a8481e93976316a920b9ad6a8;hp=d289a99353739abfb6a8e7b115f45d02e5497a10;hpb=4aa85a2e80963b73773e748fd4402fab2ad852ce;p=euphorik.git
diff --git a/js/pageMinichat/pageMinichat.js b/js/pageMinichat/pageMinichat.js
index d289a99..64914b1 100755
--- a/js/pageMinichat/pageMinichat.js
+++ b/js/pageMinichat/pageMinichat.js
@@ -18,12 +18,13 @@
/*jslint laxbreak:true */
-euphorik.PageMinichat = function(client, formateur, util) {
+euphorik.PageMinichat = function(client, formateur, util, communication) {
this.nom = "minichat";
this.client = client;
this.formateur = formateur;
this.util = util;
+ this.communication = communication;
this.commandes = new euphorik.Commandes(this.client);
// permet d'éviter d'envoyer plusieurs messages simultanément en pressant
@@ -97,6 +98,7 @@ euphorik.PageMinichat.prototype.charger = function() {
// la barre d'outils liée à chaque message
this.util.outilsMessage = $('
').prependTo("#page.minichat")
+ this.util.outilsMessage.largeur = this.util.outilsMessage.width(); // TODO : gros cheat pas beau :O
this.util.infoBulle("Extraction de la conversation à partir de ce message", $(".extraire", this.util.outilsMessage));
this.util.infoBulle("Extraction de la conversation complète", $(".extraireCompletement", this.util.outilsMessage));
@@ -226,22 +228,6 @@ euphorik.PageMinichat.prototype.decharger = function() {
this.fragment.delVal("conv")
};
-
-euphorik.PageMinichat.prototype.getJSONMessage = function(pseudo, message) {
- var repondA = [];
- objectEach(this.conversations.messagesRepond, function(id) {
- repondA.push(parseInt(id, 10));
- });
-
- return {
- "header" : { "action" : "put_message", "version" : euphorik.conf.versionProtocole },
- "cookie" : this.client.cookie,
- "nick" : pseudo,
- "content" : message,
- "answer_to" : repondA
- };
-};
-
euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) {
var thisPageMinichat = this;
@@ -275,38 +261,48 @@ euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) {
}
this.envoieMessageEnCours = true;
- jQuery.ajax({
- url : "request",
- type: "POST",
- data : this.util.jsonVersAction(this.getJSONMessage(pseudo, message)),
- dataType : "json",
- beforeSend : function(xmlHttpRequest) {
- // TODO : ça marche ça ??
- xmlHttpRequest.setRequestHeader("X-Requested-With", "");
- },
- success : function(data, textStatus) {
- if(data.reply === "ok") {
- // TODO : revoir cette partie
- // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) TODO : ya mieux ?
- objectEach(thisPageMinichat.conversations.messagesRepond, function(messId) {
- thisPageMinichat.conversations.conversations.each(function(i, conv) {
- var mess = conv.messagesParId[messId];
- if (mess) {
- mess.clientARepondu = true;
- $("#conversations #" + mess.getId(conv.getId())).addClass("repondu")
- }
- });
+ this.communication.requete(
+ "put_message",
+ this.getJSONMessage(pseudo, message),
+ function() {
+ // TODO : revoir cette partie
+ // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) TODO : ya mieux ?
+ objectEach(thisPageMinichat.conversations.messagesRepond, function(messId) {
+ thisPageMinichat.conversations.conversations.each(function(i, conv) {
+ var mess = conv.messagesParId[messId];
+ if (mess) {
+ mess.clientARepondu = true;
+ $("#conversations #" + mess.getId(conv.getId())).addClass("repondu")
+ }
});
-
- $("form#posterMessage input.message").val("");
- thisPageMinichat.conversations.enleverMessagesRepond();
- } else if (data.reply === "error") {
- thisPageMinichat.util.messageDialogue(data.error_message);
- }
+ });
+ $("form#posterMessage input.message").val("");
+ thisPageMinichat.conversations.enleverMessagesRepond();
thisPageMinichat.envoieMessageEnCours = false;
},
- error : function() {
+ function(data) {
+ thisPageMinichat.util.messageDialogue(data.error_message);
thisPageMinichat.envoieMessageEnCours = false;
+ },
+ true,
+ {
+ error : function() {
+ thisPageMinichat.envoieMessageEnCours = false;
+ }
}
+ );
+};
+
+euphorik.PageMinichat.prototype.getJSONMessage = function(pseudo, message) {
+ var repondA = [];
+ objectEach(this.conversations.messagesRepond, function(id) {
+ repondA.push(parseInt(id, 10));
});
+
+ return {
+ "cookie" : this.client.cookie,
+ "nick" : pseudo,
+ "content" : message,
+ "answer_to" : repondA
+ };
};