Grammalecte  Check-in [50fe201fc1]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[fx] dictionaries manager: update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | comdic
Files: files | file ages | folders
SHA3-256:50fe201fc1722849f6447ee6f732ef32b4bf608a0105805fb8f34b3711c8ad5f
User & Date: olr 2019-02-13 19:53:24
Context
2019-02-13
21:37
merge trunk check-in: 12dd6264d6 user: olr tags: comdic
19:53
[fx] dictionaries manager: update check-in: 50fe201fc1 user: olr tags: comdic, fx
2019-02-12
19:58
[fx] dictionaries manager: update check-in: fd372b5786 user: olr tags: comdic, fx
Changes

Changes to gc_lang/fr/webext/panel/dictionaries.css.

    39     39       display: none;
    40     40       position: fixed;
    41     41       top: 33%;
    42     42       left: calc(50% - 325px);
    43     43   }
    44     44   #message {
    45     45       display: inline-block;
    46         -    padding: 1px 10px;
           46  +    padding: 5px 20px;
    47     47       width: 600px;
    48     48       background-color: hsl(0, 50%, 50%);
    49     49       color: hsl(0, 50%, 98%);
    50     50       border-style: solid;
    51         -    border-width: 2px 0 2px 2px;
    52         -    border-color: hsl(0, 50%, 40%);
    53         -    border-radius: 3px 0 0 3px;
           51  +    border-width: 3px 0 3px 3px;
           52  +    border-color: hsla(0, 50%, 40%, .5);
           53  +    border-radius: 5px 0 0 5px;
    54     54   }
    55     55   #message_close_button {
    56     56       display: inline-block;
    57         -    padding: 1px 5px;
           57  +    padding: 5px 10px;
    58     58       background-color: hsl(0, 50%, 40%);
    59     59       color: hsl(0, 90%, 90%);
    60     60       border-style: solid;
    61         -    border-width: 2px 2px 2px 0;
    62         -    border-color: hsl(0, 50%, 30%);
    63         -    border-radius: 0 3px 3px 0;
           61  +    border-width: 3px 3px 3px 0;
           62  +    border-color: hsla(0, 50%, 30%, .5);
           63  +    border-radius: 0 5px 5px 0;
    64     64       cursor: pointer;
    65     65   }
    66     66   
    67     67   
    68     68   h1 {
    69     69       margin: 5px 0 5px 0;
    70     70       color: hsl(210, 50%, 50%);

Changes to gc_lang/fr/webext/panel/dictionaries.html.

    15     15       <div class="inbox">
    16     16         <h1>Grammalecte · Dictionnaires communautaires</h1>
    17     17   
    18     18         <div id="connect_panel">
    19     19           <form id="connect_form" method="post" enctype="multipart/form-data">
    20     20             <p>
    21     21               Non connecté.
    22         -            <label for="email">E-mail : </label> <input type="text" id="email" name="email" />
           22  +            <label for="email">E-mail : </label> <input type="email" id="email" name="email" />
    23     23               <label for="password">Mot de passe : </label> <input type="password" id="pw" name="pw" />
    24     24               <span id="submit_button">Se connecter</span>
    25     25               |
    26     26               <a href="http://dic.grammalecte.net" target="_blank">Inscription</a>
    27     27             </p>
    28     28           </form>
    29     29           <div id="connect_info">

Changes to gc_lang/fr/webext/panel/dictionaries.js.

   103    103       },
   104    104   
   105    105       listen: function () {
   106    106           document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect(); });
   107    107       },
   108    108   
   109    109       connect: function () {
          110  +        if (!this.checkValues()) {
          111  +            oMessage.show("Les valeurs des champs du formulaire ne sont pas conformes.");
          112  +            return;
          113  +        }
   110    114           let xForm = new FormData(document.getElementById('connect_form'));
   111    115           for (let [k, v] of xForm.entries()) {
   112    116               console.log("* ", k, v);
   113    117           }
   114         -        oMessage.show("TEST");
   115    118           fetch("http://localhost/connect/", {
   116    119               method: "POST", // *GET, POST, PUT, DELETE, etc.
   117    120               //mode: "cors", // no-cors, cors, *same-origin
   118    121               //cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
   119         -            /*headers: {
   120         -                "Content-Type": "multipart/form-data",  // text/plain, application/json
   121         -            },*/
          122  +            headers: {
          123  +                "Accept-Charset": "utf-8"
          124  +                //"Content-Type": "multipart/form-data",  // text/plain, application/json
          125  +            },
   122    126               credentials: "omit", // include, *same-origin, omit
   123    127               body: xForm
   124    128           })
   125    129           .then((response) => {
   126    130               if (response.ok) {
          131  +                if (response.status == 204) {
          132  +                    oMessage.show("Échec d’identification. Vérifiez l’e-mail et le mot de passe envoyés…");
          133  +                    return null;
          134  +                }
   127    135                   for (let param in response) {
   128    136                       console.log(param, response[param]);
   129    137                   }
   130    138                   console.log(response.body);
   131    139                   return response.json();
   132    140               } else {
   133         -                for (let param in response) {
   134         -                    console.log(param, response[param]);
   135         -                }
          141  +                oMessage.show("Erreur. Le serveur ne semble pas en état de répondre. Veuillez réessayer ultérieurement.");
   136    142                   return null;
   137    143               }
   138    144           })
   139    145           .then((response) => {
   140    146               if (response) {
   141         -                console.log(response);
   142         -            } else {
   143         -                console.log(response);
          147  +                console.log("response: ", response);
   144    148               }
   145    149           })
   146    150           .catch((e) => {
   147    151               showError(e);
   148    152           });
          153  +    },
          154  +
          155  +    checkValues () {
          156  +        if (document.getElementById("email").value === "") {
          157  +            return false;
          158  +        }
          159  +        let sEmail = document.getElementById("email").value;
          160  +        if (sEmail.search(/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/) === -1) {
          161  +            return false;
          162  +        }
          163  +        return true;
          164  +    },
          165  +
          166  +    showId (sLogin, sEmail) {
          167  +        document.getElementById("login_label").textContent = sLogin;
          168  +        document.getElementById("email_label").textContent = sEmail;
          169  +        hideElement("connect_form");
          170  +        showElement("connect_info");
   149    171       }
   150    172   }
   151    173   
   152    174   
   153    175   class Table {
   154    176   
   155    177       constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {