X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat%2FpageMinichat.js;fp=js%2FpageMinichat%2FpageMinichat.js;h=b71efeaac7ebae27438714ca5bb7f1c391d26e22;hp=f11dea495237f63d9e6cec947499b99ad6f4a11f;hb=8ee1535f5594573931ddaebee77bf6148a5358cb;hpb=1eaef253e3c3436668379409472d27d45b7fd2b6 diff --git a/js/pageMinichat/pageMinichat.js b/js/pageMinichat/pageMinichat.js index f11dea4..b71efea 100755 --- a/js/pageMinichat/pageMinichat.js +++ b/js/pageMinichat/pageMinichat.js @@ -25,7 +25,7 @@ euphorik.PageMinichat = function(client, formateur, util, communication) { this.formateur = formateur; this.util = util; this.communication = communication; - this.commandes = new euphorik.Commandes(this.client); + this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formateur); // permet d'éviter d'envoyer plusieurs messages simultanément en pressant // rapidement sur "enter" par exemple @@ -163,7 +163,7 @@ euphorik.PageMinichat.prototype.charger = function() { var retCommandes = thisPage.commandes.exec(message); switch (retCommandes[0]) { case euphorik.Commandes.statut.pas_une_commande : - thisPage.envoyerMessage($("form#posterMessage input.pseudo").val(), message); + thisPage.envoyerMessage(message); break; case euphorik.Commandes.statut.erreur_commande : thisPage.util.messageDialogue(retCommandes[1], euphorik.Util.messageType.erreur); @@ -213,18 +213,23 @@ euphorik.PageMinichat.prototype.chargerConversationsFragment = function() { } catch(e) { ;; console.log(e) } -} +}; euphorik.PageMinichat.prototype.decharger = function() { this.conversations.comet.stopAttenteCourante(); $("body #smiles").remove(); - this.fragment.delVal("conv") + this.fragment.delVal("conv"); }; -euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) { - var thisPageMinichat = this; +/** + * Envoie un nouve message donné, le pseudo utilisé est celui se trouvant + * dans la zone de saisie (form#posterMessage input.pseudo). + */ +euphorik.PageMinichat.prototype.envoyerMessage = function(message) { + var thisPageMinichat = this; + var pseudo = $("form#posterMessage input.pseudo").val(); // (un pseudo vide est autorisé) pseudo = this.formateur.filtrerInputPseudo(pseudo); @@ -239,6 +244,8 @@ euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) { this.util.messageDialogue("Le message est vide"); return; } + + this.client.pseudo = pseudo; if (!this.client.authentifie()) { if (!this.client.enregistrement()) { @@ -247,8 +254,6 @@ euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) { } } - this.client.pseudo = pseudo; - // évite le double post if (this.envoieMessageEnCours) { this.util.messageDialogue("Message en cours d'envoie..."); @@ -260,17 +265,6 @@ euphorik.PageMinichat.prototype.envoyerMessage = function(pseudo, message) { "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(); thisPageMinichat.envoieMessageEnCours = false;