Grammalecte  Check-in [503e7a8eba]

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: 503e7a8eba7ddb3806d36a2f6254ee99ba13f4f80c0d6e9497484cdc8de9b670
User & Date: olr on 2018-01-30 16:47:53
Other Links: manifest | tags
Context
2018-01-31
13:08
[fx] update: lexicon update (code clarification) check-in: 341fcee2ed user: olr tags: trunk, fx
2018-01-30
16:47
[fx] update: lexicon editor check-in: 503e7a8eba user: olr tags: trunk, fx
12:38
[fr] pt: faire grand bruit check-in: 28d0121978 user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/webext/panel/lex_editor.css from [0d1be3ff24] to [02dc63f476].

90
91
92
93
94
95
96



97
98
99
100
101
102
103
    border-radius: 3px;
    cursor: pointer;
}
.category:hover {
    background-color: hsl(0, 0%, 90%);
}





#section_vide {
    padding: 50px;
    font-size: 24px;
    text-align: center;
    background-color: hsl(0, 20%, 90%);
    color: hsl(0, 20%, 50%);







>
>
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    border-radius: 3px;
    cursor: pointer;
}
.category:hover {
    background-color: hsl(0, 0%, 90%);
}

.separator {
    border-left: 1px solid hsl(210, 0%, 90%);
}

#section_vide {
    padding: 50px;
    font-size: 24px;
    text-align: center;
    background-color: hsl(0, 20%, 90%);
    color: hsl(0, 20%, 50%);
204
205
206
207
208
209
210










211
212
213
214

215
216
217
218






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













>
>
>
>
>
>
>
>
>
>




>




>
>
>
>
>
>
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
236
237
238
    box-shadow: 0 0 2px hsl(0, 60%, 50%);
}


#lexicon_page {
    
}

#save_button {
    display: none;
    float: right;
    padding: 2px 20px;
    background-color: hsl(150, 50%, 50%);
    color: hsl(150, 0%, 100%);
    border-radius: 3px;
    cursor: pointer;
}

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

.delete_entry {
    cursor: pointer;
    font-weight: bold;
    color: hsl(0, 100%, 50%);
}

Modified gc_lang/fr/webext/panel/lex_editor.html from [66c585ccb9] to [a1593656cc].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

                <div id="editor">

                    <div id="categories">
                        <div class="category" id="select_nom" data-tag="N">Nom, adjectif</div>
                        <div class="category" id="select_verbe" data-tag="V">Verbe</div>
                        <div class="category" id="select_adverbe" data-tag="W">Adverbe</div>

                        <div class="separator"></div>

                        <div class="category" id="select_prenom" data-tag="M1">Prénom</div>
                        <div class="category" id="select_patronyme" data-tag="M2">Patronyme</div>
                        <div class="category" id="select_nom_propre" data-tag="MP">Nom propre</div>

                        <div class="separator"></div>

                        <div class="category" id="select_autre" data-tag="X">Autre</div>
                    </div>


                    <div id="sections">

                        <div id="section_vide">
                            Sélectionnez une catégorie.







<
<
<
|


<
<
<
|







23
24
25
26
27
28
29



30
31
32



33
34
35
36
37
38
39
40

                <div id="editor">

                    <div id="categories">
                        <div class="category" id="select_nom" data-tag="N">Nom, adjectif</div>
                        <div class="category" id="select_verbe" data-tag="V">Verbe</div>
                        <div class="category" id="select_adverbe" data-tag="W">Adverbe</div>



                        <div class="category separator" id="select_prenom" data-tag="M1">Prénom</div>
                        <div class="category" id="select_patronyme" data-tag="M2">Patronyme</div>
                        <div class="category" id="select_nom_propre" data-tag="MP">Nom propre</div>



                        <div class="category separator" id="select_autre" data-tag="X">Autre</div>
                    </div>


                    <div id="sections">

                        <div id="section_vide">
                            Sélectionnez une catégorie.
269
270
271
272
273
274
275



276



277
278
279
280
281
282
283
                    <div id="buttonline">
                        <div id="add_to_lexicon">Ajouter au dictionnaire</div>
                    </div>
                </div>
            </div>

            <div id="lexicon_page">



                <h2>Votre lexique</h2>



                <table id="table">
                    
                </table>
            </div>
        </div>









>
>
>

>
>
>







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
                    <div id="buttonline">
                        <div id="add_to_lexicon">Ajouter au dictionnaire</div>
                    </div>
                </div>
            </div>

            <div id="lexicon_page">
                <div id="save_button">
                    Enregistrer
                </div>
                <h2>Votre lexique</h2>
                
                <div class="clearer"></div>

                <table id="table">
                    
                </table>
            </div>
        </div>


Modified gc_lang/fr/webext/panel/lex_editor.js from [c815154404] to [f56336af44].

27
28
29
30
31
32
33




34
35
36
37
38
39
40
function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}


document.getElementById("lexicon_button").addEventListener("click", () => { oPage.showPage("lexicon"); }, false);
document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("lemma"); }, false);




document.getElementById("editor").addEventListener("click", (xEvent) => { oPage.onSelectionClick(xEvent); }, false);
document.getElementById("lemma").addEventListener("keyup", () => { oPage.onWrite(); }, false);
document.getElementById("lemma2").addEventListener("keyup", () => { oPage.onWrite2(); }, false);
document.getElementById("verb_pattern").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("flexion").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);







>
>
>
>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}


document.getElementById("lexicon_button").addEventListener("click", () => { oPage.showPage("lexicon"); }, false);
document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("lemma"); }, false);

