Remove the weekly troll.
[euphorik.git] / js / pageMinichat.js
index 86c059e..13f3375 100755 (executable)
 //
 // You should have received a copy of the GNU General Public License
 // along with Euphorik.  If not, see <http://www.gnu.org/licenses/>.
+
 /*jslint laxbreak:true */
 
 euphorik.PageMinichat = function(client, formater, util, communication) {
    this.name = "minichat";
-   
+
    this.client = client;
    this.formater = formater;
    this.util = util;
    this.communication = communication;
    this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formater);
-   
+
    // permet d'éviter d'envoyer plusieurs messages simultanément en pressant
    // rapidement sur "enter" par exemple
    this.envoieMessageEnCours = false;
@@ -45,14 +45,13 @@ euphorik.PageMinichat.prototype.contenu = function() {
       '  <button class="return"></button>' +
       ' </p>' +
       '</form>';
-      
-   var trollXHTML = '<div id="trollCourant">Troll de la semaine : <span class="troll"></span></div>';
+
    var conversationXHTML = '<table id="conversations"><tr></tr></table>';
-    
+
    if (this.client.chatOrder === "reverse") {
-      return trollXHTML + formulaireXHTML + conversationXHTML;
+      return formulaireXHTML + conversationXHTML;
    } else {
-      return trollXHTML + conversationXHTML + formulaireXHTML;
+      return conversationXHTML + formulaireXHTML;
    }
 };
 
