195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
xRowNode.appendChild(createNode("td", { textContent: sTags }));
return xRowNode;
},
displayTable: function (lFlex) {
this.clearTable();
if (lFlex.length > 0) {
let xTable = document.getElementById("table");
let n = 0;
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;
}
} else {
this.showElement("no_elem_line");
}
this.updateData();
},
clearTable: function () {
|
>
>
>
>
>
>
>
|
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
|
xRowNode.appendChild(createNode("td", { textContent: sTags }));
return xRowNode;
},
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();
},
clearTable: function () {
|
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
},
_getConjRules: function (sVerb) {
if (sVerb.endsWith("ir")) {
// deuxième groupe
return oConj["V2"];
} else if (sVerb.endsWith("er")) {
// premier groupe
if (sVerb.slice(-5) in oConj["V1"]) {
return oConj["V1"][sVerb.slice(-5)];
}
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)];
}
if (sVerb.slice(-3) in oConj["V1"]) {
return oConj["V1"][sVerb.slice(-3)];
}
return oConj["V1"]["er"];
} else {
// troisième groupe
return [ [0, "", ":Y/*", false] ];
|
|
>
>
>
|
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
|
},
_getConjRules: function (sVerb) {
if (sVerb.endsWith("ir")) {
// deuxième groupe
return oConj["V2"];
} else if (sVerb.endsWith("er")) {
// 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 {
// troisième groupe
return [ [0, "", ":Y/*", false] ];
|
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
const oLexicon = {
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);
}
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);
}
this.nAddedEntries += n;
this.nEntries += n;
|
|
<
<
<
<
<
<
<
<
<
<
|
|
|
<
<
<
<
<
<
<
|
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
const oLexicon = {
lFlexion: [],
nEntries: 0,
nDeletedEntries: 0,
nAddedEntries: 0,
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");
}
},
addFlexions: function (lFlex) {
let n = lFlex.length;
for (let aFlex of lFlex) {
this.lFlexion.push(aFlex);
}
this.nAddedEntries += n;
this.nEntries += n;
|
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
this.nEntries = this.lFlexion.length;
this.nAddedEntries = 0;
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.resetModif();
oWidgets.displayTable(this.lFlexion);
oWidgets.updateData();
oWidgets.setDictData(lEntry.length, sDate);
},
_getDate: function () {
let oDate = new Date();
let sMonth = (oDate.getMonth() + 1).toString().padStart(2, "0"); // Month+1: Because JS always sucks somehow.
let sDay = (oDate.getDay()).toString().padStart(2, "0");
let sHours = (oDate.getHours()).toString().padStart(2, "0");
let sMinutes = (oDate.getMinutes()).toString().padStart(2, "0");
return `${oDate.getFullYear()}-${sMonth}-${sDay}, ${sHours}:${sMinutes}`;
}
}
const oBinaryDict = {
oJSON: null,
load: function () {
if (bChrome) {
browser.storage.local.get("oDictionary", this._load);
return;
}
let xPromise = browser.storage.local.get("oDictionary");
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");
}
//oLexicon.set();
},
build: function (lEntry) {
oWidgets.showElement("build_progress");
let xProgressNode = document.getElementById("build_progress");
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 });
},
import: function () {
|
<
<
<
<
<
<
<
<
|
|
|
>
<
<
<
>
>
>
|
>
<
<
<
<
<
<
<
<
<
|
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
|
this.nEntries = this.lFlexion.length;
this.nAddedEntries = 0;
this.nDeletedEntries = 0;
},
save: function () {
oWidgets.hideElement("save_button");
this.lFlexion = this.lFlexion.filter((e) => e !== null);
oBinaryDict.build(this.lFlexion);
this.resetModif();
oWidgets.displayTable(this.lFlexion);
oWidgets.updateData();
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.
let sDay = (oDate.getDay()).toString().padStart(2, "0");
let sHours = (oDate.getHours()).toString().padStart(2, "0");
let sMinutes = (oDate.getMinutes()).toString().padStart(2, "0");
return `${oDate.getFullYear()}-${sMonth}-${sDay}, ${sHours}:${sMinutes}`;
}
}
const oBinaryDict = {
oJSON: null,
oIBDAWG: null,
load: function () {
if (bChrome) {
browser.storage.local.get("oDictionary", this._load);
return;
}
let xPromise = browser.storage.local.get("oDictionary");
xPromise.then(this._load.bind(this), showError);
},
_load: function (oResult) {
if (oResult.hasOwnProperty("oDictionary")) {
oWidgets.hideElement("export_button");
return;
}
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");
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");
},
save: function () {
browser.storage.local.set({ "oDictionary": this.oJSON });
},
import: function () {
|