<commit_before>const Command = require('../Command')
const DiscordServer = require('../../DiscordServer')

module.exports =
class BindGroupCommand extends Command {
    constructor(client) {
        super(client, {
            name: 'bindgrouprank',
            aliases: ['roverbindgrouprank', 'bindgroup', 'bindrank', 'roverbind'],
            description: "`<roblox group id> <((>|<|)group rank|\"all\")> <Discord Role>` Binds Roblox group membership or group rank to a Discord role. Middle argument can be either the required rank number (from Roblox group admin page), or the word `all` to indicate all group members. If you choose to use rank number, you can also use operators: `>` will match all members who have a rank **greater than or equal to** the given rank, and `<` will match all members who have a rank **less than** the given rank. If you exclude the operator, an exact rank number match is used.",

            args: [
                {
                    key: 'group',
                    prompt: "Group",
                    type: 'integer'
                },
                {
                    key: 'rank',
                    prompt: "Rank",
                    type: 'string'
                },
                {
                    key: 'role',
                    prompt: "Role",
                    type: 'role'
                }
            ]
        });
    }

    async fn(msg, args) {
        let binding = {};

        // Support for operators, so we parse them out before
        // saving the rank number.
        let rankUnparsed = args.rank;
        let all = false;

        if (rankUnparsed === 'all') {
            rankUnparsed = '>1';
            all = true;
        }

        if (rankUnparsed.startsWith('>')) {
            binding.operator = 'gt';
            rankUnparsed = rankUnparsed.substring(1);
        } else if (rankUnparsed.startsWith('<')) {
            binding.operator = 'lt';
            rankUnparsed = rankUnparsed.substring(1);
        }

        binding.group = args.group;
        binding.rank = parseInt(rankUnparsed, 10);
        binding.role = args.role.id;

        // Delete any previous binding with that role.
        this.server.deleteGroupRankBinding(binding.role);

        // Add the new binding.
        let serverBindings = this.server.getSetting('groupRankBindings');
        serverBindings.push(binding);
        this.server.setSetting('groupRankBindings', serverBindings);

        if (!all) {
            msg.reply(`Added rank binding: Group: ${binding.group}, Rank: ${binding.rank || 'none'}, Role: ${args.role.name}, Comparison: ${binding.operator || 'eq'}`);
        } else {
            msg.reply(`Added rank binding for all members in group: Group: ${binding.group}, Role: ${args.role.name}`);
        }
    }
}<commit_msg>Change optional argument rank to last<commit_after>const Command = require('../Command')
const DiscordServer = require('../../DiscordServer')

module.exports =
class BindGroupCommand extends Command {
    constructor(client) {
        super(client, {
            name: 'bindgrouprank',
            aliases: ['roverbindgrouprank', 'bindgroup', 'bindrank', 'roverbind'],
            description: "`<roblox group id> <Discord Role> <((>|<|)group rank|\"all\")>` Binds Roblox group membership or group rank to a Discord role. Last argument can be either the required rank number (from Roblox group admin page), or the word `all` to indicate all group members. If you choose to use rank number, you can also use operators: `>` will match all members who have a rank **greater than or equal to** the given rank, and `<` will match all members who have a rank **less than** the given rank. If you exclude the operator, an exact rank number match is used.",

            args: [
                {
                    key: 'group',
                    prompt: "Group",
                    type: 'string'
                },
                {
                    key: 'role',
                    prompt: "Role",
                    type: 'role'
                },
                {
                    key: 'rank',
                    prompt: "Rank",
                    type: 'string',
                    default: 'all'
                }
            ]
        });
    }

    async fn(msg, args) {
        let binding = {};

        // Support for operators, so we parse them out before
        // saving the rank number.
        let rankUnparsed = args.rank;
        let all = false;

        if (rankUnparsed === 'all') {
            rankUnparsed = '>1';
            all = true;
        }

        if (rankUnparsed.startsWith('>')) {
            binding.operator = 'gt';
            rankUnparsed = rankUnparsed.substring(1);
        } else if (rankUnparsed.startsWith('<')) {
            binding.operator = 'lt';
            rankUnparsed = rankUnparsed.substring(1);
        }

        binding.group = args.group;
        binding.rank = parseInt(rankUnparsed, 10);
        binding.role = args.role.id;

        // Delete any previous binding with that role.
        this.server.deleteGroupRankBinding(binding.role);

        // Add the new binding.
        let serverBindings = this.server.getSetting('groupRankBindings');
        serverBindings.push(binding);
        this.server.setSetting('groupRankBindings', serverBindings);

        if (!all) {
            msg.reply(`Added rank binding: Group: ${binding.group}, Rank: ${binding.rank || 'none'}, Role: ${args.role.name}, Comparison: ${binding.operator || 'eq'}`);
        } else {
            msg.reply(`Added rank binding for all members in group: Group: ${binding.group}, Role: ${args.role.name}`);
        }
    }
}<|endoftext|>


