Grammalecte  Check-in [ae6457bb81]

Overview
Comment:[fx] update: lexicon editor
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: ae6457bb8164b71e87fda61949b373098859e02a257754ef3ca392dcbcf26c95
User & Date: olr on 2018-01-24 16:24:59
Other Links: manifest | tags
Context
2018-01-26
17:15
[fx] update: lexical editor check-in: 4c7933e88b user: olr tags: trunk, fx
2018-01-24
16:24
[fx] update: lexicon editor check-in: ae6457bb81 user: olr tags: trunk, fx
2018-01-23
15:30
[fr] update: lexicon editor check-in: 64a6a08b79 user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/webext/panel/lex_editor.css from [3cee00f715] to [d9e3b0412e].

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
    border-radius: 20px;
}

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

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















#editor {
    display: none;
}

#categories {
    display: flex;
    padding: 10px 0;







>












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







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
    border-radius: 20px;
}

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


.main_button {
    margin: 0 5px;
    padding: 10px 30px;
    background-color: hsl(210, 10%, 90%);
    border-radius: 5px;
    cursor: pointer;
}


#add_word_page {
    display: none;
}

#editor {
    display: none;
}

#categories {
    display: flex;
    padding: 10px 0;
175
176
177
178
179
180
181













    cursor: pointer;
}
#add_to_lexicon:hover {
    background-color: hsl(0, 60%, 40%);
    color: hsl(0, 60%, 70%);
    box-shadow: 0 0 2px hsl(0, 60%, 50%);
}




















>
>
>
>
>
>
>
>
>
>
>
>
>
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    cursor: pointer;
}
#add_to_lexicon:hover {
    background-color: hsl(0, 60%, 40%);
    color: hsl(0, 60%, 70%);
    box-shadow: 0 0 2px hsl(0, 60%, 50%);
}


#lexicon_page {
    
}

th {
    padding: 5px 20px;
    border-left: 1px solid hsl(210, 10%, 90%);
}
td {
    padding: 0 20px;
}

Modified gc_lang/fr/webext/panel/lex_editor.html from [f63ed175e8] to [53b86a285e].

8
9
10
11
12
13
14






15
16
17
18
19
20
21
    
    <body>

        <div class="inbox">

            <h1>Éditeur lexical</h1>







            <h2>Nouveau mot</h2>
            <input type="text" id="word" name="word" maxlength="60" value="" placeholder="votre mot" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" autofocus />

            <div id="editor">

                <div id="categories">
                    <div class="category" id="select_nom" data-tag="N">Nom, adjectif</div>







>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    
    <body>

        <div class="inbox">

            <h1>Éditeur lexical</h1>

            <div class="container">
                <div id="lexicon_button" class="main_button">Lexique</div>
                <div id="add_word_button" class="main_button">Ajout</div>
            </div>

            <div id="add_word_page">
            <h2>Nouveau mot</h2>
            <input type="text" id="word" name="word" maxlength="60" value="" placeholder="votre mot" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" autofocus />

            <div id="editor">

                <div id="categories">
                    <div class="category" id="select_nom" data-tag="N">Nom, adjectif</div>
232
233
234
235
236
237
238

239














240
241
242
243
244
245
246
247
                    
                </div>
                
                <div id="buttonline">
                    <div id="add_to_lexicon">Ajouter au dictionnaire</div>
                </div>
            </div>

            














        </div>


        <script src="../grammalecte/graphspell/helpers.js"></script>
        <script src="lex_editor.js"></script>
    </body>
    
</html>







>

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








238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
                    
                </div>
                
                <div id="buttonline">
                    <div id="add_to_lexicon">Ajouter au dictionnaire</div>
                </div>
            </div>
            </div>
            
            <div id="lexicon_page">
                <h2>Votre lexique</h2>
                <table>
                    <tr id="head">
                        <th>#</th>
                        <th>Forme fléchie</th>
                        <th>Lemme</th>
                        <th>Étiquettes</th>
                    </tr>
                </table>
                <table id="table">
                    
                </table>
            </div>
        </div>


        <script src="../grammalecte/graphspell/helpers.js"></script>
        <script src="lex_editor.js"></script>
    </body>
    
</html>

Modified gc_lang/fr/webext/panel/lex_editor.js from [e7376134de] to [b986ace5c1].

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

"use strict";


function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}


function onSelectionClick (xEvent) {
    try {
        let xElem = xEvent.target;
        if (xElem.id) {
            if (xElem.id.startsWith("select_")) {
                oPage.showSection("section_" + xElem.id.slice(7));
                oFlex.setMainTag(xElem.dataset.tag);
                oFlex.update();
            } else if (xElem.id.startsWith("up_")) {
                oFlex.update();
            }
        }

    }
    catch (e) {
        showError(e);
    }
}

function onWrite (xEvent) {
    if (document.getElementById("word").value.trim() !== "") {
        oPage.showEditor();
    } else {
        oPage.hideEditor();
        oPage.hideActions();
    }
}

