60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
this.xPanelContent.appendChild(this.xGCPanelContent);
this.xNode = null;
this.oNodeControl = new GrammalecteNodeControl();
// Lexicographer
this.nLxgCount = 0;
this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
this.xPanelContent.appendChild(this.xLxgPanelContent);
}
createMenu () {
this.xMenu = oGrammalecte.createNode("div", {className: "grammalecte_panel_menu"});
this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"});
this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"});
this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"});
|
>
>
>
>
>
>
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
this.xPanelContent.appendChild(this.xGCPanelContent);
this.xNode = null;
this.oNodeControl = new GrammalecteNodeControl();
// Lexicographer
this.nLxgCount = 0;
this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
this.xPanelContent.appendChild(this.xLxgPanelContent);
// Conjugueur
this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML; // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>
this.xPanelContent.appendChild(this.xConjPanelContent);
this.sVerb = "";
this.bListenConj = false;
}
createMenu () {
this.xMenu = oGrammalecte.createNode("div", {className: "grammalecte_panel_menu"});
this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"});
this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"});
this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"});
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
return (this.xNode.tagName == "TEXTAREA" || this.xNode.tagName == "INPUT") ? this.xNode.value.normalize("NFC") : this.xNode.innerText.normalize("NFC");
} else {
return oGrammalecte.getPageText();
}
}
showEditor () {
this.xGCPanelContent.style.display = "block";
this.xLxgPanelContent.style.display = "none";
this.xEditorButton.style.textShadow = "2px 0 0 hsla(210, 40%, 35%, .5), -2px 0 0 hsla(210, 40%, 35%, .5), 0 2px 0 hsla(210, 40%, 35%, .5), 0 -2px 0 hsla(210, 40%, 35%, .5), 1px 1px hsla(210, 40%, 35%, .5), -1px -1px 0 hsla(210, 40%, 35%, .5), 1px -1px 0 hsla(210, 40%, 35%, .5), -1px 1px 0 hsla(210, 40%, 35%, .5)";
this.xLxgButton.style.textShadow = "";
this.xEditorButton.style.backgroundColor = "hsl(210, 60%, 40%)";
this.xLxgButton.style.backgroundColor = "";
}
showLexicographer () {
this.xGCPanelContent.style.display = "none";
this.xLxgPanelContent.style.display = "block";
this.xEditorButton.style.textShadow = "";
this.xLxgButton.style.textShadow = "2px 0 0 hsla(210, 40%, 35%, .5), -2px 0 0 hsla(210, 40%, 35%, .5), 0 2px 0 hsla(210, 40%, 35%, .5), 0 -2px 0 hsla(210, 40%, 35%, .5), 1px 1px hsla(210, 40%, 35%, .5), -1px -1px 0 hsla(210, 40%, 35%, .5), 1px -1px 0 hsla(210, 40%, 35%, .5), -1px 1px 0 hsla(210, 30%, 35%, .5)";
this.xEditorButton.style.backgroundColor = "";
this.xLxgButton.style.backgroundColor = "hsl(210, 60%, 40%)";
}
clear () {
while (this.xParagraphList.firstChild) {
this.xParagraphList.removeChild(this.xParagraphList.firstChild);
}
this.aIgnoredErrors.clear();
|
|
|
>
>
|
>
>
>
>
>
|
>
|
>
>
|
>
>
|
|
|
|
|
|
|
>
>
>
>
|
|
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
return (this.xNode.tagName == "TEXTAREA" || this.xNode.tagName == "INPUT") ? this.xNode.value.normalize("NFC") : this.xNode.innerText.normalize("NFC");
} else {
return oGrammalecte.getPageText();
}
}
showEditor () {
this.switchContentOn(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
}
showLexicographer () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOn(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
}
showConjugueur () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOn(this.xConjPanelContent, this.xConjButton);
this.listenConj();
if (!this.sVerb) {
this.conjugateVerb("être");
}
}
switchContentOn (xContent, xNodeButton) {
xContent.style.display = "block";
xNodeButton.style.backgroundColor = "hsl(210, 60%, 40%)";
xNodeButton.style.textShadow = "2px 0 0 hsla(210, 40%, 35%, .5), -2px 0 0 hsla(210, 40%, 35%, .5), 0 2px 0 hsla(210, 40%, 35%, .5), 0 -2px 0 hsla(210, 40%, 35%, .5), 1px 1px hsla(210, 40%, 35%, .5), -1px -1px 0 hsla(210, 40%, 35%, .5), 1px -1px 0 hsla(210, 40%, 35%, .5), -1px 1px 0 hsla(210, 30%, 35%, .5)";
}
switchContentOff (xContent, xNodeButton) {
xContent.style.display = "none";
xNodeButton.style.backgroundColor = "";
xNodeButton.style.textShadow = "";
}
clear () {
while (this.xParagraphList.firstChild) {
this.xParagraphList.removeChild(this.xParagraphList.firstChild);
}
this.aIgnoredErrors.clear();
|
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
setHidden (sClass, bHidden) {
let xPanelContent = this.xParent.getElementById('grammalecte_panel_content');
for (let xNode of xPanelContent.getElementsByClassName(sClass)) {
xNode.hidden = bHidden;
}
}
}
class GrammalecteTooltip {
constructor (xParent, xGCPanelContent) {
this.xParent = xParent;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
487
488
489
490
491
492
493
494
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
setHidden (sClass, bHidden) {
let xPanelContent = this.xParent.getElementById('grammalecte_panel_content');
for (let xNode of xPanelContent.getElementsByClassName(sClass)) {
xNode.hidden = bHidden;
}
}
// Conjugueur
listenConj () {
if (!this.bListenConj) {
// button
this.xParent.getElementById('grammalecte_conj_button').addEventListener("click", (e) => { this.conjugateVerb(); });
// text field
this.xParent.getElementById('grammalecte_conj_verb').addEventListener("change", (e) => { this.conjugateVerb(); });
// options
this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.updateConj(); });
this.bListenConj = true;
}
}
conjugateVerb (sVerb="") {
try {
if (!sVerb) {
sVerb = this.xParent.getElementById('grammalecte_conj_verb').value;
}
this.xParent.getElementById('grammalecte_conj_oneg').checked = false;
this.xParent.getElementById('grammalecte_conj_opro').checked = false;
this.xParent.getElementById('grammalecte_conj_oint').checked = false;
this.xParent.getElementById('grammalecte_conj_otco').checked = false;
this.xParent.getElementById('grammalecte_conj_ofem').checked = false;
// request analyzing
sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/ +/g, " ");
if (sVerb) {
if (sVerb.startsWith("ne pas ")) {
this.xParent.getElementById('grammalecte_conj_oneg').checked = true;
sVerb = sVerb.slice(7);
}
if (sVerb.startsWith("se ")) {
this.xParent.getElementById('grammalecte_conj_opro').checked = true;
sVerb = sVerb.slice(3);
} else if (sVerb.startsWith("s'")) {
this.xParent.getElementById('grammalecte_conj_opro').checked = true;
sVerb = sVerb.slice(2);
}
if (sVerb.endsWith("?")) {
this.xParent.getElementById('grammalecte_conj_oint').checked = true;
sVerb = sVerb.slice(0,-1).trim();
}
if (sVerb) {
this.sVerb = sVerb;
this.updateConj();
} else {
this.xParent.getElementById('grammalecte_conj_verb').value = "";
}
}
}
catch (e) {
console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
}
updateConj () {
let bPro = this.xParent.getElementById('grammalecte_conj_opro').checked;
let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').checked;
let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').checked;
let bInt = this.xParent.getElementById('grammalecte_conj_oint').checked;
let bFem = this.xParent.getElementById('grammalecte_conj_ofem').checked;
if (this.sVerb) {
console.log("updateConj send");
xGrammalectePort.postMessage({
sCommand: "getVerb",
dParam: {sVerb: this.sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem},
dInfo: {}
});
}
}
conjugateWith (oVerb, oConjTable) {
// function called when results come from the Worker
if (oVerb) {
this.xParent.getElementById('grammalecte_conj_verb').style = "color: #999999;";
this.xParent.getElementById('grammalecte_conj_verb').value = "";
this.xParent.getElementById('grammalecte_conj_verb_title').textContent = oVerb.sVerb;
this.xParent.getElementById('grammalecte_conj_verb_info').textContent = oVerb.sInfo;
this.xParent.getElementById('grammalecte_conj_opro').textContent = oVerb.sProLabel;
if (oVerb.bUncomplete) {
this.xParent.getElementById('grammalecte_conj_opro').checked = false;
this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
this.xParent.getElementById('grammalecte_conj_opro_lbl').style = "color: #CCC;";
this.xParent.getElementById('grammalecte_conj_otco').checked = false;
this.xParent.getElementById('grammalecte_conj_otco').disabled = true;
this.xParent.getElementById('grammalecte_conj_otco_lbl').style = "color: #CCC;";
this.xParent.getElementById('grammalecte_conj_note').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.";
} else {
this.xParent.getElementById('grammalecte_conj_otco').disabled = false;
this.xParent.getElementById('grammalecte_conj_otco_lbl').style = "color: #000;";
if (oVerb.nPronominable == 0) {
this.xParent.getElementById('grammalecte_conj_opro').checked = false;
this.xParent.getElementById('grammalecte_conj_opro').disabled = false;
this.xParent.getElementById('grammalecte_conj_opro_lbl').style = "color: #000;";
} else if (oVerb.nPronominable == 1) {
this.xParent.getElementById('grammalecte_conj_opro').checked = true;
this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
this.xParent.getElementById('grammalecte_conj_opro_lbl').style = "color: #CCC;";
} else { // -1 or 1 or error
this.xParent.getElementById('grammalecte_conj_opro').checked = false;
this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
this.xParent.getElementById('grammalecte_conj_opro_lbl').style = "color: #CCC;";
}
this.xParent.getElementById('grammalecte_conj_note').textContent = "❦";
}
this._displayConj(oConjTable);
} else {
this.xParent.getElementById('grammalecte_conj_verb').style = "color: #BB4411;";
}
}
_displayConj (oConjTable) {
if (oConjTable === null) {
return;
}
try {
this.xParent.getElementById('grammalecte_conj_verb').Text = "";
// infinitif
this.xParent.getElementById('grammalecte_conj_infi').textContent = oConjTable["infi"] || " "; // something or nbsp
// participe présent
this.xParent.getElementById('grammalecte_conj_ppre').textContent = oConjTable["ppre"] || " ";
// participes passés
this.xParent.getElementById('grammalecte_conj_ppas1').textContent = oConjTable["ppas1"] || " ";
this.xParent.getElementById('grammalecte_conj_ppas2').textContent = oConjTable["ppas2"] || " ";
this.xParent.getElementById('grammalecte_conj_ppas3').textContent = oConjTable["ppas3"] || " ";
this.xParent.getElementById('grammalecte_conj_ppas4').textContent = oConjTable["ppas4"] || " ";
// impératif
this.xParent.getElementById('grammalecte_conj_t_impe').textContent = oConjTable["t_impe"] || " ";
this.xParent.getElementById('grammalecte_conj_impe1').textContent = oConjTable["impe1"] || " ";
this.xParent.getElementById('grammalecte_conj_impe2').textContent = oConjTable["impe2"] || " ";
this.xParent.getElementById('grammalecte_conj_impe3').textContent = oConjTable["impe3"] || " ";
// présent
this.xParent.getElementById('grammalecte_conj_t_ipre').textContent = oConjTable["t_ipre"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre1').textContent = oConjTable["ipre1"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre2').textContent = oConjTable["ipre2"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre3').textContent = oConjTable["ipre3"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre4').textContent = oConjTable["ipre4"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre5').textContent = oConjTable["ipre5"] || " ";
this.xParent.getElementById('grammalecte_conj_ipre6').textContent = oConjTable["ipre6"] || " ";
// imparfait
this.xParent.getElementById('grammalecte_conj_t_iimp').textContent = oConjTable["t_iimp"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp1').textContent = oConjTable["iimp1"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp2').textContent = oConjTable["iimp2"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp3').textContent = oConjTable["iimp3"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp4').textContent = oConjTable["iimp4"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp5').textContent = oConjTable["iimp5"] || " ";
this.xParent.getElementById('grammalecte_conj_iimp6').textContent = oConjTable["iimp6"] || " ";
// passé simple
this.xParent.getElementById('grammalecte_conj_t_ipsi').textContent = oConjTable["t_ipsi"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi1').textContent = oConjTable["ipsi1"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi2').textContent = oConjTable["ipsi2"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi3').textContent = oConjTable["ipsi3"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi4').textContent = oConjTable["ipsi4"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi5').textContent = oConjTable["ipsi5"] || " ";
this.xParent.getElementById('grammalecte_conj_ipsi6').textContent = oConjTable["ipsi6"] || " ";
// futur
this.xParent.getElementById('grammalecte_conj_t_ifut').textContent = oConjTable["t_ifut"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut1').textContent = oConjTable["ifut1"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut2').textContent = oConjTable["ifut2"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut3').textContent = oConjTable["ifut3"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut4').textContent = oConjTable["ifut4"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut5').textContent = oConjTable["ifut5"] || " ";
this.xParent.getElementById('grammalecte_conj_ifut6').textContent = oConjTable["ifut6"] || " ";
// Conditionnel
this.xParent.getElementById('grammalecte_conj_t_conda').textContent = oConjTable["t_conda"] || " ";
this.xParent.getElementById('grammalecte_conj_conda1').textContent = oConjTable["conda1"] || " ";
this.xParent.getElementById('grammalecte_conj_conda2').textContent = oConjTable["conda2"] || " ";
this.xParent.getElementById('grammalecte_conj_conda3').textContent = oConjTable["conda3"] || " ";
this.xParent.getElementById('grammalecte_conj_conda4').textContent = oConjTable["conda4"] || " ";
this.xParent.getElementById('grammalecte_conj_conda5').textContent = oConjTable["conda5"] || " ";
this.xParent.getElementById('grammalecte_conj_conda6').textContent = oConjTable["conda6"] || " ";
this.xParent.getElementById('grammalecte_conj_t_condb').textContent = oConjTable["t_condb"] || " ";
this.xParent.getElementById('grammalecte_conj_condb1').textContent = oConjTable["condb1"] || " ";
this.xParent.getElementById('grammalecte_conj_condb2').textContent = oConjTable["condb2"] || " ";
this.xParent.getElementById('grammalecte_conj_condb3').textContent = oConjTable["condb3"] || " ";
this.xParent.getElementById('grammalecte_conj_condb4').textContent = oConjTable["condb4"] || " ";
this.xParent.getElementById('grammalecte_conj_condb5').textContent = oConjTable["condb5"] || " ";
this.xParent.getElementById('grammalecte_conj_condb6').textContent = oConjTable["condb6"] || " ";
// subjonctif présent
this.xParent.getElementById('grammalecte_conj_t_spre').textContent = oConjTable["t_spre"] || " ";
this.xParent.getElementById('grammalecte_conj_spre1').textContent = oConjTable["spre1"] || " ";
this.xParent.getElementById('grammalecte_conj_spre2').textContent = oConjTable["spre2"] || " ";
this.xParent.getElementById('grammalecte_conj_spre3').textContent = oConjTable["spre3"] || " ";
this.xParent.getElementById('grammalecte_conj_spre4').textContent = oConjTable["spre4"] || " ";
this.xParent.getElementById('grammalecte_conj_spre5').textContent = oConjTable["spre5"] || " ";
this.xParent.getElementById('grammalecte_conj_spre6').textContent = oConjTable["spre6"] || " ";
// subjonctif imparfait
this.xParent.getElementById('grammalecte_conj_t_simp').textContent = oConjTable["t_simp"] || " ";
this.xParent.getElementById('grammalecte_conj_simp1').textContent = oConjTable["simp1"] || " ";
this.xParent.getElementById('grammalecte_conj_simp2').textContent = oConjTable["simp2"] || " ";
this.xParent.getElementById('grammalecte_conj_simp3').textContent = oConjTable["simp3"] || " ";
this.xParent.getElementById('grammalecte_conj_simp4').textContent = oConjTable["simp4"] || " ";
this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " ";
this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " ";
}
catch (e) {
console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
}
}
class GrammalecteTooltip {
constructor (xParent, xGCPanelContent) {
this.xParent = xParent;
|