X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat%2Fconversations.js;h=94236c1d84adfd852d52b6aaea1d061a95e67090;hp=0ad7878a2d991ca97907d6e2604a7ef8558d1d5f;hb=8ee1535f5594573931ddaebee77bf6148a5358cb;hpb=a57cb5dd4f773111f734c726f61f06434c39b94e diff --git a/js/pageMinichat/conversations.js b/js/pageMinichat/conversations.js index 0ad7878..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, @@ -267,24 +265,23 @@ euphorik.Conversations.prototype.ajouterMessage = function(element, numConversat return nouvelleConversation; }; -euphorik.Conversations.prototype.nouvelleConversation = function(num) -{ - var thisMessages = this; +euphorik.Conversations.prototype.nouvelleConversation = function(num) { + var thisConversations = this; this.conversations[num] = new euphorik.Conversation(this, num); 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); } } ); @@ -301,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; @@ -365,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; @@ -376,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); } ); @@ -392,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;