X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat%2Fconversations.js;h=94236c1d84adfd852d52b6aaea1d061a95e67090;hp=26fbb66ebd299e0263b4997cd76082a58d6398b6;hb=8ee1535f5594573931ddaebee77bf6148a5358cb;hpb=d8ea5d4c3a3ed6e596a473bbb8a4df0a41b4843a diff --git a/js/pageMinichat/conversations.js b/js/pageMinichat/conversations.js index 26fbb66..94236c1 100644 --- a/js/pageMinichat/conversations.js +++ b/js/pageMinichat/conversations.js @@ -63,11 +63,11 @@ euphorik.Conversations.prototype.toggleMessageRepond = function(mess) { euphorik.Conversations.prototype.mettreAJourFragment = function() { conv = []; for(var i = 1; i < this.conversations.length; i++) { - conv.push(this.conversations[i].racine.id) + conv.push(this.conversations[i].racine.id); } this.fragment.setVal("conv", conv); this.fragment.write(); -} +}; /** * Enlève tous les messages auquel l'utilisateur souhaite répondre. @@ -99,7 +99,7 @@ euphorik.Conversations.prototype.enleverMessageRepond = function(mess) { * Définit un message comme y répondant. */ euphorik.Conversations.prototype.ajouterMessageRepond = function(mess) { - var thisMessages = this; + var thisConversations = this; // est-ce que le message fait partie de la même conversation que les autres messages ? // TODO : solution plus élégante pour prendre un mess parmis messagesRepond !? @@ -126,7 +126,7 @@ euphorik.Conversations.prototype.ajouterMessageRepond = function(mess) { $("#" + mess.getId(this.prefixIdMessage)).click( function() { $(this).fadeOut("normal", function() { - thisMessages.enleverMessageRepond(mess); + thisConversations.enleverMessageRepond(mess); $("form#posterMessage #repondA .messages").hide(); }); } @@ -195,7 +195,7 @@ euphorik.Conversations.prototype.getJSONrafraichirMessages = function() { }; euphorik.Conversations.prototype.getJSONConversations = function() { - var thisConversations = this + var thisConversations = this; var clientConv = []; this.client.conversations.each(function(i, conv) { @@ -246,9 +246,7 @@ euphorik.Conversations.prototype.ajouterMessages = function(elements, numConvers * @param numConversation le numéro de la conversation, 0 = principale * @return true si une nouvelle conversation a été créée sinon false */ -euphorik.Conversations.prototype.ajouterMessage = function(element, numConversation) { - var thisConversations = this; - +euphorik.Conversations.prototype.ajouterMessage = function(element, numConversation) { var message = new euphorik.Message( this.client, @@ -260,50 +258,30 @@ euphorik.Conversations.prototype.ajouterMessage = function(element, numConversat if (!this.conversations[numConversation]) { nouvelleConversation = true; - this.nouvelleConversation( - numConversation, - function(num) { // fermeture de la conversation - thisConversations.supprimerConversation(num); - }, - function(num) { // insertion du lien vers la conversation - thisPage.util.replaceSelection( - $("form#posterMessage input.message")[0], - "{" + thisConversations.client.conversations[num-1].root.toString(36) + "}" - ); - } - ); + this.nouvelleConversation(numConversation); } this.conversations[numConversation].ajouterMessage(message); return nouvelleConversation; }; -euphorik.Conversations.prototype.nouvelleConversation = function(num, funFermer, funLien) -{ - var thisMessages = this; +euphorik.Conversations.prototype.nouvelleConversation = function(num) { + var thisConversations = this; this.conversations[num] = new euphorik.Conversation(this, num); - if (funFermer) { - this.conversations[num].eventFermer(funFermer); - } - - if (funLien) { - this.conversations[num].eventLien(funLien); - } - this.conversations[num].setFunPage( function(num) { // page suivante - thisMessages.client.pageSuivante(num - 1); - thisMessages.rafraichirMessages(true); + thisConversations.client.pageSuivante(num - 1); + thisConversations.rafraichirMessages(true); }, function(num) { // page précédente - thisMessages.client.pagePrecedente(num - 1); - thisMessages.rafraichirMessages(true); + thisConversations.client.pagePrecedente(num - 1); + thisConversations.rafraichirMessages(true); }, function(num) { // retour à la page une - if (thisMessages.client.goPremierePage(num - 1)) { - thisMessages.rafraichirMessages(true); + if (thisConversations.client.goPremierePage(num - 1)) { + thisConversations.rafraichirMessages(true); } } ); @@ -320,7 +298,7 @@ euphorik.Conversations.prototype.supprimerConversation = function(num) { } this.conversations[num].supprimer(); - // décalage TODO : supprimer le dernier élément + // les numéros sont réassigné for (var i = num; i < this.conversations.length - 1; i++) { this.conversations[i] = this.conversations[i+1]; this.conversations[i].num -= 1; @@ -384,7 +362,7 @@ euphorik.Conversations.prototype.viderMessages = function() { * @param vider vide tous les messages avant d'afficher les nouveaux */ euphorik.Conversations.prototype.rafraichirMessages = function(vider) { - var thisMessages = this; + var thisConversations = this; vider = vider || false; @@ -395,14 +373,14 @@ euphorik.Conversations.prototype.rafraichirMessages = function(vider) { } this.comet.waitEvent( - function() { return thisMessages.getJSONrafraichirMessages(); }, + function() { return thisConversations.getJSONrafraichirMessages(); }, { "new_troll" : - function(data) { - thisMessages.trollIdCourant = data.troll_id; - $("#trollCourant .troll").html(thisMessages.formateur.traitementComplet(data.content)).unbind("click").click( + function(data) { + thisConversations.trollIdCourant = data.troll_id; + $("#trollCourant .troll").html(thisConversations.formateur.traitementComplet(data.content)).unbind("click").click( function() { - thisMessages.ouvrirConversation(data.message_id); + thisConversations.ouvrirConversation(data.message_id); } ); @@ -411,19 +389,19 @@ euphorik.Conversations.prototype.rafraichirMessages = function(vider) { "new_messages" : function(data) { if (vider) { - thisMessages.viderMessages(); + thisConversations.viderMessages(); } // ajoute les messages reçus à leur conversation respective data.conversations.each(function(numConv, conv) { - if (!thisMessages.ajouterMessages(conv, numConv)) { - thisMessages.util.messageDialogue("La conversation {" + thisMessages.client.conversations[numConv - 1].root.toString(36) + "} n'existe pas"); - thisMessages.client.supprimerConversation(numConv - 1); + if (!thisConversations.ajouterMessages(conv, numConv)) { + thisConversations.util.messageDialogue("La conversation {" + thisConversations.client.conversations[numConv - 1].root.toString(36) + "} n'existe pas"); + thisConversations.client.supprimerConversation(numConv - 1); } }); if (vider) { - thisMessages.afficherMessagesRepondConversations(); + thisConversations.afficherMessagesRepondConversations(); } vider = false;