IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Portée de variables


Sujet :

JavaScript

  1. #21
    Membre actif Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 319
    Points : 286
    Points
    286
    Par défaut
    Je relance la discussion car j'essaye de rajouter des infos et je pense que je n'ai pas tout compris.
    Peux-tu me corriger, stp ?

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
     
    function ChargementTableRelance() {
        $('#table_relance').empty();
     
        var day = new Date();
        day.setDate(day.getDate() - 1); // On sélectionne le jour précédent
        var mm = ((day.getMonth() + 1) < 10) ? '0' + (day.getMonth() + 1) : (day.getMonth() + 1);
        var dd = (day.getDate() < 10) ? '0' + day.getDate() : day.getDate();
        var dayInit_Rel = day.getFullYear().toString() + mm + dd;
        var dayInitAlt_Rel = dd + "/" + mm + "/" + day.getFullYear(); // Utiliser pour le nouveau DatePicket
     
        let TabRelanceByID = document.getElementById("table_relance");
     
        let InsertLig = "";
        let InsertCell = "";
        let NomLig = "";
        let NomCell = "";
        let BtnCell = "";
        let NomDate = "";
        let NomDate2 = "";
        let Rel_NomDate = "";
        let TitreExec = "";
        let DateExec = "";
        let JJExec = "";
        let MMExec = "";
        let AAExec = "";
        let Rel_NumLig = 0;
        let Cmd = "";
        let TypeCmd = "";
        let MinCmd = "";
        let Min = "";
     
        DateExec = $('#date_deb').datepicker("getDate");
        DateExec = FormatDate2(DateExec, "JJ/MM/AAAA");
        JJExec = DateExec.substr(0, 2);
        MMExec = DateExec.substr(3, 2);
        AAExec = DateExec.substr(6, 4);
     
        let data = {
            titre: ["<b>Relance et envoie les emails pour tous les traitements VISTA pour " +
                "une date données => reconstitue le répertoire $visu/aaaa/mm/oljjmmaaaa<br /></b>" +
                "<i>(cd $ss;sh scripts_batch_auto_guichet.csh JJ MM AAAA)</i>",
                "<b>Relance fichiers mensuels ou annuels incomplets => IL FAUT EXECUTER LES 3 SCRIPTS</b>" +
                "<br />" + "<i>(cd $ss;sh go.fab.stats.vista.mois_candidate.csh mm aaaa traitement_tot_dep_arr_aerobahn_v7;" +
                "<br />sh go.fab.stats.vista.mois_candidate.csh mm aaaa traitement_tot_dep_arr_aerobahn_taxi_time_v7;" +
                "<br />sh go.fab.stats.vista.annee.candidate.csh aaaa)</i>",
                "<b>CRAQ : Relance du CRAQ LIGHT</b><br /><i>(cd $ss;sh requete_auto_stat_qse_craq.csh " + G_UTIL + " jj mm aaaa)</i>",
                "<b>CRAQ : Relance du CRAQ journalier</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>CRAQ : Relance du CRAQ mensuel</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>PotAG : Relance du PotAG journalier</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>PotAG : Relance du PotAG mensuel</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL ORY LIGHT</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL ORY NORMAL</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL CDG / LBG LIGHT</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL CDG / LBG NORMAL</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>Relance Trafic Annuel CDG et LBG</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
            ],
            cmd: ['cd $ss;sh scripts_batch_auto_guichet.csh ' + JJExec + " " + MMExec + " " + AAExec + " &",
                "cd $ss;sh go.fab.stats.vista.mois_candidate.csh " + MMExec + " " + AAExec + " traitement_tot_dep_arr_aerobahn_v7;" +
                "sh go.fab.stats.vista.mois_candidate.csh " + MMExec + " " + AAExec + " traitement_tot_dep_arr_aerobahn_taxi_time_v7;" +
                "sh go.fab.stats.vista.annee.candidate.csh " + AAExec + " &",
                "cd $ss;sh requete_auto_stat_qse_craq.csh " + G_UTIL + " " + JJExec + " " + MMExec + " " + AAExec + " &",
                "CRAQ : Relance du CRAQ journalier - COMMANDE SH A DETERMINER",
                "CRAQ : Relance du CRAQ mensuel - COMMANDE SH A DETERMINER",
                "PotAG : Relance du PotAG journalier - COMMANDE SH A DETERMINER",
                "PotAG : Relance du PotAG mensuel - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL ORY LIGHT - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL ORY NORMAL - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL CDG / LBG LIGHT - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL CDG / LBG NORMAL - COMMANDE SH A DETERMINER",
                "Relance Trafic Annuel CDG et LBG - COMMANDE SH A DETERMINER",
            ],
            typecmd: ["SH", "SH", "SH", "SH", "SH", "SH", "SH", "XLS", "XLS", "XLS", "XLS", "XLS"
            ],
            mincmd: ["123", "123", "123", "123", "123", "123", "123", "123", "123", "123", "123", "123"
            ],
            class: ["CentrageVerticalForce Table_Largeur_Col3",
                    "text-center CentrageVerticalForce Table_Largeur_Col6"
            ],
            nom: ['C01', 'C02']
        };
     
        //pour chaque valeur du tableau titre de l'objet data :
        data.titre
            .forEach((vTitre, cTitre, vTypeCmd, vMinCmd) => 
            {
                NomLig = "L" + twoDigit(cTitre + 1);
                InsertLig = TabRelanceByID.insertRow(-1);
                InsertLig.id = NomLig;
        //pour chaque valeur dans data.nom on crée un td :
                data.nom
                    .forEach((valNom, cleNom) => 
                    {
                        InsertCell = InsertLig.insertCell(-1);
                        InsertCell.id = NomLig + valNom;
                        InsertCell.className = data.class[cleNom];
        //cleNom c'est l'index du tableau, donc soit 0 ou 1, puisqu'il ne contient que deux valeurs "C01" et "C02" 
                        switch (cleNom) 
                        {
                            case 0:
                        //quand l'index "cleNom" est 0 on met seulement le texte dans le td
                                InsertCell.innerHTML = vTitre;
                                break;
                            case 1:
                        //quand l'index est 1, on crée un bouton avec ses attributs... puis l'insérer dans le td
                                BtnCell = document.createElement("button");
                                BtnCell.id = "Rel_BTN" + twoDigit(cTitre + 1);
                                BtnCell.title = "Exécution : " + vTitre;
                                BtnCell.innerHTML = '';
                                InsertCell.appendChild(BtnCell);
                                BtnCell.className = "btn btn-warning fas fa-rocket fa-2x center";
                                BtnCell.onclick = function() 
                                {
                                    DateExec = $('#date_deb').datepicker("getDate");
                                    DateExec = FormatDate2(DateExec, "JJ/MM/AAAA");
                                    JJExec = DateExec.substr(0, 2);
                                    MMExec = DateExec.substr(3, 2);
                                    AAExec = DateExec.substr(6, 4);
                                    Cmd = data.cmd[cTitre];
                                    Min = "1234567";
                                    TypeCmd = data.typecmd(cTitre);
                                    MinCmd = data.mincmd(cTitre);
                                    if (TypeCmd == "SH")
                                    {
                                        ExecSSH(Cmd, Min);
                                    };
                                    if (TypeCmd == "XLS")
                                    {
                                        alert("Type_cmd="+TypeCmd);
                                    }
                                }
                                break;
                        }
                    });
            });
    }
    Zeb'...

  2. #22
    Membre actif Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 319
    Points : 286
    Points
    286
    Par défaut
    Quel idiot, j'ai trouvé : des " () " à la place de " [] " en lignes 119 et 120 !

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
     
    function ChargementTableRelance() {
        $('#table_relance').empty();
     
        var day = new Date();
        day.setDate(day.getDate() - 1); // On sélectionne le jour précédent
        var mm = ((day.getMonth() + 1) < 10) ? '0' + (day.getMonth() + 1) : (day.getMonth() + 1);
        var dd = (day.getDate() < 10) ? '0' + day.getDate() : day.getDate();
        var dayInit_Rel = day.getFullYear().toString() + mm + dd;
        var dayInitAlt_Rel = dd + "/" + mm + "/" + day.getFullYear(); // Utiliser pour le nouveau DatePicket
     
        let TabRelanceByID = document.getElementById("table_relance");
     
        let InsertLig = "";
        let InsertCell = "";
        let NomLig = "";
        let NomCell = "";
        let BtnCell = "";
        let NomDate = "";
        let NomDate2 = "";
        let Rel_NomDate = "";
        let TitreExec = "";
        let DateExec = "";
        let JJExec = "";
        let MMExec = "";
        let AAExec = "";
        let Rel_NumLig = 0;
        let Cmd = "";
        let TypeCmd = "";
        let MinCmd = "";
        let Min = "";
     
        DateExec = $('#date_deb').datepicker("getDate");
        DateExec = FormatDate2(DateExec, "JJ/MM/AAAA");
        JJExec = DateExec.substr(0, 2);
        MMExec = DateExec.substr(3, 2);
        AAExec = DateExec.substr(6, 4);
     
        let data = {
            titre: ["<b>Relance et envoie les emails pour tous les traitements VISTA pour " +
                "une date données => reconstitue le répertoire $visu/aaaa/mm/oljjmmaaaa<br /></b>" +
                "<i>(cd $ss;sh scripts_batch_auto_guichet.csh JJ MM AAAA)</i>",
                "<b>Relance fichiers mensuels ou annuels incomplets => IL FAUT EXECUTER LES 3 SCRIPTS</b>" +
                "<br />" + "<i>(cd $ss;sh go.fab.stats.vista.mois_candidate.csh mm aaaa traitement_tot_dep_arr_aerobahn_v7;" +
                "<br />sh go.fab.stats.vista.mois_candidate.csh mm aaaa traitement_tot_dep_arr_aerobahn_taxi_time_v7;" +
                "<br />sh go.fab.stats.vista.annee.candidate.csh aaaa)</i>",
                "<b>CRAQ : Relance du CRAQ LIGHT</b><br /><i>(cd $ss;sh requete_auto_stat_qse_craq.csh " + G_UTIL + " jj mm aaaa)</i>",
                "<b>CRAQ : Relance du CRAQ journalier</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>CRAQ : Relance du CRAQ mensuel</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>PotAG : Relance du PotAG journalier</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>PotAG : Relance du PotAG mensuel</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL ORY LIGHT</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL ORY NORMAL</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL CDG / LBG LIGHT</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>EVOL : Relance d'un EVOL CDG / LBG NORMAL</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
                "<b>Relance Trafic Annuel CDG et LBG</b><br /><i>(COMMANDE SH A DETERMINER)</i>",
            ],
            cmd: ['cd $ss;sh scripts_batch_auto_guichet.csh ' + JJExec + " " + MMExec + " " + AAExec + " &",
                "cd $ss;sh go.fab.stats.vista.mois_candidate.csh " + MMExec + " " + AAExec + " traitement_tot_dep_arr_aerobahn_v7;" +
                "sh go.fab.stats.vista.mois_candidate.csh " + MMExec + " " + AAExec + " traitement_tot_dep_arr_aerobahn_taxi_time_v7;" +
                "sh go.fab.stats.vista.annee.candidate.csh " + AAExec + " &",
                "cd $ss;sh requete_auto_stat_qse_craq.csh " + G_UTIL + " " + JJExec + " " + MMExec + " " + AAExec + " &",
                "CRAQ : Relance du CRAQ journalier - COMMANDE SH A DETERMINER",
                "CRAQ : Relance du CRAQ mensuel - COMMANDE SH A DETERMINER",
                "PotAG : Relance du PotAG journalier - COMMANDE SH A DETERMINER",
                "PotAG : Relance du PotAG mensuel - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL ORY LIGHT - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL ORY NORMAL - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL CDG / LBG LIGHT - COMMANDE SH A DETERMINER",
                "EVOL : Relance d'un EVOL CDG / LBG NORMAL - COMMANDE SH A DETERMINER",
                "Relance Trafic Annuel CDG et LBG - COMMANDE SH A DETERMINER",
            ],
            class: ["CentrageVerticalForce Table_Largeur_Col3",
                    "text-center CentrageVerticalForce Table_Largeur_Col6"
            ],
            nom: ['C01', 'C02'],
            typecmd: ["SH", "SH", "SH", "SH", "SH", "SH", "SH", "XLS", "XLS", "XLS", "XLS", "XLS"],
            mincmd: ["123", "123", "123", "123", "123", "123", "123", "123", "123", "123", "123", "123"]
        };
     
        //pour chaque valeur du tableau titre de l'objet data :
        data.titre
            .forEach((vTitre, cTitre) => 
            {
                NomLig = "L" + twoDigit(cTitre + 1);
                InsertLig = TabRelanceByID.insertRow(-1);
                InsertLig.id = NomLig;
        //pour chaque valeur dans data.nom on crée un td :
                data.nom
                    .forEach((valNom, cleNom) => 
                    {
                        InsertCell = InsertLig.insertCell(-1);
                        InsertCell.id = NomLig + valNom;
                        InsertCell.className = data.class[cleNom];
        //cleNom c'est l'index du tableau, donc soit 0 ou 1, puisqu'il ne contient que deux valeurs "C01" et "C02" 
                        switch (cleNom) 
                        {
                            case 0:
                        //quand l'index "cleNom" est 0 on met seulement le texte dans le td
                                InsertCell.innerHTML = vTitre;
                                break;
                            case 1:
                        //quand l'index est 1, on crée un bouton avec ses attributs... puis l'insérer dans le td
                                BtnCell = document.createElement("button");
                                BtnCell.id = "Rel_BTN" + twoDigit(cTitre + 1);
                                BtnCell.title = "Exécution : " + vTitre;
                                BtnCell.innerHTML = '';
                                InsertCell.appendChild(BtnCell);
                                BtnCell.className = "btn btn-warning fas fa-rocket fa-2x center";
                                BtnCell.onclick = function() 
                                {
                                    DateExec = $('#date_deb').datepicker("getDate");
                                    DateExec = FormatDate2(DateExec, "JJ/MM/AAAA");
                                    JJExec = DateExec.substr(0, 2);
                                    MMExec = DateExec.substr(3, 2);
                                    AAExec = DateExec.substr(6, 4);
                                    Cmd = data.cmd[cTitre];
                                    Min = "1234567";
                                    TypeCmd = data.typecmd[cTitre];
                                    MinCmd = data.mincmd[cTitre];
                                    if (TypeCmd == "SH")
                                    {
                                        ExecSSH(Cmd, Min);
                                    };
                                    if (TypeCmd == "XLS")
                                    {
                                        alert("Type_cmd="+TypeCmd);
                                    }
                                }
                                break;
                        }
                    });
            });
    }
    Zeb'...

  3. #23
    Expert confirmé Avatar de Toufik83
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    2 396
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2012
    Messages : 2 396
    Points : 4 825
    Points
    4 825
    Par défaut
    Bonjour,

    Je croyais que c'était mon erreur , tu m'as surpris .

    Puis je vois que tu te débrouilles bien avec une variable de type json, c'est bien d'apprendre les bonnes techniques.

  4. #24
    Membre actif Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 319
    Points : 286
    Points
    286
    Par défaut
    C'est grâce à toi, je me suis servi de ton exemple que j'ai essayé de comprendre, mais je reste un petit joueur
    Ca fait de bien de savoir qu'il y a encore des gens qui aident.
    Merci encore.
    Zeb'...

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. [FLASH MX] Portée des variables ???
    Par mic79 dans le forum Flash
    Réponses: 2
    Dernier message: 08/02/2005, 11h21
  2. Portée des variables vbscript vers ASP
    Par Immobilis dans le forum ASP
    Réponses: 3
    Dernier message: 03/11/2004, 11h14
  3. [XSL]Problème de portée des variables
    Par djulesp dans le forum XSL/XSLT/XPATH
    Réponses: 6
    Dernier message: 17/09/2004, 11h34
  4. [Portée] portée des variables
    Par parksto dans le forum Langage
    Réponses: 7
    Dernier message: 09/05/2004, 22h05
  5. [FLASH MX 2004][XML]portée de variable
    Par marco_ dans le forum Flash
    Réponses: 8
    Dernier message: 29/04/2004, 16h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo