Grammalecte  Check-in [e4ff01c69e]

Overview
Comment:[tb][fx] fix recursive function
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | fx | mailext
Files: files | file ages | folders
SHA3-256: e4ff01c69e157635e21b90f9b8848dafcc75d209f93cb7c818571edca4eb0011
User & Date: olr on 2020-07-08 11:07:47
Other Links: branch diff | manifest | tags
Context
2020-07-08
17:26
[tb][fx] adjustement for Mail Extension: no event for input -> no autorefresh check-in: 081fa7f8ca user: olr tags: tb, fx, mailext
11:07
[tb][fx] fix recursive function check-in: e4ff01c69e user: olr tags: tb, fx, mailext
06:37
[tb][fx] update for MailExtension check-in: 329a134246 user: olr tags: tb, fx, mailext
Changes

Modified gc_lang/fr/webext/content_scripts/editor.js from [237a922051] to [c240d85760].

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
/*
    Editor for HTML page (Thunderbird or Iframe)
*/
class HTMLPageEditor {

	constructor (xDocument, bCheckSignature=false) {
        this.xDocument = xDocument;
        this.xRootNode = xDocument.rootElement;


        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5"];
        this._lRootNodes = ["DIV", "UL", "OL"];
    }

    * _getParsableNodes () {
        // 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;
                        }







|
>
>






|


|







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
/*
    Editor for HTML page (Thunderbird or Iframe)
*/
class HTMLPageEditor {

	constructor (xDocument, bCheckSignature=false) {
        this.xDocument = xDocument;
        this.xRootNode = xDocument.body;
        //console.log(xDocument.body);
        //console.log(xDocument.body.innerHTML);
        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5"];
        this._lRootNodes = ["DIV", "UL", "OL"];
    }

    * _getParsableNodes (xRootNode) {
        // recursive function
        try {
            for (let xNode of 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;
                        }
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
            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);







|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
            showError(e);
        }
    }

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