Grammalecte  Diff

Differences From Artifact [0f3db968a0]:

To Artifact [7168d199f9]:


45
46
47
48
49
50
51

52
53
54
55
56






57
58
59
60
61

62
63
64
65
66
67
68
    xGCEWorker: null,
    bDictActive: null,
    loadGC: function () {
        if (this.xGCEWorker === null) {
            // Grammar checker
            echo('Loading Grammalecte');
            this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');

            let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
            xPromise.then(
                function (aVal) {
                    echo(aVal);
                    prefs.setCharPref("sGCOptions", aVal);






                },
                function (aReason) { echo('Promise rejected - ', aReason); }
            ).catch(
                function (aCaught) { echo('Promise Error - ', aCaught); }
            );

        }
    },
    fullTests: function () {
        echo('Performing tests... Wait...');
        let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
        xPromise.then(
            function (aVal) {







>





>
>
>
>
>
>





>







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
    xGCEWorker: null,
    bDictActive: null,
    loadGC: function () {
        if (this.xGCEWorker === null) {
            // Grammar checker
            echo('Loading Grammalecte');
            this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
            let that = this;
            let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
            xPromise.then(
                function (aVal) {
                    echo(aVal);
                    prefs.setCharPref("sGCOptions", aVal);
                    if (prefs.getBoolPref("bPersonalDictionary")) {
                        let sDicJSON = oFileHandler.loadFile("fr.personal.json");
                        if (sDicJSON) {
                            that.xGCEWorker.post('setDictionary', ["personal", sDicJSON]);
                        }
                    }
                },
                function (aReason) { echo('Promise rejected - ', aReason); }
            ).catch(
                function (aCaught) { echo('Promise Error - ', aCaught); }
            );

        }
    },
    fullTests: function () {
        echo('Performing tests... Wait...');
        let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
        xPromise.then(
            function (aVal) {
330
331
332
333
334
335
336
337































338
339
340
341
342
343
344
345
        xNodeDiv.appendChild(xNodeMessage);
        // suggestions
        let xNodeSuggLine = document.createElement("p");
        xNodeSuggLine.setAttribute("class", "suggestions");
        let xNodeSuggButton = document.createElement("span");
        xNodeSuggButton.setAttribute("class", "suggestions_button");
        xNodeSuggButton.textContent = "Suggestions : ";
        xNodeSuggButton.addEventListener("click", function (e) {































            if (this.bDictActive === null) {
                this.bDictActive = oSpellControl.setDictionary("fr");
            }
            try {
                let aSugg = oSpellControl.suggest(dErr['sValue']);
                if (aSugg) {
                    let n = 0;
                    for (let sSugg of aSugg) {







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
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
        xNodeDiv.appendChild(xNodeMessage);
        // suggestions
        let xNodeSuggLine = document.createElement("p");
        xNodeSuggLine.setAttribute("class", "suggestions");
        let xNodeSuggButton = document.createElement("span");
        xNodeSuggButton.setAttribute("class", "suggestions_button");
        xNodeSuggButton.textContent = "Suggestions : ";
        xNodeSuggButton.addEventListener("click", (e) => {
            let xPromise = this.xGCEWorker.post('suggest', [dErr['sValue'], 10]);
            xPromise.then(
                function (sVal) {
                    console.log(sVal);
                    if (sVal != "") {
                        let lSugg = sVal.split("|");
                        let n = 0;
                        for (let sSugg of lSugg) {
                            if (true || n > 0) {
                                xNodeSuggLine.appendChild(document.createTextNode(" "));
                            }
                            let xNodeSugg = document.createElement("span");
                            xNodeSugg.setAttribute("class", "sugg");
                            xNodeSugg.textContent = sSugg;
                            xNodeSugg.addEventListener("click", function (e) {
                                xEditor.changeParagraph(iParagraph, xNodeSugg.textContent, dErr["nStart"], dErr["nEnd"]);
                                xNodeDiv.textContent = "";
                                that.reparseParagraph(xEditor, iParagraph);
                            });
                            xNodeSuggLine.appendChild(xNodeSugg);
                            n += 1;
                        }
                    } else {
                        xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
                    }
                    
                },
                function (aReason) { console.error('Promise rejected - ', aReason); }
            ).catch(
                function (aCaught) { console.error('Promise Error - ', aCaught); }
            );
            /*if (this.bDictActive === null) {
                this.bDictActive = oSpellControl.setDictionary("fr");
            }
            try {
                let aSugg = oSpellControl.suggest(dErr['sValue']);
                if (aSugg) {
                    let n = 0;
                    for (let sSugg of aSugg) {
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
                } else {
                    xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
                }
            }
            catch (e) {
                xNodeSuggLine.appendChild(document.createTextNode("# Erreur : dictionnaire orthographique introuvable."));
                Cu.reportError(e);
            }
        });
        xNodeSuggLine.appendChild(xNodeSuggButton);
        xNodeDiv.appendChild(xNodeSuggLine);
        return xNodeDiv;
    },
    loadUI: function() {
        echo("loadUI");







|







399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
                } else {
                    xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
                }
            }
            catch (e) {
                xNodeSuggLine.appendChild(document.createTextNode("# Erreur : dictionnaire orthographique introuvable."));
                Cu.reportError(e);
            }*/
        });
        xNodeSuggLine.appendChild(xNodeSuggButton);
        xNodeDiv.appendChild(xNodeSuggLine);
        return xNodeDiv;
    },
    loadUI: function() {
        echo("loadUI");
498
499
500
501
502
503
504



505
506
507
508
509
510
511
    },
    onOpenTextFormatter: function (e) {
        oTextFormatter.openPanel();
    },
    onOpenConjugueur: function (e) {
        this.openDialog("chrome://grammarchecker/content/conjugueur.xul", "", "chrome, resizable=no");
    },



    onAbout: function (e) {
        this.openDialog("chrome://grammarchecker/content/about.xul", "", "chrome, dialog, modal, resizable=no");
    }
};


var oDictIgniter = {







>
>
>







537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
    },
    onOpenTextFormatter: function (e) {
        oTextFormatter.openPanel();
    },
    onOpenConjugueur: function (e) {
        this.openDialog("chrome://grammarchecker/content/conjugueur.xul", "", "chrome, resizable=no");
    },
    onOpenLexiconEditor: function (e) {
        this.openDialog("chrome://grammarchecker/content/lex_editor.xul", "", "chrome, resizable=no");
    },
    onAbout: function (e) {
        this.openDialog("chrome://grammarchecker/content/about.xul", "", "chrome, dialog, modal, resizable=no");
    }
};


var oDictIgniter = {