Grammalecte  Check-in [bc93713e8f]

Overview
Comment:[tb][fx] update for MailExtension
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | fx | mailext
Files: files | file ages | folders
SHA3-256: bc93713e8f979d0d9be6824f71f51ae9d349635036ae2c1677bf50aed9e1c9f4
User & Date: olr on 2020-07-06 18:45:43
Other Links: branch diff | manifest | tags
Context
2020-07-08
06:37
[tb][fx] update for MailExtension check-in: 329a134246 user: olr tags: tb, fx, mailext
2020-07-06
18:45
[tb][fx] update for MailExtension check-in: bc93713e8f user: olr tags: tb, fx, mailext
2020-07-05
09:35
[tb][fx] update for MailExtension check-in: 05b48840da user: olr tags: tb, fx, mailext
Changes

Modified gc_lang/fr/mailext/background.js from [05f690bf98] to [f076b0a893].

354
355
356
357
358
359
360

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

379
380
381
382
383
384
385
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

374




375
376
377
378
379
380
381
382







+












-

-
-
-
-
+







                break;
            default:
                console.log("[background] Unknown command: " + sCommand);
                console.log(oRequest);
        }
    });
    //xPort.postMessage({sActionDone: "newId", result: iPortId});
    //console.log("[Grammalecte] init connection to content-script");
    xPort.postMessage({sActionDone: "init", sUrl: browser.extension.getURL("")});
}

browser.runtime.onConnect.addListener(handleConnexion);



/*
    ComposeAction
    (Thunderbird only)
*/
if (bThunderbird) {
    console.log("[Grammalecte] Thunderbird: listening compose action...");
    browser.composeAction.onClicked.addListener(function (xTab, xData) {
        console.log("ComposeAction clicked");
        console.log(xTab);
        console.log(xData);
        browser.tabs.sendMessage(xTab.id, {sActionRequest: "grammar_checker_compose_window"});
        sendCommandToTab(xTab.id, "grammar_checker_compose_window");
    });
}


/*
    Context Menu
    (not for MailExtension)

Added gc_lang/fr/webext/content_scripts/editor.js version [8955fa04c4].

































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// JavaScript

// Editor for HTML page


"use strict";


class HTMLPageEditor {

	constructor (xRootNode=document.rootElement, bCheckSignature=false) {
        this.xRootNode = xRootNode;
        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI"];
        this._lRootNodes = ["DIV", "UL", "OL"];

    }

    * _getParsableNodes (xRootNode) {
        // recursive function
        try {
            for (let xNode of this.xRootNode.childNodes) {
                if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
                    && (xNode.nodeType == Node.TEXT_NODE || (xNode.nodeType == Node.ELEMENT_NODE && !xNode.textContent.startsWith(">")))
                    && xNode.textContent !== "") {
                    if (xNode.tagName === undefined) {
                        if (!this.bCheckSignature && xNode.textContent.startsWith("-- ")) {
                            break;
                        }
                        yield xNode;
                    }
                    else if (this._lParsableNodes.includes(xNode.tagName)) {
                        yield xNode;
                    }
                    else if (this._lRootNodes.includes(xNode.tagName)) {
                        yield* this._getParsableNodes(xNode);
                    }
                }
            }
        }
        catch (e) {
            showError(e);
        }
    }

    * getParagraphs () {
        try {
            let i = 0;
            for (let xNode of this._getParsableNodes()) {
                this.lNode.push(xNode);
                yield [i, xNode.textContent];
                i += 1;
            }
        }
        catch (e) {
            showError(e);
        }
    }

    getPageText () {
        try {
            let sPageText = "";
            for (let [i, sLine] of this.getParagraphs()) {
                sPageText += sLine + "\n";
            }
            return sPageText;
        }
        catch (e) {
            showError(e);
        }
    }

    getParagraph (iPara) {
        try {
            return this.lNode[iPara].textContent;
        }
        catch (e) {
            showError(e);
        }
    }

    writeParagraph (iPara, sText) {
        try {
            return this.lNode[iPara].textContent = sText;
        }
        catch (e) {
            showError(e);
        }
    }

    changeParagraph (iPara, sModif, iStart, iEnd) {
        let sText = this.getParagraph(iPara);
        this.writeParagraph(iPara, sText.slice(0, iStart) + sModif + sText.slice(iEnd));
    }
}

Modified gc_lang/fr/webext/content_scripts/init.js from [4a92e9c4a9] to [b5e2ece3a6].

381
382
383
384
385
386
387

388
389
390
391
392
393
394
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395







+







            this.bConnected = false;
            this.restart();
        }.bind(this));
        this.xConnect.onMessage.addListener(function (oMessage) {
            let { sActionDone, result, oInfo, bEnd, bError } = oMessage;
            switch (sActionDone) {
                case "init":
                    //console.log("[Grammalecte] content-script: init");
                    this.bConnected = true;
                    oGrammalecte.sExtensionUrl = oMessage.sUrl;
                    oGrammalecte.listen();
                    oGrammalecte.createButton();
                    break;
                case "ping":
                    console.log("[Grammalecte] Connection to background done.");