document.getElementById("table").addEventListener("click", (xEvent) => { oPage.onTableClick(xEvent); }, false);
document.getElementById("save_button").addEventListener("click", () => { oLexicon.save(); }, false);

document.getElementById("editor").addEventListener("click", (xEvent) => { oPage.onSelectionClick(xEvent); }, false);
document.getElementById("lemma").addEventListener("keyup", () => { oPage.onWrite(); }, false);
document.getElementById("lemma2").addEventListener("keyup", () => { oPage.onWrite2(); }, false);
document.getElementById("verb_pattern").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("flexion").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);
174
175
176
177
178
179
180




















































181
182
183
184
185
186
187

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

    hideActions: function () {
        document.getElementById("actions").style.display = "none";




















































    }
}



const oFlex = {








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







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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
236
237
238
239
240
241
242
243

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

    hideActions: function () {
        document.getElementById("actions").style.display = "none";
    },

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

    hideSaveButton: function () {
        document.getElementById("save_button").style.display = "none";
    },

    createTableHeader: function () {
        let xRowNode = createNode("tr");
        xRowNode.appendChild(createNode("th", { textContent: "·" }));
        xRowNode.appendChild(createNode("th", { textContent: "#" }));
        xRowNode.appendChild(createNode("th", { textContent: "Forme fléchie" }));
        xRowNode.appendChild(createNode("th", { textContent: "Lemme" }));
        xRowNode.appendChild(createNode("th", { textContent: "Étiquettes" }));
        return xRowNode;
    },

    createRowNode: function (n, sFlexion, sLemma, sTags) {
        let xRowNode = createNode("tr", { id: "row_" + n });
        xRowNode.appendChild(createNode("td", { textContent: "×", className: "delete_entry", title: "Effacer cette entrée" }, { id_entry: 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);
        }
    },

    onTableClick: function (xEvent) {
        try {
            let xElem = xEvent.target;
            if (xElem.className) {
                if (xElem.className == "delete_entry") {
                    let iEntry = xElem.dataset.id_entry
                    oLexicon.lFlexion[parseInt(iEntry)] = null;
                    document.getElementById("row_"+iEntry).style.display = "none";
                    this.showSaveButton();
                }
            }
        }
        catch (e) {
            showError(e);
        }
    }
}



const oFlex = {

396
397
398
399
400
401
402
403
404
405
406
407
408

409
410
411
412
413
414
415
            oPage.hideActions();
        }
    },

    addToLexicon: function () {
        try {
            oLexicon.addFlexions(this.lFlexion);
            oLexicon.save();
            document.getElementById("lemma").value = "";
            oPage.showSection("section_vide");
            oPage.hideEditor();
            oPage.hideActions();
            oPage.clear();

            this.clear();
        }
        catch (e) {
            showError(e);
        }
    }
}







<





>







452
453
454
455
456
457
458

459
460
461
462
463
464
465
466
467
468
469
470
471
            oPage.hideActions();
        }
    },

    addToLexicon: function () {
        try {
            oLexicon.addFlexions(this.lFlexion);

            document.getElementById("lemma").value = "";
            oPage.showSection("section_vide");
            oPage.hideEditor();
            oPage.hideActions();
            oPage.clear();
            oPage.showSaveButton();
            this.clear();
        }
        catch (e) {
            showError(e);
        }
    }
}
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481

482
483
484
485
486


487
488
489
490
491
492
493
    _setList: function (dResult) {
        if (dResult.hasOwnProperty("lexicon_list")) {
            this.lFlexion = dResult.lexicon_list;
        }
    },

    display: function () {
        this.clearTable();
        let xTable = document.getElementById("table");
        let n = 0;
        if (this.lFlexion.length > 0) {
            xTable.appendChild(this._createTableHeader());
            for (let [sFlexion, sLemma, sTags] of this.lFlexion) {
                xTable.appendChild(this._createRowNode(n, sFlexion, sLemma, sTags));
                n += 1;
            }
        } else {
            xTable.appendChild(createNode("tr", { textContent: "Aucun élément." }));
        }
    },

    _createTableHeader: function () {
        let xRowNode = createNode("tr");
        xRowNode.appendChild(createNode("th", { textContent: "#" }));
        xRowNode.appendChild(createNode("th", { textContent: "Forme fléchie" }));
        xRowNode.appendChild(createNode("th", { textContent: "Lemme" }));
        xRowNode.appendChild(createNode("th", { textContent: "Étiquettes" }));
        return xRowNode;
    },

    _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 () {







|



|

|







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







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517




518

519
520







521




522
523

524

525
526
527
528
529
530
531
532
533
534
    _setList: function (dResult) {
        if (dResult.hasOwnProperty("lexicon_list")) {
            this.lFlexion = dResult.lexicon_list;
        }
    },

    display: function () {
        oPage.clearTable();
        let xTable = document.getElementById("table");
        let n = 0;
        if (this.lFlexion.length > 0) {
            xTable.appendChild(oPage.createTableHeader());
            for (let [sFlexion, sLemma, sTags] of this.lFlexion) {
                xTable.appendChild(oPage.createRowNode(n, sFlexion, sLemma, sTags));
                n += 1;
            }
        } else {
            xTable.appendChild(createNode("tr", { textContent: "Aucun élément." }));
        }
    },

    save: function () {
        console.log("u");




        oPage.hideSaveButton();

        let lResult = [];
        for (let e of this.lFlexion) {







            if (e !== null) {




                lResult.push(e);
            }

        }

        browser.storage.local.set({ "lexicon_list": lResult });
        this.lFlexion = lResult;
        this.display();
    },

    build: function () {
        return null;
    },

    export: function () {