@@ -62,20 +61,20 @@ euphorik.PageMinichat.prototype.classes = function() {
 
 euphorik.PageMinichat.prototype.charger = function() {
    thisPage = this;
-   
+
    $("#posterMessage input.nick").val(this.client.nick);
-   
+
    // cet appel ne doit pas être fait avant l'appel à 'charger'
-   this.conversations = new euphorik.Conversations(this.client, this.formater, this.util, this.communication, this.fragment);   
-   
+   this.conversations = new euphorik.Conversations(this.client, this.formater, this.util, this.communication, this.fragment);
+
    this.chargerConversationsFragment();
-   
-   this.conversations.rafraichirMessages(true);   
+
+   this.conversations.rafraichirMessages(true);
 
    this.util.setCaretToEnd($("form#posterMessage input.message")[0]);
 
    // les outils de bannissement (uniquement pour les ekMaster)
-   if (this.client.ekMaster) {    
+   if (this.client.ekMaster) {
       // TODO : augmentation un peu space, à revoir
       this.util.outilsBan = $(
          '<span id="outilsBan">' +
@@ -86,16 +85,15 @@ euphorik.PageMinichat.prototype.charger = function() {
          ' <img id="slap" src="img/slap.gif" alt="Avertissement" />' +
          '</span>'
       );
-      
+
       this.util.infoBulle("Slap", $("#slap", this.util.outilsBan));
       this.util.infoBulle("Kick (" + euphorik.conf.tempsKick + "min)", $("#kick", this.util.outilsBan));
       this.util.infoBulle("Ban (" + euphorik.conf.tempsBan / 24 / 60 + " jours)", $("#ban", this.util.outilsBan));
       this.util.infoBulle("La raison", $("input", this.util.outilsBan));
    }
-   
+
    // la barre d'outils liée à chaque message
-   this.util.outilsMessage = $('<div id="outilsMess"><div class="extraire"></div><div class="extraireCompletement"></div></div>').prependTo("#page.minichat");   
-   this.util.infoBulle("Ouvrir la conversation liée au troll de la semaine", $("#trollCourant .troll"));   
+   this.util.outilsMessage = $('<div id="outilsMess"><div class="extraire"></div><div class="extraireCompletement"></div></div>').prependTo("#page.minichat");
    this.util.infoBulle("Cliquer sur les messages pour les enlevers de la liste",
       $("form#posterMessage #repondA").hover(
          function() {
@@ -112,7 +110,7 @@ euphorik.PageMinichat.prototype.charger = function() {
             if ($(e.target).is(".nb")) {
                thisPage.conversations.enleverMessagesRepond();
             }
-         }     
+         }
       ),
       euphorik.Util.positionBulleType.droite
    );
@@ -145,19 +143,19 @@ euphorik.PageMinichat.prototype.charger = function() {
       }
    );
    // </smiles>
-      
+
    // événements
-   var nouveauMessage = 
-      function() {  
+   var nouveauMessage =
+      function() {
          // captcha anti bot
          if ($("form#posterMessage input.captcha").val() !== "") {
             return;
          }
-         
+
          var message = $("form#posterMessage input.message").val();
-         
+
          // traitement des commandes..
-         var retCommandes = thisPage.commandes.exec(message);         
+         var retCommandes = thisPage.commandes.exec(message);
          switch (retCommandes[0]) {
             case euphorik.Commandes.statut.pas_une_commande :
                thisPage.envoyerMessage(message);
@@ -168,11 +166,11 @@ euphorik.PageMinichat.prototype.charger = function() {
             case euphorik.Commandes.statut.ok :
                $("form#posterMessage input.message").val("");
                break;
-         }         
-            
+         }
+
          $("form#posterMessage input.message").focus();
       };
-      
+
    $("form#posterMessage").keypress(
       function(e) {
          if (e.which === 13) { // return
@@ -180,12 +178,12 @@ euphorik.PageMinichat.prototype.charger = function() {
          }
       }
    );
-   
+
    $("form#posterMessage button.return").click(nouveauMessage);
-   
+
    // interdiction de submiter le formulaire
    $("form#posterMessage").submit(function(){ return false; });
-   
+
    $("input.nick").click(
       function() {
          var input = $("input.nick")[0];
@@ -197,8 +195,8 @@ euphorik.PageMinichat.prototype.charger = function() {
 };
 
 euphorik.PageMinichat.prototype.chargerConversationsFragment = function() {
-   var thisPageMinichat = this; 
-   
+   var thisPageMinichat = this;
+
    // attention : "conv" doit être un tableau d'entier
    try {
       var conv = this.fragment.getVal("conv");
@@ -211,12 +209,12 @@ euphorik.PageMinichat.prototype.chargerConversationsFragment = function() {
       ;; console.log(e)
    }
 };
-  
+
 euphorik.PageMinichat.prototype.decharger = function() {
    this.conversations.comet.stopAttenteCourante();
-   
+
    $("body #smiles").remove();
-   
+
     this.fragment.delVal("conv");
 };
 
@@ -224,46 +222,46 @@ euphorik.PageMinichat.prototype.decharger = function() {
   * Envoie un nouve message donné, le nick utilisé est celui se trouvant
   * dans la zone de saisie (form#posterMessage input.nick).
   */
-euphorik.PageMinichat.prototype.envoyerMessage = function(message) {   
-   var thisPageMinichat = this;   
+euphorik.PageMinichat.prototype.envoyerMessage = function(message) {
+   var thisPageMinichat = this;
    var nick = $("form#posterMessage input.nick").val();
 
    // (un nick vide est autorisé)
    nick = this.formater.formatNick(nick);
-   
+
    if (nick === euphorik.conf.defaultNick) {
-      this.util.messageDialog("Le nick ne peut pas être " + euphorik.conf.defaultNick);
+      this.util.messageDialog("Choose a nickname");
       return;
    }
-   
+
    message = message.trim();
    if (!message) {
-      this.util.messageDialog("Le message est vide");
+      this.util.messageDialog("The message is empty");
       return;
    }
-   
+
    if (!this.client.authentifie()) {
       if (!this.client.enregistrement()) {
-         this.util.messageDialog("login impossible");
+         this.util.messageDialog("unable to login");
          return;
       }
    }
-      
+
    // évite le double post
    if (this.envoieMessageEnCours) {
       this.util.messageDialog("Message en cours d'envoie...");
       return;
    }
    this.envoieMessageEnCours = true;
-   
+
    this.client.nick = nick;
-   
+
    this.communication.requete(
       "put_message",
       this.getJSONMessage(this.client.nick, message),
       function() {
          $("form#posterMessage input.message").val("");
-         thisPageMinichat.conversations.enleverMessagesRepond(); 
+         thisPageMinichat.conversations.enleverMessagesRepond();
          thisPageMinichat.envoieMessageEnCours = false;
       },
       function(data) {
@@ -284,7 +282,7 @@ euphorik.PageMinichat.prototype.getJSONMessage = function(nick, message) {
    objectEach(this.conversations.messagesRepond, function(id) {
       repondA.push(parseInt(id, 10));
    });
-      
+
    return {
       "cookie" : this.client.cookie,
       "nick" : nick,