<commit_before>angular.module('ZoumProfiler')
    .factory('monsters', function () {
        var monsters = {};

        monsters.families = {
            Animal: {
                "Chauve-Souris":3,
                "Chauve-Souris Géante":4,
                "Cheval à Dents de Sabre":23,
                Dindon:1,
                "Dindon du Chaos":1,
                "Geck'oo":15,
                "Geck'oo majestueux":40,
                Glouton:20,
                Gnu:1,
                "Gnu Sauvage":1,
                "Gnu Domestique":1,
                Gowap:1,
                "Gowap Apprivoisé":1,
                "Gowap Sauvage":1,
                "Lapin Blanc":1,
                "Rat":1,
                "Rat Géant":2,
                Sagouin:3,
                "Tubercule Tueur":14
            },
            Insecte: {
                Ankheg: 10,
                "Anoploure Purpurin":36,
                "Araignée":1,
                "Araignée Géante":2,
                Coccicruelle:22,
                "Essaim Cratérien":30,
                "Essaim Sanguinaire":25,
                Foudroyeur:38,
                Labeilleux:26,
                "Limace Géante":10,
                "Mante Fulcreuse":30,
                "Mille-Pattes":13,
                "Mille-Pattes Géant":14,
                "Nuage d'Insectes":7,
                "Nuée de Vermine":13,
                Pititabeille:0,
                "Scarabée":3,
                "Scarabée Géant":4,
                "Scorpion Géant":10,
                Strige:2,
                "Thri-kreen":10
            },
            "Mort-Vivant": {
                "Ame-en-peine":8,
                Banshee:16,
                Capitan:35,
                Croquemitaine:6,
                Ectoplasme:18,
                Fantôme:24,
                Goule:4,
                Liche:50,
                Mohrg:35,
                Momie:4,
                "Nâ-Hàniym-Hééé":0,
                Nécrochore:37,
                Nécromant:39,
                Nécrophage:8,
                Ombre:2,
                Spectre:14,
                Squelette:1,
                Vampire:29,
                Zombie:2
            },
            Monstre: {
                "Amibe":8,
                "Amibe Géante":9,
                "Anaconda des Catacombes":8,
                Basilisk:11,
                Behir:14,
                Beholder:50,
                Bondin:9,
                "Bouj'Dla":19,
                "Bouj'Dla Placide":37,
                Bulette:19,
                Carnosaure:25,
                Chimère:13,
                Chonchon:24,
                Cockatrice:5,
                Crasc:10,
                "Crasc Médius":17,
                "Crasc Maexus":24,
                "Cube Gélatineux":32,
                Djinn:29,
                Effrit:27,
                "Esprit-Follet":16,
                Familier:1,
                "Feu Follet":20,
                Fungus:8,
                "Fungus Géant":9,
                "Fungus Violet":4,
                Gargouille:3,
                Gorgone:11,
                Grouilleux:4,
                Grylle:31,
                Harpie:4,
                Hydre:50,
                "Lézard":4,
                "Lézard Géant":5,
                Manticore:9,
                Mimique:6,
                "Monstre Rouilleur":3,
                "Mouch'oo":14,
                "Mouch'oo Domestique":14,
                "Mouch'oo Sauvage":14,
                "Mouch'oo Majestueux":33,
                "Mouch'oo Majestueux Sauvage":33,
                Naga:10,
                "Ombre de Roches":13,
                Phoenix:32,
                "Plante Carnivore":4,
                Slaad:5,
                "Tertre Errant":20,
                Trancheur:35,
                Tutoki:4,
                "Ver Carnivore":11,
                "Ver Carnivore Géant":12,
                Vouivre:33,
                Worg:5
            },
            Démon: {
                "Abishaii Bleu":19,
                "Abishaii Noir":10,
                "Abishaii Rouge":23,
                "Abishaii Vert":15,
                Balrog:50,
                Barghest:36,
                Behemoth:34,
                "Chevalier du Chaos":20,
                Daemonite:27,
                Diablotin:5,
                "Elementaire d'Air":23,
                "Elémentaire d'Air":23,
                "Elementaire d'Eau":17,
                "Elémentaire d'Eau":17,
                "Elementaire de Feu":21,
                "Elémentaire de Feu":21,
                "Elementaire de Terre":21,
                "Elémentaire de Terre":21,
                "Elementaire du Chaos":26,
                "Elémentaire du Chaos":26,
                "Elementaire Magmatique":0,
                "Elémentaire Magmatique":0,
                Erinyes:7,
                "Grosse Erinyes":8,
                Fumeux:22,
                Gritche:39,
                Hellrot:18,
                Incube:13,
                Marilith:33,
                "Molosse Satanique":8,
                "Palefroi Infernal":29,
                "Pseudo-Dragon":5,
                Shai:28,
                Succube:13,
                Xorn:14
            },
            Humanoïde: {
                Ashashin:35,
                Boggart:3,
                Caillouteux:1,
                "Champi-Glouton":3,
                Ettin:8,
                "Flagelleur Mental":33,
                Furgolin:10,
                "Géant de Pierre":13,
                "Géant des Gouffres":22,
                Gnoll:5,
                Goblin:4,
                Goblours:4,
                "Golem de cuir":1,
                "Golem de mithril":1,
                "Golem de métal":1,
                "Golem de papier":1,
                "Golem d'Argile":15,
                "Golem de Chair":8,
                "Golem de Fer":31,
                "Golem de Pierre":23,
                Gremlins:3,
                "Homme-Lézard":4,
                Hurleur:8,
                Kobold:2,
                "Loup-Garou":8,
                Lutin:4,
                Méduse:6,
                Mégacéphale:38,
                Minotaure:7,
                Ogre:7,
                Orque:3,
                "Ours-Garou":18,
                Raquettou:1,
                "Rat-Garou":3,
                Rocketeux:5,
                Sorcière:17,
                Sphinx:30,
                "Tigre-Garou":12,
                Titan:26,
                "Veskan du Chaos":14,
                "Veskan Du Chaos":14,
                Yéti:8,
                "Yuan-ti":15
            }
        };

        //Alchimiste
        //Agressif				+1
        //Alpha				+11
        //Archaique			-1
        //Archiatre			+2
        //Attentionné			+2
        //Barbare				+1
        //Berserker			+3
        //Champion			+4
        //Cogneur			+2
        //Colossal			+7
        //Coriace				+1
        //Corrompu			+1
        //Cracheur			+2
        //de Premier Cercle	-1
        //de Second Cercle	+0
        //de Troisième Cercle	+2
        //de Quatrième Cercle	+4
        //de Cinquième Cercle	+5
        //des Abysses			+3
        //Effrayé				-1
        //Enragé				+3
        //Esculape			+2
        //Ethéré				+3
        //Fanatique			+2
        //Fou					+1
        //Fouisseur			+0
        //Frénétique			+3
        //Frondeur			+2
        //Fustigateur			+2
        //Gardien				+20
        //Gargantuesque		+3
        //Gigantesque			+1
        //Grand Frondeur		+4
        //Gros				+0
        //Guérisseur			+2
        //Guerrier				+1
        //Héros				+5
        //Homochrome	 	+0
        //Homomorphe	 	+0
        //Implacable			+3
        //Invocateur			+5	(avant +3)
        //Maitre				+8
        //Lobotomisateur		+2
        //Malade				-1
        //Médicastre			+2
        //Mentat				+2
        //Morticole			+2
        //Mutant				+2
        //Nécromant			+5
        //Ouvrier				+0
        //Paysan				-1
        //Petit				-1
        //Planque	 			+0
        //Prince				+8
        //Psychophage		+2
        //Reine				+11
        //Ronfleur				+2
        //Scout				+2 (avant +1)
        //Shaman				+0
        //Soldat				+2 (avant +3)
        //Sorcier				+0
        //Spectral	 			+0
        //Strident				+3
        //Traqueur			+1
        //Voleur				+2
        //Vorace				+1
        monsters.templates = {
            Alchimiste:0,
            Agressif:1,
            Agressive:1,
            Alpha:11,
            Archaïque:-1,
            Archiatre:2,
            Attentionné:2,
            Attentionnée:2,
            Barbare:1,
            Berserker:3,
            Berserkere:3,
            Champion:4,
            Championne:4,
            Cogneur:2,
            Cogneuse:2,
            Colossal:7,
            Colossale:7,
            Coriace:1,
            Corrompu:1,
            Corrompue:1,
            Cracheur:2,
            Cracheuse:2,
            "de Premier Cercle":-1,
            "de Second Cercle":0,
            "de Troisième Cercle":2,
            "de Quatrième Cercle":4,
            "de Cinquième Cercle":5,
            "des Abysses":3,
            Effrayé:-1,
            Effrayée:-1,
            Enragé:3,
            Enragée:3,
            Esculape:2,
            Ethéré:3,
            Fanatique:2,
            Fou:1,
            Fouisseur:0,
            Fouisseuse:0,
            Frénétique:3,
            Frondeur:2,
            Frondeuse:2,
            Fustigateur:2,
            Fustigatrice:2,
            Gardien:20,
            Gargantuesque:3,
            Gigantesque:1,
            "Grand Frondeur":4,
            Gros:0,
            Grosse:0,
            Guérisseur:2,
            Guérisseuse:2,
            Guerrier:1,
            Guerrière:1,
            Héros:5,
            Homochrome:0,
            Homomorphe:0,
            Implacable:3,
            Invocateur:5,
            Invocatrice:5,
            Maitre:8,
            Maître:8,
            Maîtresse:8,
            Lobotomisateur:2,
            Lobotomisatrice:2,
            Malade:-1,
            Médicastre:2,
            Mentat:2,
            Morticole:2,
            Mutant:2,
            Mutante:2,
            Nécromant:5,
            Nécromante:5,
            Ouvrier:0,
            Ouvrière:0,
            Paysan:-1,
            Paysanne:-1,
            Petit:-1,
            Petite:-1,
            Planque:0,
            Planqué:0,
            Prince:8,
            Princesse:8,
            Psychophage:2,
            Reine:11,
            Ronfleur:2,
            Ronfleuse:2,
            Scout:2,
            Shaman:0,
            Soldat:2,
            Sorcier:0,
            Sorcière:0,
            Spectral:0,
            Spectrale:0,
            Strident:3,
            Stridente:3,
            Traqueur:1,
            Traqueuse:1,
            Voleur:2,
            Voleuse:2,
            Vorace:1
        };
        //+0	Bébé			Initial		Nouveau	Larve		Nouveau		Naissant
        //+1	Enfançon		Novice		Jeune		Immature	Jeune		Récent
        //+2	Jeune			Mineur		Adulte		Juvénile		Adulte		Ancien
        //+3	Adulte			Favori		Vétéran		Imago		Vétéran		Vénérable
        //+4	Mature			Majeur		Briscard		Développé	Briscard		Séculaire
        //+5	Chef de Harde	Supérieur	Doyen		Mûr			Doyen		Antique
        //+6	Ancien			Suprême	Légendaire	Accompli	Légendaire	Ancestral
        //+7	Ancêtre			Ultime		Mythique	Achevé		Mythique	Antédiluvien

        monsters.ages = {
            Animal: {Bébé:0, Enfançon:1, Jeune:2, Adulte:3, Mature:4, "Chef de Harde":5, "Chef de harde":5, Ancien:6, Ancienne:6, Ancêtre:7},
            Démon: {Initial:0, Initiale:0, Novice:1, Mineur:2, Mineure:2, Favori:3, Favorite:3, Majeur:4, Majeure:4, Supérieur:5, Supérieure:5, Suprême:6, Ultime:7},
            Humanoïde: {Nouveau:0, Nouvelle:0, Jeune:1, Adulte:2, Vétéran:3, Briscard:4, Briscarde:4, Doyen:5, Doyenne:5, Légendaire:6, Mythique:7},
            Insecte: {Larve:0, Immature:1, Juvénile:2, Imago:3, Développé:4, Développée:4, Mûr:5, Mûre:5, Accompli:6, Accomplie:6, Achevé:7, Achevée:7},
            Monstre: {Nouveau:0, Nouvelle:0, Jeune:1, Adulte:2, Vétéran:3, Briscard:4, Briscarde:4, Doyen:5, Doyenne:5, Légendaire:6, Mythique:7},
            "Mort-Vivant": {Naissant:0, Naissante:0, Récent:1, Récente:1, Ancien:2, Ancienne:2, Vénérable:3, Séculaire:4, Antique:5, Ancestral:6, Ancestrale:6, Antédiluvien:7, Antédiluvienne:7}
        };

        return monsters;
    });
