Grammalecte  Check-in [fd372b5786]

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:fd372b578628dadfb933da6507517550c09760768d6fe57e444cba38caa67b2d
User & Date: olr 2019-02-12 19:58:49
Context
2019-02-13
19:53
[fx] dictionaries manager: update check-in: 50fe201fc1 user: olr tags: fx, comdic
2019-02-12
19:58
[fx] dictionaries manager: update check-in: fd372b5786 user: olr tags: fx, comdic
2019-02-10
00:31
[core][js] echo function for debugging check-in: bcd8a483d5 user: olr tags: core, comdic
Changes

Changes to gc_lang/fr/webext/manifest.json.

128
129
130
131
132
133
134

135
136
137
138
139
140
141
  ],

  "permissions": [
    "*://localhost/*",
    "*://dic.grammalecte.net/*",
    "activeTab",
    "contextMenus",

    "downloads",
    "storage"
  ],

  "chrome_settings_overrides": {
    "search_provider": {
      "name": "Grammalecte",







>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  ],

  "permissions": [
    "*://localhost/*",
    "*://dic.grammalecte.net/*",
    "activeTab",
    "contextMenus",
    "cookies",
    "downloads",
    "storage"
  ],

  "chrome_settings_overrides": {
    "search_provider": {
      "name": "Grammalecte",

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

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
..
79
80
81
82
83
84
85















86
87
88
89
90
91
92
    width: 800px;
    margin: 20px auto 10px auto;
    padding: 10px 30px 30px 30px;
    background: hsl(0, 0%, 100%);
    border: 2px solid hsl(210, 0%, 90%);
    border-radius: 20px;
}
































h1 {
    margin: 5px 0 5px 0;
    color: hsl(210, 50%, 50%);
    font: bold 30px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
    text-align: center;
}
h2 {
    margin: 10px 0 2px 0;
    color: hsl(0, 50%, 50%);
    font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}


/*
    Main buttons
*/

ul {
    margin-left: 30px;
}

input[type=text].large {
    display: inline-block;
    width: 250px;
    padding: 5px 10px;
    border: 2px solid hsl(0, 0%, 80%);
    border-radius: 3px;
    height: 24px;
................................................................................
    color: hsl(0, 0%, 20%);
}

input[placeholder] {
    color: hsl(0, 0%, 50%);
}

















.dic_button {
    margin: 2px;
    display: inline-block;
}
.dic_button_close {
    display: inline-block;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|
<








<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
...
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
    width: 800px;
    margin: 20px auto 10px auto;
    padding: 10px 30px 30px 30px;
    background: hsl(0, 0%, 100%);
    border: 2px solid hsl(210, 0%, 90%);
    border-radius: 20px;
}


#message_box {
    display: none;
    position: fixed;
    top: 33%;
    left: calc(50% - 325px);
}
#message {
    display: inline-block;
    padding: 1px 10px;
    width: 600px;
    background-color: hsl(0, 50%, 50%);
    color: hsl(0, 50%, 98%);
    border-style: solid;
    border-width: 2px 0 2px 2px;
    border-color: hsl(0, 50%, 40%);
    border-radius: 3px 0 0 3px;
}
#message_close_button {
    display: inline-block;
    padding: 1px 5px;
    background-color: hsl(0, 50%, 40%);
    color: hsl(0, 90%, 90%);
    border-style: solid;
    border-width: 2px 2px 2px 0;
    border-color: hsl(0, 50%, 30%);
    border-radius: 0 3px 3px 0;
    cursor: pointer;
}


h1 {
    margin: 5px 0 5px 0;
    color: hsl(210, 50%, 50%);
    font: bold 24px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;

}
h2 {
    margin: 10px 0 2px 0;
    color: hsl(0, 50%, 50%);
    font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}










input[type=text].large {
    display: inline-block;
    width: 250px;
    padding: 5px 10px;
    border: 2px solid hsl(0, 0%, 80%);
    border-radius: 3px;
    height: 24px;
................................................................................
    color: hsl(0, 0%, 20%);
}

input[placeholder] {
    color: hsl(0, 0%, 50%);
}


