Grammalecte  Diff

Differences From Artifact [83ad0c7397]:

To Artifact [e10aed13d1]:


375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
            oGrammalecte.startGCPanel(result, false); // result is the selected text
            // selected text is sent to the GC worker in the background script.
            break;
        case "grammar_checker_iframe":
            console.log("[Grammalecte] selected iframe: ", result);
            if (document.activeElement.tagName == "IFRAME") {
                //console.log(document.activeElement.id); frameId given by result is different than frame.id
                oGrammalecte.startGCPanel(document.activeElement.contentWindow.document.body.innerText);
            } 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;
        // rescan page command
        case "rescanPage":
            oGrammalecte.rescanPage();







|







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
            oGrammalecte.startGCPanel(result, false); // result is the selected text
            // selected text is sent to the GC worker in the background script.
            break;
        case "grammar_checker_iframe":
            console.log("[Grammalecte] selected iframe: ", result);
            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;
        // rescan page command
        case "rescanPage":
            oGrammalecte.rescanPage();
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419






420
421
422
423
424
425
426
    The API script must be injected this way to be callable by the page
*/
let xScriptGrammalecteAPI = document.createElement("script");
xScriptGrammalecteAPI.src = browser.extension.getURL("content_scripts/api.js");
document.documentElement.appendChild(xScriptGrammalecteAPI);

document.addEventListener("GrammalecteCall", function (xEvent) {
    // GrammalecteCall events are dispatched by functions in the API
    try {
        let oCommand = xEvent.detail;
        switch (oCommand.sCommand) {
            case "parseNode":
                if (oCommand.xNode) {
                    oGrammalecte.startGCPanel(oCommand.xNode);
                }
                break;
            case "parseText":
                if (oCommand.sText) {
                    oGrammalecte.startGCPanel(oCommand.sText);
                }






                break;
            default:
                console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand);
        }
    }
    catch (e) {
        showError(e);







|



|




|



>
>
>
>
>
>







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
    The API script must be injected this way to be callable by the page
*/
let xScriptGrammalecteAPI = document.createElement("script");
xScriptGrammalecteAPI.src = browser.extension.getURL("content_scripts/api.js");
document.documentElement.appendChild(xScriptGrammalecteAPI);

document.addEventListener("GrammalecteCall", function (xEvent) {
    // GrammalecteCall events are dispatched by functions in the API script
    try {
        let oCommand = xEvent.detail;
        switch (oCommand.sCommand) {
            case "openPanelForNode":
                if (oCommand.xNode) {
                    oGrammalecte.startGCPanel(oCommand.xNode);
                }
                break;
            case "openPanelForText":
                if (oCommand.sText) {
                    oGrammalecte.startGCPanel(oCommand.sText);
                }
                break;
            case "parseNode":
                // todo
                break;
            case "parseText":
                // todo
                break;
            default:
                console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand);
        }
    }
    catch (e) {
        showError(e);