<commit_msg>code style<commit_after>angular.module('ZoumProfiler')
    .factory('monsters', function () {
        var monsters = {};

        // Nivals des monstres, catégorisés par famille
        monsters.families = {
            Animal: {
                "Chauve-Souris":3,
                "Chauve-Souris Géante":4,
                "Cheval à Dents de Sabre":23,
                Dindon:1,
                "Dindon du Chaos":1,
                "Geck'oo":15,
                "Geck'oo majestueux":40,
                Glouton:20,
                Gnu:1,
                "Gnu Sauvage":1,
                "Gnu Domestique":1,
                Gowap:1,
                "Gowap Apprivoisé":1,
                "Gowap Sauvage":1,
                "Lapin Blanc":1,
                "Rat":1,
                "Rat Géant":2,
                Sagouin:3,
                "Tubercule Tueur":14
            },
            Insecte: {
                Ankheg: 10,
                "Anoploure Purpurin":36,
                "Araignée":1,
                "Araignée Géante":2,
                Coccicruelle:22,
                "Essaim Cratérien":30,
                "Essaim Sanguinaire":25,
                Foudroyeur:38,
                Labeilleux:26,
                "Limace Géante":10,
                "Mante Fulcreuse":30,
                "Mille-Pattes":13,
                "Mille-Pattes Géant":14,
                "Nuage d'Insectes":7,
                "Nuée de Vermine":13,
                Pititabeille:0,
                "Scarabée":3,
                "Scarabée Géant":4,
                "Scorpion Géant":10,
                Strige:2,
                "Thri-kreen":10
            },
            "Mort-Vivant": {
                "Ame-en-peine":8,
                Banshee:16,
                Capitan:35,
                Croquemitaine:6,
                Ectoplasme:18,
                Fantôme:24,
                Goule:4,
                Liche:50,
                Mohrg:35,
                Momie:4,
                "Nâ-Hàniym-Hééé":0,
                Nécrochore:37,
                Nécromant:39,
                Nécrophage:8,
                Ombre:2,
                Spectre:14,
                Squelette:1,
                Vampire:29,
                Zombie:2
            },
            Monstre: {
                "Amibe":8,
                "Amibe Géante":9,
                "Anaconda des Catacombes":8,
                Basilisk:11,
                Behir:14,
                Beholder:50,
                Bondin:9,
                "Bouj'Dla":19,
                "Bouj'Dla Placide":37,
                Bulette:19,
                Carnosaure:25,
                Chimère:13,
                Chonchon:24,
                Cockatrice:5,
                Crasc:10,
                "Crasc Médius":17,
                "Crasc Maexus":24,
                "Cube Gélatineux":32,
                Djinn:29,
                Effrit:27,
                "Esprit-Follet":16,
                Familier:1,
                "Feu Follet":20,
                Fungus:8,
                "Fungus Géant":9,
                "Fungus Violet":4,
                Gargouille:3,
                Gorgone:11,
                Grouilleux:4,
                Grylle:31,
                Harpie:4,
                Hydre:50,
                "Lézard":4,
                "Lézard Géant":5,
                Manticore:9,
                Mimique:6,
                "Monstre Rouilleur":3,
                "Mouch'oo":14,
                "Mouch'oo Domestique":14,
                "Mouch'oo Sauvage":14,
                "Mouch'oo Majestueux":33,
                "Mouch'oo Majestueux Sauvage":33,
                Naga:10,
                "Ombre de Roches":13,
                Phoenix:32,
                "Plante Carnivore":4,
                Slaad:5,
                "Tertre Errant":20,
                Trancheur:35,
                Tutoki:4,
                "Ver Carnivore":11,
                "Ver Carnivore Géant":12,
                Vouivre:33,
                Worg:5
            },
            Démon: {
                "Abishaii Bleu":19,
                "Abishaii Noir":10,
                "Abishaii Rouge":23,
                "Abishaii Vert":15,
                Balrog:50,
                Barghest:36,
                Behemoth:34,
                "Chevalier du Chaos":20,
                Daemonite:27,
                Diablotin:5,
                "Elementaire d'Air":23,
                "Elémentaire d'Air":23,
                "Elementaire d'Eau":17,
                "Elémentaire d'Eau":17,
                "Elementaire de Feu":21,
                "Elémentaire de Feu":21,
                "Elementaire de Terre":21,
                "Elémentaire de Terre":21,
                "Elementaire du Chaos":26,
                "Elémentaire du Chaos":26,
                "Elementaire Magmatique":0,
                "Elémentaire Magmatique":0,
                Erinyes:7,
                "Grosse Erinyes":8,
                Fumeux:22,
                Gritche:39,
                Hellrot:18,
                Incube:13,
                Marilith:33,
                "Molosse Satanique":8,
                "Palefroi Infernal":29,
                "Pseudo-Dragon":5,
                Shai:28,
                Succube:13,
                Xorn:14
            },
            Humanoïde: {
                Ashashin:35,
                Boggart:3,
                Caillouteux:1,
                "Champi-Glouton":3,
                Ettin:8,
                "Flagelleur Mental":33,
                Furgolin:10,
                "Géant de Pierre":13,
                "Géant des Gouffres":22,
                Gnoll:5,
                Goblin:4,
                Goblours:4,
                "Golem de cuir":1,
                "Golem de mithril":1,
                "Golem de métal":1,
                "Golem de papier":1,
                "Golem d'Argile":15,
                "Golem de Chair":8,
                "Golem de Fer":31,
                "Golem de Pierre":23,
                Gremlins:3,
                "Homme-Lézard":4,
                Hurleur:8,
                Kobold:2,
                "Loup-Garou":8,
                Lutin:4,
                Méduse:6,
                Mégacéphale:38,
                Minotaure:7,
                Ogre:7,
                Orque:3,
                "Ours-Garou":18,
                Raquettou:1,
                "Rat-Garou":3,
                Rocketeux:5,
                Sorcière:17,
                Sphinx:30,
                "Tigre-Garou":12,
                Titan:26,
                "Veskan du Chaos":14,
                "Veskan Du Chaos":14,
                Yéti:8,
                "Yuan-ti":15
            }
        };

        // Templates et bonus par template
        monsters.templates = {
            Alchimiste:0,
            Agressif:1,
            Agressive:1,
            Alpha:11,
            Archaïque:-1,
            Archiatre:2,
            Attentionné:2,
            Attentionnée:2,
            Barbare:1,
            Berserker:3,
            Berserkere:3,
            Champion:4,
            Championne:4,
            Cogneur:2,
            Cogneuse:2,
            Colossal:7,
            Colossale:7,
            Coriace:1,
            Corrompu:1,
            Corrompue:1,
            Cracheur:2,
            Cracheuse:2,
            "de Premier Cercle":-1,
            "de Second Cercle":0,
            "de Troisième Cercle":2,
            "de Quatrième Cercle":4,
            "de Cinquième Cercle":5,
            "des Abysses":3,
            Effrayé:-1,
            Effrayée:-1,
            Enragé:3,
            Enragée:3,
            Esculape:2,
            Ethéré:3,
            Fanatique:2,
            Fou:1,
            Fouisseur:0,
            Fouisseuse:0,
            Frénétique:3,
            Frondeur:2,
            Frondeuse:2,
            Fustigateur:2,
            Fustigatrice:2,
            Gardien:20,
            Gargantuesque:3,
            Gigantesque:1,
            "Grand Frondeur":4,
            Gros:0,
            Grosse:0,
            Guérisseur:2,
            Guérisseuse:2,
            Guerrier:1,
            Guerrière:1,
            Héros:5,
            Homochrome:0,
            Homomorphe:0,
            Implacable:3,
            Invocateur:5,
            Invocatrice:5,
            Maitre:8,
            Maître:8,
            Maîtresse:8,
            Lobotomisateur:2,
            Lobotomisatrice:2,
            Malade:-1,
            Médicastre:2,
            Mentat:2,
            Morticole:2,
            Mutant:2,
            Mutante:2,
            Nécromant:5,
            Nécromante:5,
            Ouvrier:0,
            Ouvrière:0,
            Paysan:-1,
            Paysanne:-1,
            Petit:-1,
            Petite:-1,
            Planque:0,
            Planqué:0,
            Prince:8,
            Princesse:8,
            Psychophage:2,
            Reine:11,
            Ronfleur:2,
            Ronfleuse:2,
            Scout:2,
            Shaman:0,
            Soldat:2,
            Sorcier:0,
            Sorcière:0,
            Spectral:0,
            Spectrale:0,
            Strident:3,
            Stridente:3,
            Traqueur:1,
            Traqueuse:1,
            Voleur:2,
            Voleuse:2,
            Vorace:1
        };

        // Âge des monstres et bonus par âge (catégorisé par famille)
        monsters.ages = {
            Animal: {
                Bébé:0,
                Enfançon:1,
                Jeune:2,
                Adulte:3,
                Mature:4,
                "Chef de Harde":5,
                "Chef de harde":5,
                Ancien:6,
                Ancienne:6,
                Ancêtre:7
            },
            Démon: {
                Initial:0,
                Initiale:0,
                Novice:1,
                Mineur:2,
                Mineure:2,
                Favori:3,
                Favorite:3,
                Majeur:4,
                Majeure:4,
                Supérieur:5,
                Supérieure:5,
                Suprême:6,
                Ultime:7
            },
            Humanoïde: {
                Nouveau:0,
                Nouvelle:0,
                Jeune:1,
                Adulte:2,
                Vétéran:3,
                Briscard:4,
                Briscarde:4,
                Doyen:5,
                Doyenne:5,
                Légendaire:6,
                Mythique:7
            },
            Insecte: {
                Larve:0,
                Immature:1,
                Juvénile:2,
                Imago:3,
                Développé:4,
                Développée:4,
                Mûr:5,
                Mûre:5,
                Accompli:6,
                Accomplie:6,
                Achevé:7,
                Achevée:7
            },
            Monstre: {
                Nouveau:0,
                Nouvelle:0,
                Jeune:1,
                Adulte:2,
                Vétéran:3,
                Briscard:4,
                Briscarde:4,
                Doyen:5,
                Doyenne:5,
                Légendaire:6,
                Mythique:7
            },
            "Mort-Vivant": {
                Naissant:0,
                Naissante:0,
                Récent:1,
                Récente:1,
                Ancien:2,
                Ancienne:2,
                Vénérable:3,
                Séculaire:4,
                Antique:5,
                Ancestral:6,
                Ancestrale:6,
                Antédiluvien:7,
                Antédiluvienne:7
            }
        };

        return monsters;
    });
