Grammalecte  Check-in [98cbcc00d8]

Overview
Comment:[fx] send result in event also if Grammalecte is launched by the context menu
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 98cbcc00d87242917ebd26a39b0967a6f7ab4f24afe543011ccc2891c88b8054
User & Date: olr on 2020-03-09 19:17:11
Other Links: manifest | tags
Context
2020-03-10
07:01
[fx] send result via event only with the parameter grammalecte_result_via_event check-in: 981544fa30 user: olr tags: trunk, fx
2020-03-09
19:17
[fx] send result in event also if Grammalecte is launched by the context menu check-in: 98cbcc00d8 user: olr tags: trunk, fx
18:56
[fx] remove console.log() check-in: 442f6eaf7e user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [646f2e9c29] to [e1f7754754].

87
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116







-
+














-
+







        if (oOptions.hasOwnProperty("ui_options")) {
            this.oOptions = oOptions.ui_options;
            // textarea
            for (let xNode of document.getElementsByTagName("textarea")) {
                if (xNode.dataset.grammalecte_callbutton && document.getElementById(xNode.dataset.grammalecte_callbutton)) {
                    let xButton = document.getElementById(xNode.dataset.grammalecte_callbutton)
                    xButton.onclick = () => {
                        oGrammalecte.startGCPanel(xNode, true, true);
                        oGrammalecte.startGCPanel(xNode);
                    };
                    this.lButton.push(xButton);
                    this.nButton += 1;
                }
                else if (this.oOptions.textarea  &&  xNode.style.display !== "none" && xNode.style.visibility !== "hidden" && xNode.getAttribute("spellcheck") !== "false") {
                    this.lButton.push(new GrammalecteButton(this.nButton, xNode));
                    this.nButton += 1;
                }
            }
            // editable nodes
            for (let xNode of document.querySelectorAll("[contenteditable]")) {
                if (xNode.dataset.grammalecte_callbutton && document.getElementById(xNode.dataset.grammalecte_callbutton)) {
                    let xButton = document.getElementById(xNode.dataset.grammalecte_callbutton)
                    xButton.onclick = () => {
                        oGrammalecte.startGCPanel(xNode, true, true);
                        oGrammalecte.startGCPanel(xNode);
                    };
                    this.lButton.push(xButton);
                    this.nButton += 1;
                }
                else if (this.oOptions.editablenode  &&  xNode.style.display !== "none" && xNode.style.visibility !== "hidden") {
                    this.lButton.push(new GrammalecteButton(this.nButton, xNode));
                    this.nButton += 1;
172
173
174
175
176
177
178
179

180
181
182
183
184

185
186
187
188
189
190
191
172
173
174
175
176
177
178

179
180
181
182
183

184
185
186
187
188
189
190
191







-
+




-
+







    createMessageBox: function () {
        if (this.oMessageBox === null) {
            this.oMessageBox = new GrammalecteMessageBox("grammalecte_message_box", "Grammalecte");
            this.oMessageBox.insertIntoPage();
        }
    },

    startGCPanel: function (what, bCheckText=true, bResultInEvent=false) {
    startGCPanel: function (what, bCheckText=true) {
        this.createGCPanel();
        this.oGCPanel.clear();
        this.oGCPanel.show();
        this.oGCPanel.showEditor();
        this.oGCPanel.start(what, bResultInEvent);
        this.oGCPanel.start(what);
        this.oGCPanel.startWaitIcon();
        if (what && bCheckText) {
            let sText = this.oGCPanel.oTextControl.getText();
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
                dInfo: (what.nodeType && what.nodeType === 1) ? {sTextAreaId: what.id} : {}

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [f4ff64b873] to [952baf8eed].

135
136
137
138
139
140
141
142

143
144
145
146
147
148
149
150
151
152
135
136
137
138
139
140
141

142
143
144

145
146
147
148
149
150
151







-
+


-







        this.xMenu.appendChild(this.xTFButton)
        this.xMenu.appendChild(this.xEditorButton)
        this.xMenu.appendChild(this.xLxgButton)
        this.xMenu.appendChild(this.xConjButton)
        this.xPanelBar.appendChild(this.xMenu);
    }

    start (what, bResultInEvent=false) {
    start (what) {
        this.oTooltip.hide();
        this.bWorking = false;
        this.oTextControl.bResultInEvent = bResultInEvent;
        this.clear();
        this.hideMessage();
        this.resetTimer();
        if (typeof(what) === "string") {
            // text
            this.xNode = null;
            this.oTextControl.setText(what);
962
963
964
965
966
967
968

969
970
971
972
973
974
975
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975







+







        this.clear();
        this.xNode = xNode;
        this.bTextArea = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT");
        if (!this.bTextArea) {
            oGrammalecte.oGCPanel.addMessageToGCPanel("Attention : La zone de texte analysée est un champ textuel enrichi susceptible de contenir des éléments non textuels qui seront effacés lors de la correction.");
        }
        this.xNode.disabled = true;
        this.bResultInEvent = Boolean(xNode.dataset.grammalecte_callbutton);
        this.loadText((this.bTextArea) ? this.xNode.value : this.xNode.innerText);
    }

    setText (sText) {
        this.clear();
        oGrammalecte.oGCPanel.addMessageToGCPanel("Note : Aucun champ textuel défini. Les changements ne seront pas répercutés sur la zone d’où le texte a été extrait.");
        this.loadText(sText);