#connect_panel {
    background-color: hsl(210, 50%, 90%);
    border-radius: 5px;
    padding: 3px 10px;
}
#submit_button {
    display: inline-block;
    padding: 1px 5px;
    background-color: hsl(210, 50%, 30%);
    color: hsl(210, 0%, 100%);
    border-radius: 3px;
    cursor: pointer;
}


.dic_button {
    margin: 2px;
    display: inline-block;
}
.dic_button_close {
    display: inline-block;

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

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
    <link rel="stylesheet" type="text/css" href="dictionaries.css" />
    <title>Grammalecte · Dictionnaires communautaires</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  </head>

  <body>

    <div class="inbox">




      <h1>Dictionnaires communautaires</h1>

        <div id="connect_panel">
            <div id="connect_form">
                <div>Inscription</div>
                <p>Vous n’êtes pas identifié.</p>
                <p>
                    <label value="E-mail"><input type="text" name="email"></label>
                    <label value="Mot de passe"><input type="password" name="pw"></label>


                    <div id="submit_button">Envoyer</div>


                </p>
            </div>

            <div id="connect_info">
                <p>
                    Identifiants : <span id="login_label"> </span>, <span id="email_label"> </span>
                </p>
            </div>
        </div>

        <div id="apply" class="apply">Appliquer les modifications</div>
        <h2>Dictionnaires sélectionnés</h2>
        <p id="dictionaries_list">[Aucun]<p>



        <h2><span id="num_dic">0</span> dictionnaires disponibles</h2>
        <progress id="wait_progress" value="0"></progress>
        <table id="dictionaries_table">
        </table>

    </div>


    <script src="../grammalecte/graphspell/helpers.js"></script>
    <script src="../grammalecte/graphspell/char_player.js"></script>
    <script src="../grammalecte/graphspell/str_transform.js"></script>
    <script src="../grammalecte/graphspell/dawg.js"></script>
    <script src="../grammalecte/graphspell/ibdawg.js"></script>
    <script src="../grammalecte/graphspell/dic_merger.js"></script>
    <script src="../grammalecte/graphspell/spellchecker.js"></script>
    <script src="dictionaries.js"></script>
  </body>

</html>







|
>
>

>
|

|
|
<
<
|
<
|
>
>
|
>
>
|
<
>
|
|
|
|
|
|

<
|
|

<
>
|
|
|
|
<
|













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
    <link rel="stylesheet" type="text/css" href="dictionaries.css" />
    <title>Grammalecte · Dictionnaires communautaires</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  </head>

  <body>

    <div id="message_box">
      <div id="message">[néant]</div><div id="message_close_button">×</div>
    </div>

    <div class="inbox">
      <h1>Grammalecte · Dictionnaires communautaires</h1>

      <div id="connect_panel">
        <form id="connect_form" method="post" enctype="multipart/form-data">


          <p>

            Non connecté.
            <label for="email">E-mail : </label> <input type="text" id="email" name="email" />
            <label for="password">Mot de passe : </label> <input type="password" id="pw" name="pw" />
            <span id="submit_button">Se connecter</span>
            |
            <a href="http://dic.grammalecte.net" target="_blank">Inscription</a>
          </p>

        </form>
        <div id="connect_info">
          <p>
            Connecté. Identifiants : <span id="login_label"> </span>, <span id="email_label"> </span>
          </p>
        </div>
      </div>


      <h2>Dictionnaires sélectionnés</h2>
      <p id="dictionaries_list">[Aucun]<p>


      <div id="apply" class="apply">Appliquer les modifications</div>
      <h2><span id="num_dic">0</span> dictionnaires disponibles</h2>
      <progress id="wait_progress" value="0"></progress>
      <table id="dictionaries_table">
      </table>

    </div> <!-- inbox -->


    <script src="../grammalecte/graphspell/helpers.js"></script>
    <script src="../grammalecte/graphspell/char_player.js"></script>
    <script src="../grammalecte/graphspell/str_transform.js"></script>
    <script src="../grammalecte/graphspell/dawg.js"></script>
    <script src="../grammalecte/graphspell/ibdawg.js"></script>
    <script src="../grammalecte/graphspell/dic_merger.js"></script>
    <script src="../grammalecte/graphspell/spellchecker.js"></script>
    <script src="dictionaries.js"></script>
  </body>

</html>

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

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
...
352
353
354
355
356
357
358


359
360
361
    let msgBuffer = new TextEncoder('utf-8').encode(sText);
    let hashBuffer = await crypto.subtle.digest(sAlgorithm, msgBuffer);
    let hashArray = Array.from(new Uint8Array(hashBuffer));
    return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
}



