<|endoftext|>


<commit_before>import { transformFromAst } from "babel-core";
import traverse from "babel-traverse";

import { pluggable } from "pluggable";
import { assign } from "lodash";

/**
 * Give a module whose dependencies have been identified and compiled, replace
 * all original `require("path/to/dep")` with `require("HASH_OF_DEP")`.
 *
 * @param  {Object}  module  Module with AST containing original require expressions.
 *
 * @return {Object}          Module with AST containing require expressions whose
 *                           arguments have been replaced with corresponding dependency
 *                           module hashes.
 */
export default pluggable(function updateRequires (module) {
  traverse.cheap(module.ast, node => {
    if (
      node.type === "CallExpression" &&
      node.callee.name === "require"
    ) {
      const originalVal = node.arguments[0].value;
      const correspondingModule = module.dependenciesByInternalRef[originalVal];
      node.arguments[0].value = correspondingModule.hash;
      node.arguments[0].raw = `"$(correspondingModule.hash)"`;
    }
  });

  return assign({}, module, { ast: module.ast });
});
<commit_msg>Lintz<commit_after>import traverse from "babel-traverse";

import { pluggable } from "pluggable";
import { assign } from "lodash";

/**
 * Give a module whose dependencies have been identified and compiled, replace
 * all original `require("path/to/dep")` with `require("HASH_OF_DEP")`.
 *
 * @param  {Object}  module  Module with AST containing original require expressions.
 *
 * @return {Object}          Module with AST containing require expressions whose
 *                           arguments have been replaced with corresponding dependency
 *                           module hashes.
 */
export default pluggable(function updateRequires (module) {
  traverse.cheap(module.ast, node => {
    if (
      node.type === "CallExpression" &&
      node.callee.name === "require"
    ) {
      const originalVal = node.arguments[0].value;
      const correspondingModule = module.dependenciesByInternalRef[originalVal];
      node.arguments[0].value = correspondingModule.hash;
      node.arguments[0].raw = `"$(correspondingModule.hash)"`;
    }
  });

  return assign({}, module, { ast: module.ast });
});
<|endoftext|>