function onWrite2 (xEvent) {
    if (document.getElementById("word2").value.trim() !== "") {
        oPage.showWord2();
    } else {
        oPage.hideWord2();
    }
}


document.getElementById("editor").addEventListener("click", onSelectionClick, false);
document.getElementById("word").addEventListener("keyup", onWrite, false);
document.getElementById("word2").addEventListener("keyup", onWrite2, false);
document.getElementById("lemma").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);



/*
    ACTIONS
*/

const oPage = {











    showEditor: function () {
        document.getElementById("editor").style.display = "block";
    },

    hideEditor: function () {
        document.getElementById("editor").style.display = "none";





<
<
<
|
<
<

|
|
<
<
|
|
<
<

<
>






|
|
<
<
<
<

|

<
<
<
<
<
<
<
|
|
|
|
|











>
>
>
>
>
>
>
>
>
>







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

"use strict";





function createNode  (sType, oAttr, oDataset=null) {


    try {
        let xNode = document.createElement(sType);
        Object.assign(xNode, oAttr);


        if (oDataset) {
            Object.assign(xNode.dataset, oDataset);


            }

        return xNode;
    }
    catch (e) {
        showError(e);
    }
}

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);




    }









document.getElementById("lexicon_button").addEventListener("click", () => { oPage.showPage("lex"); }, false);
document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("word"); }, false);
document.getElementById("editor").addEventListener("click", (xEvent) => { oPage.onSelectionClick(xEvent); }, false);
document.getElementById("word").addEventListener("keyup", () => { oPage.onWrite(); }, false);
document.getElementById("word2").addEventListener("keyup", () => { oPage.onWrite2(); }, false);
document.getElementById("lemma").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);



/*
    ACTIONS
*/

const oPage = {

    showPage: function (sPage) {
        if (document.getElementById("lexicon_page").style.display == "block") {
            document.getElementById("lexicon_page").style.display = "none";
            document.getElementById("add_word_page").style.display = "block";
        } else {
            document.getElementById("add_word_page").style.display = "none";
            document.getElementById("lexicon_page").style.display = "block";
        }
    },

    showEditor: function () {
        document.getElementById("editor").style.display = "block";
    },

    hideEditor: function () {
        document.getElementById("editor").style.display = "none";
116
117
118
119
120
121
122



































123
124
125
126
127
128
129
            document.getElementById("lemma").value = "";
            document.getElementById("tags").value = "";
        }
        catch (e) {
            showError(e);
        }
    },




































    showWord2: function () {
        document.getElementById("word_section2").style.display = "block";
    },

    hideWord2: function () {
        document.getElementById("word_section2").style.display = "none";







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







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
            document.getElementById("lemma").value = "";
            document.getElementById("tags").value = "";
        }
        catch (e) {
            showError(e);
        }
    },

    onSelectionClick: function (xEvent) {
        try {
            let xElem = xEvent.target;
            if (xElem.id) {
                if (xElem.id.startsWith("select_")) {
                    this.showSection("section_" + xElem.id.slice(7));
                    oFlex.setMainTag(xElem.dataset.tag);
                    oFlex.update();
                } else if (xElem.id.startsWith("up_")) {
                    oFlex.update();
                }
            }
        }
        catch (e) {
            showError(e);
        }
    },

    onWrite: function () {
        if (document.getElementById("word").value.trim() !== "") {
            this.showEditor();
        } else {
            this.hideEditor();
            this.hideActions();
        }
    },

    onWrite2: function () {
        if (document.getElementById("word2").value.trim() !== "") {
            this.showWord2();
        } else {
            this.hideWord2();
        }
    },

    showWord2: function () {
        document.getElementById("word_section2").style.display = "block";
    },

    hideWord2: function () {
        document.getElementById("word_section2").style.display = "none";
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215
216
217
218
219

220
221
222

223
224
225
226
227
228

229
230
231
232
233
234
235
                            }
                        }
                        break;
                    case "V":
                        if (!sWord.endsWith("er") && !sWord.endsWith("ir")) {
                            break;
                        }

                        let c_g = (sWord.endsWith("er")) ? "1" : "2";
                        let c_i = (document.getElementById("up_v_i").checked) ? "i" : "_";
                        let c_t = (document.getElementById("up_v_t").checked) ? "t" : "_";
                        let c_n = (document.getElementById("up_v_n").checked) ? "n" : "_";
                        let c_p = (document.getElementById("up_v_p").checked) ? "p" : "_";
                        let c_m = (document.getElementById("up_v_m").checked) ? "m" : "_";
                        let c_ae = (document.getElementById("up_v_ae").checked) ? "e" : "_";
                        let c_aa = (document.getElementById("up_v_aa").checked) ? "a" : "_";
                        let sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa;
                        if (!sVerbTag.endsWith("__") && !sVerbTag.startsWith("____")) {
                            this.addFlexion(sWord, sWord, ":V" + c_g + "_" + sVerbTag);
                        }
                        break;
                    case "W":

                        this.addFlexion(sWord, sWord, ":W");
                        break;
                    case "M1":

                        sGenderTag = this.getRadioValue("genre_m1");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M1"+sGenderTag+":i");
                        }
                        break;
                    case "M2":

                        sGenderTag = this.getRadioValue("genre_m2");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M2"+sGenderTag+":i");
                        }
                        break;
                    case "MP":
                        sGenderTag = this.getRadioValue("genre_mp");







