Grammalecte  Diff

Differences From Artifact [349ae0830b]:

To Artifact [96169a3c96]:


74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88







-
+








    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"});
        this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"});
        this.xLEButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur lexical"});
        this.xLEButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur lexical"});
        this.xTFButton.onclick = () => {
            if (this.xNode  && (this.xNode.tagName == "TEXTAREA" || this.xNode.tagName == "INPUT" || this.xNode.isContentEditable)) {
                oGrammalecte.createTFPanel();
                oGrammalecte.oTFPanel.start(this);
                oGrammalecte.oTFPanel.show();
            } else {
                oGrammalecte.showMessage("Aucune zone de texte éditable sur laquelle appliquer le formatage de texte.")
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
317
318
319
320
321
322
323

324
325
326
327
328
329
330







-








    blockParagraph (xParagraph) {
        xParagraph.contentEditable = "false";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "!!";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = "hsl(0, 50%, 50%)";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.boxShadow = "0 0 0 3px hsla(0, 0%, 50%, .2)";
        this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.animation = "grammalecte-pulse 1s linear infinite";

    }

    freeParagraph (xParagraph) {
        xParagraph.contentEditable = "true";
        let nStart = parseInt(xParagraph.dataset.caret_position_start);
        let nEnd = parseInt(xParagraph.dataset.caret_position_end);
        oGrammalecte.setCaretPosition(xParagraph, nStart, nEnd);
389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
404
405

406
407
408
409
410
411
412
388
389
390
391
392
393
394

395
396
397
398
399
400
401
402


403
404
405
406
407
408
409
410







-
+







-
-
+







        document.execCommand("copy");
    }

    copyTextToClipboard () {
        this.startWaitIcon();
        try {
            let xClipboardButton = this.xParent.getElementById("grammalecte_clipboard_button");
            xClipboardButton.textContent = "->>";
            xClipboardButton.textContent = "⇒ presse-papiers";
            let sText = "";
            // Quand c'est dans un shadow "this.xParent.getElementsByClassName" n'existe pas.
            let xElem = this.xParent.getElementById("grammalecte_gc_panel");
            for (let xNode of xElem.getElementsByClassName("grammalecte_paragraph")) {
                sText += xNode.textContent + "\n";
            }
            this._copyToClipboard(sText);
            xClipboardButton.textContent = "⇒ presse-papiers";
            window.setTimeout(function() { xClipboardButton.textContent = "📋"; } , 2000);
            window.setTimeout(() => { xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            showError(e);
        }
        this.stopWaitIcon();
    }

516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
514
515
516
517
518
519
520

521
522
523
524
525
526
527







-







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







-











-
+



-
+



-
+


-
+



-
+



-
+



-
+



-
+





-
+







    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').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;
            this.xParent.getElementById('grammalecte_conj_opro_lbl').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_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_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;";
                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;";
                    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;";
                    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_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;";
            this.xParent.getElementById('grammalecte_conj_verb').style.color = "#BB4411";
        }
    }

    _displayConj (oConjTable) {
        if (oConjTable === null) {
            return;
        }