Grammalecte  Diff

Differences From Artifact [689258b9fa]:

To Artifact [4a92e9c4a9]:


23
24
25
26
27
28
29
30



31

32
33
34
35
36
37
38
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}
if (typeof(messenger) === "object") {



    bThunderbird = true;

}

/*
function loadImage (sContainerClass, sImagePath) {
    let xRequest = new XMLHttpRequest();
    xRequest.open('GET', browser.extension.getURL("")+sImagePath, false);
    xRequest.responseType = "arraybuffer";







|
>
>
>

>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}
if (typeof(messenger) === "object" || browser.hasOwnProperty("composeAction")) {
    // JS sucks again.
    // In Thunderbird, <browser> exists in content-scripts, but not <messenger>
    // <browner> has property <composeAction> but is undefined...
    bThunderbird = true;
    //console.log("[Grammalecte] Thunderbird...");
}

/*
function loadImage (sContainerClass, sImagePath) {
    let xRequest = new XMLHttpRequest();
    xRequest.open('GET', browser.extension.getURL("")+sImagePath, false);
    xRequest.responseType = "arraybuffer";
465
466
467
468
469
470
471







472
473
474
475
476
477
478
                    if (document.activeElement.tagName == "IFRAME") {
                        //console.log(document.activeElement.id); frameId given by result is different than frame.id
                        oGrammalecte.startGCPanel(document.activeElement);
                    } else {
                        oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
                    }
                    break;







                default:
                    console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
            }
        }.bind(this));
    },

    /*







>
>
>
>
>
>
>







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
                    if (document.activeElement.tagName == "IFRAME") {
                        //console.log(document.activeElement.id); frameId given by result is different than frame.id
                        oGrammalecte.startGCPanel(document.activeElement);
                    } else {
                        oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
                    }
                    break;
                /*
                    composeAction
                    (Thunderbird only)
                */
                case "grammar_checker_compose_window":
                    oGrammalecte.startGCPanel("__ThunderbirdComposeWindow__");
                    break;
                default:
                    console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
            }
        }.bind(this));
    },

    /*
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
    }
}


oGrammalecteBackgroundPort.start();


/*
    ComposeAction
    (Thunderbird only)
*/
if (bThunderbird) {
    console.log("Listen...");
    try {
        browser.composeAction.onClicked.addListener(function (oTab, oData) {
            console.log("START");
            oGrammalecte.startGCPanel("J'en aie mare...");
        });
    }
    catch (e) {
        showError(e)
    }
    console.log("Done.");
}


/*
    Callable API for the webpage.
    (Not for Thunderbird)
*/
if (!bThunderbird) {
    document.addEventListener("GrammalecteCall", function (xEvent) {







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







511
512
513
514
515
516
517


















518
519
520
521
522
523
524
    }
}


oGrammalecteBackgroundPort.start();





















/*
    Callable API for the webpage.
    (Not for Thunderbird)
*/
if (!bThunderbird) {
    document.addEventListener("GrammalecteCall", function (xEvent) {