Grammalecte  Check-in [a646054ced]

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: a646054cedde110bd53d63b85a6e33af665407f62f217bbcbb9008b02dc4284c
User & Date: olr on 2019-02-09 14:07:22
Other Links: branch diff | manifest | tags
Context
2019-02-09
20:27
merge trunk check-in: aea2e8d9ee user: olr tags: comdic
14:07
[fx] dictionaries manager: update check-in: a646054ced user: olr tags: comdic, fx
2019-02-05
18:40
merge trunk check-in: 521f9f5963 user: olr tags: comdic
Changes

Modified gc_lang/fr/webext/panel/dictionaries.html from [8ce0f3ed0b] to [2c8f4ed726].

     7      7     </head>
     8      8   
     9      9     <body>
    10     10   
    11     11       <div class="inbox">
    12     12   
    13     13         <h1>Dictionnaires communautaires</h1>
           14  +
           15  +        <div id="connect_panel">
           16  +            <div id="connect_form">
           17  +                <div>Inscription</div>
           18  +                <p>Vous n’êtes pas identifié.</p>
           19  +                <p>
           20  +                    <label value="E-mail"><input type="text" name="email"></label>
           21  +                    <label value="Mot de passe"><input type="password" name="pw"></label>
           22  +                    <div id="submit_button">Envoyer</div>
           23  +                </p>
           24  +            </div>
           25  +            <div id="connect_info">
           26  +                <p>
           27  +                    Identifiants : <span id="login_label"> </span>, <span id="email_label"> </span>
           28  +                </p>
           29  +            </div>
           30  +        </div>
    14     31   
    15     32           <div id="apply" class="apply">Appliquer les modifications</div>
    16     33           <h2>Dictionnaires sélectionnés</h2>
    17     34           <p id="dictionaries_list">[Aucun]<p>
    18     35   
    19     36   
    20     37           <h2><span id="num_dic">0</span> dictionnaires disponibles</h2>

Modified gc_lang/fr/webext/panel/dictionaries.js from [f9a15fdf35] to [66c74db008].

    46     46       if (document.getElementById(sElemId)) {
    47     47           document.getElementById(sElemId).style.display = "none";
    48     48       } else {
    49     49           console.log("HTML node named <" + sElemId + "> not found.")
    50     50       }
    51     51   }
    52     52   
           53  +async function hashText (sText, sAlgorithm = 'SHA-256') {
           54  +    let msgBuffer = new TextEncoder('utf-8').encode(sText);
           55  +    let hashBuffer = await crypto.subtle.digest(sAlgorithm, msgBuffer);
           56  +    let hashArray = Array.from(new Uint8Array(hashBuffer));
           57  +    return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
           58  +}
           59  +
           60  +
           61  +oConnect = {
           62  +    bConnected: false,
           63  +
           64  +    init: function () {
           65  +        if (bChrome) {
           66  +            browser.storage.local.get("credentials", this._init().bind(this));
           67  +            return;
           68  +        }
           69  +        let xPromise = browser.storage.local.get("credentials");
           70  +        xPromise.then(this._init.bind(this), showError);
           71  +    },
           72  +
           73  +    _init: function (oData) {
           74  +        if (oData.hasOwnProperty("credentials")) {
           75  +            hideElement("connect_form");
           76  +            showElement("connect_info");
           77  +            this.bConnected = true;
           78  +        }
           79  +        else {
           80  +            hideElement("connect_form");
           81  +            showElement("connect_info");
           82  +        }
           83  +    },
           84  +
           85  +    listen: function () {
           86  +        document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect() });
           87  +    },
           88  +
           89  +    connect: function () {
           90  +        let sEmail = document.getElementById("email").value;
           91  +        let sPassword = document.getElementById("password").value;
           92  +        console.log(sEmail, sPassword);
           93  +    }
           94  +}
    53     95   
    54     96   
    55     97   class Table {
    56     98   
    57     99       constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {
    58    100           this.sNodeId = sNodeId;
    59    101           this.xTable = document.getElementById(sNodeId);
................................................................................
   310    352           browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "community", oDict: oDict}, dInfo: {} });
   311    353       }
   312    354   }
   313    355   
   314    356   const oDicTable = new Table("dictionaries_table", ["Nom", "Entrées", "Description", "Date"], "wait_progress", "num_dic", false, true);
   315    357   
   316    358   oDicTable.init();
          359  +
          360  +oConnect.init();
          361  +oConnect.listen();