X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat.js;h=1f6a1188088e82d15b3e9f1211844ee9dfd22598;hp=ed0321c4f7cd7daf463c2814bb46e1c2d9d3dd3a;hb=8bec0dac79e750d0040de8a009c6ae864479642e;hpb=a2f6d159387e456847fb4e7607b4663ab8fa94fc diff --git a/js/pageMinichat.js b/js/pageMinichat.js index ed0321c..1f6a118 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -15,6 +15,7 @@ function PageMinichat(client, formateur, util) PageMinichat.prototype.contenu = function() { return '\ +
Troll de la semaine :
\
\

\ \ @@ -671,6 +672,8 @@ function Messages(client, formateur, util) this.conversations = new Array() // les conversations, la première représente la conversation principale this.nouvelleConversation(0) + this.trollIdCourant = 0 + this.pageEvent = new PageEvent("chat", this.util) } @@ -682,10 +685,11 @@ Messages.prototype.getJSONrafraichirMessages = function() var mess = { "message_count" : conf.nbMessageAffiche, "main_page" : this.client.pagePrincipale, - "conversations" : this.getJSONConversations() + "conversations" : this.getJSONConversations(), + "troll_id" : this.trollIdCourant } - if (this.client.cookie != null) mess["cookie"] = this.client.cookie; + if (this.client.cookie != null) mess["cookie"] = this.client.cookie mess["last_message_id"] = this.conversations[0].idDernierMessageAffiche return mess @@ -894,21 +898,32 @@ Messages.prototype.rafraichirMessages = function(vider) function() { return thisMessages.getJSONrafraichirMessages() }, function(data) { - if (vider) - { - thisMessages.viderMessages() - vider = false - } - - // ajoute les messages reçus à leur conversation respective - for (var numConv = 0; numConv < data["conversations"].length; numConv++) - { - if (! thisMessages.ajouterMessages(data["conversations"][numConv], numConv)) + if (vider) + { + thisMessages.viderMessages() + vider = false + } + + // en fonction du message + switch(data["reply"]) + { + case "new_troll" : + thisMessages.trollIdCourant = data["troll_id"] + $("#trollCourant .troll").html(thisMessages.formateur.traitementComplet(data["content"])) + break + + case "new_messages" : + // ajoute les messages reçus à leur conversation respective + for (var numConv = 0; numConv < data["conversations"].length; numConv++) { - thisMessages.util.messageDialogue("La conversation {" + thisMessages.client.conversations[numConv -1].root.toString(36) + "} n'existe pas") - thisMessages.client.supprimerConversation(numConv - 1) + if (! thisMessages.ajouterMessages(data["conversations"][numConv], numConv)) + { + thisMessages.util.messageDialogue("La conversation {" + thisMessages.client.conversations[numConv -1].root.toString(36) + "} n'existe pas") + thisMessages.client.supprimerConversation(numConv - 1) + } } - } + break + } } ) }