<commit_before>(function($) {

    $(window).load(function() {
    	var clock = $('
WebSocket Clock: subscribing...
').prependTo('footer');
    	setTimeout(function() {
	        $.atmosphere.subscribe(
	        	location.protocol + '//' + location.host + '/websocket/clock', function callback(response) {
	            if (response.status == 200 && response.responseBody && response.state != 'connected' && response.state != 'closed') {
	                $('span', clock).html(response.responseBody);
	            }
	        }, $.atmosphere.request = {
	            logLevel: 'none',
	            transport: 'websocket'
	        });
        }, 200);
    });

    $(function() {
    	$('#options, #view').bind('beforeSend', function(e) {
			if (console) {
				console.log(e);
			}
		}).bind('complete', function(e) {
			if (console) {
				console.log(e);
			}
    	});
    });

})(jQuery);<commit_msg>Improves formatting and console detection.<commit_after>(function($) {

    $(window).load(function() {
        var clock = $('
WebSocket Clock: subscribing...
').prependTo('footer');
        setTimeout(function() {
            $.atmosphere.subscribe(
                location.protocol + '//' + location.host + '/websocket/clock', function callback(response) {
                if (response.status == 200 && response.responseBody && response.state != 'connected' && response.state != 'closed') {
                    $('span', clock).html(response.responseBody);
                }
            }, $.atmosphere.request = {
                logLevel: 'none',
                transport: 'websocket'
            });
        }, 200);
    });

    $(function() {
        $('#options, #view').bind('beforeSend', function(e) {
            if (window.console) {
                window.console.log(e);
            }
        }).bind('complete', function(e) {
            if (window.console) {
                window.console.log(e);
            }
        });
    });

})(jQuery);<|endoftext|>


<commit_before>class LocalStorageMock {
  constructor() {
    this.store = {};
  }

  clear() {
    this.store = {};
  }

  getItem(key) {
    return this.store[key] || null;
  }

  setItem(key, value) {
    this.store[key] = value.toString();
  }

  removeItem(key) {
    delete this.store[key];
  }
};

window.localStorage = new LocalStorageMock;
<commit_msg>eslint<commit_after>class LocalStorageMock {
  constructor() {
    this.store = {};
  }

  clear() {
    this.store = {};
  }

  getItem(key) {
    return this.store[key] || null;
  }

  setItem(key, value) {
    this.store[key] = value.toString();
  }

  removeItem(key) {
    delete this.store[key];
  }
}

window.localStorage = new LocalStorageMock;
<|endoftext|>


<commit_before>/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow
 */

/* eslint-env node */

'use strict';

const {transformSync: babelTransformSync} = require('@babel/core');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
 * found when Flow v0.54 was deployed. To see the error delete this comment and
 * run Flow. */
const babelRegisterOnly = require('metro-babel-register');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
 * found when Flow v0.54 was deployed. To see the error delete this comment and
 * run Flow. */
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
const generate = require('@babel/generator').default;

const nodeFiles = new RegExp(
  [
    '/local-cli/',
    '/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc
  ].join('|'),
);
const nodeOptions = babelRegisterOnly.config([nodeFiles]);

babelRegisterOnly([]);

/* $FlowFixMe(site=react_native_oss) */
const transformer = require('metro/src/reactNativeTransformer');
module.exports = {
  process(src /*: string */, file /*: string */) {
    if (nodeFiles.test(file)) {
      // node specific transforms only
      return babelTransformSync(src, {
        filename: file,
        sourceType: 'script',
        ...nodeOptions,
        ast: false,
      }).code;
    }

    const {ast} = transformer.transform({
      filename: file,
      options: {
        ast: true, // needed for open source (?) https://github.com/facebook/react-native/commit/f8d6b97140cffe8d18b2558f94570c8d1b410d5c#r28647044
        dev: true,
        disableBabelRuntime: true,
        inlineRequires: true,
        minify: false,
        platform: '',
        projectRoot: '',
        retainLines: true,
        sourceType: 'unambiguous', // b7 required. detects module vs script mode
      },
      src,
      plugins: [
        [require('@babel/plugin-transform-block-scoping')],
        // the flow strip types plugin must go BEFORE class properties!
        // there'll be a test case that fails if you don't.
        [require('@babel/plugin-transform-flow-strip-types')],
        [
          require('@babel/plugin-proposal-class-properties'),
          // use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
          {loose: true},
        ],
        [require('@babel/plugin-transform-computed-properties')],
        [require('@babel/plugin-transform-destructuring')],
        [require('@babel/plugin-transform-function-name')],
        [require('@babel/plugin-transform-literals')],
        [require('@babel/plugin-transform-parameters')],
        [require('@babel/plugin-transform-shorthand-properties')],
        [require('@babel/plugin-transform-react-jsx')],
        [require('@babel/plugin-transform-regenerator')],
        [require('@babel/plugin-transform-sticky-regex')],
        [require('@babel/plugin-transform-unicode-regex')],
        [
          require('@babel/plugin-transform-modules-commonjs'),
          {strict: false, allowTopLevelThis: true},
        ],
        [require('@babel/plugin-transform-classes')],
        [require('@babel/plugin-transform-arrow-functions')],
        [require('@babel/plugin-transform-spread')],
        [require('@babel/plugin-proposal-object-rest-spread')],
        [
          require('@babel/plugin-transform-template-literals'),
          {loose: true}, // dont 'a'.concat('b'), just use 'a'+'b'
        ],
        [require('@babel/plugin-transform-exponentiation-operator')],
        [require('@babel/plugin-transform-object-assign')],
        [require('@babel/plugin-transform-for-of'), {loose: true}],
        [require('@babel/plugin-transform-react-display-name')],
        [require('@babel/plugin-transform-react-jsx-source')],
      ],
    });

    return generate(
      ast,
      {
        code: true,
        comments: false,
        compact: false,
        filename: file,
        retainLines: true,
        sourceFileName: file,
        sourceMaps: true,
      },
      src,
    ).code;
  },

  getCacheKey: createCacheKeyFunction([
    __filename,
    require.resolve('metro/src/reactNativeTransformer'),
    require.resolve('@babel/core/package.json'),
  ]),
};
<commit_msg>Cleanup the transformer flow types<commit_after>/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow
 */

/* eslint-env node */

'use strict';

const {transformSync: babelTransformSync} = require('@babel/core');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
 * found when Flow v0.54 was deployed. To see the error delete this comment and
 * run Flow. */
const babelRegisterOnly = require('metro-babel-register');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
 * found when Flow v0.54 was deployed. To see the error delete this comment and
 * run Flow. */
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
const generate = require('@babel/generator').default;

const nodeFiles = new RegExp(
  [
    '/local-cli/',
    '/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc
  ].join('|'),
);
const nodeOptions = babelRegisterOnly.config([nodeFiles]);

babelRegisterOnly([]);

/* $FlowFixMe(site=react_native_oss) */
const transformer = require('metro/src/reactNativeTransformer');
module.exports = {
  process(src /*: string */, file /*: string */) {
    if (nodeFiles.test(file)) {
      // node specific transforms only
      return babelTransformSync(src, {
        filename: file,
        sourceType: 'script',
        ...nodeOptions,
        ast: false,
      }).code;
    }

    const {ast} = transformer.transform({
      filename: file,
      options: {
        ast: true, // needed for open source (?) https://github.com/facebook/react-native/commit/f8d6b97140cffe8d18b2558f94570c8d1b410d5c#r28647044
        dev: true,
        disableBabelRuntime: true,
        experimentalImportSupport: false,
        hot: false,
        inlineRequires: true,
        minify: false,
        platform: '',
        projectRoot: '',
        retainLines: true,
        sourceType: 'unambiguous', // b7 required. detects module vs script mode
      },
      src,
      plugins: [
        [require('@babel/plugin-transform-block-scoping')],
        // the flow strip types plugin must go BEFORE class properties!
        // there'll be a test case that fails if you don't.
        [require('@babel/plugin-transform-flow-strip-types')],
        [
          require('@babel/plugin-proposal-class-properties'),
          // use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
          {loose: true},
        ],
        [require('@babel/plugin-transform-computed-properties')],
        [require('@babel/plugin-transform-destructuring')],
        [require('@babel/plugin-transform-function-name')],
        [require('@babel/plugin-transform-literals')],
        [require('@babel/plugin-transform-parameters')],
        [require('@babel/plugin-transform-shorthand-properties')],
        [require('@babel/plugin-transform-react-jsx')],
        [require('@babel/plugin-transform-regenerator')],
        [require('@babel/plugin-transform-sticky-regex')],
        [require('@babel/plugin-transform-unicode-regex')],
        [
          require('@babel/plugin-transform-modules-commonjs'),
          {strict: false, allowTopLevelThis: true},
        ],
        [require('@babel/plugin-transform-classes')],
        [require('@babel/plugin-transform-arrow-functions')],
        [require('@babel/plugin-transform-spread')],
        [require('@babel/plugin-proposal-object-rest-spread')],
        [
          require('@babel/plugin-transform-template-literals'),
          {loose: true}, // dont 'a'.concat('b'), just use 'a'+'b'
        ],
        [require('@babel/plugin-transform-exponentiation-operator')],
        [require('@babel/plugin-transform-object-assign')],
        [require('@babel/plugin-transform-for-of'), {loose: true}],
        [require('@babel/plugin-transform-react-display-name')],
        [require('@babel/plugin-transform-react-jsx-source')],
      ],
    });

    return generate(
      ast,
      {
        code: true,
        comments: false,
        compact: false,
        filename: file,
        retainLines: true,
        sourceFileName: file,
        sourceMaps: true,
      },
      src,
    ).code;
  },

  getCacheKey: createCacheKeyFunction([
    __filename,
    require.resolve('metro/src/reactNativeTransformer'),
    require.resolve('@babel/core/package.json'),
  ]),
};
<|endoftext|>


<commit_before>/*
 * Ikasoa RPC JavaScript Client  (http://ikasoa.com/)
 *
 * @license MIT License (c) copyright 2018 original author or authors.
 * @author Larry
 * @version 1.0
 */

JavaType = {
  _byte: {
    value: 'byte',
    array: 0
  },
  Byte: {
    value: 'java.lang.Byte',
    array: 0
  },
  _int: {
    value: 'int',
    array: 0
  },
  Integer: {
    value: 'java.lang.Integer',
    array: 0
  },
  _long: {
    value: 'long',
    array: 0
  },
  Long: {
    value: 'java.lang.Long',
    array: 0
  },
  String: {
    value: 'java.lang.String',
    array: 0
  },
  _float: {
    value: 'float',
    array: 0
  },
  Float: {
    value: 'java.lang.Float',
    array: 0
  },
  _double: {
    value: 'double',
    array: 0
  },
  Double: {
    value: 'java.lang.Double',
    array: 0
  },
  _boolean: {
    value: 'boolean',
    array: 0
  },
  Boolean: {
    value: 'java.lang.Boolean',
    array: 0
  },
  _char: {
    value: 'char',
    array: 0
  },
  Char: {
    value: 'java.lang.Character',
    array: 0
  },
  String_: {
    value: '[Ljava.lang.String;',
    array: 1
  },
  _byte_: {
    value: '[B',
    array: 1
  },
  Byte_: {
    value: '[Ljava.lang.Byte;',
    array: 1
  },
  _int_: {
    value: '[I',
    array: 1
  },
  Integer_: {
    value: '[Ljava.lang.Integer;',
    array: 1
  },
  _long_: {
    value: '[L',
    array: 1
    },
  Long_: {
    value: '[Ljava.lang.Long;',
    array: 1
  },
  _float_: {
    value: '[F',
    array: 1
  },
  Float_: {
    value: '[Ljava.lang.Float;',
    array: 1
  },
  _double_: {
    value: '[D',
    array: 1
  },
  Double_: {
    value: '[Ljava.lang.Double;',
    array: 1
  },
  _boolean_: {
    value: '[Z',
    array: 1
  },
  Boolean_: {
    value: '[Ljava.lang.Boolean;',
    array: 1
  },
  List: {
    value: 'java.util.List',
    array: 1
  },
  Map: {
    value: 'java.util.Map',
    array: 1
  },
  Set: {
    value: 'java.util.Set',
    array: 1
  }
};

_JavaType = function(value, array) {
  this.value = value;
  this.array = array;
};

function getService(sUrl, cName, mName, rType, pTypes) {
  var tMp = new Thrift.Multiplexer();
  var tTp = new Thrift.Transport(sUrl);
  var rTypeStr = 'void';
  var pTypesStr = '[]';
  if(rType != null) rTypeStr = rType.value;
  if(pTypes != null) {
    if(!(pTypes instanceof Array)) pTypes = new Array(pTypes);
    if (pTypes.length > 0) {
      pTypesStr = '[';
      for(i = 0; i < pTypes.length; i++) {
        var prefix = suffix = '"';
        if(pTypes.length != i + 1) suffix += ',';
        pTypesStr += prefix + pTypes[i].value + suffix;
      }
      pTypesStr += ']';
    }
  }
  return new Service(tMp.createClient(('{"iClass"|"' + cName + '","methodName"|"' + mName + '","parameterTypes"|' + pTypesStr + ',"returnType"|"' + rTypeStr + '"}').replace(/\"/g, '\\"'), ServiceClient, tTp), pTypes, pTypesStr, rType);
};

Service = function(tService, pTypes, pTypesStr, rType) {
  this.tService = tService;
  this.pTypes = pTypes;
  this.pTypesStr = pTypesStr;
  this.rType = rType;
}

Service.prototype.execute = function() {
  var argsStr = '';
  if (arguments.length > 0) {
    if(arguments.length < this.pTypes.length) throw 'Arguments length error !';
    argsStr = String.fromCharCode(150) + '[';
    for(i = 0; i < this.pTypes.length; i++) {
      argsStr += JSON.stringify(arguments[i]);
      if(arguments.length != i + 1) argsStr += ',';
    }
    argsStr += ']';
  }
  var r = this.tService.get(this.pTypesStr + argsStr).split(String.fromCharCode(150));
  if(r.length == 1)
    if(r[0] == String.fromCharCode(152)) return;
    else throw JSON.parse(r[0]);
  if(this.rType.array) return JSON.parse(r[1]);
  return r[1];
};

ServiceGetArgs = function(args) {
  this.arg = null;
  if (args && args.arg !== undefined && args.arg !== null) this.arg = args.arg;
};
ServiceGetArgs.prototype = {};
ServiceGetArgs.prototype.write = function(output) {
  output.writeStructBegin('Service_get_args');
  if (this.arg !== null && this.arg !== undefined) {
    output.writeFieldBegin('arg', Thrift.Type.STRING, 1);
    output.writeString(this.arg);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

ServiceGetResult = function(args) {
  this.success = null;
  if (args && args.success !== undefined && args.success !== null) this.success = args.success;
};
ServiceGetResult.prototype = {};
ServiceGetResult.prototype.read = function(input) {
  input.readStructBegin();
  while(true) {
    var ret = input.readFieldBegin();
    if(ret.ftype == Thrift.Type.STOP) break;
    if(ret.fid == 0) this.success = input.readString().value;
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

ServiceGetResult.prototype.write = function(output) {
  output.writeStructBegin('Service_get_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.STRING, 0);
    output.writeString(this.success);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

ServiceClient = function(input, output) {
    this.input = input;
    this.output = (!output) ? input : output;
    this.seqid = 0;
};
ServiceClient.prototype = {};
ServiceClient.prototype.get = function(arg) {
  this.sendGet(arg);
  return this.recvGet();
};

ServiceClient.prototype.sendGet = function(arg) {
  this.output.writeMessageBegin('get', Thrift.MessageType.CALL, this.seqid);
  var params = {
    arg: arg
  };
  var args = new ServiceGetArgs(params);
  args.write(this.output);
  this.output.writeMessageEnd();
  return this.output.getTransport().flush();
};

ServiceClient.prototype.recvGet = function() {
  this.input.readMessageBegin();
  var result = new ServiceGetResult();
  result.read(this.input);
  this.input.readMessageEnd();
  if (null !== result.success) return result.success;
  throw 'get failed: unknown result';
};
<commit_msg>jsclient<commit_after>/*
 * Ikasoa RPC JavaScript Client  (http://ikasoa.com/)
 *
 * @license MIT License (c) copyright 2018 original author or authors.
 * @author Larry
 * @version 1.0
 */

JavaType = {
  _byte: { value: 'byte', array: 0 },
  Byte: { value: 'java.lang.Byte', array: 0 },
  _int: { value: 'int', array: 0 },
  Integer: { value: 'java.lang.Integer', array: 0 },
  _long: { value: 'long', array: 0 },
  Long: { value: 'java.lang.Long', array: 0 },
  String: { value: 'java.lang.String', array: 0 },
  _float: { value: 'float', array: 0 },
  Float: { value: 'java.lang.Float', array: 0 },
  _double: { value: 'double', array: 0 },
  Double: { value: 'java.lang.Double', array: 0 },
  _boolean: { value: 'boolean', array: 0 },
  Boolean: { value: 'java.lang.Boolean', array: 0 },
  _char: { value: 'char', array: 0 },
  Char: { value: 'java.lang.Character', array: 0 },
  String_: { value: '[Ljava.lang.String;', array: 1 },
  _byte_: { value: '[B', array: 1 },
  Byte_: { value: '[Ljava.lang.Byte;', array: 1 },
  _int_: { value: '[I', array: 1 },
  Integer_: { value: '[Ljava.lang.Integer;', array: 1 },
  _long_: { value: '[L', array: 1 },
  Long_: { value: '[Ljava.lang.Long;', array: 1 },
  _float_: { value: '[F', array: 1 },
  Float_: { value: '[Ljava.lang.Float;', array: 1 },
  _double_: { value: '[D', array: 1 },
  Double_: { value: '[Ljava.lang.Double;', array: 1 },
  _boolean_: { value: '[Z', array: 1 },
  Boolean_: { value: '[Ljava.lang.Boolean;', array: 1 },
  List: { value: 'java.util.List', array: 1 },
  Map: { value: 'java.util.Map', array: 1 },
  Set: { value: 'java.util.Set', array: 1 }
};

_JavaType = function(value, array) {
  this.value = value;
  this.array = array;
};

function getService(sUrl, cName, mName, rType, pTypes) {
  var tMp = new Thrift.Multiplexer();
  var tTp = new Thrift.Transport(sUrl);
  var rTypeStr = 'void';
  var pTypesStr = '[]';
  if(rType != null) rTypeStr = rType.value;
  if(pTypes != null) {
    if(!(pTypes instanceof Array)) pTypes = new Array(pTypes);
    if (pTypes.length > 0) {
      pTypesStr = '[';
      for(i = 0; i < pTypes.length; i++) {
        var prefix = suffix = '"';
        if(pTypes.length != i + 1) suffix += ',';
        pTypesStr += prefix + pTypes[i].value + suffix;
      }
      pTypesStr += ']';
    }
  }
  return new Service(tMp.createClient(('{"iClass"|"' + cName + '","methodName"|"' + mName + '","parameterTypes"|' + pTypesStr + ',"returnType"|"' + rTypeStr + '"}').replace(/\"/g, '\\"'), ServiceClient, tTp), pTypes, pTypesStr, rType);
};

Service = function(tService, pTypes, pTypesStr, rType) {
  this.tService = tService;
  this.pTypes = pTypes;
  this.pTypesStr = pTypesStr;
  this.rType = rType;
}

Service.prototype.execute = function() {
  var argsStr = '';
  if (arguments.length > 0) {
    if(arguments.length < this.pTypes.length) throw 'Arguments length error !';
    argsStr = String.fromCharCode(150) + '[';
    for(i = 0; i < this.pTypes.length; i++) {
      argsStr += JSON.stringify(arguments[i]);
      if(arguments.length != i + 1) argsStr += ',';
    }
    argsStr += ']';
  }
  var r = this.tService.get(this.pTypesStr + argsStr).split(String.fromCharCode(150));
  if(r.length == 1)
    if(r[0] == String.fromCharCode(152)) return;
    else throw JSON.parse(r[0]);
  if(this.rType.array) return JSON.parse(r[1]);
  return r[1];
};

ServiceGetArgs = function(args) {
  this.arg = null;
  if (args && args.arg !== undefined && args.arg !== null) this.arg = args.arg;
};
ServiceGetArgs.prototype = {};
ServiceGetArgs.prototype.write = function(output) {
  output.writeStructBegin('Service_get_args');
  if (this.arg !== null && this.arg !== undefined) {
    output.writeFieldBegin('arg', Thrift.Type.STRING, 1);
    output.writeString(this.arg);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

ServiceGetResult = function(args) {
  this.success = null;
  if (args && args.success !== undefined && args.success !== null) this.success = args.success;
};
ServiceGetResult.prototype = {};
ServiceGetResult.prototype.read = function(input) {
  input.readStructBegin();
  while(true) {
    var ret = input.readFieldBegin();
    if(ret.ftype == Thrift.Type.STOP) break;
    if(ret.fid == 0) this.success = input.readString().value;
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

ServiceGetResult.prototype.write = function(output) {
  output.writeStructBegin('Service_get_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.STRING, 0);
    output.writeString(this.success);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

ServiceClient = function(input, output) {
    this.input = input;
    this.output = (!output) ? input : output;
    this.seqid = 0;
};
ServiceClient.prototype = {};
ServiceClient.prototype.get = function(arg) {
  this.sendGet(arg);
  return this.recvGet();
};

ServiceClient.prototype.sendGet = function(arg) {
  this.output.writeMessageBegin('get', Thrift.MessageType.CALL, this.seqid);
  var params = {
    arg: arg
  };
  var args = new ServiceGetArgs(params);
  args.write(this.output);
  this.output.writeMessageEnd();
  return this.output.getTransport().flush();
};

ServiceClient.prototype.recvGet = function() {
  this.input.readMessageBegin();
  var result = new ServiceGetResult();
  result.read(this.input);
  this.input.readMessageEnd();
  if (null !== result.success) return result.success;
  throw 'get failed: unknown result';
};<|endoftext|>


<commit_before>/* eslint-disable react/no-danger */
import { Component, PropTypes } from "react";
import ReactMixin from "react-mixin";
import { graphql } from "react-apollo";
import { connect } from "react-redux";
import gql from "graphql-tag";

import Loading from "../../components/loading";
import {
  nav as navActions,
  audio as audioActions,
  header as headerActions,
} from "../../store";

import Headerable from "../../mixins/mixins.Header";
import Likeable from "../../mixins/mixins.Likeable";
import Shareable from "../../mixins/mixins.Shareable";

import time from "../../util/time";
import react from "../../util/react";
import contentHelpers from "../../util/content";
import collections from "../../util/collections";

import SingleVideoPlayer from "../../components/players/video/Player";
import SeriesVideoList from "./series.VideoList";

const CURRENT_SERMON_QUERY = gql`
  query getSermon($sermonId: ID!) {
    content: node(id: $sermonId) {
      ... on Content {
        entryId: id
        title
        status
        channelName
        meta {
          urlTitle
          siteId
          date
          actualDate
          channelId
        }
        content {
          audio {
            duration
            file: s3
          }
          description
          speaker
          ooyalaId
        }
      }
    }
  }
`;
const withCurrentSermon = graphql(CURRENT_SERMON_QUERY, {
  name: "currentSermon",
  options: ownProps => ({
    variables: { sermonId: ownProps.params.sermonId },
  }),
});

const SERIES_QUERY = gql`
  query getSeriesSingle($id: ID!) {
    content: node(id: $id) {
      id
      ... on Content {
        entryId: id
        title
        status
        channelName
        meta {
          urlTitle
          siteId
          date
          channelId
        }
        content {
          description
          images(sizes: ["large", "medium", "small"]) {
            fileName
            fileType
            fileLabel
            url
            size
          }
          ooyalaId
          colors {
            id
            value
            description
          }
          isLight
        }
      }
    }
  }
`;
const withSeries = graphql(SERIES_QUERY, {
  name: "series",
  options: ownProps => ({
    variables: { id: ownProps.params.id },
  }),
});

const mapStateToProps = state => ({ live: state.live });

@connect(null, mapStateToProps)
@withCurrentSermon
@withSeries
@ReactMixin.decorate(Likeable)
@ReactMixin.decorate(Shareable)
@ReactMixin.decorate(Headerable)
export default class SeriesSingleVideo extends Component {

  static propTypes = {
    dispatch: PropTypes.func.isRequired,
    live: PropTypes.object.isRequired,
    currentSermon: PropTypes.object.isRequired,
    series: PropTypes.object.isRequired,
    params: PropTypes.object.isRequired,
  }

  componentWillMount() {
    if (process.env.WEB) return;

    // needed for client cache
    this.handleHeader(this.props);

    this.props.dispatch(navActions.setLevel("CONTENT"));
    this.props.dispatch(navActions.setAction("CONTENT", {
      id: 2,
      action: this.likeableAction,
    }));
  }

  componentWillUpdate(nextProps) {
    this.handleHeader(nextProps);
  }

  handleHeader = (nextProps) => {
    const content = nextProps.series.content;
    if (!content) return;

    const { isLight } = nextProps.series.content.content;
    const color = collections.color(content);

    const { live } = this.props.live;

    const options = {
      title: "Series",
      color,
      light: !isLight,
    };

    if (!live) options.subTitle = content.title;

    this.props.dispatch(headerActions.set(options));
  }

  playAudio = (e) => {
    e.preventDefault();
    const currentSermon = this.props.currentSermon.content;
    const series = this.props.series.content;
    this.props.dispatch(audioActions.setPlaying({
      track: {
        ...currentSermon.content.audio[0],
        title: currentSermon.title,
        artist: contentHelpers.speakers(currentSermon),
      },
      album: series,
    }));
  }

  render() {
    const sermonContent = this.props.currentSermon.content;
    const seriesContent = this.props.series.content;

    if (!(sermonContent && seriesContent)) {
      // loading
      return (

            <Loading />

      );
    }

    const currentSermon = sermonContent;

    return (

        <SingleVideoPlayer ooyalaId={currentSermon.content.ooyalaId} />

          <h7 style={{ verticalAlign: "middle" }}>Listen To Audio</h7>

{currentSermon.title}

{contentHelpers.speakers(currentSermon)}

{time.date(currentSermon)}

        <SeriesVideoList id={this.props.params.id} />

    );
  }
}
<commit_msg>removed null argument to connect<commit_after>/* eslint-disable react/no-danger */
import { Component, PropTypes } from "react";
import ReactMixin from "react-mixin";
import { graphql } from "react-apollo";
import { connect } from "react-redux";
import gql from "graphql-tag";

import Loading from "../../components/loading";
import {
  nav as navActions,
  audio as audioActions,
  header as headerActions,
} from "../../store";

import Headerable from "../../mixins/mixins.Header";
import Likeable from "../../mixins/mixins.Likeable";
import Shareable from "../../mixins/mixins.Shareable";

import time from "../../util/time";
import react from "../../util/react";
import contentHelpers from "../../util/content";
import collections from "../../util/collections";

import SingleVideoPlayer from "../../components/players/video/Player";
import SeriesVideoList from "./series.VideoList";

const CURRENT_SERMON_QUERY = gql`
  query getSermon($sermonId: ID!) {
    content: node(id: $sermonId) {
      ... on Content {
        entryId: id
        title
        status
        channelName
        meta {
          urlTitle
          siteId
          date
          actualDate
          channelId
        }
        content {
          audio {
            duration
            file: s3
          }
          description
          speaker
          ooyalaId
        }
      }
    }
  }
`;
const withCurrentSermon = graphql(CURRENT_SERMON_QUERY, {
  name: "currentSermon",
  options: ownProps => ({
    variables: { sermonId: ownProps.params.sermonId },
  }),
});

const SERIES_QUERY = gql`
  query getSeriesSingle($id: ID!) {
    content: node(id: $id) {
      id
      ... on Content {
        entryId: id
        title
        status
        channelName
        meta {
          urlTitle
          siteId
          date
          channelId
        }
        content {
          description
          images(sizes: ["large", "medium", "small"]) {
            fileName
            fileType
            fileLabel
            url
            size
          }
          ooyalaId
          colors {
            id
            value
            description
          }
          isLight
        }
      }
    }
  }
`;
const withSeries = graphql(SERIES_QUERY, {
  name: "series",
  options: ownProps => ({
    variables: { id: ownProps.params.id },
  }),
});

const mapStateToProps = state => ({ live: state.live });

@connect(mapStateToProps)
@withCurrentSermon
@withSeries
@ReactMixin.decorate(Likeable)
@ReactMixin.decorate(Shareable)
@ReactMixin.decorate(Headerable)
export default class SeriesSingleVideo extends Component {

  static propTypes = {
    dispatch: PropTypes.func.isRequired,
    live: PropTypes.object.isRequired,
    currentSermon: PropTypes.object.isRequired,
    series: PropTypes.object.isRequired,
    params: PropTypes.object.isRequired,
  }

  componentWillMount() {
    if (process.env.WEB) return;

    // needed for client cache
    this.handleHeader(this.props);

    this.props.dispatch(navActions.setLevel("CONTENT"));
    this.props.dispatch(navActions.setAction("CONTENT", {
      id: 2,
      action: this.likeableAction,
    }));
  }

  componentWillUpdate(nextProps) {
    this.handleHeader(nextProps);
  }

  handleHeader = (nextProps) => {
    const content = nextProps.series.content;
    if (!content) return;

    const { isLight } = nextProps.series.content.content;
    const color = collections.color(content);

    const { live } = this.props.live;

    const options = {
      title: "Series",
      color,
      light: !isLight,
    };

    if (!live) options.subTitle = content.title;

    this.props.dispatch(headerActions.set(options));
  }

  playAudio = (e) => {
    e.preventDefault();
    const currentSermon = this.props.currentSermon.content;
    const series = this.props.series.content;
    this.props.dispatch(audioActions.setPlaying({
      track: {
        ...currentSermon.content.audio[0],
        title: currentSermon.title,
        artist: contentHelpers.speakers(currentSermon),
      },
      album: series,
    }));
  }

  render() {
    const sermonContent = this.props.currentSermon.content;
    const seriesContent = this.props.series.content;

    if (!(sermonContent && seriesContent)) {
      // loading
      return (

            <Loading />

      );
    }

    const currentSermon = sermonContent;

    return (

        <SingleVideoPlayer ooyalaId={currentSermon.content.ooyalaId} />

          <h7 style={{ verticalAlign: "middle" }}>Listen To Audio</h7>

{currentSermon.title}

{contentHelpers.speakers(currentSermon)}

{time.date(currentSermon)}

        <SeriesVideoList id={this.props.params.id} />

    );
  }
}
<|endoftext|>


<commit_before>; (function($, undefined) {

    // Initial idea: http://blog.teamtreehouse.com/handlebars-js-part-3-tips-and-tricks

    // Plugin Logic
    $.fn.extend({

        handlebars: function(template, data, options) {

            // The data object literal must contain data
            if ($.isEmptyObject(data)) {
                return this;
            }

            // Set our options from the defaults, overriding with the
            // parameter we pass into this function
            options = $.extend({}, $.fn.handlebars.options, options);

            // jQuery object reference
            var $selector = null,

                // jQuery object reference for this. Only select the first selector of the collection
                $this = $(this).first();

            // If a string is passed then check if it's compiled or get the jQuery object
            if (typeof template === 'string') {

                // If compiled already
                if (typeof compiled[template] === 'function') {

                    // Debugging only
                    console.log(template + ' already exists');

                    // Return to continue chaining
                    return setElement(this, $this, options, compiled[template](data));

                }

                // Not compiled

                // Get the first selection only
                $selector = $(template).first();

                // If the selector doesn't exist for whatever reason, then set to null
                if ($selector.length === 0) {
                    $selector = null;
                }

            // If a valid jQuery selector object
            } else if (template instanceof $ && typeof template.length === 'number' && template.length > 0) {

                // Get the first selection only
                $selector = template.first();

                // Get the selector name for using with the compiled object literal
                // If the selector property doesn't exist, then this will be set to null
                template = typeof $selector.selector !== 'undefined' ? $selector.selector : null;

                // If compiled already
                if (template !== null && typeof compiled[template] === 'function') {

                    // Debugging only
                    console.log(template + ' already exists');

                    // Return to continue chaining
                    return setElement(this, $this, options, compiled[template](data));

                }
            }

            // If an invalid selector, then return this to continue chaining
            if ($selector === null || template === null || $selector.length === 0) {
                return this;
            }

            // Get the HTML of the template only
            var html = $selector.html();

            // Store the compiled template in the compiled store
            compiled[template] = Handlebars.compile(html);

            // Return to continue chaining
            return setElement(this, $this, options, compiled[template](data));
        }

    });

    // Fields (Private)

    // Store the compiled templates, using the selector string as the identifier i.e. key
    var compiled = {};

    // Methods (Private)

    // Helper function for setting an element with a template
    // Variables are called self instead of this, to avoid conflict
    var setElement = function(self, $self, options, compiled) {
        // Empty the previous contents of this, excluding all Handlebarjs template script elements
        //
        // Previous implementations
        // $self.children('*').not('script[type="text/x-handlebars-template"]').empty();
        // $self.children('*:not(script[type="text/x-handlebars-template"])').empty();

        // Get all nodes apart from the Handlebarjs template script elements
        var filtered = $self.contents().filter(function() {
            // Only filter those which don't have the handlebarsjs type and SCRIPT node name and not whitespace
            return this.nodeName !== 'SCRIPT' && this.type !== 'text/x-handlebars-template' && /[^\t\n\r ]/.test(this.textContent);
        });

        // If set to not overwrite nodes exist, then return this
        if (!options.overwrite && filtered.length > 0) {
            return self;
        }

        // Remove from the DOM
        filtered.remove();

        // Append to this
        $self.append(compiled);

        return self;
    };

    // Defaults
    $.fn.handlebars.options = {
        overwrite: true
    };

})(jQuery);
<commit_msg>Added debugging console lines<commit_after>; (function($, undefined) {

    // Initial idea: http://blog.teamtreehouse.com/handlebars-js-part-3-tips-and-tricks

    // Plugin Logic
    $.fn.extend({

        handlebars: function(template, data, options) {

            // The data object literal must contain data
            if ($.isEmptyObject(data)) {

                console.log('Data was not passed or is an empty plain object');
                return this;

            }

            // Set our options from the defaults, overriding with the
            // parameter we pass into this function
            options = $.extend({}, $.fn.handlebars.options, options);

            // jQuery object reference
            var $selector = null,

                // jQuery object reference for this. Only select the first selector of the collection
                $this = $(this).first();

            // If a string is passed then check if it's compiled or get the jQuery object
            if (typeof template === 'string') {

                // If compiled already
                if (typeof compiled[template] === 'function') {

                    // Debugging only
                    console.log(template + ' already exists');

                    // Return to continue chaining
                    return setElement(this, $this, options, compiled[template](data));

                }

                // Not compiled

                // Get the first selection only
                $selector = $(template).first();

                // If the selector doesn't exist for whatever reason, then set to null
                if ($selector.length === 0) {
                    $selector = null;
                }

            // If a valid jQuery selector object
            } else if (template instanceof $ && typeof template.length === 'number' && template.length > 0) {

                // Get the first selection only
                $selector = template.first();

                // Get the selector name for using with the compiled object literal
                // If the selector property doesn't exist, then this will be set to null
                template = typeof $selector.selector !== 'undefined' ? $selector.selector : null;

                // If compiled already
                if (template !== null && typeof compiled[template] === 'function') {

                    // Debugging only
                    console.log(template + ' already exists');

                    // Return to continue chaining
                    return setElement(this, $this, options, compiled[template](data));

                }
            }

            // If an invalid selector, then return this to continue chaining
            if ($selector === null || template === null || $selector.length === 0) {

                // Debugging only
                console.log('Template cannot be found');
                return this;

            }

            // Get the HTML of the template only
            var html = $selector.html();

            // Store the compiled template in the compiled store
            compiled[template] = Handlebars.compile(html);

            // Return to continue chaining
            return setElement(this, $this, options, compiled[template](data));
        }

    });

    // Fields (Private)

    // Store the compiled templates, using the selector string as the identifier i.e. key
    var compiled = {};

    // Methods (Private)

    // Helper function for setting an element with a template
    // Variables are called self instead of this, to avoid conflict
    var setElement = function(self, $self, options, compiled) {
        // Empty the previous contents of this, excluding all Handlebarjs template script elements
        //
        // Previous implementations
        // $self.children('*').not('script[type="text/x-handlebars-template"]').empty();
        // $self.children('*:not(script[type="text/x-handlebars-template"])').empty();

        // Get all nodes apart from the Handlebarjs template script elements
        var filtered = $self.contents().filter(function() {
            // Only filter those which don't have the handlebarsjs type and SCRIPT node name and not whitespace
            return this.nodeName !== 'SCRIPT' && this.type !== 'text/x-handlebars-template' && /[^\t\n\r ]/.test(this.textContent);
        });

        // If set to not overwrite nodes exist, then return this
        if (!options.overwrite && filtered.length > 0) {

            // Debugging only
            console.log('Overwrite has been set to false and the content element is not empty');
            return self;

        }

        // Remove from the DOM
        filtered.remove();

        // Append to this
        $self.append(compiled);

        return self;
    };

    // Defaults
    $.fn.handlebars.options = {
        overwrite: true
    };

})(jQuery);
<|endoftext|>


<commit_before>jQuery.extend({

    BeaconPush: {
        addEventListener: function(event, handler) {
            Beacon.listen(function(data) {
                if(data.name == event) {
                    return handler(data);
                }
            });
        },

        append: function(list, tmpl, event) {
            $(tmpl).tmpl(event.data).appendTo(list);
        },

        prepend: function(list, tmpl, event) {
            $(tmpl).tmpl(event.data).prependTo(list);
        }
    }

});<commit_msg>added comments on how to use the little jQuery plugin<commit_after>jQuery.extend({

    BeaconPush: {
        addEventListener: function(event, handler) {
            Beacon.listen(function(data) {
                if(data.name == event) {
                    return handler(data);
                }
            });
        },

        // Ignore these if you dont know how to use jQuery Tmpl
        append: function(list, tmpl, event) {
            $(tmpl).tmpl(event.data).appendTo(list);
        },

        prepend: function(list, tmpl, event) {
            $(tmpl).tmpl(event.data).prependTo(list);
        }
    }

});

/* ########## Usage #############
* ### PHP
* $beaconpush->send_to_channels(array('theBestChannel', 'foo'), 'newMessage', array('myMessage' => 'Hello everyone!'));
*
* ### JavaScript
* $.BeaconPush('newMessage', function(event) {
*     console.log('The message: ' + event.data.myMessage);
*     console.log('The event: ' + event.name);
* });<|endoftext|>