oConnect = {
    bConnected: false,

    init: function () {
        if (bChrome) {
            browser.storage.local.get("credentials", this._init().bind(this));
            return;
        }
        let xPromise = browser.storage.local.get("credentials");
        xPromise.then(this._init.bind(this), showError);
    },

    _init: function (oData) {
        if (oData.hasOwnProperty("credentials")) {
            hideElement("connect_form");
            showElement("connect_info");
            this.bConnected = true;
        }
        else {

            hideElement("connect_form");
            showElement("connect_info");
        }




    },

    listen: function () {
        document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect() });
    },

    connect: function () {
        let sEmail = document.getElementById("email").value;
        let sPassword = document.getElementById("password").value;





























        console.log(sEmail, sPassword);







    }
}


class Table {

    constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {
................................................................................
        browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "community", oDict: oDict}, dInfo: {} });
    }
}

const oDicTable = new Table("dictionaries_table", ["Nom", "Entrées", "Description", "Date"], "wait_progress", "num_dic", false, true);

oDicTable.init();



oConnect.init();
oConnect.listen();







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|




|


|



|
|
|
<


<
>



>
>
>
>



|



|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>







 







>
>



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
408
409
410
411
412
413
414
415
416
417
418
419
    let msgBuffer = new TextEncoder('utf-8').encode(sText);
    let hashBuffer = await crypto.subtle.digest(sAlgorithm, msgBuffer);
    let hashArray = Array.from(new Uint8Array(hashBuffer));
    return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
}


const oMessage = {
    show: function (sMessage, nDelay=10000) {
        document.getElementById("message").textContent = sMessage;
        showElement("message_box");
        window.setTimeout(this.close, nDelay);
    },

    listen: function () {
        document.getElementById("message_close_button").addEventListener("click", (xEvent) => { this.close(); });
    },

    close: function () {
        hideElement("message_box");
    }
}


const oConnect = {
    bConnected: false,

    init: function () {
        if (bChrome) {
            browser.cookies.getAll({ domain: "localhost" }, this._init.bind(this));
            return;
        }
        let xPromise = browser.cookies.getAll({ domain: "localhost" });
        xPromise.then(this._init.bind(this), showError);
    },

    _init: function (lData) {
        for (let xCookie of lData) {
            console.log(xCookie.name, xCookie.value);

            this.bConnected = true;
        }

        if (this.bConnected) {
            hideElement("connect_form");
            showElement("connect_info");
        }
        else {
            showElement("connect_form");
            hideElement("connect_info");
        }
    },

    listen: function () {
        document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect(); });
    },

    connect: function () {
        let xForm = new FormData(document.getElementById('connect_form'));
        for (let [k, v] of xForm.entries()) {
            console.log("* ", k, v);
        }
        oMessage.show("TEST");
        fetch("http://localhost/connect/", {
            method: "POST", // *GET, POST, PUT, DELETE, etc.
            //mode: "cors", // no-cors, cors, *same-origin
            //cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
            /*headers: {
                "Content-Type": "multipart/form-data",  // text/plain, application/json
            },*/
            credentials: "omit", // include, *same-origin, omit
            body: xForm
        })
        .then((response) => {
            if (response.ok) {
                for (let param in response) {
                    console.log(param, response[param]);
                }
                console.log(response.body);
                return response.json();
            } else {
                for (let param in response) {
                    console.log(param, response[param]);
                }
                return null;
            }
        })
        .then((response) => {
            if (response) {
                console.log(response);
            } else {
                console.log(response);
            }
        })
        .catch((e) => {
            showError(e);
        });
    }
}


class Table {

    constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) {
................................................................................
        browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "community", oDict: oDict}, dInfo: {} });
    }
}

const oDicTable = new Table("dictionaries_table", ["Nom", "Entrées", "Description", "Date"], "wait_progress", "num_dic", false, true);

oDicTable.init();

oMessage.listen();

oConnect.init();
oConnect.listen();