>














>



>






>







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
                            }
                        }
                        break;
                    case "V":
                        if (!sWord.endsWith("er") && !sWord.endsWith("ir")) {
                            break;
                        }
                        sWord = sWord.toLowerCase();
                        let c_g = (sWord.endsWith("er")) ? "1" : "2";
                        let c_i = (document.getElementById("up_v_i").checked) ? "i" : "_";
                        let c_t = (document.getElementById("up_v_t").checked) ? "t" : "_";
                        let c_n = (document.getElementById("up_v_n").checked) ? "n" : "_";
                        let c_p = (document.getElementById("up_v_p").checked) ? "p" : "_";
                        let c_m = (document.getElementById("up_v_m").checked) ? "m" : "_";
                        let c_ae = (document.getElementById("up_v_ae").checked) ? "e" : "_";
                        let c_aa = (document.getElementById("up_v_aa").checked) ? "a" : "_";
                        let sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa;
                        if (!sVerbTag.endsWith("__") && !sVerbTag.startsWith("____")) {
                            this.addFlexion(sWord, sWord, ":V" + c_g + "_" + sVerbTag);
                        }
                        break;
                    case "W":
                        sWord = sWord.toLowerCase();
                        this.addFlexion(sWord, sWord, ":W");
                        break;
                    case "M1":
                        sWord = sWord.slice(0,1).toUpperCase() + sWord.slice(1);
                        sGenderTag = this.getRadioValue("genre_m1");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M1"+sGenderTag+":i");
                        }
                        break;
                    case "M2":
                        sWord = sWord.slice(0,1).toUpperCase() + sWord.slice(1);
                        sGenderTag = this.getRadioValue("genre_m2");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M2"+sGenderTag+":i");
                        }
                        break;
                    case "MP":
                        sGenderTag = this.getRadioValue("genre_mp");
290
291
292
293
294
295
296

297
298
299



300


































301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316

    lFlexion: [],

    addFlexions: function (lFlex) {
        for (let aFlex of lFlex) {
            this.lFlexion.push(aFlex);
        }

    },

    load: function () {






































    },

    save: function () {
        console.log(this.lFlexion);
    },

    build: function () {
        return null;
    },

    export: function () {
        let xBlob = new Blob(['{ "app": "grammalecte", "data": ["énum", "test"] }'], {type: 'application/json'}); 
        let sURL = URL.createObjectURL(xBlob);
        browser.downloads.download({ filename: "grammalecte_personal_dictionary.json", url: sURL, saveAs: true });
    }
}







>



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



|












319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

    lFlexion: [],

    addFlexions: function (lFlex) {
        for (let aFlex of lFlex) {
            this.lFlexion.push(aFlex);
        }
        this.display();
    },

    load: function () {
        if (bChrome) {
            browser.storage.local.get("lexicon_list", this._setList);
            return;
        }
        let xPromise = browser.storage.local.get("lexicon_list");
        xPromise.then(this._setList, showError);
    },

    _setList: function (dResult) {
        console.log("LOAD");
        if (dResult.hasOwnProperty("lexicon_list")) {
            this.lFlexion = dResult.lexicon_list;
        }
    },

    display: function () {
        let xTable = document.getElementById("table");
        let n = 0;
        for (let [sFlexion, sLemma, sTags] of this.lFlexion) {
            xTable.appendChild(this._createRowNode(n, sFlexion, sLemma, sTags));
            n += 1;
        }
    },

    _createRowNode: function (n, sFlexion, sLemma, sTags) {
        let xRowNode = createNode("tr", { id: "row_"+n });
        xRowNode.appendChild(createNode("td", { textContent: n }));
        xRowNode.appendChild(createNode("td", { textContent: sFlexion }));
        xRowNode.appendChild(createNode("td", { textContent: sLemma }));
        xRowNode.appendChild(createNode("td", { textContent: sTags }));
        return xRowNode;
    },

    clearTable: function () {
        let xTable = document.getElementById("table");
        while (xTable.firstChild) {
            xTable.removeChild(xTable.firstChild);
        }
    },

    save: function () {
        browser.storage.local.set({ "lexicon_list": this.lFlexion });
    },

    build: function () {
        return null;
    },

    export: function () {
        let xBlob = new Blob(['{ "app": "grammalecte", "data": ["énum", "test"] }'], {type: 'application/json'}); 
        let sURL = URL.createObjectURL(xBlob);
        browser.downloads.download({ filename: "grammalecte_personal_dictionary.json", url: sURL, saveAs: true });
    }
}