X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat%2Fcommandes.js;fp=js%2FpageMinichat%2Fcommandes.js;h=0000000000000000000000000000000000000000;hp=dbcc76ab9dbee327949558f6a99fdfa2f07c86a1;hb=e49a1c483f1751f129c0766d1061b3da44b60581;hpb=d6dcd0fd8af56bd4791aa4e621c2e5058033c37a diff --git a/js/pageMinichat/commandes.js b/js/pageMinichat/commandes.js deleted file mode 100644 index dbcc76a..0000000 --- a/js/pageMinichat/commandes.js +++ /dev/null @@ -1,120 +0,0 @@ -// coding: utf-8 -// Copyright 2008 Grégory Burri -// -// This file is part of Euphorik. -// -// Euphorik is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Euphorik is distributed in the hope that it will be useful, -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Euphorik. If not, see . - - /*jslint laxbreak:true */ - -/** - * Permet d'executer des commandes tapées par l'utilisateur. - * les commandes sont entrées directement dans la ligne de saisie du message sous la forme : - * / - * - * Voici les commandes supportées : - * /nick - * Modifie le pseudo courant - */ -euphorik.Commandes = function(client, pageMinichat, util, formater) { - var thisCommandes = this; - - this.client = client; - this.pageMinichat = pageMinichat; - this.util = util; - this.formater = formater; - - // construction du texte d'aide (liste des commandes) de manière statique - this.texteAide = "

Commandes

    "; - objectEach( - euphorik.Commandes.liste, - function(nom, commande) { - thisCommandes.texteAide += "
  • " + thisCommandes.formater.traitementComplet(commande.usage) + " : " + thisCommandes.formater.traitementComplet(commande.description) + "
  • "; - } - ); - this.texteAide += "
"; -}; - -euphorik.Commandes.statut = {ok : 0, pas_une_commande : 1, erreur_commande : 2}; - -euphorik.Commandes.liste = { - "nick" : { - description : "Change le pseudo courant", - usage : "/nick ", - exec : function(args, client) { - - if (args.length === 0) { - return [euphorik.Commandes.statut.erreur_commande, 'Utilisation de la commande : ' + this.usage]; - } - - client.pseudo = args[0]; - $("form#posterMessage input.pseudo").val(client.pseudo); - - return [euphorik.Commandes.statut.ok, '']; - } - }, - "cpf" : { - description : "Envoie le message \"C'est pas faux\"", - usage : "/cpf", - exec : function(args, client, pageMinichat) { - pageMinichat.envoyerMessage("C'est pas faux"); - return [euphorik.Commandes.statut.ok, '']; - } - }, - "osef" : { - description : "Envoie le message \"On s'en fout !\"", - usage : "/osef", - exec : function(args, client, pageMinichat) { - pageMinichat.envoyerMessage("On s'en fout !"); - return [euphorik.Commandes.statut.ok, '']; - } - } -}; - -/** - * Execute une commande. - * @return [statut, message], 'message' n'est utilisé que pour le statut 'erreur_commande'. - */ -euphorik.Commandes.prototype.exec = function(chaine) { - chaine = chaine.trim(); - - var fragments = chaine.split(/\s+/); - if (fragments.length === 0 || fragments[0].charAt(0) != '/') { - return [euphorik.Commandes.statut.pas_une_commande, '']; - } - - var nomCommande = fragments[0].slice(1); - var args = fragments.slice(1); - - if (nomCommande === "") { - return [euphorik.Commandes.statut.erreur_commande, 'La commande est vide']; - } - // commandes spéciales pour afficher l'aide : "?", "h", "help", "aide" - if (nomCommande === "?" || nomCommande === "h" || nomCommande === "help" || nomCommande === "aide") { - this.util.messageDialog( - this.texteAide, - euphorik.Util.messageType.informatif, - {"fermer" : function(){}}, - false, - -1 - ); - return [euphorik.Commandes.statut.ok, '']; - } - - if (euphorik.Commandes.liste.hasOwnProperty(nomCommande)) { - return euphorik.Commandes.liste[nomCommande].exec(args, this.client, this.pageMinichat); - } - - return [euphorik.Commandes.statut.erreur_commande, 'La commande /' + nomCommande + ' est inconnue']; -};