Grammalecte  Check-in [8ef28ff1b3]

Overview
Comment:[fx] right-clicked node in main object
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext3
Files: files | file ages | folders
SHA3-256: 8ef28ff1b3582f1b777949153d26a2424f33f44f9dcdc0cd9dcbc8a4dd4cb08d
User & Date: olr on 2017-10-13 12:07:48
Other Links: branch diff | manifest | tags
Context
2017-10-13
13:14
[fx] WebExt: check if right-clicked element have been registered (they aren’t in iframe!) check-in: b7c9949be0 user: olr tags: fx, webext3
12:07
[fx] right-clicked node in main object check-in: 8ef28ff1b3 user: olr tags: fx, webext3
2017-10-12
11:02
[fx] WebExt: invisible panel marker must be “visible” to be retrieved by innerText check-in: 8eaecc0c96 user: olr tags: fx, webext3
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [989fb6def3] to [07c285cff2].

42
43
44
45
46
47
48








49
50
51
52
53
54
55

    nMenu: 0,
    lMenu: [],

    oTFPanel: null,
    oLxgPanel: null,
    oGCPanel: null,









    createMenus: function () {
        let lNode = document.getElementsByTagName("textarea");
        for (let xNode of lNode) {
            if (xNode.style.display !== "none" && xNode.style.visibility !== "hidden") {
                this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
                this.nMenu += 1;







>
>
>
>
>
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

    nMenu: 0,
    lMenu: [],

    oTFPanel: null,
    oLxgPanel: null,
    oGCPanel: null,

    xRightClickedNode: null,

    listenRightClick: function () {
        document.addEventListener('contextmenu', function (xEvent) {
            this.xRightClickedNode = xEvent.target;
        }.bind(this), true);
    },

    createMenus: function () {
        let lNode = document.getElementsByTagName("textarea");
        for (let xNode of lNode) {
            if (xNode.style.display !== "none" && xNode.style.visibility !== "hidden") {
                this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
                this.nMenu += 1;
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
}


/*
    Node where a right click is done
    Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
*/
let xRightClickedNode = null;
document.addEventListener('contextmenu', function (xEvent) {
    xRightClickedNode = xEvent.target;
}, true);


/*
    Connexion to the background
*/
let xGrammalectePort = browser.runtime.connect({name: "content-script port"});








<
<
<
<







147
148
149
150
151
152
153




154
155
156
157
158
159
160
}


/*
    Node where a right click is done
    Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
*/






/*
    Connexion to the background
*/
let xGrammalectePort = browser.runtime.connect({name: "content-script port"});

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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
            break;
        /*
            Commands received from the context menu
            (Context menu are initialized in background)
        */
        // Grammar checker commands
        case "rightClickGCEditableNode":
            oGrammalecte.startGCPanel(xRightClickedNode);
            sText = (xRightClickedNode.tagName == "TEXTAREA") ? xRightClickedNode.value : xRightClickedNode.textContent;
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
                dInfo: {sTextAreaId: xRightClickedNode.id}
            });
            break;
        case "rightClickGCPage":
            oGrammalecte.startGCPanel();
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: oGrammalecte.getPageText(), sCountry: "FR", bDebug: false, bContext: false},
                dInfo: {}
            });
            break;
        case "rightClickGCSelectedText":
            oGrammalecte.startGCPanel();
            // selected text is sent to the GC worker in the background script.
            break;
        // Lexicographer commands
        case "rightClickLxgEditableNode":
            oGrammalecte.startLxgPanel();
            sText = (xRightClickedNode.tagName == "TEXTAREA") ? xRightClickedNode.value : xRightClickedNode.textContent;
            xGrammalectePort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: sText},
                dInfo: {sTextAreaId: xRightClickedNode.id}
            });
            break;
        case "rightClickLxgPage":
            oGrammalecte.startLxgPanel();
            xGrammalectePort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: oGrammalecte.getPageText()},







|
|



|

















|



|







184
185
186
187
188
189
190
191
192
193
194
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
224
225
            break;
        /*
            Commands received from the context menu
            (Context menu are initialized in background)
        */
        // Grammar checker commands
        case "rightClickGCEditableNode":
            oGrammalecte.startGCPanel(oGrammalecte.xRightClickedNode);
            sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent;
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
                dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id}
            });
            break;
        case "rightClickGCPage":
            oGrammalecte.startGCPanel();
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: oGrammalecte.getPageText(), sCountry: "FR", bDebug: false, bContext: false},
                dInfo: {}
            });
            break;
        case "rightClickGCSelectedText":
            oGrammalecte.startGCPanel();
            // selected text is sent to the GC worker in the background script.
            break;
        // Lexicographer commands
        case "rightClickLxgEditableNode":
            oGrammalecte.startLxgPanel();
            sText = (oGrammalecte.xRightClickedNode.tagName == "TEXTAREA") ? oGrammalecte.xRightClickedNode.value : oGrammalecte.xRightClickedNode.textContent;
            xGrammalectePort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: sText},
                dInfo: {sTextAreaId: oGrammalecte.xRightClickedNode.id}
            });
            break;
        case "rightClickLxgPage":
            oGrammalecte.startLxgPanel();
            xGrammalectePort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: oGrammalecte.getPageText()},
235
236
237
238
239
240
241

242
243
    }
});


/*
    Start
*/

oGrammalecte.createMenus();
oGrammalecte.createMenus2();







>


239
240
241
242
243
244
245
246
247
248
    }
});


/*
    Start
*/
oGrammalecte.listenRightClick();
oGrammalecte.createMenus();
oGrammalecte.createMenus2();