Grammalecte  Check-in [fd372b5786]

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 on 2019-02-12 19:58:49
Other Links: branch diff | manifest | tags
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

Modified gc_lang/fr/webext/manifest.json from [8ca9ed57ec] to [f83d1e1e3e].

128
129
130
131
132
133
134

135
136
137
138
139
140
141
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",

Modified gc_lang/fr/webext/panel/dictionaries.css from [f2b5daf12c] to [11fa8484fe].

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
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








+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



-
+
-








-
-
-
-
-
-
-
-







    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 30px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
    font: bold 24px "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;
79
80
81
82
83
84
85















86
87
88
89
90
91
92
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    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;

Modified gc_lang/fr/webext/panel/dictionaries.html from [2c8f4ed726] to [7f63251ae3].

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
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










-
+
+
+

+
-
+

-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
+
+

-
-
-
-
-
+
+
+
+
+
-
-
+







<!DOCTYPE HTML>
<html>
  <head>
    <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">
    <div id="message_box">
      <div id="message">[néant]</div><div id="message_close_button">×</div>
    </div>

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

        <div id="connect_panel">
            <div id="connect_form">
      <div id="connect_panel">
        <form id="connect_form" method="post" enctype="multipart/form-data">
                <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>
          <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>

        <div id="apply" class="apply">Appliquer les modifications</div>
        <h2>Dictionnaires sélectionnés</h2>
        <p id="dictionaries_list">[Aucun]<p>
      <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 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>
    </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>

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

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
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+




-
+


-
+



-
-
-
+
+
+
-


-
+



+
+
+
+



-
+



-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    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");
    }
}


oConnect = {
const oConnect = {
    bConnected: false,

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

    _init: function (oData) {
        if (oData.hasOwnProperty("credentials")) {
            hideElement("connect_form");
    _init: function (lData) {
        for (let xCookie of lData) {
            console.log(xCookie.name, xCookie.value);
            showElement("connect_info");
            this.bConnected = true;
        }
        else {
        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() });
        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);
        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) {
352
353
354
355
356
357
358


359
360
361
408
409
410
411
412
413
414
415
416
417
418
419







+
+



        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();