Index: gc_lang/fr/webext/panel/lex_editor.css
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.css
+++ gc_lang/fr/webext/panel/lex_editor.css
@@ -235,15 +235,23 @@
display: block;
margin-left: 5px;
background-color: hsl(210, 50%, 50%);
color: hsl(210, 0%, 100%);
}
+#import_button {
+ display: none;
+}
#build_progress {
display: none;
width: 100%;
}
+
+#display_progress {
+ display: none;
+ width: 100%;
+}
th {
padding: 5px 10px;
border-left: 1px solid hsl(210, 10%, 90%);
text-align: left;
Index: gc_lang/fr/webext/panel/lex_editor.html
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.html
+++ gc_lang/fr/webext/panel/lex_editor.html
@@ -290,10 +290,11 @@
Nombre d’entrées : 0.
Aucun élément.
+
Index: gc_lang/fr/webext/panel/lex_editor.js
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.js
+++ gc_lang/fr/webext/panel/lex_editor.js
@@ -197,18 +197,25 @@
},
displayTable: function (lFlex) {
this.clearTable();
if (lFlex.length > 0) {
+ this.showElement("display_progress");
+ let xDisplayProgress = document.getElementById("display_progress");
let xTable = document.getElementById("table");
let n = 0;
+ xDisplayProgress.max = lFlex.length;
+ xDisplayProgress.value = 1;
this.hideElement("no_elem_line");
xTable.appendChild(this.createTableHeader());
for (let [sFlexion, sLemma, sTags] of lFlex) {
xTable.appendChild(this.createRowNode(n, sFlexion, sLemma, sTags));
n += 1;
+ xDisplayProgress.value += 1;
}
+ xDisplayProgress.value = xDisplayProgress.max;
+ this.hideElement("display_progress");
} else {
this.showElement("no_elem_line");
}
this.updateData();
},
@@ -442,20 +449,23 @@
_getConjRules: function (sVerb) {
if (sVerb.endsWith("ir")) {
// deuxième groupe
return oConj["V2"];
} else if (sVerb.endsWith("er")) {
- // premier groupe
+ // premier groupe, conjugaison en fonction de la terminaison du lemme
+ // 5 lettres
if (sVerb.slice(-5) in oConj["V1"]) {
return oConj["V1"][sVerb.slice(-5)];
}
+ // 4 lettres
if (sVerb.slice(-4) in oConj["V1"]) {
if (sVerb.endsWith("eler") || sVerb.endsWith("eter")) {
return oConj["V1"][sVerb.slice(-4)]["1"];
}
return oConj["V1"][sVerb.slice(-4)];
}
+ // 3 lettres
if (sVerb.slice(-3) in oConj["V1"]) {
return oConj["V1"][sVerb.slice(-3)];
}
return oConj["V1"]["er"];
} else {
@@ -510,38 +520,21 @@
lFlexion: [],
nEntries: 0,
nDeletedEntries: 0,
nAddedEntries: 0,
- load: function () {
- if (bChrome) {
- browser.storage.local.get("oLexicon", this._load);
- return;
- }
- let xPromise = browser.storage.local.get("oLexicon");
- xPromise.then(this._load.bind(this), showError);
- },
-
- _load: function (oResult) {
- if (oResult.hasOwnProperty("oLexicon")) {
- this.lFlexion = oResult.oLexicon.lEntry;
- oWidgets.setDictData(this.lFlexion.length, oResult.oLexicon.sDate);
- oWidgets.displayTable(this.lFlexion);
- }
+ set: function (lFlexion) {
+ this.lFlexion = lFlexion;
+ this.resetModif();
+ oWidgets.displayTable(this.lFlexion);
if (this.lFlexion.length > 0) {
oWidgets.showElement("export_button");
} else {
oWidgets.hideElement("export_button");
}
},
- set: function (lFlexion) {
- this.lFlexion = lFlexion; // clear the array
- this.resetModif();
- oWidgets.displayTable(this.lFlexion);
- },
-
addFlexions: function (lFlex) {
let n = lFlex.length;
for (let aFlex of lFlex) {
this.lFlexion.push(aFlex);
}
@@ -562,24 +555,16 @@
this.nDeletedEntries = 0;
},
save: function () {
oWidgets.hideElement("save_button");
- let lEntry = [];
- for (let e of this.lFlexion) {
- if (e !== null) {
- lEntry.push(e);
- }
- }
- let sDate = this._getDate();
- browser.storage.local.set({ "oLexicon": {"lEntry": lEntry, "sDate": sDate} });
- this.lFlexion = lEntry;
- oBinaryDict.build(lEntry);
+ this.lFlexion = this.lFlexion.filter((e) => e !== null);
+ oBinaryDict.build(this.lFlexion);
this.resetModif();
oWidgets.displayTable(this.lFlexion);
oWidgets.updateData();
- oWidgets.setDictData(lEntry.length, sDate);
+ oWidgets.setDictData(this.lFlexion.length, this._getDate());
},
_getDate: function () {
let oDate = new Date();
let sMonth = (oDate.getMonth() + 1).toString().padStart(2, "0"); // Month+1: Because JS always sucks somehow.
@@ -592,10 +577,11 @@
const oBinaryDict = {
oJSON: null,
+ oIBDAWG: null,
load: function () {
if (bChrome) {
browser.storage.local.get("oDictionary", this._load);
return;
@@ -604,16 +590,17 @@
xPromise.then(this._load.bind(this), showError);
},
_load: function (oResult) {
if (oResult.hasOwnProperty("oDictionary")) {
- this.oJSON = oResult.oDictionary;
- oWidgets.showElement("export_button");
- } else {
oWidgets.hideElement("export_button");
+ return;
}
- //oLexicon.set();
+ this.oJSON = oResult.oDictionary;
+ this.oIBDAWG = new IBDAWG(this.oJSON);
+ oLexicon.set([oIBDAWG.select()]);
+ oWidgets.showElement("export_button");
},
build: function (lEntry) {
oWidgets.showElement("build_progress");
let xProgressNode = document.getElementById("build_progress");
@@ -620,19 +607,10 @@
let oDAWG = new DAWG(lEntry, "Français - dictionnaire personnel", "S", xProgressNode);
this.oJSON = oDAWG.createBinary(1);
this.save();
oWidgets.hideElement("build_progress");
oWidgets.showElement("export_button");
- // debug
- for (let e of oDAWG.select()) {
- console.log(e);
- }
- console.log("=======");
- let oIBDAWG = new IBDAWG(this.oJSON);
- for (let e of oIBDAWG.select()) {
- console.log(e);
- }
},
save: function () {
browser.storage.local.set({ "oDictionary": this.oJSON });
},