FIX problème de mise à jour du profile
[euphorik.git] / js / pageMinichat.js
index a8afb97..8dc7b00 100755 (executable)
@@ -98,7 +98,7 @@ PageMinichat.prototype.charger = function()
       {
          var opacityBase = $(this).css("opacity")
          $(this).click(
-            function(event)
+            function()
             {
                thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formateur.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""))
             }
@@ -302,6 +302,7 @@ function Message(client, formateur, element)
    this.systeme = element["system"] // est-ce un message 'système' ?
    this.setRepondA(element["answer_to"]) // un ensemble de reponse (voir Reponse) indexé par l'id du message de la reponses
    this.ekMaster = element["ek_master"]
+   this.degreeOstentatoire = element["ostentatious_master"]
 }
 
 /**
@@ -354,21 +355,24 @@ Message.prototype.getConversation = function(messages)
       if (messages.messages[i].repondA.hasOwnProperty(this.id))
          messagesEnEvidence[messages.messages[i].id] = 2
    
-   var premierNiveau = true
-   var f = function(tabIds)
+   // parcours en 
+   var f = function(tabIds, premierNiveau)
    {
       for(var id in tabIds)
       {
+         // si le message (id) a déjà été traité
+         if (messagesEnEvidence[id] != undefined && !premierNiveau)
+            continue
+           
          var message = messages.messagesParId[id]
          if (message != undefined)
          {         
             messagesEnEvidence[id] = premierNiveau ? 3 : (message.auteurId == thisMessage.auteurId ? 1 : 0)
-            premierNiveau = false
-            f (message.repondA)
+            f (message.repondA, false)
          }
       }
    }
-   f(this.repondA)
+   f(this.repondA, true)
    
    return messagesEnEvidence
 }
@@ -387,8 +391,8 @@ Message.prototype.XHTML = function(messagePair, pre)
    // construit l'identifiant de la personne
    var identifiant = 
       this.client.nickFormat == "nick" || this.login == "" ? this.formateur.traitementComplet(this.pseudo) : 
-      (this.client.nickFormat == "login" ? this.formateur.traitementComplet(message.login) : 
-      this.formateur.traitementComplet(this.pseudo) + "<span class=\"login\">(" + this.formateur.traitementComplet(message.login) +")</span>" )
+      (this.client.nickFormat == "login" ? this.formateur.traitementComplet(this.login) : 
+      this.formateur.traitementComplet(this.pseudo) + "<span class=\"login\">(" + this.formateur.traitementComplet(this.login) +")</span>" )
 
    var XHTMLrepondA = ""
    var debut = true
@@ -406,7 +410,7 @@ Message.prototype.XHTML = function(messagePair, pre)
          (this.clientARepondu ? " repondu" : "") +
          (this.estUneReponse ? " reponse" : "") +
          (this.systeme ? " systeme" : "") +
-         (this.ekMaster ? " ekMaster" : "") +
+         (this.ekMaster ? " ekMaster" + this.degreeOstentatoire : "") +
       "\">" +
          "<div class=\"outilsMess\"><div class=\"extraire\"></div><div class=\"extraireCompletement\"></div></div><span class=\"entete\">" +
          "<span class=\"dateComplete\">[<span class=\"date\">" + this.date + "</span>]</span>" +
@@ -449,7 +453,7 @@ function Conversation(conversations, num)
       '<div class="messages"></div>' +
       '<div class="titre">' +
          '<div class="barre">' +
-             (num == 0 ? '' : '<div class="fermer"></div><div class="lien"></div>') +
+             (num == 0 ? '' : '<div class="fermer"></div><div class="lien"></div><div class="reduire"></div>') +
              '<span class="next">&lt;</span><span class="numPage">1</span><span class="prev">&gt;</span>' +
              '</div>' +
          '</div>' +
@@ -463,13 +467,13 @@ function Conversation(conversations, num)
       this.util.infoBulle("Fermer la conversation", $("#conversations #" + this.getId() + " .fermer"))   
    }
 }
+
 /**
   * @racine un message représentant la racine de la conversation, vaut undefined pour la conversation générale
   */
 Conversation.prototype.setRacine = function(racineElement)
 {
    this.racine = new Message(this.client, this.formateur, racineElement)
-   this.majRacine()
 }
 
 /**
@@ -480,9 +484,14 @@ Conversation.prototype.majRacine = function()
 {
    if (this.racine == undefined)
       return
-
+     
    if (!(this.racine.id in this.messagesParId))
-      $("#" + this.getId() + " .titre").prepend(this.racine.XHTML(true, this.getId()))
+   {
+      this.messagesParId[this.racine.id] = this.racine
+      var element = $(this.racine.XHTML(true, this.getId()))
+      this.attacherEventsSurMessage(element)
+      $("#" + this.getId() + " .titre").prepend(element)
+   }
 }
 
 Conversation.prototype.enleverMiseEnEvidence = function()
@@ -643,7 +652,7 @@ Conversation.prototype.flush = function()
    // enlève les messages exedentaires
    var nbMessagesAffiche = $("#" + this.getId() + " .message").size()   
    if (nbMessagesAffiche > this.nbMessageMax)
-      $("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).remove()
+      $("#conversations #" + this.getId() + " .messages .message").slice(this.nbMessageMax, nbMessagesAffiche).remove()
    
    if (this.messages.length > 0)
       this.idDernierMessageAffiche = this.messages[this.messages.length-1].id
@@ -657,8 +666,8 @@ Conversation.prototype.attacherEventsSurMessage = function(element)
    // l'id du message
    var idMess = this.idMessageFromString($(element).attr("id"))
 
-   this.util.infoBulle("Extraction de la conversation à partir de ce message", $(".extraire", this))
-   this.util.infoBulle("Extraction de la conversation complète", $(".extraireCompletement", this))
+   this.util.infoBulle("Extraction de la conversation à partir de ce message", $(".extraire", element))
+   this.util.infoBulle("Extraction de la conversation complète", $(".extraireCompletement", element))
    
    var thisConversation = this
    $(".lienConv", element).click(