Grammalecte  Diff

Differences From Artifact [89f16a45e4]:

To Artifact [4b52ef9dfc]:


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
63
64
65
66
67
68
69

70
71
72
73
74

75
76
77
78
79
80
81







-





-







        this.nEntry = 0
        this._createHeader();
        this.listen();
    }

    _createHeader () {
        let xListheadNode = createNode("listhead");
        xListheadNode.appendChild(createNode("listheader", { label: "·", width: "12px" }));
        for (let sColumn of this.lColumn) {
            xListheadNode.appendChild(createNode("listheader", { label: sColumn }));
        }
        this.xTable.appendChild(xListheadNode);
        let xListcolsNode = createNode("listcols");
        xListcolsNode.appendChild(createNode("listcol", { flex: 1 }));
        for (let cColumn of this.lColumnWidth) {
            xListcolsNode.appendChild(createNode("listcol", { flex: cColumn }));
        }
        this.xTable.appendChild(xListcolsNode);
    }

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







-
+




-
+
-
-














+

-
+
+







        }
        this.nEntry += lFlex.length;
        this.showEntryNumber();
    }

    showEntryNumber () {
        if (this.xNumEntry) {
            this.xNumEntry.textContent = this.nEntry;
            this.xNumEntry.value = this.nEntry;
        }
    }

    _addRow (lData) {
        let xRowNode = createNode("listitem", { id: this.sNodeId + "_row_" + this.iEntryIndex });
        let xRowNode = createNode("listitem", { id: this.sNodeId + "_item_" + this.iEntryIndex, value: this.iEntryIndex });
        xRowNode.appendChild(createNode("listcell", { label: "×", className: "delete_entry", title: "Effacer cette entrée", value: this.iEntryIndex }));
        //xRowNode.appendChild(createNode("listcell", { label: this.iEntryIndex }));
        for (let data of lData) {
            xRowNode.appendChild(createNode("listcell", { label: data }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    listen () {
        this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false);
    }

    onTableClick (xEvent) {
        try {
            let xElem = xEvent.target;
            console.log(xElem);
            if (xElem.className) {
                if (xElem.className == "delete_entry") {
                if (xElem.className.startsWith(this.sNodeId+"_item_")) {
                    console.log("!");
                    this.deleteRow(xElem.value);
                }
            }
        }
        catch (e) {
            showError(e);
        }
447
448
449
450
451
452
453


454
455
456
457
458
459
460
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460







+
+







            let lEntry = [];
            for (let s of this.oIBDAWG.select()) {
                lEntry.push(s.split("\t"));
            }        
            oLexiconTable.fill(lEntry);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            enableElement("export_button");
        } else {
            disableElement("export_button");
        }
    },

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },
471
472
473
474
475
476
477

478
479





480
481
482
483
484
485
486
471
472
473
474
475
476
477
478


479
480
481
482
483
484
485
486
487
488
489
490







+
-
-
+
+
+
+
+







        if (lEntry.length > 0) {
            let oDAWG = new DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel", xProgressNode);
            let oJSON = oDAWG.createBinaryJSON(1);
            prefs.setCharPref("oPersonalDictionary", JSON.stringify(oJSON));
            this.oIBDAWG = new IBDAWG(oJSON);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            //browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sType: "personal", oDict: oJSON}, dInfo: {} });
            enableElement("export_button");
        }
        enableElement("export_button");
        } else {
            prefs.setCharPref("oPersonalDictionary", "");
            this.setDictData(0, "[néant]");
            disableElement("export_button");
        }
    },

    import: function () {
        console.log("import");
    },

    export: function () {
512
513
514
515
516
517
518
519
520


521
522
523
524
516
517
518
519
520
521
522


523
524
525
526
527
528







-
-
+
+




             }
        });
    }
}



const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10],"progress_lexicon", "num_entries");
const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], [10, 10], "progress_new_words");
const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10], "progress_lexicon", "num_entries");
const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], [1, 1], "progress_new_words");

oBinaryDict.load();
oBinaryDict.listen();
oGenerator.listen();